diff options
-rw-r--r-- | llvm/include/llvm/Object/ELF.h | 8 | ||||
-rw-r--r-- | llvm/test/Object/invalid.test | 21 |
2 files changed, 24 insertions, 5 deletions
diff --git a/llvm/include/llvm/Object/ELF.h b/llvm/include/llvm/Object/ELF.h index 5638ea73935..c18453d1155 100644 --- a/llvm/include/llvm/Object/ELF.h +++ b/llvm/include/llvm/Object/ELF.h @@ -599,12 +599,10 @@ ELFFile<ELFT>::getStringTable(const Elf_Shdr *Section) const { return V.takeError(); ArrayRef<char> Data = *V; if (Data.empty()) - // TODO: this error is untested. - return createError("empty string table"); + return createError("SHT_STRTAB string table section " + + getSecIndexForError(this, Section) + " is empty"); if (Data.back() != '\0') - return createError(object::getELFSectionTypeName(getHeader()->e_machine, - Section->sh_type) + - " string table section " + + return createError("SHT_STRTAB string table section " + getSecIndexForError(this, Section) + " is non-null terminated"); return StringRef(Data.begin(), Data.size()); diff --git a/llvm/test/Object/invalid.test b/llvm/test/Object/invalid.test index 5fe107ff268..7071dee98eb 100644 --- a/llvm/test/Object/invalid.test +++ b/llvm/test/Object/invalid.test @@ -606,3 +606,24 @@ FileHeader: Type: ET_REL Machine: EM_X86_64 SHOffset: 0xffffffffffffffff + +## Check that llvm-objdump reports an error when it tries to dump a +## symbol name and .strtab is empty. + +# RUN: yaml2obj %s --docnum=29 -o %t29 +# RUN: not llvm-objdump -syms %t29 2>&1 | FileCheck -DFILE=%t29 --check-prefix=STRTAB-EMPTY2 %s + +# STRTAB-EMPTY2: error: '[[FILE]]': SHT_STRTAB string table section [index 1] is empty + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_DYN + Machine: EM_X86_64 +Sections: + - Name: .strtab + Type: SHT_STRTAB + Content: "" +Symbols: + - Name: foo |