Date: Wed, 19 Dec 2001 19:05:37 -0500 From: Jake Burkholder <jake@locore.ca> To: Bernd Walter <ticso@cicely9.cicely.de> Cc: Maxime Henrion <mux@qualys.com>, freebsd-hackers@FreeBSD.ORG Subject: Re: init code in dynamic libraries Message-ID: <20011219190537.N39205@locore.ca> In-Reply-To: <20011219204645.GB66211@cicely9.cicely.de>; from ticso@cicely9.cicely.de on Wed, Dec 19, 2001 at 09:46:46PM %2B0100 References: <20011219184930.GA66211@cicely9.cicely.de> <20011219200620.A281@nebula.noos.fr> <20011219204645.GB66211@cicely9.cicely.de>
next in thread | previous in thread | raw e-mail | index | archive | help
Apparently, On Wed, Dec 19, 2001 at 09:46:46PM +0100, Bernd Walter said words to the effect of; > On Wed, Dec 19, 2001 at 08:06:20PM +0100, Maxime Henrion wrote: > > Bernd Walter wrote: > > > How can I add initalisation code to a library without needing to > > > call a function in the using application? > > > What I saw is that libc does something like this but havn't found > > > the starting point of this. > > > > There are two special functions for that : _init() which will be called > > when the object is loaded, and _fini() which will be called when it is > > released. > > I can see that symbol defined in libc.so.5 but no reference in the libc > source code. > All I see are several *_init functions. > Are they all called from within an autocreated _init function? > If yes in which order? The _init and _fini functions call global constructors and destructors (in c++). There's a gcc extension for making a constructor in C, put __attribute__((constructor)) in the prototype. The dynamic linker will call them when it loads the library. I don't know if the order that they're called in is defined or not. > > -- > B.Walter COSMO-Project http://www.cosmo-project.de > ticso@cicely.de Usergroup info@cosmo-project.de > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message 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?20011219190537.N39205>