Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 26 Dec 1998 10:32:03 -0500
From:      "Kaleb S. KEITHLEY" <kaleb@ics.com>
To:        hackers@FreeBSD.ORG
Subject:   Re: dynamic libraries loading
Message-ID:  <36850172.41C67EA6@ics.com>
References:  <Pine.LNX.4.05.9812251142440.319-100000@gizmo.kyrnet.kg>

next in thread | previous in thread | raw e-mail | index | archive | help
CyberPsychotic wrote:
> 
> I used my own _init(..) function on Linux, which is called, when the
> library is loaded, and compiling it library with -nostdlib switch was
> enough to get rid off names collision. However I noticed that neither
> FreeBSD nor BSDi calls _init when loads library.

On which version of FreeBSD? On my 3.0-RELEASE machine the shared lib
_init() and _fini() functions are called.

Note however that the ELF specification says that these functions should
be called .init() and .fini(). 

(Getting functions named .init() and .fini requires a little extra
effort; but it's not that hard. You have to compile to assembler, then
change the names (using sed) because a leading '.' is not valid for a
name in C, then use the assembler to generate the .o file(s))

Looking at the sources in /usr/src/libexec/rtld-elf/, I see that rtld
relies on the DT_INIT and DT_FINI tags to find the functions in the
shared lib. Apparently it's ld that looks for functions named _init()
and _fini() and tags them accordingly. Guess I'll have to suck down the
FreeBSD/gnu sources to have a look see.

--
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?36850172.41C67EA6>