From owner-freebsd-hackers Fri Jan 21 11:52:50 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from fanf.noc.demon.net (fanf.noc.demon.net [195.11.55.83]) by hub.freebsd.org (Postfix) with ESMTP id 99D92154F6; Fri, 21 Jan 2000 11:52:29 -0800 (PST) (envelope-from fanf@demon.net) Received: from fanf by fanf.noc.demon.net with local (Exim 3.02 #13) id 12Bk6U-00032O-00; Fri, 21 Jan 2000 19:52:18 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit From: Tony Finch To: freebsd-hackers@freebsd.org, jdp@freebsd.org Cc: Tony Finch Subject: Re: LD_PRELOAD In-Reply-To: References: X-Mailer: VM 6.34 under Emacs 19.34.1 Message-Id: Date: Fri, 21 Jan 2000 19:52:18 +0000 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Tony Finch wrote: > > This brings me on to the second problem. I want to do some > initialization of my library before the real action starts. On Solaris > the linker calls a function in the object called _init() when it is > loaded; it's easy to make this work. I can see similar functionality > in FreeBSD's rtld but it looks like I have to jump through obscure > hoops to make it work (an ELF DT_INIT section if I understand it > correctly). After some more playing I found that adding the following declarations shut up the linker and caused the _init and _fini functions to be called as I desired. My only remaining questions are whether the gcc command line I used is correct and if it is what does it all mean? #ifdef __FreeBSD__ static void _init(void) __attribute__ ((section (".init"))); static void _fini(void) __attribute__ ((section (".fini"))); #endif Tony. -- the dot at person To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message