[PATCH] D37623: [ELF] - Simplify removeUnusedSyntheticSections a bit.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 8 06:15:15 PDT 2017
grimar created this revision.
Herald added subscribers: arichardson, sdardis, emaste.
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.
https://reviews.llvm.org/D37623
Files:
ELF/SyntheticSections.cpp
ELF/Writer.cpp
Index: ELF/Writer.cpp
===================================================================
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -1198,8 +1198,6 @@
OutputSection *OS = SS->getParent();
if (!SS->empty() || !OS)
continue;
- if ((SS == InX::Got || SS == InX::MipsGot) && ElfSym::GlobalOffsetTable)
- continue;
std::vector<BaseCommand *>::iterator Empty = OS->Commands.end();
for (auto I = OS->Commands.begin(), E = OS->Commands.end(); I != E; ++I) {
Index: ELF/SyntheticSections.cpp
===================================================================
--- ELF/SyntheticSections.cpp
+++ ELF/SyntheticSections.cpp
@@ -665,7 +665,8 @@
bool GotSection::empty() const {
// If we have a relocation that is relative to GOT (such as GOTOFFREL),
// we need to emit a GOT even if it's empty.
- return NumEntries == 0 && !HasGotOffRel;
+ // Do the same if we have reference to _GLOBAL_OFFSET_TABLE_ symbol.
+ return NumEntries == 0 && !HasGotOffRel && !ElfSym::GlobalOffsetTable;
}
void GotSection::writeTo(uint8_t *Buf) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37623.114348.patch
Type: text/x-patch
Size: 1061 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170908/3ec9aa4e/attachment.bin>
More information about the llvm-commits
mailing list