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 @@ -429,3 +429,26 @@ Value: 0x123 - Tag: DT_NULL Value: 0 + +## Check we report a warning when the entry size of the dynamic symbol table is zero. +# RUN: yaml2obj %s --docnum=13 -o %t14 +# RUN: llvm-readobj --dyn-symbols %t14 2>&1 | FileCheck %s -DFILE=%t14 --check-prefix=DYNSYM-ZERO-ENTSIZE-LLVM +# RUN: llvm-readelf --dyn-symbols %t14 2>&1 | \ +# RUN: FileCheck %s -DFILE=%t14 --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 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;