|
1 # Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 # All rights reserved. |
|
3 # This component and the accompanying materials are made available |
|
4 # under the terms of "Eclipse Public License v1.0" |
|
5 # which accompanies this distribution, and is available |
|
6 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 # |
|
8 # Initial Contributors: |
|
9 # Nokia Corporation - initial contribution. |
|
10 # |
|
11 # Contributors: |
|
12 # |
|
13 # Description: |
|
14 # |
|
15 |
|
16 package DepUtil; |
|
17 |
|
18 require Exporter; |
|
19 @ISA=qw(Exporter); |
|
20 |
|
21 @EXPORT=qw( |
|
22 GenDependencies |
|
23 ); |
|
24 use strict; |
|
25 my ($interworking, $outfile, $genpath, $libpath, $librariesRef, $gVerbose); |
|
26 sub GenDependencies { |
|
27 ($interworking, $outfile, $genpath, $libpath, $librariesRef, $gVerbose) = @_; |
|
28 my @dsoList; |
|
29 foreach my $alib (@$librariesRef) { |
|
30 # .lib files are archive file. Get the corresponding dso file which is in ELF. |
|
31 if($alib =~ /(.*)\.lib$/) { |
|
32 my $dso = "$1.dso"; |
|
33 if(-e $dso){ |
|
34 push @dsoList, $dso; |
|
35 } |
|
36 } |
|
37 elsif($alib =~ /.*\.dso$/) { |
|
38 if(-e $alib){ |
|
39 push @dsoList, $alib; |
|
40 } |
|
41 } |
|
42 } |
|
43 my @linkAsList=(); |
|
44 foreach my $dso (@dsoList) { |
|
45 # Get the linkas names of the libraries |
|
46 open PIPE, "getexports -s $dso |"; |
|
47 while(<PIPE>) { |
|
48 if($_ =~ /(\S+)/){ |
|
49 push @linkAsList, $1; |
|
50 } |
|
51 } |
|
52 close PIPE; |
|
53 } |
|
54 GenLinkerSteeringFileForDeps(\@linkAsList) if($outfile); |
|
55 } |
|
56 |
|
57 sub GenLinkerSteeringFileForDeps { |
|
58 # Generate the linker steering file to indicate in the final ELF file |
|
59 # about the static dependencies. This list gives the list and order of |
|
60 # library names in which name lookup shall happen. Whether they were |
|
61 # actually linked-in in the final ELF shall be determined by the import |
|
62 # table. The import table fails to maintain the linking order and is |
|
63 # achieved through these linker directives. |
|
64 |
|
65 my ($LinkAsNamesRef) = @_; |
|
66 my $depfile = "$genpath\\$outfile.dep"; |
|
67 open OUTFILE, ">$depfile" or |
|
68 die "Can't create file $depfile\n"; |
|
69 print OUTFILE "; This is a generated file for Static Dependency listing"; |
|
70 print OUTFILE "; causing the linker to create DT_NEEDED tag(s) in the dynamic array\n\n"; |
|
71 |
|
72 foreach my $name (@$LinkAsNamesRef) { |
|
73 print OUTFILE "\n\tREQUIRE \"$name\""; |
|
74 } |
|
75 print OUTFILE "\n"; |
|
76 close OUTFILE; |
|
77 } |
|
78 |
|
79 1; |