From owner-freebsd-stable Fri Jul 21 2:28:33 2000 Delivered-To: freebsd-stable@freebsd.org Received: from tepid.osl.fast.no (tepid.osl.fast.no [213.188.9.130]) by hub.freebsd.org (Postfix) with ESMTP id 709AC37B62F; Fri, 21 Jul 2000 02:28:27 -0700 (PDT) (envelope-from raw@fast.no) Received: from raw.gren.fast.no (fw-oslo.fast.no [213.188.9.129]) by tepid.osl.fast.no (8.9.3/8.9.1) with ESMTP id JAA88153; Fri, 21 Jul 2000 09:29:20 GMT (envelope-from raw@fast.no) Received: (from raw@localhost) by raw.gren.fast.no (8.9.3/8.9.3) id KAA16115; Fri, 21 Jul 2000 10:16:53 +0200 (CEST) (envelope-from raw) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <14711.10742.914512.819982@raw.gren.fast.no> X-Mailer: VM 6.72 under 21.1 (patch 9) "Canyonlands" XEmacs Lucid From: Raymond Wiker To: freebsd-hackers@freebsd.org Subject: dlopen() and friends from a statically-linked binary? Date: Thu, 20 Jul 2000 18:33:58 +0200 (CEST) Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG [ Re-sent, as it seemed to get lost on my first try. ] 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. 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. raw : ~ $ cat dltest.c #include #include main() { void *handle; void *sym; handle = dlopen(0, RTLD_LAZY); if (handle == 0) { fprintf(stderr, "dlopen returned 0: %s\n", dlerror()); } else { fprintf(stderr, "Handle: %p, main: %p\n", handle, dlsym(handle, "main")); } fprintf(stderr, "Handle: %p, main: %p\n", 0, dlsym(0, "main")); return 0; } 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. ] -- Raymond Wiker To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message