[llvm-commits] [PATCH] Look up symbols in a specific library with DynamicLibrary

Jordy Rose jediknil at belkadan.com
Wed Aug 10 22:08:34 PDT 2011


On Aug 10, 2011, at 17:35, Argyrios Kyrtzidis wrote:

> Sorry, I wasn't clear, I totally agree with you that manually uniquing is pointless.
> 
> My point is that your patch introduces this API usage model:
> 
> DynamicLibrary dylib("mylib.dylib");
> void *p = dylib.getAddressOfSymbol("mysymbol");
> 
> but wait, I need to also call LoadLibraryPermanently:
> 
> DynamicLibrary::LoadLibraryPermanently("mylib.dylib");
> DynamicLibrary dylib("mylib.dylib");
> void *p = dylib.getAddressOfSymbol("mysymbol");

My bad. I kept thinking of this only in Clang terms, where libraries are loaded once by -load way ahead of time. Which is silly. I guess I shouldn't be worrying about the future case where we start paying attention to refcounting libraries.

On the other hand, I'm slightly worried about what happens if we do an infinite number of dlopens without any dlcloses. I would then leave the RTTI but use your API (and make sure to hide the copy constructor). That should make it easy to eventually allow getTemporaryLibrary.

> DynamicLibrary dylib = DynamicLibrary::getPermanentLibrary("mylib.dylib");  // will be added to permanent libraries if it is not already
> void *p = dylib.getAddressOfSymbol("mysymbol");


Jordy



More information about the llvm-commits mailing list