Debian Codegraph @

unix/ldAix

raw symbols SCIP
1 #!/bin/sh
2 #
3 # ldAix ldCmd ldArg ldArg ...
4 #
5 # This shell script provides a wrapper for ld under AIX in order to
6 # create the .exp file required for linking. Its arguments consist
7 # of the name and arguments that would normally be provided to the
8 # ld command. This script extracts the names of the object files
9 # from the argument list, creates a .exp file describing all of the
10 # symbols exported by those files, and then invokes "ldCmd" to
11 # perform the real link.
12
13 # Extract from the arguments the names of all of the object files.
14
15 args=$*
16 ofiles=""
17 for i do
18 x=`echo $i | grep '[^.].o$'`
19 if test "$x" != ""; then
20 ofiles="$ofiles $i"
21 fi
22 done
23
24 # Extract the name of the object file that we're linking.
25 outputFile=`echo $args | sed -e 's/.*-o \([^ ]*\).*/\1/'`
26
27 # Create the export file from all of the object files, using nm followed
28 # by sed editing. Here are some tricky aspects of this:
29 #
30 # - Use the -X32_64 switch to nm to handle 32 or 64bit compiles.
31 # - Eliminate lines that end in ":": these are the names of object files
32 # - Eliminate entries with the "U" key letter; these are undefined symbols
33 # - If a line starts with ".", delete the leading ".", since this will just
34 # cause confusion later
35 # - Eliminate everything after the first field in a line, so that we're
36 # left with just the symbol name
37
38 nmopts="-g -C -h -X32_64"
39 rm -f lib.exp
40 echo "#! $outputFile" >lib.exp
41 /usr/ccs/bin/nm $nmopts $ofiles | sed -e '/:$/d' -e '/ U /d' -e 's/^\.//' -e 's/[ |].*//' | sort | uniq >>lib.exp
42
43 # If we're linking a .a file, then link all the objects together into a
44 # single file "shr.o" and then put that into the archive. Otherwise link
45 # the object files directly into the .a file.
46
47 noDotA=`echo $outputFile | sed -e '/\.a$/d'`
48 echo "noDotA=\"$noDotA\""
49 if test "$noDotA" = "" ; then
50 linkArgs=`echo $args | sed -e 's/-o .*\.a /-o shr.o /'`
51 echo $linkArgs
52 eval $linkArgs
53 echo ar cr $outputFile shr.o
54 ar cr $outputFile shr.o
55 rm -f shr.o
56 else
57 eval $args
58 fi