[ELF] Dont discard sections in the input file.

The reader was discarding certain types of sections from the input file.

llvm-svn: 228268
This commit is contained in:
Shankar Easwaran 2015-02-05 02:56:06 +00:00
parent 3be4efa341
commit d67bcb5f5c
2 changed files with 53 additions and 10 deletions

View File

@ -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:

49
lld/test/elf/note.test Normal file
View File

@ -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
...