summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShankar Easwaran <shankare@codeaurora.org>2013-08-23 20:03:35 +0000
committerShankar Easwaran <shankare@codeaurora.org>2013-08-23 20:03:35 +0000
commitf9fe6250ffef0bcf65763dfe3310a8d2cb40c212 (patch)
treec98fcc01b912ca9ee5cd25191e0a066e314a0faf
parent78457803bcde8a9504309f6da0df2ea60a4c4454 (diff)
downloadbcm5719-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.h4
-rw-r--r--lld/test/elf/X86_64/Inputs/zerosizedsection.obin0 -> 760 bytes
-rw-r--r--lld/test/elf/X86_64/Inputs/zerosizedsection.s3
-rw-r--r--lld/test/elf/X86_64/dontignorezerosize-sections.test11
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
new file mode 100644
index 00000000000..a0f2f13a307
--- /dev/null
+++ b/lld/test/elf/X86_64/Inputs/zerosizedsection.o
Binary files differ
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
OpenPOWER on IntegriCloud