Egcs for AIX

Andrey Slepuhin pooh@msu.ru
Fri Apr 30 23:15:00 GMT 1999


On 21-Apr-99 David Edelsohn wrote:
>       I haven't paid much attention to exactly how shared versions of
> runtime libraries are created, but I assume that it is creating a single
> relocateable, shared object.  I think that I misspoke in my previous
> message and that collect2 does actually try to use the AIX linker's
> garbage collection of symbols.
> 
>       With a normal archive, this limits the member objects to those
> actually needed (and their associated static constructors).  With a shared
> object, the linker presumably sees the entire, single shared object as
> active which prompts collect2 to find every static constructor in the
> object.
> 
>       When you use the normal archive for collect2 preliminary step, the
> garbage collection works and then you somehow convert those unresolved
> static constructors and the rest of the symbols in the library back into
> imported symbols.  You use the archive to determine the list of static
> constructors instead of the shared object.

This is wery unclear moment. Imagine an archive library which works
e.g. with some device. And an initialization of this device is done
using a ctor of a global object in some object file. Note, that
this global object is *never* referenced neither from your program,
nor from other objects in archive. So if we will use garbage collection
for objects which have global objects with ctors/dtors, such object
will not be linked into your program and device initialization will
not be done.

> 
>       I think that much of this would be accomplished by using AIX's
> -binitfini mechanism to run static constructors instead of using the
> collect2 mechanism.  Then one would not scan all shared libraries because
> they already would specify static constructors and AIX would take care of
> running (all of) them upon load.

Yes, -binitfini mechanism is good, but it only works for AIX4.2 and later.
So using this mechanism will cause two problems:
1) We need to distinguish AIX4.2 and later from earlier AIX versions
   in collect2 (and to code a second mechanism).
2) What occurs if we want to link an executable on AIX4.2 with a shared
   library linked on AIX4.1? I'm not sure that this will work correctly...

> 
>       Using import lists more agressively will help this, but does add
> more dependencies on shared objects because of AIX shared library
> semantics.
> 
>       BTW, I believe that one can specify both absolute and relative
> pathnames for shared objects.  When a shared object dependency is
> relative, AIX uses LIBPATH to look for the libraries by name.  Note that
> the zeroth import file id is a LIBPATH.
> 
>       Let me know if you discover anything about getting
> use_import_list() to work.
> 
> Thanks, David

Regards,
Andrey.




More information about the Gcc mailing list