[PATCH] D48502: Fix direct calls to __wrap_sym when it is relocated

Matthew Koontz via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 2 14:10:34 PDT 2018


matthew.koontz added a comment.

I've attached a basic program that will crash. It looks like this only happens when creating a shared object file, otherwise it gets a direct call like you describe. The problem is the `applySymbolWrap` duplicates `__wrap_sym`, and then sets the `IsUsedInRegularObj` in one of them to false. From then on, these get treated as two separate symbols. I think the cause of the runtime crash is setting the `IsUsedInRegularObj` prevents adding an entry in the dynamic symbol table, so the lookup fails. Also, the former code creates two PLT entries for `__wrap_sym`, when they should share a PLT entry since they really are the same symbol.

Ideally, we wouldn't do this memcpy and somehow have all of the references to `sym` to now point to `__wrap_sym`, but I can't think of a good way of doing that with the current code.

F6562635: lld-test.tar.bz2 <https://reviews.llvm.org/F6562635>


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D48502





More information about the llvm-commits mailing list