llvm.org GIT mirror llvm / 3f6881e
[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 Michael J. Spencer 4 years ago
3 changed file(s) with 24 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
628628 }
629629
630630 // Get string table sections.
631 ErrorOr StrTabSecOrErr = getSection(getStringTableIndex());
632 if ((EC = StrTabSecOrErr.getError()))
633 return;
634
635 ErrorOr SymtabOrErr = getStringTable(*StrTabSecOrErr);
636 if ((EC = SymtabOrErr.getError()))
637 return;
638 DotShstrtab = *SymtabOrErr;
631 uintX_t StringTableIndex = getStringTableIndex();
632 if (StringTableIndex) {
633 ErrorOr StrTabSecOrErr =
634 getSection(getStringTableIndex());
635 if ((EC = StrTabSecOrErr.getError()))
636 return;
637
638 ErrorOr SymtabOrErr = getStringTable(*StrTabSecOrErr);
639 if ((EC = SymtabOrErr.getError()))
640 return;
641 DotShstrtab = *SymtabOrErr;
642 }
639643
640644 // Build symbol name side-mapping if there is one.
641645 if (SymbolTableSectionHeaderIndex) {
745749 ErrorOr
746750 ELFFile::getSectionName(const Elf_Shdr *Section) const {
747751 uint32_t Offset = Section->sh_name;
752 if (Offset == 0)
753 return StringRef();
748754 if (Offset >= DotShstrtab.size())
749755 return object_error::parse_failed;
750756 return StringRef(DotShstrtab.data() + Offset);
0 RUN: llvm-readobj %p/Inputs/no-section-header-string-table.elf-x86-64 --sections \
1 RUN: | FileCheck %s
2
3 CHECK: Type: SHT_PROGBITS (0x1)
4 CHECK: Type: SHT_PROGBITS (0x1)
5 CHECK: Type: SHT_PROGBITS (0x1)
6 CHECK: Type: SHT_RELA (0x4)
7 CHECK: Type: SHT_SYMTAB (0x2)
8 CHECK: Type: SHT_STRTAB (0x3)
9 CHECK: Type: SHT_STRTAB (0x3)