Chris / Ralph / Others, On Fri, 2007-07-20 at 08:14 -0700, Chris Lattner wrote:> On Fri, 20 Jul 2007, Ralph Corderoy wrote: > > I could be missing something, but shouldn't the use of dlsym() be > > The authors of dlsym() realised the return value was overloaded AFAICS. > > Yep, patches welcome :) > > -Chris >I don't recall who originally asked for help with this, but here's a patch that could fix it. Please try this and let me know if it works. If so, I'll commit it. The patch isn't complete (it should do something in the error condition) but it should allow you to find symbols whose address is 0. Reid. Index: DynamicLibrary.cpp ==================================================================--- DynamicLibrary.cpp (revision 40112) +++ DynamicLibrary.cpp (working copy) @@ -130,11 +130,19 @@ if (I != g_symbols.end()) return I->second; + // Clear the error status of the ltdl library + lt_dlerror(); + // Now search the libraries. for (std::vector<lt_dlhandle>::iterator I = OpenedHandles.begin(), E = OpenedHandles.end(); I != E; ++I) { lt_ptr ptr = lt_dlsym(*I, symbolName); - if (ptr) + + // Get the error for the lt_dlsym call. If there was no error and the result + // from lt_dlsym was 0 then 0 is the address of the symbol, not an + // indication that it couldn't be found. + const char *errmsg = lt_dlerror(); + if (ptr || !errmsg) return ptr; } Please apply to lib/System/DynamicLibrary.cpp. -------------- next part -------------- A non-text attachment was scrubbed... Name: DL.patch Type: text/x-patch Size: 817 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20070720/5ddddf80/attachment.bin>
Hey Reid, I don't recall who originally asked for help with this, but here's a> patch that could fix it. Please try this and let me know if it works. If > so, I'll commit it. The patch isn't complete (it should do something in > the error condition) but it should allow you to find symbols whose > address is 0. >It was me who was having the issues with Objective-C in the interpreter. Thankyou, I did try the patch, and it doesn't seem to work, or at least for my one program. In JIT mode it still segfaults and in interpreter mode it cannot resolve the symbol. I am at my wits end with this problem, the dlopen documentation states that if it explicidly fails, it will return a NULL pointer. However it doesn't say anything about succeeding with a NULL pointer. If the simple Objective-C program is still failing, even when checking if the lt_dlerror() code is set. I see two possibilities: a) The error code is being set even when the symbol is found and has a 0 address b) The error is caused by some other problem, maybe further upstream, indicated by the fact that the JIT interpreter crashes with a segfault. Because normal unresolved symbols will not crash the interpreter even in JIT mode. I'm using the 2.0 release, and I'm about to get the bleeding edge SVN version to try, however my mac is quite slow and will take an hour or two to compile the source code. My knowleage of the Obj-C runtime is quite limited and I am new to the LLVM architecture. So I'm sorry if I can't be of more assistance code wise. But I'm currently reading up on both in my spare time. Andy. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20070721/bbc490fd/attachment.html>
Hi Andy, On Sat, 2007-07-21 at 14:56 +1000, Andy Kitchen wrote:> Hey Reid, > > I don't recall who originally asked for help with this, but > here's a > patch that could fix it. Please try this and let me know if it > works. If > so, I'll commit it. The patch isn't complete (it should do > something in > the error condition) but it should allow you to find symbols > whose > address is 0. > > It was me who was having the issues with Objective-C in the > interpreter.Okay, sorry, I didn't remember.> Thankyou, I did try the patch, and it doesn't seem to work, or at > least for my one program. In JIT mode it still segfaults and in > interpreter mode it cannot resolve the > symbol.Bummer.> I am at my wits end with this problem, the dlopen documentation states > that if it > explicidly fails, it will return a NULL pointer. However it doesn't > say anything about > succeeding with a NULL pointer. If the simple Objective-C program is > still failing, even > when checking if the lt_dlerror() code is set. I see two > possibilities: > > > a) The error code is being set even when the symbol is found and has a > 0 addressunlikely> b) The error is caused by some other problem, maybe further upstream, > indicated by the > fact that the JIT interpreter crashes with a segfault. Because normal > unresolved > symbols will not crash the interpreter even in JIT mode.This is probably it. The JIT probably doesn't know what to do with a symbol whose address is 0, so, just for grins, it tries dereferencing it. What exactly are these symbols? How would one differentiate them if they all have 0 address? What should the JIT do with them?> I'm using the 2.0 release, and I'm about to get the bleeding edge SVN > version to try, > however my mac is quite slow and will take an hour or two to compile > the source code.I don't think much has changed in this area since 2.0, but you could try.> My knowleage of the Obj-C runtime is quite limited and I am new to the > LLVM > architecture. So I'm sorry if I can't be of more assistance code wise. > But I'm currently > reading up on both in my spare time.I don't know the Obj-C runtime at all so that makes you an expert compared to me :) Reading up will probably help a lot. Best Regards, Reid.> > > Andy. > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Maybe Matching Threads
- [LLVMdev] Trouble Resolving Objective-C Symbols in lli
- [LLVMdev] Trouble Resolving Objective-C Symbols in lli
- [LLVMdev] Trouble Resolving Objective-C Symbols in lli
- [LLVMdev] Trouble Resolving Objective-C Symbols in lli
- [LLVMdev] Trouble Resolving Objective-C Symbols in lli