public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* shared library, init
@ 2001-09-19  5:04 Roger Wells
  2001-09-21 16:51 ` Marc Espie
  0 siblings, 1 reply; 2+ messages in thread
From: Roger Wells @ 2001-09-19  5:04 UTC (permalink / raw)
  To: gcc

When I use the linker flag, -Wl,-init,  the linker complains that my _init()
conflicts with one in crti.o.  When I give the -init flag the name of a
function that I supply it is ignored.  Can someone advise me of the correct
syntax to establish a shared library initialization (& termination)
function.

Roger Wells, P.E.
SAIC
221 Third St
Newport, RI 02840
401-847-4210 (voice)
401-849-1585 (fax)
roger@mtg.saic.com


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: shared library, init
  2001-09-19  5:04 shared library, init Roger Wells
@ 2001-09-21 16:51 ` Marc Espie
  0 siblings, 0 replies; 2+ messages in thread
From: Marc Espie @ 2001-09-21 16:51 UTC (permalink / raw)
  To: ROGER.K.WELLS; +Cc: gcc

In article < 00d301c14103$3c921b00$f05a798b@mtg.saic.com > you write:
>When I use the linker flag, -Wl,-init,  the linker complains that my _init()
>conflicts with one in crti.o.  When I give the -init flag the name of a
>function that I supply it is ignored.  Can someone advise me of the correct
>syntax to establish a shared library initialization (& termination)
>function.

In the gcc context, assuming this is C, see attribute constructor and 
destructor in the gcc documentation. For C++, this is even more trivial. 
This assumes you're running gcc on a platform with full support for 
this (which is either provided directly by ld + ELF or by collect2 usually). 

Note that the semantics are a bit hard to guarantee and check: it is often
unknown in which order several initialisation routines will be run (and how 
many times), and it is even harder to be sure that a finalization routine 
will actually be run...

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-09-21 16:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-19  5:04 shared library, init Roger Wells
2001-09-21 16:51 ` Marc Espie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).