>>>>> "Raymond" == Raymond Wiker <[EMAIL PROTECTED]> 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 [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to