Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Apr 1999 05:07:58 -0500 (EST)
From:      Alfred Perlstein <bright@rush.net>
To:        Jacques Vidrine <n@nectar.com>
Cc:        hackers@FreeBSD.ORG
Subject:   Re: __attribute__ ((constructor)) functions & shared libs 
Message-ID:  <Pine.BSF.3.96.990418050442.11384D-100000@cygnus.rush.net>
In-Reply-To: <199904180914.EAA22349@spawn.nectar.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 18 Apr 1999, Jacques Vidrine wrote:

> On 18 April 1999 at 3:53, Jacques Vidrine <n@nectar.com> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.96.990418050442.11384D-100000>