[PATCH] D58103: [llvm-readobj] Only allow 4-byte pr_data
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 12 01:32:21 PST 2019
MaskRay updated this revision to Diff 186416.
MaskRay added a comment.
.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58103/new/
https://reviews.llvm.org/D58103
Files:
test/tools/llvm-readobj/note-gnu-property.s
tools/llvm-readobj/ELFDumper.cpp
Index: tools/llvm-readobj/ELFDumper.cpp
===================================================================
--- tools/llvm-readobj/ELFDumper.cpp
+++ tools/llvm-readobj/ELFDumper.cpp
@@ -3677,14 +3677,12 @@
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();
@@ -3702,7 +3700,7 @@
OS << ", ";
}
if (CFProtection)
- OS << format("<unknown flags: 0x%llx>", CFProtection);
+ OS << format("<unknown flags: 0x%x>", CFProtection);
return OS.str();
}
}
Index: test/tools/llvm-readobj/note-gnu-property.s
===================================================================
--- test/tools/llvm-readobj/note-gnu-property.s
+++ test/tools/llvm-readobj/note-gnu-property.s
@@ -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 @@
/* 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 @@
.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 @@
/* 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 */
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58103.186416.patch
Type: text/x-patch
Size: 3481 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190212/7f7d2cc0/attachment.bin>
More information about the llvm-commits
mailing list