From owner-freebsd-hackers Sun Apr 18 2:55:12 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from cygnus.rush.net (cygnus.rush.net [209.45.245.133]) by hub.freebsd.org (Postfix) with ESMTP id 8AFD5152F5 for ; Sun, 18 Apr 1999 02:55:09 -0700 (PDT) (envelope-from bright@rush.net) Received: from localhost (bright@localhost) by cygnus.rush.net (8.9.3/8.9.3) with SMTP id FAA09116; Sun, 18 Apr 1999 05:08:00 -0500 (EST) Date: Sun, 18 Apr 1999 05:07:58 -0500 (EST) From: Alfred Perlstein To: Jacques Vidrine Cc: hackers@FreeBSD.ORG Subject: Re: __attribute__ ((constructor)) functions & shared libs In-Reply-To: <199904180914.EAA22349@spawn.nectar.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sun, 18 Apr 1999, Jacques Vidrine wrote: > On 18 April 1999 at 3:53, Jacques Vidrine wrote: > > I'm porting an application that uses ``__attribute__ ((constructor))'' > > to give shared libraries initialization functions. Unfortunately, it > > seems that environ is not yet initialized when these functions are > > called. > > BTW, this is the situation on ELF systems only. a.out systems > behave as expected. I'm no compiler/linker expert, but when i wanted to do this sort of thing, what i did was create my shared objects with functions void _init(void) and void _fini(void) if you link the .so with -nostdlib then the init and fini functions will be called when the shared object is linked in. gcc -shared -nostdlib -o blah.so obj1.o obj2.o .... i'm not sure if this is the solution you are looking for, but it may be. -Alfred To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message