From owner-freebsd-hackers Sun Apr 18 9:42:10 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from wall.polstra.com (rtrwan160.accessone.com [206.213.115.74]) by hub.freebsd.org (Postfix) with ESMTP id 2E08E14CEC for ; Sun, 18 Apr 1999 09:42:06 -0700 (PDT) (envelope-from jdp@polstra.com) Received: from vashon.polstra.com (vashon.polstra.com [206.213.73.13]) by wall.polstra.com (8.9.3/8.9.1) with ESMTP id JAA21664; Sun, 18 Apr 1999 09:39:41 -0700 (PDT) (envelope-from jdp@polstra.com) From: John Polstra Received: (from jdp@localhost) by vashon.polstra.com (8.9.3/8.9.1) id JAA20403; Sun, 18 Apr 1999 09:39:41 -0700 (PDT) (envelope-from jdp@polstra.com) Date: Sun, 18 Apr 1999 09:39:41 -0700 (PDT) Message-Id: <199904181639.JAA20403@vashon.polstra.com> To: n@nectar.com Subject: Re: __attribute__ ((constructor)) functions & shared libs In-Reply-To: <199904180853.DAA22110@spawn.nectar.com> Organization: Polstra & Co., Seattle, WA Cc: hackers@freebsd.org Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In article <199904180853.DAA22110@spawn.nectar.com>, Jacques Vidrine wrote: > Hi all, > > 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. Which version/date of FreeBSD? > What might I be missing? Looking at src/lib/csu/i386-elf/crt1.c, it > seems as if environ is set before invoking the run time linker. If it's ELF, the dynamic linker runs before crt1 gets control. The kernel invokes the dynamic linker directly. After it has finished its job, the dynamic linker transfers control to the main program's entry point. You are not officially "allowed" to assume that anything is already initialized in those constructor/destructor functions. Not even printf is really guaranteed to work. But perhaps we can make some simple changes so that most things will work despite that. John -- John Polstra jdp@polstra.com John D. Polstra & Co., Inc. Seattle, Washington USA "Self-interest is the aphrodisiac of belief." -- James V. DeLong To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message