[PATCH] D65396: [llvm/Object] - Add a test for "empty string table" error.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 31 01:11:18 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL367391: [llvm/Object] - Add a test for "empty string table" error. (authored by grimar, committed by ).
Herald added a project: LLVM.
Changed prior to commit:
https://reviews.llvm.org/D65396?vs=212156&id=212519#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D65396/new/
https://reviews.llvm.org/D65396
Files:
llvm/trunk/include/llvm/Object/ELF.h
llvm/trunk/test/Object/invalid.test
Index: llvm/trunk/include/llvm/Object/ELF.h
===================================================================
--- llvm/trunk/include/llvm/Object/ELF.h
+++ llvm/trunk/include/llvm/Object/ELF.h
@@ -599,12 +599,10 @@
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());
Index: llvm/trunk/test/Object/invalid.test
===================================================================
--- llvm/trunk/test/Object/invalid.test
+++ llvm/trunk/test/Object/invalid.test
@@ -606,3 +606,24 @@
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65396.212519.patch
Type: text/x-patch
Size: 1799 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190731/e3c6da41/attachment.bin>
More information about the llvm-commits
mailing list