This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by MaskRay on Jan 21 2021, 10:54 AM.

Details

Summary

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).

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 keep non-LTO/LTO/relocatable links' behaviors similar
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).

Diff Detail

Event Timeline

MaskRay created this revision.Jan 21 2021, 10:54 AM
MaskRay requested review of this revision.Jan 21 2021, 10:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 21 2021, 10:54 AM
MaskRay edited the summary of this revision. (Show Details)Jan 21 2021, 10:55 AM

Apart from a couple of nits, I'll leave reviewing this to @andrewng, since I know he's looked into the issue more (he and I work together).

lld/ELF/Driver.cpp
1930
lld/ELF/Options.td
475–476

This line looks quite long?

andrewng accepted this revision.Jan 22 2021, 1:56 AM

Apart from the nits already pointed out by @jhenderson, LGTM.

This revision is now accepted and ready to land.Jan 22 2021, 1:56 AM
MaskRay added inline comments.Jan 22 2021, 9:01 AM
lld/ELF/Driver.cpp
1930

. is a valid part of a URL and this will make clicking the URL broken in many systems...

MaskRay updated this revision to Diff 318544.Jan 22 2021, 9:09 AM

wrap long line

This revision was landed with ongoing or failed builds.Jan 22 2021, 9:20 AM
This revision was automatically updated to reflect the committed changes.