diff options
author | Georgii Rymar <grimar@accesssoftek.com> | 2019-11-28 13:20:25 +0300 |
---|---|---|
committer | Georgii Rymar <grimar@accesssoftek.com> | 2019-11-29 11:09:56 +0300 |
commit | 7ab14813619189d13382da047409a81c94ebc58d (patch) | |
tree | 18ca65241aa1c402b9ceafc8ef021a6d4c32b57e /llvm/test | |
parent | 06e5ebf8dbd9c19c2ef58e6eee6346de8688bc5b (diff) | |
download | bcm5719-llvm-7ab14813619189d13382da047409a81c94ebc58d.tar.gz bcm5719-llvm-7ab14813619189d13382da047409a81c94ebc58d.zip |
[llvm-readelf/llvm-readobj] - Check version of SHT_GNU_verdef section entries when dumping.
Elfxx_Verdef contains the following field:
vd_version
Version revision. This field shall be set to 1.
(https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/symversion.html)
Our code should check the struct version for correctness. This patch does that.
(This will help to simplify or eliminate ELFDumper<ELFT>::LoadVersionDefs() which
has it's own logic to parse version definitions for no reason. It checks the
struct version currently).
Differential revision: https://reviews.llvm.org/D70810
Diffstat (limited to 'llvm/test')
-rw-r--r-- | llvm/test/tools/llvm-readobj/elf-verdef-invalid.test | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/llvm/test/tools/llvm-readobj/elf-verdef-invalid.test b/llvm/test/tools/llvm-readobj/elf-verdef-invalid.test index 3a4de369838..44be4f2fdac 100644 --- a/llvm/test/tools/llvm-readobj/elf-verdef-invalid.test +++ b/llvm/test/tools/llvm-readobj/elf-verdef-invalid.test @@ -91,7 +91,7 @@ Sections: Link: .dynstr Info: 0x1 Entries: - - Version: 0 + - Version: 1 Flags: 0 VersionNdx: 0 Hash: 0 @@ -122,7 +122,7 @@ Sections: Link: .dynstr Info: 0x1 Entries: - - Version: 0 + - Version: 1 Flags: 0 VersionNdx: 0 Hash: 0 @@ -141,7 +141,7 @@ DynamicSymbols: # PAST-STRTAB-END-LLVM: VersionDefinitions [ # PAST-STRTAB-END-LLVM-NEXT: Definition { -# PAST-STRTAB-END-LLVM-NEXT: Version: 0 +# PAST-STRTAB-END-LLVM-NEXT: Version: 1 # PAST-STRTAB-END-LLVM-NEXT: Flags [ (0x0) # PAST-STRTAB-END-LLVM-NEXT: ] # PAST-STRTAB-END-LLVM-NEXT: Index: 0 @@ -153,7 +153,7 @@ DynamicSymbols: # PAST-STRTAB-END-GNU: Version definition section '.gnu.version_d' contains 1 entries: # PAST-STRTAB-END-GNU-NEXT: Addr: 0000000000000000 Offset: 0x000040 Link: 2 (.strtab) -# PAST-STRTAB-END-GNU-NEXT: 0x0000: Rev: 0 Flags: none Index: 0 Cnt: 1 Name: <invalid vda_name: 5> +# PAST-STRTAB-END-GNU-NEXT: 0x0000: Rev: 1 Flags: none Index: 0 Cnt: 1 Name: <invalid vda_name: 5> --- !ELF FileHeader: @@ -167,7 +167,7 @@ Sections: Link: .strtab Info: 0x1 Entries: - - Version: 0 + - Version: 1 Flags: 0 VersionNdx: 0 Hash: 0 @@ -200,7 +200,7 @@ Sections: Link: .dynstr Info: 0x1 Entries: - - Version: 0 + - Version: 1 Flags: 0 VersionNdx: 0 Hash: 0 @@ -230,7 +230,35 @@ Sections: Link: .dynstr Info: 0x1 ## The byte offset to the auxiliary entry is 0x13, i.e. it is not correctly aligned in memory. - Content: "0000000000000100000000001300000000000000" + Content: "0100000000000100000000001300000000000000" DynamicSymbols: - Name: foo Binding: STB_GLOBAL + +## Check how we handle the case when a version definition entry has an unsupported version. + +# RUN: yaml2obj %s --docnum=9 -o %t9 +# RUN: llvm-readobj -V %t9 2>&1 | FileCheck %s --check-prefix=UNSUPPORTED-VERSION -DFILE=%t9 +# RUN: llvm-readelf -V %t9 2>&1 | FileCheck %s --check-prefix=UNSUPPORTED-VERSION -DFILE=%t9 + +# UNSUPPORTED-VERSION: warning: '[[FILE]]': unable to dump SHT_GNU_verdef section with index 1: version 65278 is not yet supported + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_DYN + Machine: EM_X86_64 +Sections: + - Name: .gnu.version_d + Type: SHT_GNU_verdef + Link: .dynstr + Info: 0x1 + Entries: + - Version: 0xfefe + Flags: 0 + VersionNdx: 0 + Hash: 0 + Names: [] +DynamicSymbols: + - Name: foo |