From owner-freebsd-hackers Sun Apr 18 9:45:23 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 EC1EE152F7 for ; Sun, 18 Apr 1999 09:45:19 -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 JAA21688; Sun, 18 Apr 1999 09:42:54 -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 JAA20431; Sun, 18 Apr 1999 09:42:54 -0700 (PDT) (envelope-from jdp@polstra.com) Date: Sun, 18 Apr 1999 09:42:54 -0700 (PDT) Message-Id: <199904181642.JAA20431@vashon.polstra.com> To: bright@rush.net Subject: Re: __attribute__ ((constructor)) functions & shared libs In-Reply-To: Organization: Polstra & Co., Seattle, WA Cc: hackers@freebsd.org Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In article , Alfred Perlstein wrote: > 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. It's better to use the attributes as Jacques did. The _init() and _fini() functions, like almost all functions whose names begin with "_", are private to the implementation. That is, they are for the use of the runtime system. Applications aren't allowed to override them. We probably shouldn't even mention them in the documentation. 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