[llvm-readobj] Only allow 4-byte pr_data

Summary: AMD64 psABI says: "The pr_data field of each property contains a 4-byte unsigned integer." Thus we don't need to handle 8-byte pr_data.

Reviewers: mike.dvoretsky, grimar, craig.topper, xiangzhangllvm, hjl.tools

Reviewed By: grimar

Subscribers: rupprecht, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D58103

llvm-svn: 353815
This commit is contained in:
Fangrui Song 2019-02-12 09:56:01 +00:00
parent b1d6f52005
commit 8e0d5ac715
2 changed files with 12 additions and 14 deletions

View File

@ -17,7 +17,7 @@
// GNU-NEXT: stack size: <corrupt length: 0x4>
// GNU-NEXT: no copy on protected <corrupt length: 0x1>
// GNU-NEXT: X86 features: <corrupt length: 0x0>
// GNU-NEXT: X86 features: IBT, <unknown flags: 0xf000f000f000f000>
// GNU-NEXT: X86 features: IBT, <unknown flags: 0xf000f000>
// GNU-NEXT: <corrupt type (0x2) datasz: 0x1>
// LLVM: Notes [
@ -40,7 +40,7 @@
// LLVM-NEXT: stack size: <corrupt length: 0x4>
// LLVM-NEXT: no copy on protected <corrupt length: 0x1>
// LLVM-NEXT: X86 features: <corrupt length: 0x0>
// LLVM-NEXT: X86 features: IBT, <unknown flags: 0xf000f000f000f000>
// LLVM-NEXT: X86 features: IBT, <unknown flags: 0xf000f000>
// LLVM-NEXT: <corrupt type (0x2) datasz: 0x1>
// LLVM-NEXT: ]
// LLVM-NEXT: }
@ -72,8 +72,8 @@ begin:
/* CET property note */
.long 0xc0000002 /* Type: GNU_PROPERTY_X86_FEATURE_1_AND */
.long 8 /* Data size */
.quad 2 /* GNU_PROPERTY_X86_FEATURE_1_SHSTK */
.long 4 /* Data size */
.long 2 /* GNU_PROPERTY_X86_FEATURE_1_SHSTK */
.p2align 3 /* Align to 8 byte for 64 bit */
/* CET property note with padding */
@ -83,8 +83,8 @@ begin:
.p2align 3 /* Align to 8 byte for 64 bit */
.long 0xc0000002 /* Type: GNU_PROPERTY_X86_FEATURE_1_AND */
.long 8 /* Data size */
.quad 0 /* Empty flags, not an error */
.long 4 /* Data size */
.long 0 /* Empty flags, not an error */
.p2align 3 /* Align to 8 byte for 64 bit */
/* All notes below are broken. Test we are able to report them. */
@ -118,8 +118,8 @@ begin:
/* CET note with bad flags */
.long 0xc0000002 /* Type: GNU_PROPERTY_X86_FEATURE_1_AND */
.long 8 /* Data size */
.quad 0xf000f000f000f001 /* GNU_PROPERTY_X86_FEATURE_1_IBT and bad bits */
.long 4 /* Data size */
.long 0xf000f001 /* GNU_PROPERTY_X86_FEATURE_1_IBT and bad bits */
.p2align 3 /* Align to 8 byte for 64 bit */
/* GNU_PROPERTY_NO_COPY_ON_PROTECTED with pr_datasz and without data */

View File

@ -3670,14 +3670,12 @@ static std::string getGNUProperty(uint32_t Type, uint32_t DataSize,
return OS.str();
case GNU_PROPERTY_X86_FEATURE_1_AND:
OS << "X86 features: ";
if (DataSize != 4 && DataSize != 8) {
if (DataSize != 4) {
OS << format("<corrupt length: 0x%x>", DataSize);
return OS.str();
}
uint64_t CFProtection =
(DataSize == 4)
? support::endian::read32<ELFT::TargetEndianness>(Data.data())
: support::endian::read64<ELFT::TargetEndianness>(Data.data());
uint32_t CFProtection =
support::endian::read32<ELFT::TargetEndianness>(Data.data());
if (CFProtection == 0) {
OS << "none";
return OS.str();
@ -3695,7 +3693,7 @@ static std::string getGNUProperty(uint32_t Type, uint32_t DataSize,
OS << ", ";
}
if (CFProtection)
OS << format("<unknown flags: 0x%llx>", CFProtection);
OS << format("<unknown flags: 0x%x>", CFProtection);
return OS.str();
}
}