diff options
author | Shankar Easwaran <shankare@codeaurora.org> | 2013-08-23 20:03:35 +0000 |
---|---|---|
committer | Shankar Easwaran <shankare@codeaurora.org> | 2013-08-23 20:03:35 +0000 |
commit | f9fe6250ffef0bcf65763dfe3310a8d2cb40c212 (patch) | |
tree | c98fcc01b912ca9ee5cd25191e0a066e314a0faf | |
parent | 78457803bcde8a9504309f6da0df2ea60a4c4454 (diff) | |
download | bcm5719-llvm-f9fe6250ffef0bcf65763dfe3310a8d2cb40c212.tar.gz bcm5719-llvm-f9fe6250ffef0bcf65763dfe3310a8d2cb40c212.zip |
[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.
llvm-svn: 189139
-rw-r--r-- | lld/lib/ReaderWriter/ELF/File.h | 4 | ||||
-rw-r--r-- | lld/test/elf/X86_64/Inputs/zerosizedsection.o | bin | 0 -> 760 bytes | |||
-rw-r--r-- | lld/test/elf/X86_64/Inputs/zerosizedsection.s | 3 | ||||
-rw-r--r-- | lld/test/elf/X86_64/dontignorezerosize-sections.test | 11 |
4 files changed, 15 insertions, 3 deletions
diff --git a/lld/lib/ReaderWriter/ELF/File.h b/lld/lib/ReaderWriter/ELF/File.h index dcbcab65815..0c2c3b80fe5 100644 --- a/lld/lib/ReaderWriter/ELF/File.h +++ b/lld/lib/ReaderWriter/ELF/File.h @@ -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: diff --git a/lld/test/elf/X86_64/Inputs/zerosizedsection.o b/lld/test/elf/X86_64/Inputs/zerosizedsection.o Binary files differnew file mode 100644 index 00000000000..a0f2f13a307 --- /dev/null +++ b/lld/test/elf/X86_64/Inputs/zerosizedsection.o diff --git a/lld/test/elf/X86_64/Inputs/zerosizedsection.s b/lld/test/elf/X86_64/Inputs/zerosizedsection.s new file mode 100644 index 00000000000..651ee3aab50 --- /dev/null +++ b/lld/test/elf/X86_64/Inputs/zerosizedsection.s @@ -0,0 +1,3 @@ +.text +.data +.word .text diff --git a/lld/test/elf/X86_64/dontignorezerosize-sections.test b/lld/test/elf/X86_64/dontignorezerosize-sections.test new file mode 100644 index 00000000000..21a467dcd82 --- /dev/null +++ b/lld/test/elf/X86_64/dontignorezerosize-sections.test @@ -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 |