[PATCH] D95152: [ELF] --wrap: retain __wrap_foo if foo is defined in an object/bitcode file

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 21 10:54:20 PST 2021


MaskRay created this revision.
MaskRay added reviewers: andrewng, grimar, jhenderson.
Herald added subscribers: dang, steven_wu, hiraditya, arichardson, emaste.
MaskRay requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

If foo is referenced in any object file, bitcode file or shared object,
`__wrap_foo` should be retained as the redirection target of sym
(f96ff3c0f8ebd941b3f6b345164c3d858b781484 <https://reviews.llvm.org/rGf96ff3c0f8ebd941b3f6b345164c3d858b781484>).

If the object file defining foo has foo references, we cannot easily distinguish
the case from cases where foo is not referenced (we haven't scanned
relocations). Retain `__wrap_foo` because we choose to wrap sym references
regardless of whether sym is defined to address
https://sourceware.org/bugzilla/show_bug.cgi?id=26358 .

If foo is defined in a shared object, `__wrap_foo` can still be omitted
(`wrap-dynamic-undef.s`).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95152

Files:
  lld/ELF/Driver.cpp
  lld/ELF/Options.td
  lld/docs/ld.lld.1
  lld/test/ELF/lto/wrap-defined.ll
  lld/test/ELF/wrap-defined.s
  lld/test/ELF/wrap-shlib-undefined.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95152.318256.patch
Type: text/x-patch
Size: 4668 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210121/045d010f/attachment.bin>


More information about the llvm-commits mailing list