This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: GNU ld and -init/-fini


   From: mark@codesourcery.com
   Date: Mon, 21 Jun 1999 16:09:57 -0700

   The IRIX 6 linker provdides -init and -fini switches.  These switches
   set DT_INIT and DT_FINI flags in the dynamic table, which cause the
   named functions to be executed at initialization/finalization time.
   GCC uses these to call global constructors when a shared library is
   loaded.

   There do not seem to be equivalent GNU ld switches.  What is the
   method used on Linux, etc. in order to make the same sort of thing
   happen?

As Richard said, the GNU linker recognizes _init and _fini specially.
It sets DT_INIT to the value of the _init symbol, and sets DT_FINI to
the value of the _fini symbol.  This convention was taken from SVR4,
and indeed it is required in order to work on SVR4 and Solaris.

I think it would be appropriate to add -init and -fini options to work
for any ELF target, and permit them to override the default of _init
and _fini.

Ian

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]