This is an archive of the discontinued LLVM Phabricator instance.

[ELF][RISCV] --wrap=foo: Correctly update st_value(foo)
ClosedPublic

Authored by MaskRay on May 30 2023, 7:10 PM.

Details

Summary

With --wrap=foo, we may have d->file != file for a defined symbol foo.
For the object file defining foo, its symbol table may not contain
foo after redirectSymbols changed the foo entry to __wrap_foo (see D50569).

Therefore, skipping foo with the condition if (!d || d->file != file) may
cause __wrap_foo not to be updated. See ab.o w.o --wrap=foo in the new test
(originally reported by D150220).

We could adjust the condition to if (!d), but that would leave many anchors
entries if a symbol is referenced by many files. Switch to iterating over
symtab instead.

Note: D149735 (actually not NFC) allowed duplicate anchors entries and fixed
a.o bw.o --wrap=foo.

Diff Detail

Event Timeline

MaskRay created this revision.May 30 2023, 7:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 30 2023, 7:10 PM
MaskRay requested review of this revision.May 30 2023, 7:10 PM
jobnoorman accepted this revision.May 31 2023, 1:52 AM
This revision is now accepted and ready to land.May 31 2023, 1:52 AM
MaskRay edited the summary of this revision. (Show Details)May 31 2023, 7:17 AM
This revision was automatically updated to reflect the committed changes.