mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
[Object][ELF] Handle files with no section header string table.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242839 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
68a4b41648
commit
3f6881efa5
@ -629,14 +629,18 @@ ELFFile<ELFT>::ELFFile(StringRef Object, std::error_code &EC)
|
||||
}
|
||||
|
||||
// Get string table sections.
|
||||
ErrorOr<const Elf_Shdr *> StrTabSecOrErr = getSection(getStringTableIndex());
|
||||
if ((EC = StrTabSecOrErr.getError()))
|
||||
return;
|
||||
uintX_t StringTableIndex = getStringTableIndex();
|
||||
if (StringTableIndex) {
|
||||
ErrorOr<const Elf_Shdr *> StrTabSecOrErr =
|
||||
getSection(getStringTableIndex());
|
||||
if ((EC = StrTabSecOrErr.getError()))
|
||||
return;
|
||||
|
||||
ErrorOr<StringRef> SymtabOrErr = getStringTable(*StrTabSecOrErr);
|
||||
if ((EC = SymtabOrErr.getError()))
|
||||
return;
|
||||
DotShstrtab = *SymtabOrErr;
|
||||
ErrorOr<StringRef> SymtabOrErr = getStringTable(*StrTabSecOrErr);
|
||||
if ((EC = SymtabOrErr.getError()))
|
||||
return;
|
||||
DotShstrtab = *SymtabOrErr;
|
||||
}
|
||||
|
||||
// Build symbol name side-mapping if there is one.
|
||||
if (SymbolTableSectionHeaderIndex) {
|
||||
@ -746,6 +750,8 @@ template <class ELFT>
|
||||
ErrorOr<StringRef>
|
||||
ELFFile<ELFT>::getSectionName(const Elf_Shdr *Section) const {
|
||||
uint32_t Offset = Section->sh_name;
|
||||
if (Offset == 0)
|
||||
return StringRef();
|
||||
if (Offset >= DotShstrtab.size())
|
||||
return object_error::parse_failed;
|
||||
return StringRef(DotShstrtab.data() + Offset);
|
||||
|
BIN
test/Object/Inputs/no-section-header-string-table.elf-x86-64
Normal file
BIN
test/Object/Inputs/no-section-header-string-table.elf-x86-64
Normal file
Binary file not shown.
10
test/Object/no-section-header-string-table.test
Normal file
10
test/Object/no-section-header-string-table.test
Normal file
@ -0,0 +1,10 @@
|
||||
RUN: llvm-readobj %p/Inputs/no-section-header-string-table.elf-x86-64 --sections \
|
||||
RUN: | FileCheck %s
|
||||
|
||||
CHECK: Type: SHT_PROGBITS (0x1)
|
||||
CHECK: Type: SHT_PROGBITS (0x1)
|
||||
CHECK: Type: SHT_PROGBITS (0x1)
|
||||
CHECK: Type: SHT_RELA (0x4)
|
||||
CHECK: Type: SHT_SYMTAB (0x2)
|
||||
CHECK: Type: SHT_STRTAB (0x3)
|
||||
CHECK: Type: SHT_STRTAB (0x3)
|
Loading…
Reference in New Issue
Block a user