Date: Tue, 24 Nov 1998 10:28:56 -0500 From: "Kaleb S. KEITHLEY" <kaleb@ics.com> To: hackers@FreeBSD.ORG Subject: Re: ELF Global Constructors Message-ID: <365AD0B8.E50AC6C3@ics.com> References: <199811240822.TAA07814@cimlogic.com.au>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?365AD0B8.E50AC6C3>