📄 elistgen.hp
字号:
XCOMM!/bin/shXCOMM $XConsortium: elistgen.hp /main/2 1996/12/04 10:13:14 swick $XCOMMXCOMM #########################################################################XCOMM Construct shared-library export lists for HP-UX based on standardizedXCOMM export list description fileXCOMMXCOMM Usage: exportlistgen libfoo.sl libfoo.elist > libfoo.loptXCOMMXCOMM libfoo.sl => shared library of interestXCOMM libfoo.elist => Meta description of necessary export list.XCOMMXCOMM The output may then be passed to the linker to reconstruct theXCOMM shared library. For unknown reasons naming only exported symbolsXCOMM with "+e" does not work for debuggable C++ code, even though "nm"XCOMM reports no difference between the resulting libraries. The linkerXCOMM complains that "first non-inline virtual function" is not defined forXCOMM vtables. We instead hide internal symbols with "-h" as a work-around.XCOMMXCOMM Author: Aloke Gupta 5/25/94.XCOMM (c) Copyright 1996 Digital Equipment Corporation.XCOMM (c) Copyright 1994,1996 Hewlett-Packard Company.XCOMM (c) Copyright 1996 International Business Machines Corp.XCOMM (c) Copyright 1996 Sun Microsystems, Inc.XCOMM (c) Copyright 1996 Novell, Inc.XCOMM (c) Copyright 1996 FUJITSU LIMITED.XCOMM (c) Copyright 1996 Hitachi.XCOMMXCOMM #########################################################################XCOMM Utility programsFILTER=CXXFILT # C++ symbol demanglerAWK=awk # awkPATH=/usr/bin:/bin:/usr/ucb # For nm, cat, pr, expand, awk, c++filtXCOMM Temporary filesEXPORTLIST=/tmp/elistgen1.$$ # list of export symbols from "libfoo.elist"NMLIST=/tmp/elistgen2.$$ # name list from libfoo.slFILTLIST=/tmp/elistgen3.$$ # demangled (C++) version of NMLISTXCOMM Print useful information at the top of the outputecho "#" `date`echo "# This linker options list was produced by" $0echo "# Input export list description taken from:" $2echo "# Target library:" $1echo "# Target Operating System:" `uname -msrv`echo "# "XCOMM Extract the globally visible symbols from target libraryXCOMM The NMLIST generated here is later used to cross-check the symbols in theXCOMM supplied export-list.XCOMMnm -p $1 | $AWK ' / [cCTDB][S ] [^\$]/{print $3} # Text, Data, BSS, or Secondary symbols' > $NMLISTXCOMM Demangle the global library symbols. This operation is necessary toXCOMM convert mangled C++ symbols into their C++ notation.${FILTER:-cat} $NMLIST > $FILTLISTXCOMMXCOMM Cleanup the export-list description file.XCOMM Note that C++ symbols may have embedded spaces in them.XCOMMcat $2 | $AWK ' BEGIN { csyms = 0; # C language symbols in libfoo.list cplusplus = 0; # C++ language symbols in libfoo.list isyms = 0; # C internal symbols in libfoo.elist icplusplus = 0; # C++ internal symbols in libfoo.elist implicit = ""; # Handling of implicit symbols. } $1 == "default" { # A default clause suppresses warnings about implicit symbols. if ($2 != "" && $2 != "force" && $2 != "public" && $2 != "private" && $2 != "internal") { print "# Warning: illegal default clause:", $2 | "cat 1>&2"; next; } if (implicit != "") print "# Warning: multiple default clauses." | "cat 1>&2"; implicit = $2; next; } $1 == "force" || $1 == "public" || $1 == "private" { csyms ++; print $1 ";;" $2; next; } $1 == "publicC++" || $1 == "privateC++" { cplusplus ++; string = $2; for (n = 3; n <= NF; n++) string = string " " $n; print $1 ";;" string; next; } $1 == "internal" { isyms ++; print $1 ";;" $2; next; } $1 == "internalC++" { icplusplus ++; string = $2; for (n = 3; n <= NF; n++) string = string " " $n; print $1 ";;" string; next; } END { printf("# Exporting %d C and %d C++ symbols, hiding %d and %d.\n", csyms, cplusplus, isyms, icplusplus) | "cat 1>&2"; if (implicit != "") { print "# Unspecified symbols are " implicit "." | "cat 1>&2"; print "default;;" implicit; } }' > $EXPORTLISTXCOMM Read in the above files and write result to stdout. The contentsXCOMM of NMLIST and FILTLIST are used to construct a symbol lookup table.XCOMM The contents of EXPORTLIST are converted with the help of this table.XCOMM Use ";" as a delimiter in the symbol lookup table.XCOMM(pr -m -s";" -t -w1024 $NMLIST $FILTLIST| expand -t 1;cat $EXPORTLIST ) | $AWK ' BEGIN { FS = ";"; implicit = 0; } NF == 2 { # This is "pr" output, i.e., symbol translation table. syms[$2] = $1; next; } NF == 3 && $1 == "default" { # Treatment of unspecified symbols. if ($3 == "internal" || $3 == "internalC++") implicit = 1; else if ($3 == "private" || $3 == "privateC++") implicit = 2; else if ($3 == "public" || $3 == "publicC++") implicit = 3; else # $3 == "force" implicit = 4; next; } NF == 3 { # Parse our instructions for this symbol. if ($1 == "internal" || $1 == "internalC++") export = 1; else if ($1 == "private" || $1 == "privateC++") export = 2; else if ($1 == "public" || $1 == "publicC++") export = 3; else # $1 == "force" export = 4; # Process it. if (length(syms[$3]) > 0) { if (donelist[$3]) print "# Warning: Duplicate entry for", $3, "in export list" | "cat 1>&2"; if (donelist[$3] < export) donelist[$3] = export; } else { if (export == 4) donelist[$3] = export; else print "# Warning:", $3, "was not in the nm list for this library" | "cat 1>&2"; } next; } END { # Force implicit exporting of errno. if (! donelist["errno"]) donelist["errno"] = 4; # Complain about some implicit symbols. for (i in syms) { if (!donelist[i] && (length(syms[i]) > 0)) { # Ignore automatic symbols generated by the C++ compiler. if (implicit == 0 && (syms[i] !~ /^__noperfopt__/) && (syms[i] !~ /^__ptbl_vec__/) && (syms[i] !~ /^__vtbl__[0-9]*_/) && (syms[i] !~ /^__cfront_version_[0-9]*_xxxxxxxx$/)) print "# Warning:", syms[i], "was not in the export list" | "cat 1>&2"; donelist[i] = implicit; } if ((donelist[i] > 1) && (length(syms[i]) > 0)) print "-e", syms[i]; } }'XCOMM Clean up temporary filesrm $EXPORTLISTrm $NMLISTrm $FILTLIST
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -