Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 Jul 2000 01:53:22 +0930 (CST)
From:      "Daniel O'Connor" <darius@dons.net.au>
To:        Raymond Wiker <Raymond.Wiker@fast.no>
Cc:        freebsd-hackers@freebsd.org
Subject:   RE: dlopen() and friends from a statically-linked binary?
Message-ID:  <XFMail.000722015322.darius@dons.net.au>
In-Reply-To: <14711.10742.914512.819982@raw.gren.fast.no>

next in thread | previous in thread | raw e-mail | index | archive | help

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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.000722015322.darius>