From owner-freebsd-hackers Sat Dec 26 06:12:13 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id GAA02192 for freebsd-hackers-outgoing; Sat, 26 Dec 1998 06:12:13 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from ics.com (ics.com [140.186.40.192]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id GAA02187 for ; Sat, 26 Dec 1998 06:12:10 -0800 (PST) (envelope-from kaleb@ics.com) Received: from kaleb.keithley.belmont.ma.us (pmdialin5.ics.com [140.186.40.179]) by ics.com (8.9.0.Beta5/8.9.0.Beta5) with ESMTP id JAA03002 Sat, 26 Dec 1998 09:07:37 -0500 (EST) Received: from kaleb.keithley.belmont.ma.us (localhost [127.0.0.1]) by kaleb.keithley.belmont.ma.us (8.9.1/8.9.1) with SMTP id KAA06882 for ; Sat, 26 Dec 1998 10:32:10 -0500 (EST) (envelope-from kaleb@ics.com) Message-ID: <36850172.41C67EA6@ics.com> Date: Sat, 26 Dec 1998 10:32:03 -0500 From: "Kaleb S. KEITHLEY" Organization: Integrated Computer Solutions X-Mailer: Mozilla 3.04Gold (X11; I; FreeBSD 3.0-RELEASE i386) MIME-Version: 1.0 To: hackers@FreeBSD.ORG Subject: Re: dynamic libraries loading References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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