summaryrefslogtreecommitdiffstats
path: root/llvm/test/tools/llvm-readobj
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2019-06-14 11:56:10 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2019-06-14 11:56:10 +0000
commitd6df7ded6e3dc7e19fb5c5e8483528863f13162c (patch)
tree7105eb0c65db08ceb59a61f0b7a7aa5801d45190 /llvm/test/tools/llvm-readobj
parent3058a62b90819d4a1d8b9d5d84dff5d805e1a3d2 (diff)
downloadbcm5719-llvm-d6df7ded6e3dc7e19fb5c5e8483528863f13162c.tar.gz
bcm5719-llvm-d6df7ded6e3dc7e19fb5c5e8483528863f13162c.zip
[llvm-readobj] - Do not fail to dump the object which has wrong type of .shstrtab.
Imagine we have object that has .shstrtab with type != SHT_STRTAB. In this case, we fail to dump the object, though GNU readelf dumps it without any issues and warnings. This patch fixes that. It adds a code to ELFDumper.cpp which is based on the implementation of getSectionName from the ELF.h: https://github.com/llvm-mirror/llvm/blob/master/include/llvm/Object/ELF.h#L608 https://github.com/llvm-mirror/llvm/blob/master/include/llvm/Object/ELF.h#L431 https://github.com/llvm-mirror/llvm/blob/master/include/llvm/Object/ELF.h#L539 The difference is that all non critical errors are ommitted what allows us to improve the dumping on a tool side. Also, this opens a road for a follow-up that should allow us to dump the section headers, but drop the section names in case if .shstrtab is completely absent and/or broken. Differential revision: https://reviews.llvm.org/D63266 llvm-svn: 363371
Diffstat (limited to 'llvm/test/tools/llvm-readobj')
-rw-r--r--llvm/test/tools/llvm-readobj/Inputs/wrong-shstrtab-type.elf-x86-64bin0 -> 541 bytes
-rw-r--r--llvm/test/tools/llvm-readobj/elf-wrong-shstrtab-type.test11
2 files changed, 11 insertions, 0 deletions
diff --git a/llvm/test/tools/llvm-readobj/Inputs/wrong-shstrtab-type.elf-x86-64 b/llvm/test/tools/llvm-readobj/Inputs/wrong-shstrtab-type.elf-x86-64
new file mode 100644
index 00000000000..801a21be823
--- /dev/null
+++ b/llvm/test/tools/llvm-readobj/Inputs/wrong-shstrtab-type.elf-x86-64
Binary files differ
diff --git a/llvm/test/tools/llvm-readobj/elf-wrong-shstrtab-type.test b/llvm/test/tools/llvm-readobj/elf-wrong-shstrtab-type.test
new file mode 100644
index 00000000000..2d5fd68cd57
--- /dev/null
+++ b/llvm/test/tools/llvm-readobj/elf-wrong-shstrtab-type.test
@@ -0,0 +1,11 @@
+## wrong-shstrtab-type.elf-x86-64 contains .shstrtab section which has SHT_PROGBITS type.
+## Check we do not fail to dump the section headers in this case.
+
+# RUN: llvm-readobj -S %p/Inputs/wrong-shstrtab-type.elf-x86-64 | FileCheck %s --check-prefix LLVM
+# RUN: llvm-readelf -S %p/Inputs/wrong-shstrtab-type.elf-x86-64 | FileCheck %s --check-prefix GNU
+
+# LLVM: Name: .shstrtab
+# LLVM-NEXT: Type: SHT_PROGBITS
+
+# GNU: [Nr] Name Type
+# GNU: [ 3] .shstrtab PROGBITS
OpenPOWER on IntegriCloud