|
| 1 | +#!/bin/sh |
| 2 | +# |
| 3 | +# =========================================================================== |
| 4 | +# FILE: makexp_aix |
| 5 | +# TYPE: standalone executable |
| 6 | +# SYSTEM: AIX 3.2.5 and AIX 4 |
| 7 | +# |
| 8 | +# DESCRIPTION: This script creates an export list of ALL global symbols |
| 9 | +# from a list of object or archive files. |
| 10 | +# |
| 11 | +# USAGE: makexp_aix <OutputFile> "<FirstLine>" <InputFile> ... |
| 12 | +# |
| 13 | +# where: |
| 14 | +# <OutputFile> is the target export list filename. |
| 15 | +# <FirstLine> is the path/file string to be appended |
| 16 | +# after the "#!" symbols in the first line of the |
| 17 | +# export file. Passing "" means deferred resolution. |
| 18 | +# <InputFile> is an object (.o) or an archive file (.a). |
| 19 | +# |
| 20 | +# HISTORY: |
| 21 | +# 1-Jul-1996 -- added header information |
| 22 | +# Vladimir Marangozov |
| 23 | +# |
| 24 | +# 28-Jun-1996 -- initial code |
| 25 | +# Vladimir Marangozov ([email protected]) |
| 26 | +# ========================================================================== |
| 27 | + |
| 28 | +# Variables |
| 29 | +expFileName=$1 |
| 30 | +toAppendStr=$2 |
| 31 | +shift; shift; |
| 32 | +inputFiles=$* |
| 33 | +automsg="Generated automatically by makexp_aix" |
| 34 | +notemsg="NOTE: lists _all_ global symbols defined in the above file(s)." |
| 35 | +curwdir=`pwd` |
| 36 | + |
| 37 | +# Create the export file and setup the header info |
| 38 | +echo "#!"$toAppendStr > $expFileName |
| 39 | +echo "*" >> $expFileName |
| 40 | +echo "* $automsg (`date -u`)" >> $expFileName |
| 41 | +echo "*" >> $expFileName |
| 42 | +echo "* Base Directory: $curwdir" >> $expFileName |
| 43 | +echo "* Input File(s) : $inputFiles" >> $expFileName |
| 44 | +echo "*" >> $expFileName |
| 45 | +echo "* $notemsg" >> $expFileName |
| 46 | +echo "*" >> $expFileName |
| 47 | + |
| 48 | +# Extract the symbol list using 'nm' which produces quite |
| 49 | +# different output under AIX 4 than under AIX 3.2.5. |
| 50 | +# The following handles both versions by using a common flagset. |
| 51 | +# Here are some hidden tricks: |
| 52 | +# 1. Use /usr/ccs/bin/nm. Relevant to AIX 3.2.5 which has |
| 53 | +# another version under /usr/ucb/bin/nm. |
| 54 | +# 2. Use the -B flag to have a standard BSD representation |
| 55 | +# of the symbol list on both AIX 3.2.5 and AIX 4. The "-B" |
| 56 | +# flag is missing in the AIX 3.2.5 online usage help of 'nm'. |
| 57 | +# 3. Use the -x flag to have a hex representation of the symbol |
| 58 | +# values. This fills the leading whitespaces on AIX 4, |
| 59 | +# thus simplifying the sed statement. |
| 60 | +# 4. Eliminate all entries except those with either "B", "D" |
| 61 | +# or "T" key letters. We are interested only in the global |
| 62 | +# (extern) BSS, DATA and TEXT symbols. With the same statement |
| 63 | +# we eliminate object member lines relevant to AIX 4. |
| 64 | +# 5. Eliminate entries containing a dot. We can have a dot only |
| 65 | +# as a symbol prefix, but such symbols are undefined externs. |
| 66 | +# 6. Eliminate everything including the key letter, so that we're |
| 67 | +# left with just the symbol name. |
| 68 | +# |
| 69 | +/usr/ccs/bin/nm -Bex $inputFiles \ |
| 70 | +| sed -e '/ [^BDT] /d' -e '/\./d' -e 's/.* [BDT] //' \ |
| 71 | +| sort | uniq >> $expFileName |
0 commit comments