Remove a global variable that we can live without.
authorRui Ueyama <ruiu@google.com>
Tue, 23 Oct 2018 17:39:43 +0000 (17:39 +0000)
committerRui Ueyama <ruiu@google.com>
Tue, 23 Oct 2018 17:39:43 +0000 (17:39 +0000)
Out::DebugInfo was used only by GdbIndex class to determine if
we need to create a .gdb_index section, but we can do the same
check without it.

Added a test that this patch doesn't change the existing behavior.

llvm-svn: 345058

lld/ELF/OutputSections.cpp
lld/ELF/OutputSections.h
lld/ELF/SyntheticSections.cpp
lld/ELF/Writer.cpp
lld/test/ELF/gdb-index-no-debug.s [new file with mode: 0644]

index 0e8e406b91d9f91b6a98fc300a024f93c7bfbeb5..c2c7f2c032009b8754d1b1b022abc64af5745aca 100644 (file)
@@ -32,7 +32,6 @@ using namespace lld::elf;
 
 uint8_t Out::First;
 PhdrEntry *Out::TlsPhdr;
-OutputSection *Out::DebugInfo;
 OutputSection *Out::ElfHeader;
 OutputSection *Out::ProgramHeaders;
 OutputSection *Out::PreinitArray;
index efb6aabe9743ca657108658580c9bd6980e311fd..c004c1f19bfed0b73933ae1c3848db5c7a4e5c91 100644 (file)
@@ -130,7 +130,6 @@ std::vector<InputSection *> getInputSections(OutputSection* OS);
 struct Out {
   static uint8_t First;
   static PhdrEntry *TlsPhdr;
-  static OutputSection *DebugInfo;
   static OutputSection *ElfHeader;
   static OutputSection *ProgramHeaders;
   static OutputSection *PreinitArray;
index 92cad5a0ce3dc072142adc4f89b29e4bb541ca0b..6bf602ce2374531ef25dd89d8a3350f24e8c4429 100644 (file)
@@ -2595,7 +2595,7 @@ void GdbIndexSection::writeTo(uint8_t *Buf) {
   }
 }
 
-bool GdbIndexSection::empty() const { return !Out::DebugInfo; }
+bool GdbIndexSection::empty() const { return Chunks.empty(); }
 
 EhFrameHeader::EhFrameHeader()
     : SyntheticSection(SHF_ALLOC, SHT_PROGBITS, 4, ".eh_frame_hdr") {}
index 64839afa412d82919407a16097836763e61a738e..d76141844fe95f0c3b8a8c7029b24615ff684e1f 100644 (file)
@@ -1533,7 +1533,6 @@ static bool computeIsPreemptible(const Symbol &B) {
 
 // Create output section objects and add them to OutputSections.
 template <class ELFT> void Writer<ELFT>::finalizeSections() {
-  Out::DebugInfo = findSection(".debug_info");
   Out::PreinitArray = findSection(".preinit_array");
   Out::InitArray = findSection(".init_array");
   Out::FiniArray = findSection(".fini_array");
diff --git a/lld/test/ELF/gdb-index-no-debug.s b/lld/test/ELF/gdb-index-no-debug.s
new file mode 100644 (file)
index 0000000..dba5fcf
--- /dev/null
@@ -0,0 +1,8 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld -o %t.exe -gdb-index %t.o
+# RUN: llvm-objdump --section-headers %t.exe | FileCheck %s
+# CHECK-NOT: .gdb_index
+
+.global _start
+_start: