[LLVMdev] Trouble Resolving Objective-C Symbols in lli

Reid Spencer rspencer at reidspencer.com
Fri Jul 20 03:19:12 PDT 2007


Hi Ralph,

On Fri, 2007-07-20 at 10:38 +0100, Ralph Corderoy wrote:
> Hi Chris,

> I could be missing something, but shouldn't the use of dlsym() be
> 
>     char *err;
>     void *p;
> 
>     if ((err = dlerror())) {
>         error("earlier undetected dlerror: %s\n", err);
>     }
>     p = dlsym(handle, sym);
>     if ((err = dlerror())) {
>         error("dlsym failed: %s\n", err);
>     }
> 
>     return p;
> 
> The authors of dlsym() realised the return value was overloaded AFAICS.

No, you're not missing anything. The correct way to check for errors is
with dlerror. 

Please note that on the "trunk" revision of llvm (soon to be 2.1), and I
think also 2.0, there are 0 calls to dlsym in the Intercept.cpp. They
have been replaced with a call to

  sys::DynamicLibrary::SearchForAddressOfSymbol(NameStr)

Which is part of LLVM's lib/System package. That package implements this
using the libtool "ltdl" library, which presumably gets this right in an
operating system correct way.

One of the issues with this is that on some systems you can't get the
symbols that were linked into the native executable, but only from an
actually loaded shared object.

Reid.

> 
> Cheers,
> 
> 
> Ralph.
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list