2 XCOMM $XConsortium: elistgen.hp /main/2 1996/12/04 10:13:14 swick $
4 XCOMM #########################################################################
5 XCOMM Construct shared-library export lists for HP-UX based on standardized
6 XCOMM export list description file
8 XCOMM Usage: exportlistgen libfoo.sl libfoo.elist > libfoo.lopt
10 XCOMM libfoo.sl => shared library of interest
11 XCOMM libfoo.elist => Meta description of necessary export list.
13 XCOMM The output may then be passed to the linker to reconstruct the
14 XCOMM shared library. For unknown reasons naming only exported symbols
15 XCOMM with "+e" does not work for debuggable C++ code, even though "nm"
16 XCOMM reports no difference between the resulting libraries. The linker
17 XCOMM complains that "first non-inline virtual function" is not defined for
18 XCOMM vtables. We instead hide internal symbols with "-h" as a work-around.
20 XCOMM Author: Aloke Gupta 5/25/94.
21 XCOMM (c) Copyright 1996 Digital Equipment Corporation.
22 XCOMM (c) Copyright 1994,1996 Hewlett-Packard Company.
23 XCOMM (c) Copyright 1996 International Business Machines Corp.
24 XCOMM (c) Copyright 1996 Sun Microsystems, Inc.
25 XCOMM (c) Copyright 1996 Novell, Inc.
26 XCOMM (c) Copyright 1996 FUJITSU LIMITED.
27 XCOMM (c) Copyright 1996 Hitachi.
29 XCOMM #########################################################################
31 XCOMM Utility programs
32 FILTER=CXXFILT # C++ symbol demangler
34 PATH=/usr/bin:/bin:/usr/ucb # For nm, cat, pr, expand, awk, c++filt
37 EXPORTLIST=/tmp/elistgen1.$$ # list of export symbols from "libfoo.elist"
38 NMLIST=/tmp/elistgen2.$$ # name list from libfoo.sl
39 FILTLIST=/tmp/elistgen3.$$ # demangled (C++) version of NMLIST
41 XCOMM Print useful information at the top of the output
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 -msrv`
49 XCOMM Extract the globally visible symbols from target library
50 XCOMM The NMLIST generated here is later used to cross-check the symbols in the
51 XCOMM supplied export-list.
54 / [cCTDB][S ] [^\$]/{print $3} # Text, Data, BSS, or Secondary symbols
57 XCOMM Demangle the global library symbols. This operation is necessary to
58 XCOMM convert mangled C++ symbols into their C++ notation.
59 ${FILTER:-cat} $NMLIST > $FILTLIST
62 XCOMM Cleanup the export-list description file.
63 XCOMM Note that C++ symbols may have embedded spaces in them.
67 csyms = 0; # C language symbols in libfoo.list
68 cplusplus = 0; # C++ language symbols in libfoo.list
69 isyms = 0; # C internal symbols in libfoo.elist
70 icplusplus = 0; # C++ internal symbols in libfoo.elist
71 implicit = ""; # Handling of implicit symbols.
74 # A default clause suppresses warnings about implicit symbols.
75 if ($2 != "" && $2 != "force" && $2 != "public" &&
76 $2 != "private" && $2 != "internal") {
77 print "# Warning: illegal default clause:", $2 | "cat 1>&2";
81 print "# Warning: multiple default clauses." | "cat 1>&2";
85 $1 == "force" || $1 == "public" || $1 == "private" {
90 $1 == "publicC++" || $1 == "privateC++" {
93 for (n = 3; n <= NF; n++)
94 string = string " " $n;
103 $1 == "internalC++" {
106 for (n = 3; n <= NF; n++)
107 string = string " " $n;
108 print $1 ";;" string;
112 printf("# Exporting %d C and %d C++ symbols, hiding %d and %d.\n",
113 csyms, cplusplus, isyms, icplusplus) | "cat 1>&2";
114 if (implicit != "") {
115 print "# Unspecified symbols are " implicit "." | "cat 1>&2";
116 print "default;;" implicit;
121 XCOMM Read in the above files and write result to stdout. The contents
122 XCOMM of NMLIST and FILTLIST are used to construct a symbol lookup table.
123 XCOMM The contents of EXPORTLIST are converted with the help of this table.
124 XCOMM Use ";" as a delimiter in the symbol lookup table.
126 (pr -m -s";" -t -w1024 $NMLIST $FILTLIST| expand -t 1;cat $EXPORTLIST ) | $AWK '
132 # This is "pr" output, i.e., symbol translation table.
136 NF == 3 && $1 == "default" {
137 # Treatment of unspecified symbols.
138 if ($3 == "internal" || $3 == "internalC++")
140 else if ($3 == "private" || $3 == "privateC++")
142 else if ($3 == "public" || $3 == "publicC++")
149 # Parse our instructions for this symbol.
150 if ($1 == "internal" || $1 == "internalC++")
152 else if ($1 == "private" || $1 == "privateC++")
154 else if ($1 == "public" || $1 == "publicC++")
160 if (length(syms[$3]) > 0) {
162 print "# Warning: Duplicate entry for", $3,
163 "in export list" | "cat 1>&2";
164 if (donelist[$3] < export)
165 donelist[$3] = export;
168 donelist[$3] = export;
170 print "# Warning:", $3,
171 "was not in the nm list for this library" | "cat 1>&2";
176 # Force implicit exporting of errno.
177 if (! donelist["errno"])
178 donelist["errno"] = 4;
180 # Complain about some implicit symbols.
182 if (!donelist[i] && (length(syms[i]) > 0)) {
183 # Ignore automatic symbols generated by the C++ compiler.
185 (syms[i] !~ /^__noperfopt__/) &&
186 (syms[i] !~ /^__ptbl_vec__/) &&
187 (syms[i] !~ /^__vtbl__[0-9]*_/) &&
188 (syms[i] !~ /^__cfront_version_[0-9]*_xxxxxxxx$/))
189 print "# Warning:", syms[i],
190 "was not in the export list" | "cat 1>&2";
191 donelist[i] = implicit;
193 if ((donelist[i] > 1) && (length(syms[i]) > 0))
199 XCOMM Clean up temporary files