[PATCH] D33657: Allow libraries to be loaded with RTLD_LOCAL on Unix.

Frederich Munch via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 6 11:10:30 PDT 2017


marsupial added a comment.

>From what I can tell, in LLVM the clients of this are solely clang and lldb.
Nothing should break for them as they explicitly search single libraries for symbols.

https://reviews.llvm.org/D33529 attempts to mitigate any problems that might occur for external usage by giving greater control of how symbols are searched.

But moving to **RTLD_LOCAL** by default though, may cause breakage for clients of the JIT  as a normal pattern would be:

  1. DynamicLibrary::getPermanentLibrary(nullptr); // synonym for Process = dlopen(nullptr, RTLD_LAZY  | RTLD_GLOBAL);
  2. // Other code...
  3. DynamicLibrary::getAddressOfSymbol("SomeSymbol"); // synonym for dlsym(Process, "SomeSymbol");

A. If any other libraries were loaded **RTLD_LOCAL** by default in step 2, step 3 would no longer find the symbols. (though again, https://reviews.llvm.org/D33529 should make it easy to update their implementation).
B. On Windows this behaviour would differ as there is no concept of **RTLD_LOCAL** and that would have to be tracked by hand if parity was wanted.

I kind of think the cost against **A** is worth it as the injection of symbols globally is generally bad, but the disparity of behaviour from **B ** gives me pause.
The easiest solution for **B** would rely on Module Handles being the same across calls which I don't think is documented but perhaps worth the risk?


https://reviews.llvm.org/D33657





More information about the llvm-commits mailing list