From owner-freebsd-hackers Fri Jul 21 9:23:44 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from midget.dons.net.au (daniel.lnk.telstra.net [139.130.137.70]) by hub.freebsd.org (Postfix) with ESMTP id B340637BB99 for ; Fri, 21 Jul 2000 09:23:37 -0700 (PDT) (envelope-from darius@guppy.dons.net.au) Received: from guppy.dons.net.au (guppy.dons.net.au [203.31.81.9]) by midget.dons.net.au (8.9.3/8.9.1) with ESMTP id BAA79843; Sat, 22 Jul 2000 01:53:31 +0930 (CST) (envelope-from darius@guppy.dons.net.au) Received: (from darius@localhost) by guppy.dons.net.au (8.9.3/8.9.3) id BAA00828; Sat, 22 Jul 2000 01:53:26 +0930 (CST) (envelope-from darius) Message-ID: X-Mailer: XFMail 1.4.0 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <14711.10742.914512.819982@raw.gren.fast.no> Date: Sat, 22 Jul 2000 01:53:22 +0930 (CST) From: "Daniel O'Connor" To: Raymond Wiker Subject: RE: dlopen() and friends from a statically-linked binary? Cc: freebsd-hackers@freebsd.org Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On 20-Jul-00 Raymond Wiker wrote: > Is it possible, at all, to use dlopen etc from a > statically-linked executable? My experiments with FreeBSD-4.0 (see > below) indicate that it's not possible. You can't do it from a statically linked binary, however you can create a dynamic executable with no external unresolved references.. I forget how though :-/ > The reason that I'd like this to work is that SBCL (a Common > Lisp implementation, see http://sbcl.sourceforge.net) needs the > addresses of certain library symbols (e.g, errno) when building the > initial lisp image. This seems to require static linking. On the other > hand, SBCL is severely handicapped if it cannot subsequently use > dlopen() to load foreign code into the running lisp system. Well, I don't see why it would need static linking for that.. When the binary runs the libraries it uses will get loaded, and then it can use dlsym() to get the addresses it needs.. (ie what I am saying is I don't understand your explanation :) > raw : ~ $ gcc -static dltest.c -o dltest > raw : ~ $ ./dltest > dlopen returned 0: Service unavailable > Handle: 0x0, main: 0x0 > > raw : ~ $ gcc dltest.c -o dltest > raw : ~ $ ./dltest > Handle: 0x2805e000, main: 0x0 > Handle: 0x0, main: 0x0 > > [ Note: this seems wrong; according to the manpage for dlsym, the > second call should give the same output as the first. ] Agreed. --- Daniel O'Connor software and network engineer for Genesis Software - http://www.gsoft.com.au "The nice thing about standards is that there are so many of them to choose from." -- Andrew Tanenbaum To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message