[lld] r189139 - [lld][ELF] Dont ignore zero sized sections.

Shankar Easwaran shankare at codeaurora.org
Fri Aug 23 13:03:35 PDT 2013


Author: shankare
Date: Fri Aug 23 15:03:35 2013
New Revision: 189139

URL: http://llvm.org/viewvc/llvm-project?rev=189139&view=rev
Log:
[lld][ELF] Dont ignore zero sized sections.

There may be relocations that may be pointing to the section
even if the section sizes are 0. We shouldnot ignore them
for that regard.

Added:
    lld/trunk/test/elf/X86_64/Inputs/zerosizedsection.o
    lld/trunk/test/elf/X86_64/Inputs/zerosizedsection.s
    lld/trunk/test/elf/X86_64/dontignorezerosize-sections.test
Modified:
    lld/trunk/lib/ReaderWriter/ELF/File.h

Modified: lld/trunk/lib/ReaderWriter/ELF/File.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/File.h?rev=189139&r1=189138&r2=189139&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/File.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/File.h Fri Aug 23 15:03:35 2013
@@ -354,7 +354,7 @@ public:
 
       // If the section has no symbols, create a custom atom for it.
       if (section && section->sh_type == llvm::ELF::SHT_PROGBITS &&
-          symbols.empty() && !sectionContents->empty()) {
+          symbols.empty()) {
         ELFDefinedAtom<ELFT> *newAtom = createSectionAtom(
             section, *sectionName, secCont);
         _definedAtoms._atoms.push_back(newAtom);
@@ -606,8 +606,6 @@ private:
   /// \brief Do we want to ignore the section. Ignored sections are
   /// not processed to create atoms
   bool isIgnoredSection(const Elf_Shdr *section) {
-    if (section->sh_size == 0)
-      return true;
     switch (section->sh_type) {
     case llvm::ELF::SHT_NOTE:
     case llvm::ELF::SHT_STRTAB:

Added: lld/trunk/test/elf/X86_64/Inputs/zerosizedsection.o
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/X86_64/Inputs/zerosizedsection.o?rev=189139&view=auto
==============================================================================
Binary files lld/trunk/test/elf/X86_64/Inputs/zerosizedsection.o (added) and lld/trunk/test/elf/X86_64/Inputs/zerosizedsection.o Fri Aug 23 15:03:35 2013 differ

Added: lld/trunk/test/elf/X86_64/Inputs/zerosizedsection.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/X86_64/Inputs/zerosizedsection.s?rev=189139&view=auto
==============================================================================
--- lld/trunk/test/elf/X86_64/Inputs/zerosizedsection.s (added)
+++ lld/trunk/test/elf/X86_64/Inputs/zerosizedsection.s Fri Aug 23 15:03:35 2013
@@ -0,0 +1,3 @@
+.text
+.data
+.word .text

Added: lld/trunk/test/elf/X86_64/dontignorezerosize-sections.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/X86_64/dontignorezerosize-sections.test?rev=189139&view=auto
==============================================================================
--- lld/trunk/test/elf/X86_64/dontignorezerosize-sections.test (added)
+++ lld/trunk/test/elf/X86_64/dontignorezerosize-sections.test Fri Aug 23 15:03:35 2013
@@ -0,0 +1,11 @@
+# This tests that lld is not ignoring zero sized sections
+RUN: lld -flavor gnu -target x86_64-linux %p/Inputs/zerosizedsection.o  \
+RUN: --noinhibit-exec -emit-yaml -o %t
+RUN: FileCheck %s < %t
+
+CHECK:    section-name:    .text
+CHECK:    section-name:    .data
+CHECK:    references:      
+CHECK:      - kind:            R_X86_64_16
+CHECK:        offset:          0
+CHECK:        target:          L000





More information about the llvm-commits mailing list