[llvm] 7eecf2b - [llvm-readelf/llvm-readobj] - Check the version of SHT_GNU_verneed section entries.
Georgii Rymar via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 2 01:57:44 PST 2019
Author: Georgii Rymar
Date: 2019-12-02T12:57:23+03:00
New Revision: 7eecf2b872e506927f59b6a1f4a8546d8baaa700
URL: https://github.com/llvm/llvm-project/commit/7eecf2b872e506927f59b6a1f4a8546d8baaa700
DIFF: https://github.com/llvm/llvm-project/commit/7eecf2b872e506927f59b6a1f4a8546d8baaa700.diff
LOG: [llvm-readelf/llvm-readobj] - Check the version of SHT_GNU_verneed section entries.
It is a follow-up for D70826 and it is similar to D70810.
SHT_GNU_verneed contains the following fields:
`vn_version`: Version of structure. This value is currently set to 1, and will be reset
if the versioning implementation is incompatibly altered.
(https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/symversion.html)
We should check it for correctness.
Differential revision: https://reviews.llvm.org/D70842
Added:
Modified:
llvm/test/tools/llvm-readobj/elf-verneed-invalid.test
llvm/tools/llvm-readobj/ELFDumper.cpp
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-readobj/elf-verneed-invalid.test b/llvm/test/tools/llvm-readobj/elf-verneed-invalid.test
index 53f8562989d5..88039f89c593 100644
--- a/llvm/test/tools/llvm-readobj/elf-verneed-invalid.test
+++ b/llvm/test/tools/llvm-readobj/elf-verneed-invalid.test
@@ -520,3 +520,34 @@ Sections:
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
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 1031e0a181db..adc3ae7dcc83 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -526,6 +526,12 @@ ELFDumper<ELFT>::getVersionDependencies(const Elf_Shdr *Sec) const {
": found a misaligned version dependency entry at offset 0x" +
Twine::utohexstr(VerneedBuf - Start));
+ unsigned Version = *reinterpret_cast<const Elf_Half *>(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<const Elf_Verneed *>(VerneedBuf);
More information about the llvm-commits
mailing list