From owner-freebsd-hackers Tue Nov 24 07:29:10 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id HAA02954 for freebsd-hackers-outgoing; Tue, 24 Nov 1998 07:29:10 -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 HAA02948 for ; Tue, 24 Nov 1998 07:29:05 -0800 (PST) (envelope-from kaleb@ics.com) Received: from ics.com (sunoco.ics.com [140.186.40.142]) by ics.com (8.9.0.Beta5/8.9.0.Beta5) with ESMTP id KAA27425 Tue, 24 Nov 1998 10:28:56 -0500 (EST) Message-ID: <365AD0B8.E50AC6C3@ics.com> Date: Tue, 24 Nov 1998 10:28:56 -0500 From: "Kaleb S. KEITHLEY" Organization: Integrated Computer Solutions X-Mailer: Mozilla 4.5 [en] (X11; I; SunOS 5.5.1 sun4u) X-Accept-Language: en MIME-Version: 1.0 To: hackers@FreeBSD.ORG Subject: Re: ELF Global Constructors References: <199811240822.TAA07814@cimlogic.com.au> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG John Birrell wrote: > > Jonathan Gapen wrote: > > I'm in the process of porting GNUstep to FreeBSD 3.0, and I've run > > into a lack of documentation. Consequently, I don't know where the > > problem lies. It's like this: > > GNUstep needs to have a function _gnu_process_args() called before > > main() to set up information about the process for use by the Foundation > > library. On non-Linux ELF systems, it tries this bit of code: > > > > static void *__gnustep_base_subinit_args__ > > __attribute__ ((section ("_libc_subinit"))) = &(_gnu_process_args); > > > > This is where the lack of documentation is getting me. I can't find > > out what *will* work. I don't know if this is the correct way to hook in > > a function call before main() and FreeBSD is broken, or egcs is broken, or > > if it's the wrong way entirely. > > I'm not even sure where to dig into the system source to find out > > what's going on, so I'd appreciate any help/pointers. Thanks! > > For an example of a constructor, have a look at: > > src/lib/libc_r/uthread/uthread_autoinit.cc > > This is how a threaded process is initialised prior to the process calling > main(). This code works with the in-tree compiler (I haven't used egcs, so > I'm not sure about that). The ELF Specification (a.k.a. the System V ABI) says that the .init() function in the shared lib(s) is/are called before main(). Likewise the .fini() function is called after the program exits normally. Any initialization the shared library needs, e.g. calling global constructors, can be put there. -- Kaleb To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message