This is an archive of the discontinued LLVM Phabricator instance.

ELF: Set symbol binding to STB_GLOBAL when undefining symbols during LTO.
ClosedPublic

Authored by pcc on May 1 2017, 9:34 PM.

Details

Summary

If there is a bug in the LTO implementation that causes it to fail to provide
an expected symbol definition, the linker should report an undefined symbol
error. Unfortunately, we were failing to do so if the symbol definition
was weak, as the undefine() function was turning the definition into a weak
undefined symbol, which resolves to zero if the symbol remains undefined. This
patch causes us to set the binding to STB_GLOBAL when we undefine a symbol.

I can't see a good way to test this. The behaviour should only be observable
if there is a bug in the LTO implementation.

Diff Detail

Repository
rL LLVM

Event Timeline

pcc created this revision.May 1 2017, 9:34 PM
ruiu accepted this revision.May 1 2017, 10:16 PM

LGTM

lld/ELF/LTO.cpp
108 ↗(On Diff #97387)

Please add a comment to describe why you are doing this. Without comment it is hard to understand why because the linker works fine without this piece of code.

This revision is now accepted and ready to land.May 1 2017, 10:16 PM
This revision was automatically updated to reflect the committed changes.
pcc added a comment.May 2 2017, 8:50 PM

Actually I don't think this change is necessary, and it was masking a bug (PR32899). We should be able to revert once that is fixed.