[PATCH] D37623: [ELF] - Simplify removeUnusedSyntheticSections a bit.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 25 05:10:01 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL314099: [ELF] - Simplify removeUnusedSyntheticSections a bit. (authored by grimar).

Changed prior to commit:
  https://reviews.llvm.org/D37623?vs=115988&id=116538#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37623

Files:
  lld/trunk/ELF/SyntheticSections.cpp
  lld/trunk/ELF/Writer.cpp


Index: lld/trunk/ELF/SyntheticSections.cpp
===================================================================
--- lld/trunk/ELF/SyntheticSections.cpp
+++ lld/trunk/ELF/SyntheticSections.cpp
@@ -656,9 +656,10 @@
 void GotSection::finalizeContents() { Size = NumEntries * Config->Wordsize; }
 
 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;
+  // 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_).
+  return NumEntries == 0 && !HasGotOffRel && !ElfSym::GlobalOffsetTable;
 }
 
 void GotSection::writeTo(uint8_t *Buf) {
Index: lld/trunk/ELF/Writer.cpp
===================================================================
--- lld/trunk/ELF/Writer.cpp
+++ lld/trunk/ELF/Writer.cpp
@@ -1187,8 +1187,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) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37623.116538.patch
Type: text/x-patch
Size: 1328 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170925/1e944784/attachment.bin>


More information about the llvm-commits mailing list