[PATCH] D30107: Refactor DynamicLibrary so searching for a symbol will have a defined order and libraries are properly unloaded when llvm_shutdown is called.

Philippe Canal via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 26 03:28:18 PDT 2017


pcanal added a comment.

In https://reviews.llvm.org/D30107#763829, @marsupial wrote:

> > You should test it with ROOT, there we do a `dlopen(libcling, RTLD_LAZY|RTLD_LOCAL)` and I think there the symbol resolution doesn't work as before.
>
> RTLD_LOCAL means any symbols loaded will not be available for lookup.
>  If you are relying on symbol lookup via a process handle [ **dlsym(dlopen(NULL, Flags), "Symbol")** ] then you need to use RTLD_GLOBAL.


For the same reasons that dlsym has two modes, the equivalent LLVM routine must have the same two modes.
(1) dlsym by process which does a search in load ordering
(2) dlsym by handle which does a search in dependency ordering

I understand from marsupial that (1) is more performance for his use case but (2) is the order that was supported before and should stay the default.

One other major difference is that doing (1) followed by (2) is **not** equivalent to doing just (2) as it prevents override symbols.

One could argue that there is even a 3rd option to be added, which is whether the RTLD_LOCAL are search (again the legacy behavior and new default should be to search those).

As is the patch is introducing a (weakly or not) documented change in behavior and worse is **preventing** a return to the old (useful) behavior.

Cheers,
Philippe.


Repository:
  rL LLVM

https://reviews.llvm.org/D30107





More information about the llvm-commits mailing list