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

Jordy Rose jediknil at belkadan.com
Thu Aug 11 21:04:55 PDT 2011


On Aug 11, 2011, at 13:20, Jordy Rose wrote:

> On Aug 11, 2011, at 11:53, David Blaikie wrote:
> 
>> It'd be a pity if we couldn't make something more RAII-esque, though I
>> agree it's hard without movement support. I haven't looked closely -
>> but is there any (portable) way to duplicate a dynamic library handle?
>> In which case the copy ctor could just use that & the dtor could
>> dlclose & then we could return by value, etc, with relatively low
>> cost. (the only alternative, while preserving RAII-esque semantics, is
>> for the DynamicLibrary to remember what file/options it used & dlopen
>> on every copy (knowing it'll hit the OS's cache) which is probably
>> still pretty costly even for a cache hit)
> 
> dlopen does its own caching (otherwise it wouldn't be guaranteed to return the same handle each time), but remembering the file/options in each DynamicLibrary instance is probably a waste of space. Ah, well. And no handle-copying in dlfcn.h.
> 
> I will leave the semantics the way they are now, only allowing permanent loads and ignoring ref-counting. Thanks for the review.

Updated patch attached. Intended use:

    DynamicLibrary library = DynamicLibrary::getPermanentLibrary("libX.dylib");
    void *sym = library.getAddressOfSymbol("interestingSymbol");

Good to commit?
Jordy

-------------- next part --------------
A non-text attachment was scrubbed...
Name: DynamicLibrary.2.patch
Type: application/octet-stream
Size: 14092 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110811/85fd8ba2/attachment.obj>
-------------- next part --------------




More information about the llvm-commits mailing list