Index: llvm/test/tools/llvm-readobj/elf-verneed-invalid.test =================================================================== --- llvm/test/tools/llvm-readobj/elf-verneed-invalid.test +++ llvm/test/tools/llvm-readobj/elf-verneed-invalid.test @@ -503,3 +503,34 @@ Content: "0100010001000000110000000000000000000000" DynamicSymbols: - Name: foo + +## Check how we handle the case when a dependency definition entry has an unsupported version. + +# RUN: yaml2obj %s --docnum=12 -o %t12 +# RUN: llvm-readobj -V %t12 2>&1 | FileCheck %s --check-prefix=UNSUPPORTED-VERSION -DFILE=%t12 +# RUN: llvm-readelf -V %t12 2>&1 | FileCheck %s --check-prefix=UNSUPPORTED-VERSION -DFILE=%t12 + +# UNSUPPORTED-VERSION: warning: '[[FILE]]': unable to dump SHT_GNU_verneed section with index 1: version 65278 is not yet supported + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 +Sections: + - Name: .gnu.version_r + Type: SHT_GNU_verneed + Flags: [ SHF_ALLOC ] + Info: 1 + Link: .dynstr + Dependencies: + - Version: 0xfefe + File: foo + Entries: + - Name: 'foo' + Hash: 0 + Flags: 0 + Other: 0 +DynamicSymbols: + - Name: foo Index: llvm/tools/llvm-readobj/ELFDumper.cpp =================================================================== --- llvm/tools/llvm-readobj/ELFDumper.cpp +++ llvm/tools/llvm-readobj/ELFDumper.cpp @@ -505,6 +505,12 @@ ": found a misaligned version dependency entry at offset 0x" + Twine::utohexstr(VerneedBuf - Start)); + unsigned Version = *reinterpret_cast(VerneedBuf); + if (Version != 1) + return createError("unable to dump SHT_GNU_verneed section with index " + + Twine(SecNdx) + ": version " + Twine(Version) + + " is not yet supported"); + const Elf_Verneed *Verneed = reinterpret_cast(VerneedBuf);