This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Simplify removeUnusedSyntheticSections a bit.
ClosedPublic

Authored by grimar on Sep 8 2017, 6:15 AM.

Details

Summary

Previously`InX::Got` and InX::MipsGot synthetic sections
were not removed if ElfSym::GlobalOffsetTable was defined.
ElfSym::GlobalOffsetTable is a symbol for _GLOBAL_OFFSET_TABLE_.

Patch moves ElfSym::GlobalOffsetTable check out from removeUnusedSyntheticSections.
Also note that there was no point to check ElfSym::GlobalOffsetTable for MIPS case
because InX::MipsGot::empty() always returns false for non-relocatable case, and in case
of relocatable output we do not create special symbols anyways.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar created this revision.Sep 8 2017, 6:15 AM
ruiu added inline comments.Sep 19 2017, 12:31 PM
ELF/SyntheticSections.cpp
666–668 ↗(On Diff #114348)

Instead of adding more and more comments, you want to rewrite in most cases: We need to emit a GOT even if it's empty if there's a relocation that is relative to GOT (such as GOTOFFREL) or there's a symbol that points to a GOT (i.e. _GLOBAL_OFFSET_TABLE_).

grimar updated this revision to Diff 115988.Sep 20 2017, 5:37 AM
  • Applied suggested comment.
ruiu accepted this revision.Sep 24 2017, 7:59 PM

LGTM

This revision is now accepted and ready to land.Sep 24 2017, 7:59 PM
This revision was automatically updated to reflect the committed changes.