From owner-freebsd-hackers Fri Jul 21 3:19:45 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from gatekeeper.isltd.insignia.com (gatekeeper.isltd.insignia.com [195.153.60.130]) by hub.freebsd.org (Postfix) with ESMTP id 0FC3037B906 for ; Fri, 21 Jul 2000 03:19:35 -0700 (PDT) (envelope-from martin.hopkins@insignia.com) Received: from saracen.isltd.insignia.com (saracen.isltd.insignia.com [193.112.17.171]) by gatekeeper.isltd.insignia.com (8.9.3/8.9.3) with ESMTP id LAA25675; Fri, 21 Jul 2000 11:18:54 +0100 (BST) Received: from whittard.home.isltd.insignia.com (dhcp16-223.isltd.insignia.com [193.112.16.223]) by saracen.isltd.insignia.com (8.8.4/BSCF-1.2) with SMTP id LAA13503; Fri, 21 Jul 2000 11:18:50 +0100 (BST) From: Martin Hopkins MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <14712.8884.57869.666781@whittard.home> Date: Fri, 21 Jul 2000 11:15:16 +0100 (BST) To: Raymond Wiker Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: dlopen() and friends from a statically-linked binary? In-Reply-To: <14711.10742.914512.819982@raw.gren.fast.no> References: <14711.10742.914512.819982@raw.gren.fast.no> X-Mailer: VM 6.75 under Emacs 19.34.1 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG >>>>> "Raymond" == Raymond Wiker writes: Raymond> raw : ~ $ cat dltest.c Raymond> #include Raymond> #include Raymond> main() Raymond> { Raymond> void *handle; Raymond> void *sym; Raymond> handle = dlopen(0, RTLD_LAZY); Raymond> if (handle == 0) Raymond> { Raymond> fprintf(stderr, "dlopen returned 0: %s\n", dlerror()); Raymond> } Raymond> else Raymond> { Raymond> fprintf(stderr, "Handle: %p, main: %p\n", handle, dlsym(handle, "main")); Raymond> } Raymond> fprintf(stderr, "Handle: %p, main: %p\n", 0, dlsym(0, "main")); Raymond> return 0; Raymond> } Raymond> raw : ~ $ gcc -static dltest.c -o dltest Raymond> raw : ~ $ ./dltest Raymond> dlopen returned 0: Service unavailable Raymond> Handle: 0x0, main: 0x0 Raymond> raw : ~ $ gcc dltest.c -o dltest Raymond> raw : ~ $ ./dltest Raymond> Handle: 0x2805e000, main: 0x0 Raymond> Handle: 0x0, main: 0x0 Raymond> [ Note: this seems wrong; according to the manpage for dlsym, the Raymond> second call should give the same output as the first. ] It does, it returns NULL. I'm not sure what your issues with SBCL are (I'll try to take a look later if I get time). I believe to get your sample code above to work you want... gcc dltest.c -Xlinker -export-dynamic -o dltest This then gives me Handle: 0x2805d000, main: 0x8048508 Handle: 0x0, main: 0x8048508 Hope this helps, Martin To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message