[LLVMdev] Trouble Resolving Objective-C Symbols in lli

Ralph Corderoy ralph at inputplus.co.uk
Fri Jul 20 02:38:30 PDT 2007


Hi Chris,

> Once you have that, you are hitting another problem.  Specifically,
> the JIT::getPointerToNamedFunction method in
> lib/ExecutionEngine/JIT/Intercept.cpp just does a dlsym on missing
> symbols.  If dlsym returns null, you get the error message.
> 
> The problem here is that .objc_class_name_* are special symbols that
> are used by the objc linker support and they have magic meaning.  This
> itself isn't a problem, the problem is that they are absolute symbols
> (which is why nm prints 'A' for the symbol) and their absolute value
> is 0.  When dlsym correctly returns the address of this symbol, it
> returns a null pointer (which is the address of the symbol) and lli
> aborts because it thinks dlsym returned failure.
> 
> After consulting with our dynamic linker guru, I don't think there is
> a wonderful clean way to do this.

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.

Cheers,


Ralph.




More information about the llvm-dev mailing list