[PATCH] D82180: [llvm-readelf] - Do not crash when dumping the dynamic symbol table when its sh_entzize == 0.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 22 05:53:17 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf38f068b14d8: [llvm-readelf] - Do not crash when dumping the dynamic symbol table when its… (authored by grimar).
Changed prior to commit:
https://reviews.llvm.org/D82180?vs=272046&id=272396#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D82180/new/
https://reviews.llvm.org/D82180
Files:
llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
llvm/tools/llvm-readobj/ELFDumper.cpp
Index: llvm/tools/llvm-readobj/ELFDumper.cpp
===================================================================
--- llvm/tools/llvm-readobj/ELFDumper.cpp
+++ llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -678,8 +678,7 @@
StrTable = DynamicStringTable;
Syms = dynamic_symbols();
SymtabName = DynSymtabName;
- if (DynSymRegion)
- Entries = DynSymRegion->Size / DynSymRegion->EntSize;
+ Entries = Syms.size();
} else {
if (!DotSymtabSec)
return;
Index: llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
===================================================================
--- llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
+++ llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
@@ -490,3 +490,26 @@
Sections:
- Section: .dynstr
- Section: .dynamic
+
+## Check we report a warning when the entry size of the dynamic symbol table is zero.
+# RUN: yaml2obj %s --docnum=14 -o %t15
+# RUN: llvm-readobj --dyn-symbols %t15 2>&1 | FileCheck %s -DFILE=%t15 --check-prefix=DYNSYM-ZERO-ENTSIZE-LLVM
+# RUN: llvm-readelf --dyn-symbols %t15 2>&1 | \
+# RUN: FileCheck %s -DFILE=%t15 --check-prefix=DYNSYM-ZERO-ENTSIZE-GNU --implicit-check-not="Symbol table"
+
+# DYNSYM-ZERO-ENTSIZE-LLVM: DynamicSymbols [
+# DYNSYM-ZERO-ENTSIZE-LLVM-NEXT: warning: '[[FILE]]': section with index 1 has invalid size (0x10) or entry size (0x0)
+# DYNSYM-ZERO-ENTSIZE-LLVM-NEXT: ]
+
+# DYNSYM-ZERO-ENTSIZE-GNU: warning: '[[FILE]]': section with index 1 has invalid size (0x10) or entry size (0x0)
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_DYN
+ Machine: EM_386
+Sections:
+ - Name: .dynsym
+ Type: SHT_DYNSYM
+ EntSize: 0x0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82180.272396.patch
Type: text/x-patch
Size: 1715 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200622/5c32417b/attachment-0001.bin>
More information about the llvm-commits
mailing list