OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tcl/] [unix/] [ldAix] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
#!/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
# RCS: @(#) $Id: ldAix,v 1.1.1.1 2002-01-16 10:25:37 markom Exp $
14
 
15
# Extract from the arguments the names of all of the object files.
16
 
17
args=$*
18
ofiles=""
19
for i do
20
    x=`echo $i | grep '[^.].o$'`
21
    if test "$x" != ""; then
22
        ofiles="$ofiles $i"
23
    fi
24
done
25
 
26
# Create the export file from all of the object files, using nm followed
27
# by sed editing.  Here are some tricky aspects of this:
28
#
29
# 1. Nm produces different output under AIX 4.1 than under AIX 3.2.5;
30
#    the following statements handle both versions.
31
# 2. Use the -g switch to nm instead of -e under 4.1 (this shows just
32
#    externals, not statics;  -g isn't available under 3.2.5, though).
33
# 3. Eliminate lines that end in ":": these are the names of object
34
#    files (relevant in 4.1 only).
35
# 4. Eliminate entries with the "U" key letter;  these are undefined
36
#    symbols (relevant in 4.1 only).
37
# 5. Eliminate lines that contain the string "0|extern" preceded by space;
38
#    in 3.2.5, these are undefined symbols (address 0).
39
# 6. Eliminate lines containing the "unamex" symbol.  In 3.2.5, these
40
#    are also undefined symbols.
41
# 7. If a line starts with ".", delete the leading ".", since this will
42
#    just cause confusion later.
43
# 8. Eliminate everything after the first field in a line, so that we're
44
#    left with just the symbol name.
45
 
46
nmopts="-g -C"
47
osver=`uname -v`
48
if test $osver -eq 3; then
49
  nmopts="-e"
50
fi
51
rm -f lib.exp
52
echo "#! " >lib.exp
53
/usr/ccs/bin/nm $nmopts -h $ofiles | sed -e '/:$/d' -e '/ U /d' -e '/[  ]0|extern/d' -e '/unamex/d' -e 's/^\.//' -e 's/[        |].*//' | sort | uniq >>lib.exp
54
 
55
# Extract the name of the object file that we're linking.  If it's a .a
56
# file, then link all the objects together into a single file "shr.o"
57
# and then put that into the archive.  Otherwise link the object files
58
# directly into the .a file.
59
 
60
outputFile=`echo $args | sed -e 's/.*-o \([^ ]*\).*/\1/'`
61
noDotA=`echo $outputFile | sed -e '/\.a$/d'`
62
echo "noDotA=\"$noDotA\""
63
if test "$noDotA" = "" ; then
64
    linkArgs=`echo $args | sed -e 's/-o .*\.a /-o shr.o /'`
65
    echo $linkArgs
66
    eval $linkArgs
67
    echo ar cr $outputFile shr.o
68
    ar cr $outputFile shr.o
69
    rm -f shr.o
70
else
71
    eval $args
72
fi

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.