summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShankar Easwaran <shankare@codeaurora.org>2015-02-05 02:56:06 +0000
committerShankar Easwaran <shankare@codeaurora.org>2015-02-05 02:56:06 +0000
commitd67bcb5f5cdd472c900c0cc52aae70dc559f9424 (patch)
treebb6c6824fe39c9f0b1f9073b47dce392e6fec389
parent3be4efa3416dfe0d3ce5028cfed5d33e1e88e62c (diff)
downloadbcm5719-llvm-d67bcb5f5cdd472c900c0cc52aae70dc559f9424.tar.gz
bcm5719-llvm-d67bcb5f5cdd472c900c0cc52aae70dc559f9424.zip
[ELF] Dont discard sections in the input file.
The reader was discarding certain types of sections from the input file. llvm-svn: 228268
-rw-r--r--lld/lib/ReaderWriter/ELF/ELFFile.h14
-rw-r--r--lld/test/elf/note.test49
2 files changed, 53 insertions, 10 deletions
diff --git a/lld/lib/ReaderWriter/ELF/ELFFile.h b/lld/lib/ReaderWriter/ELF/ELFFile.h
index ff2895fe432..c59d63000a7 100644
--- a/lld/lib/ReaderWriter/ELF/ELFFile.h
+++ b/lld/lib/ReaderWriter/ELF/ELFFile.h
@@ -479,12 +479,6 @@ std::error_code ELFFile<ELFT>::createAtomizableSections() {
continue;
}
- // Create a sectionSymbols entry for every progbits section.
- if ((section.sh_type == llvm::ELF::SHT_PROGBITS) ||
- (section.sh_type == llvm::ELF::SHT_INIT_ARRAY) ||
- (section.sh_type == llvm::ELF::SHT_FINI_ARRAY))
- _sectionSymbols[&section];
-
if (section.sh_type == llvm::ELF::SHT_RELA) {
auto sHdr = _objFile->getSection(section.sh_info);
@@ -497,9 +491,7 @@ std::error_code ELFFile<ELFT>::createAtomizableSections() {
_relocationAddendReferences[*sectionName] = make_range(rai, rae);
totalRelocs += std::distance(rai, rae);
- }
-
- if (section.sh_type == llvm::ELF::SHT_REL) {
+ } else if (section.sh_type == llvm::ELF::SHT_REL) {
auto sHdr = _objFile->getSection(section.sh_info);
auto sectionName = _objFile->getSectionName(sHdr);
@@ -511,6 +503,8 @@ std::error_code ELFFile<ELFT>::createAtomizableSections() {
_relocationReferences[*sectionName] = make_range(ri, re);
totalRelocs += std::distance(ri, re);
+ } else {
+ _sectionSymbols[&section];
}
}
_references.reserve(totalRelocs);
@@ -840,7 +834,7 @@ template <class ELFT> void ELFFile<ELFT>::updateReferences() {
template <class ELFT>
bool ELFFile<ELFT>::isIgnoredSection(const Elf_Shdr *section) {
switch (section->sh_type) {
- case llvm::ELF::SHT_NOTE:
+ case llvm::ELF::SHT_NULL:
case llvm::ELF::SHT_STRTAB:
case llvm::ELF::SHT_SYMTAB:
case llvm::ELF::SHT_SYMTAB_SHNDX:
diff --git a/lld/test/elf/note.test b/lld/test/elf/note.test
new file mode 100644
index 00000000000..f0e9c6b2f8d
--- /dev/null
+++ b/lld/test/elf/note.test
@@ -0,0 +1,49 @@
+# Check that the linker is not ignoring input sections.
+# RUN: yaml2obj -format=elf %s > %t.obj
+# RUN: lld -flavor gnu -target x86_64 %t.obj -o %t.exe --noinhibit-exec
+# RUN: llvm-objdump -h %t.exe | FileCheck %s
+
+# CHECK: {{[0-9]+}} .note
+
+---
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ OSABI: ELFOSABI_GNU
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x0000000000000004
+ Content: ''
+ - Name: .data
+ Type: SHT_PROGBITS
+ Flags: [ SHF_WRITE, SHF_ALLOC ]
+ AddressAlign: 0x0000000000000004
+ Content: ''
+ - Name: .bss
+ Type: SHT_NOBITS
+ Flags: [ SHF_WRITE, SHF_ALLOC ]
+ AddressAlign: 0x0000000000000004
+ Content: ''
+ - Name: .note
+ Type: SHT_NOTE
+ AddressAlign: 0x0000000000000001
+ Content: '00'
+Symbols:
+ Local:
+ - Name: .text
+ Type: STT_SECTION
+ Section: .text
+ - Name: .data
+ Type: STT_SECTION
+ Section: .data
+ - Name: .bss
+ Type: STT_SECTION
+ Section: .bss
+ - Name: .note
+ Type: STT_SECTION
+ Section: .note
+...
OpenPOWER on IntegriCloud