2
XCOMM $XConsortium: elistgen.ibm /main/2 1996/12/04 10:13:18 swick $
4
XCOMM #########################################################################
5
XCOMM Construct shared-library export lists for IBM-AIX based on standardized
6
XCOMM export list description file
8
XCOMM Usage: elistgen libfoo.sl libfoo.elist > libfoo.lopt
10
XCOMM libfoo.a => shared library of interest
11
XCOMM libfoo.elist => Meta description of necessary export list.
13
XCOMM The output file, "libfoo.lopt" may then be passed to the IBM linker to
14
XCOMM reconstruct the shared library, libfoo.sl.
16
XCOMM Author: Yanling Qi 10/03/94, Last updated 10/03/94
17
XCOMM (c) Copyright 1996 Digital Equipment Corporation.
18
XCOMM (c) Copyright 1996 Hewlett-Packard Company.
19
XCOMM (c) Copyright 1994,1996 International Business Machines Corp.
20
XCOMM (c) Copyright 1996 Sun Microsystems, Inc.
21
XCOMM (c) Copyright 1996 Novell, Inc.
22
XCOMM (c) Copyright 1996 FUJITSU LIMITED.
23
XCOMM (c) Copyright 1996 Hitachi.
25
XCOMM #########################################################################
29
XCOMM Utility programs
30
FILTER=CXXFILT # C++ symbol demangler
33
XCOMM For dump, cat, pr, expand, awk, c++filt
34
PATH=/usr/bin:/bin:/usr/ucb:/usr/lpp/xlC/bin
37
EXPORTLIST=/tmp/elistgen1.$$ # export directives from "libfoo.list"
38
NMLIST=/tmp/elistgen2.$$ # name list from libfoo.sl
39
FILTLIST=/tmp/elistgen3.$$ # demangled (C++) version of above
41
XCOMM Print useful information
43
echo "* This linker options list was produced by" $0
44
echo "* Input export list description taken from:" $2
45
echo "* Target library:" $1
46
echo "* Target Operating System:" `uname`
49
XCOMM Extract the globally visible symbols from target library
50
dump -g $1 | $AWK '$1 ~ /[0-9][0-9]/ && $2 !~ /^[\.]/ {print $2}' > $NMLIST
52
XCOMM Demangle the global library symbols
53
${FILTER:-cat} $NMLIST > $FILTLIST
56
XCOMM Clean up the export-list description file.
57
XCOMM Note that C++ symbols may have embedded spaces in them.
61
csyms = 0; # C language symbols in libfoo.list
62
cplusplus = 0; # C++ language symbols in libfoo.list
63
isyms = 0; # C internal symbols in libfoo.list
64
iplusplus = 0; # C++ internal symbols in libfoo.list
65
count = 0; # Running count of symbols
66
implicit = ""; # Handling of implicit symbols.
69
HASH A default clause suppresses warnings about implicit symbols.
70
if ($2 != "" && $2 != "force" && $2 != "public" &&
71
$2 != "private" && $2 != "internal") {
72
print "# Warning: illegal default clause:", $2 | "cat 1>&2";
76
print "# Warning: multiple default clauses." | "cat 1>&2";
80
$1 == "force" || $1 == "public" || $1 == "private" {
82
symbol[count++] = $1 ";;" $2;
85
$1 == "publicC++" || $1 == "privateC++" {
86
HASH forceC++ is unsupported because we only know how to demangle,
87
HASH not how to mangle symbols, and the final ld input file must
91
for (n = 3; n <= NF; n++)
92
string = string " " $n;
93
symbol[count++] = $1 ";;" string;
98
symbol[count++] = $1 ";;" $2;
101
$1 == "internalC++" {
104
for (n = 3; n <= NF; n++)
105
string = string " " $n;
106
symbol[count++] = $1 ";;" string;
109
$1 == "#line" || $1 == "#" {
110
HASH cpp will have removed comments, but may have added other stuff.
114
print "# Warning: unrecognized directive:", $0 | "cat 1>&2";
118
printf("# Exporting %d C and %d C++ symbols, hiding %d and %d.\n",
119
csyms, cplusplus, isyms, iplusplus) | "cat 1>&2";
120
if (implicit != "") {
121
print "# Unspecified symbols are " implicit "." | "cat 1>&2";
122
print "default;;" implicit;
130
XCOMM Read in the above files and write result to stdout. Use the
131
XCOMM delimiter ";" to identify the entries in the symbol lookup table.
133
(pr -m -s";" -t -w1024 $NMLIST $FILTLIST | expand -t 1; cat $EXPORTLIST) | $AWK '
139
HASH This is "pr" output, i.e., symbol translation table
141
gsub(/ /,"",r2); # Remove spaces because c++filt is unpredictable
145
mangled[r1] = 1; # Save the mangling because the export lists
146
HASH sometimes use it instead of a prototype.
149
NF == 3 && $1 == "default" {
150
HASH Treatment of unspecified symbols.
151
if ($3 == "internal")
153
else if ($3 == "private" || $3 == "privateC++")
155
else if ($3 == "public" || $3 == "publicC++")
162
HASH Generate canonical demangled form as an alternate symbol.
164
gsub(/ \.\.\./,",...",alt); # change " ..." to ",..." to match c++filt
165
gsub(/ /,"",alt); # remove all spaces
166
gsub(/\(void\)/,"()",alt); # change "(void)" to "()" to match c++filt
168
HASH Parse our instructions for this symbol.
169
if ($1 == "internal" || $1 == "internalC++")
171
else if ($1 == "private" || $1 == "privateC++")
173
else if ($1 == "public" || $1 == "publicC++")
179
if ((length(syms[alt]) > 0) || mangled[alt]) {
180
HASH This symbol is present in the library.
182
print "# Warning: Duplicate entry for", $3,
183
"in export list" | "cat 1>&2";
184
if (donelist[alt] < export) {
187
donelist[alt] = export;
190
HASH Print forced-export symbols without complaining.
193
donelist[alt] = export;
195
print "# Warning:", $3,
196
"was not in the nm list for this library" | "cat 1>&2";
203
HASH Process implicit symbols.
205
if ((! donelist[i]) && (length(syms[i]) > 0)) {
206
HASH Do not complain about C++ virtual function tables.
207
if (implicit == 0 && syms[i] !~ /^__vft[0-9]*_/)
208
print "# Warning:", syms[i],
209
"was not in the export list" | "cat 1>&2";
217
XCOMM Clean up temporary files