This is the mail archive of the egcs@egcs.cygnus.com mailing list for the EGCS project. See the EGCS home page for more information.
----- Original Message -----
From: Martin v. Loewis <martin@mira.isdn.cs.tu-berlin.de>
To: <doug@seaspace.com>
Cc: <egcs@egcs.cygnus.com>
Sent: Friday, February 26, 1999 9:25 AM
Subject: Re: Shared library compilation
>> Is there a particular reason why gcc -shared calls ld with all the
>> crt*.o files? What happens is that when I build a shared library this
>> way, even on a 900 byte .o file, the shared library is 32 K.
>> If I build the shared library with ld -shared (gnu linker, btw), it
doesn't
>> bring in these files.
>
>On ELF, this is needed so that the .ctors and .dtors sections get
>combined and referenced from a suitable .init section. Pretty much the
>same holds for the exception handling support code.
>
>Regards,
>Martin
>
Damn. That's what I kind of thought, but I was hoping it wasn't the case.
So, if I don't have global statics in the library, it should be ok to build
it using the ld -static rather than the gcc -static? Or am I missing
something?
The reason I am curious is:
1) Even though the size increase is only (cough) 32 K, we have quite a few
libraries which we are thinking about going shared.
2) Multiple instances of the crt.* files. If the OS gets changed between
revs of one of the libraries, can we guarantee the correct version of the
file
gets linked??? EG:
I build lib1.so and lib2.so using solaris 2.5, and build my apps
referencing
those libraries. Later, lib2 undergoes changes, and we rebuild. however,
in the meantime, solaris 2.5.1 comes out, changing crt1.o. lib2.so is
built
including this file. We release the library, and the executable references
both the old version of crt1.o and the new version of crt1.o. Which one
gets
loaded???? (I am not really savvy on the internals of the dynamic linker
on solaris, or any other box for that matter....I only present this as a
really
basic example :).....)
3) Again, like I said in the original email, if someone builds (by
accident,
from what you are telling me...ugh) a new version of the library using the
ld command line against an executable which was built using the gcc
version....undefined symbol errors appear when trying to run....
I wish there was a better way :)
---
Doug Semler | doug@seaspace.com
SeaSpace Corporation | Garbage In -- Gospel Out
Least Senior Software Developer; | Minister of things to do Next Quarter
Low Man on the Totem Pole | (but will Never Be Done) DNRC O-
A closed mind is a terrible thing | Bus Error (passengers dumped)
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS/M d---(pu) s++:- a-- C++ UILSH+++$ P--- L++ E--- W+
N++ o-- K? w--(++$) O- M-- V- PS+ !PE Y PGP t(+) 5+++ X+
R- tv+(-) b+(++) DI++++ D G e++>++++ h!>--- r% y+>+++++**
------END GEEK CODE BLOCK------