mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
[Object, ELF] Fix segmentation fault in ELFFile::getSectionName().
Don't do a null dereference if .shstrtab section is missing. llvm-svn: 239124
This commit is contained in:
parent
0d416a532a
commit
0a55c45eea
@ -928,7 +928,7 @@ ErrorOr<StringRef> ELFFile<ELFT>::getSymbolName(const Elf_Shdr *Section,
|
||||
template <class ELFT>
|
||||
ErrorOr<StringRef>
|
||||
ELFFile<ELFT>::getSectionName(const Elf_Shdr *Section) const {
|
||||
if (Section->sh_name >= dot_shstrtab_sec->sh_size)
|
||||
if (!dot_shstrtab_sec || Section->sh_name >= dot_shstrtab_sec->sh_size)
|
||||
return object_error::parse_failed;
|
||||
return StringRef(getString(dot_shstrtab_sec, Section->sh_name));
|
||||
}
|
||||
|
BIN
test/DebugInfo/Inputs/invalid.elf.no-shstrtab
Normal file
BIN
test/DebugInfo/Inputs/invalid.elf.no-shstrtab
Normal file
Binary file not shown.
@ -4,3 +4,6 @@ RUN: llvm-dwarfdump %p/Inputs/invalid.elf 2>&1 | FileCheck %s --check-prefix=INV
|
||||
RUN: llvm-dwarfdump %p/Inputs/invalid.elf.2 2>&1 | FileCheck %s --check-prefix=INVALID-ELF
|
||||
RUN: llvm-dwarfdump %p/Inputs/invalid.elf.3 2>&1 | FileCheck %s --check-prefix=INVALID-ELF
|
||||
INVALID-ELF: Invalid data was encountered while parsing the file
|
||||
|
||||
RUN: llvm-dwarfdump %p/Inputs/invalid.elf.no-shstrtab 2>&1 | FileCheck %s --check-prefix=EMPTY
|
||||
EMPTY: .debug_info contents:
|
||||
|
Loading…
Reference in New Issue
Block a user