[LLVMdev] Add RTLD_GLOBAL to dlopen

Bram Adams bram.adams at ugent.be
Wed Jul 9 04:54:31 PDT 2008


Hi,

Today, I've made the transition from LLVM 2.1 to 2.3. I invoke opt  
with two dynamic libraries to "-load", the first of which contains  
transformation passes and support code whereas the second one provides  
extra passes which make use of the first library's support code. In  
other words, the symbols loaded in for the first library should be  
available when the second library is loaded.

In LLVM 2.1, this approach worked, but I noticed that the  
DynamicLibrary::LoadLibraryPermanently(...) implementation in $LLVM/ 
lib/System/DynamicLibrary.cpp has been altered for LLVM 2.3. The  
rewrite does not make loaded symbols available for future loaded  
libraries.

Changing on line 64:

void *H = dlopen(Filename, RTLD_LAZY);

... into ...

void *H = dlopen(Filename, RTLD_LAZY | RTLD_GLOBAL);

fixes this. Could this change be incorporated into future releases?  
Thanks in advance!

Kind regards,

Bram Adams
GH-SEL, INTEC, Ghent University (Belgium)



More information about the llvm-dev mailing list