[llvm] r353815 - [llvm-readobj] Only allow 4-byte pr_data
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 12 01:56:02 PST 2019
Author: maskray
Date: Tue Feb 12 01:56:01 2019
New Revision: 353815
URL: http://llvm.org/viewvc/llvm-project?rev=353815&view=rev
Log:
[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
Modified:
llvm/trunk/test/tools/llvm-readobj/note-gnu-property.s
llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
Modified: llvm/trunk/test/tools/llvm-readobj/note-gnu-property.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/note-gnu-property.s?rev=353815&r1=353814&r2=353815&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-readobj/note-gnu-property.s (original)
+++ llvm/trunk/test/tools/llvm-readobj/note-gnu-property.s Tue Feb 12 01:56:01 2019
@@ -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 */
Modified: llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ELFDumper.cpp?rev=353815&r1=353814&r2=353815&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/ELFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/ELFDumper.cpp Tue Feb 12 01:56:01 2019
@@ -3670,14 +3670,12 @@ static std::string getGNUProperty(uint32
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
OS << ", ";
}
if (CFProtection)
- OS << format("<unknown flags: 0x%llx>", CFProtection);
+ OS << format("<unknown flags: 0x%x>", CFProtection);
return OS.str();
}
}
More information about the llvm-commits
mailing list