From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Edelsohn To: pooh@msu.ru Cc: egcs@cygnus.com Subject: Re: egcs on AIX: native or gnu ld? Date: Sun, 19 Oct 1997 14:52:00 -0000 Message-id: <9710192145.AA33534@rios1.watson.ibm.com> References: <34492834.BA7DDDC4@msu.ru> X-SW-Source: 1997-10/msg00845.html >>>>> Andrey Slepuhin writes: Andrey> ld: 0711-319 WARNING: Exported symbol not defined: _GLOBAL_.I.f__Fv Andrey> ld: 0711-318 ERROR: Undefined symbols were found. Andrey> _GLOBAL_.I.f__Fv [2] ER DS ccMav3Ma.c(/tmp/ccMav3Ma.o) I think that this is an individual constructor. Andrey> Manually relinking files once more I obtain correct exexutable (If extra pass Andrey> is needed why not to do it automatically?). Unfortunately, -frepo option is Andrey> bad documented :-( XLC has a twolink option performs the link phase twice. This allows the IBM garbage-collecting linker to perform a pass and then re-examine the global symbols needing export. This frequently is useful for static contructors. What may happen is that the initial examination recognizes the symbol as a candidate for export but the linker discovers that the symbol is not referenced and removes it altogether which then causes an error because the original pass included it in the list of exports. The two-pass version only exports those symbols present after symbol garbage-collection. >> The _GLOBAL__DI/_GLOBAL_DD symbols invoke the global constructors >> and destructors for a shared object and are exported for AIX. Because >> each shared object will contain those same entry points, they will be >> duplicated and the AIX linker will warn about them. In AIX 4, the linker >> now announced a lot more warnings about these type of issues which always >> were produced by GCC. Andrey> Well, I undestand this, but if I link my program with several shared objects, Andrey> can I be sure that global constructors/destructors code will be called for Andrey> each object? These GLOBAL__DI/DD symbols exist for each library. collect2 and gnu ld collect all of the static constructors to be run at program startup -- both symbols within the program and symbols within any libraries. The GLOBAL__DI/DD symbols are present and duplicated in the executable because they are present in each library as a defining instance, but they never are referenced because collect2 has created a separate list of all of the constructor symbols for the executable. Wilfried Philips and someone from IBM Austin previously posted makeC++SharedLib-like scripts to create an export file. I do not know if you can use it (appended) combined with your own hacks and any necessary multiple link phases automation to create a single patch for improved shared library support by GCC/EGCS that you would like to submit for inclusion in future releases. David ----- Begin Included Text ----- From: Wilfried Philips Newsgroups: comp.unix.aix Subject: Re: Dynamic Loading... Date: 17 Feb 1997 18:40:40 +0100 Organization: ELIS-RUG (University of Gent, Belgium) %%%%%%%%%%%mkexps%%%%%%%%%%%%%%%%%%%%%% #!/bin/ksh # # mkexps - make export list # This program creates an export list by combining all the "." and normal names # into one list. # if [[ "$#" -ne 1 ]] then print "Usage: mkexps ArchiveFile" exit -2 fi if [[ ! -f $1 ]] then print "mkexps: Cannot open file \"$1\"" exit -1 fi dump -g $1 | awk ' BEGIN { top = 1 } /^[ ]*[0-9][0-9]*/ { if ( (n = index( $2, "." )) > 0 ) { export_array[ top++ ] = substr( $2, n+1, length( $2 )) } else { export_array[ top++ ] = $2 } } END { for ( i = 1; i < top; i++ ) { print export_array[ i ] } }' | sort | uniq %%%%%%%%%%%mkexps%%%%%%%%%%%%%%%%%%%%%% *** OR *** From: dosha@austin.ibm.com Subject: Re: Dynamic Loading... Date: Thu, 20 Feb 1997 17:30:29 -0600 Organization: IBM Austin Try the following: nm libtest.a | grep ' [BAD] ' | cut -f1 -d ' ' > test.exp ----- End Incuded Text ----- =============================================================================== David Edelsohn T.J. Watson Research Center dje@watson.ibm.com P.O. Box 218 +1 914 945 4364 (TL 862) Yorktown Heights, NY 10598