Guido van Rossum | b4ae6a3 | 1996-08-08 19:05:09 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # =========================================================================== |
| 4 | # FILE: makexp_aix |
| 5 | # TYPE: standalone executable |
Kevin Adler | c79667f | 2020-11-16 09:16:10 -0600 | [diff] [blame] | 6 | # SYSTEM: AIX |
Guido van Rossum | b4ae6a3 | 1996-08-08 19:05:09 +0000 | [diff] [blame] | 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: |
Guido van Rossum | c6a681a | 1998-04-09 21:46:02 +0000 | [diff] [blame] | 21 | # 3-Apr-1998 -- remove C++ entries of the form Class::method |
| 22 | # Vladimir Marangozov |
| 23 | # |
Guido van Rossum | b4ae6a3 | 1996-08-08 19:05:09 +0000 | [diff] [blame] | 24 | # 1-Jul-1996 -- added header information |
| 25 | # Vladimir Marangozov |
| 26 | # |
| 27 | # 28-Jun-1996 -- initial code |
| 28 | # Vladimir Marangozov (Vladimir.Marangozov@imag.fr) |
| 29 | # ========================================================================== |
| 30 | |
| 31 | # Variables |
| 32 | expFileName=$1 |
| 33 | toAppendStr=$2 |
| 34 | shift; shift; |
| 35 | inputFiles=$* |
| 36 | automsg="Generated automatically by makexp_aix" |
| 37 | notemsg="NOTE: lists _all_ global symbols defined in the above file(s)." |
| 38 | curwdir=`pwd` |
| 39 | |
| 40 | # Create the export file and setup the header info |
| 41 | echo "#!"$toAppendStr > $expFileName |
| 42 | echo "*" >> $expFileName |
| 43 | echo "* $automsg (`date -u`)" >> $expFileName |
| 44 | echo "*" >> $expFileName |
| 45 | echo "* Base Directory: $curwdir" >> $expFileName |
| 46 | echo "* Input File(s) : $inputFiles" >> $expFileName |
| 47 | echo "*" >> $expFileName |
| 48 | echo "* $notemsg" >> $expFileName |
| 49 | echo "*" >> $expFileName |
| 50 | |
Kevin Adler | c79667f | 2020-11-16 09:16:10 -0600 | [diff] [blame] | 51 | # Extract the symbol list using 'nm' |
Guido van Rossum | b4ae6a3 | 1996-08-08 19:05:09 +0000 | [diff] [blame] | 52 | # Here are some hidden tricks: |
Kevin Adler | c79667f | 2020-11-16 09:16:10 -0600 | [diff] [blame] | 53 | # - Use the -B flag to have a standard BSD representation |
| 54 | # of the symbol list. |
| 55 | # - Use the -x flag to have a hex representation of the symbol |
| 56 | # values. This fills the leading whitespaces, thus simplifying |
| 57 | # the sed statement. |
| 58 | # - Eliminate all entries except those with either "B", "D" |
| 59 | # or "T" key letters. We are interested only in the global |
| 60 | # (extern) BSS, DATA and TEXT symbols. With the same statement |
| 61 | # we eliminate object member lines relevant to AIX 4. |
| 62 | # - Eliminate entries containing a dot. We can have a dot only |
| 63 | # as a symbol prefix, but such symbols are undefined externs. |
| 64 | # - Eliminate everything including the key letter, so that we're |
| 65 | # left with just the symbol name. |
| 66 | # - Eliminate all entries containing two colons, like Class::method |
Guido van Rossum | b4ae6a3 | 1996-08-08 19:05:09 +0000 | [diff] [blame] | 67 | # |
Guido van Rossum | 8ee3e5a | 2005-09-14 18:09:42 +0000 | [diff] [blame] | 68 | |
Kevin Adler | c79667f | 2020-11-16 09:16:10 -0600 | [diff] [blame] | 69 | /usr/ccs/bin/nm -Bex -X32_64 $inputFiles \ |
Guido van Rossum | c6a681a | 1998-04-09 21:46:02 +0000 | [diff] [blame] | 70 | | sed -e '/ [^BDT] /d' -e '/\./d' -e 's/.* [BDT] //' -e '/::/d' \ |
Guido van Rossum | b4ae6a3 | 1996-08-08 19:05:09 +0000 | [diff] [blame] | 71 | | sort | uniq >> $expFileName |