Date: Fri, 21 Jul 2000 11:15:16 +0100 (BST) From: Martin Hopkins <martin.hopkins@insignia.com> To: Raymond Wiker <Raymond.Wiker@fast.no> Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: dlopen() and friends from a statically-linked binary? Message-ID: <14712.8884.57869.666781@whittard.home> In-Reply-To: <14711.10742.914512.819982@raw.gren.fast.no> References: <14711.10742.914512.819982@raw.gren.fast.no>
next in thread | previous in thread | raw e-mail | index | archive | help
>>>>> "Raymond" == Raymond Wiker <Raymond.Wiker@fast.no> writes: Raymond> raw : ~ $ cat dltest.c Raymond> #include <dlfcn.h> Raymond> #include <stdio.h> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?14712.8884.57869.666781>