Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 27 Dec 1998 15:42:55 -0500
From:      "Kaleb S. KEITHLEY" <kaleb@ics.com>
To:        Ulrich Drepper <drepper@cygnus.com>
Cc:        hackers@FreeBSD.ORG, bug-gnu-utils@gnu.org
Subject:   Re: ld (bfd): wrong function names for ELF shared library  DT_{INIT,FINI}
Message-ID:  <36869BCF.2F1CF0FB@ics.com>
References:  <Pine.BSF.4.01.9812271747560.383-100000@herring.nlsystems.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Doug Rabson wrote:
> 
> On 27 Dec 1998, Ulrich Drepper wrote:
> 
> > "Kaleb S. KEITHLEY" <kaleb@ics.com> writes:
> >
> > > The ELF specification says that the names of the DT_{INIT,FINI}
> > > functions in shared libraries are named .init() and .fini(), not _init()
> > > and _fini().
> >
> > I assume you refer to the section titled "Initialization adn
> > Termination Functions" in the TIS.  If yes, read it again.
> >
> > What is named ".init" and ".fini" are the **section** where these
> > functions are placed in.  This are not the function names.  In fact,
> > the function names are not specified at all.  _init and _fini come
> > from folklore (speek, the first ELF implementations).
> 
> I haven't looked at the i386 code but the alpha _init() and _fini() are
> already in the correct sections.

On x86 ELF binutils/ld does not create .init or .fini sections.

In the past, given the lack of tools to tag things as belonging in the
.init and .fini sections that I have kludged it with assembler to create
.init() and .fini() functions, and they were called. Given that the
.init and .fini sections are simply executable code, I think the
distinction between being sections and being functions is too subtle to
support your case.

So, to assert that the binutils/ld is compatible with SVR4 is erroneous. 

Furthermore, since we're allowing folkloric evidence, I'll assert that,
kludge though it may be, the fact that my kludge works on the ELF
reference implementation means that it should work elsewhere too.

(The current release of SunPro C has #pragma init(fn[,fn...]) and
#pragma fini(fn[,fn]) to tag functions for inclusion in .init and
.fini.)

And having reread the spec, as you so eloquently suggested, I'll take
this opportunity return the favor and point out that binutils/ld has no
support whatsoever for DT_INIT_ARRAY, DT_FINI_ARRAY, thereby precluding
the possibility that a shared lib could have multiple initialization
and/or termination functions. Nor does it handle multiple occurances of
_init() or _fini() -- not that that would be the right way to handle
multiple initialization and termination functions in any event.

--
Kaleb

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?36869BCF.2F1CF0FB>