[llvm] r362490 - [AARCH64][ELF][llvm-readobj] Support for AArch64 .note.gnu.property
Peter Smith via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 4 04:28:22 PDT 2019
Author: psmith
Date: Tue Jun 4 04:28:22 2019
New Revision: 362490
URL: http://llvm.org/viewvc/llvm-project?rev=362490&view=rev
Log:
[AARCH64][ELF][llvm-readobj] Support for AArch64 .note.gnu.property
ELF for the 64-bit Arm Architecture defines a processor specific property
type GNU_PROPERTY_AARCH64_FEATURE_1_AND as GNU_PROPERTY_LOPROC. This
property works in a similar way to the existing X86 processor specific
property GNU_PROPERTY_GNU_X86_FEATURE_1_AND.
Two feature bits are defined for GNU_PROPERTY_AARCH64_FEATURE_1_AND:
- GNU_PROPERTY_AARCH64_FEATURE_1_BTI 0x1
- GNU_PROPERTY_AARCH64_FEATURE_1_PAC 0x2
This patch defines the property, feature bits and implements support for
printing in llvm-readobj.
Differential Revision: https://reviews.llvm.org/D62595
Added:
llvm/trunk/test/tools/llvm-readobj/AArch64/aarch64-note-gnu-property.s
Modified:
llvm/trunk/include/llvm/BinaryFormat/ELF.h
llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
Modified: llvm/trunk/include/llvm/BinaryFormat/ELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/BinaryFormat/ELF.h?rev=362490&r1=362489&r2=362490&view=diff
==============================================================================
--- llvm/trunk/include/llvm/BinaryFormat/ELF.h (original)
+++ llvm/trunk/include/llvm/BinaryFormat/ELF.h Tue Jun 4 04:28:22 2019
@@ -1364,6 +1364,7 @@ enum {
enum : unsigned {
GNU_PROPERTY_STACK_SIZE = 1,
GNU_PROPERTY_NO_COPY_ON_PROTECTED = 2,
+ GNU_PROPERTY_AARCH64_FEATURE_1_AND = 0xc0000000,
GNU_PROPERTY_X86_FEATURE_1_AND = 0xc0000002,
GNU_PROPERTY_X86_ISA_1_NEEDED = 0xc0008000,
GNU_PROPERTY_X86_FEATURE_2_NEEDED = 0xc0008001,
@@ -1371,6 +1372,12 @@ enum : unsigned {
GNU_PROPERTY_X86_FEATURE_2_USED = 0xc0010001,
};
+// aarch64 processor feature bits.
+enum : unsigned {
+ GNU_PROPERTY_AARCH64_FEATURE_1_BTI = 1 << 0,
+ GNU_PROPERTY_AARCH64_FEATURE_1_PAC = 1 << 1,
+};
+
// x86 processor feature bits.
enum : unsigned {
GNU_PROPERTY_X86_FEATURE_1_IBT = 1 << 0,
Added: llvm/trunk/test/tools/llvm-readobj/AArch64/aarch64-note-gnu-property.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/AArch64/aarch64-note-gnu-property.s?rev=362490&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-readobj/AArch64/aarch64-note-gnu-property.s (added)
+++ llvm/trunk/test/tools/llvm-readobj/AArch64/aarch64-note-gnu-property.s Tue Jun 4 04:28:22 2019
@@ -0,0 +1,38 @@
+// RUN: llvm-mc -filetype=obj -triple aarch64-linux-gnu %s -o %t
+// RUN: llvm-readelf --notes %t | FileCheck %s --check-prefix=GNU
+// RUN: llvm-readobj --notes %t | FileCheck %s --check-prefix=LLVM
+
+// GNU: Displaying notes found at file offset 0x00000040 with length 0x00000020:
+// GNU-NEXT: Owner Data size Description
+// GNU-NEXT: GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 (property note)
+// GNU-NEXT: Properties: aarch64 feature: BTI, PAC
+
+// LLVM: Notes [
+// LLVM-NEXT: NoteSection {
+// LLVM-NEXT: Offset: 0x40
+// LLVM-NEXT: Size: 0x20
+// LLVM-NEXT: Note {
+// LLVM-NEXT: Owner: GNU
+// LLVM-NEXT: Data size: 0x10
+// LLVM-NEXT: Type: NT_GNU_PROPERTY_TYPE_0 (property note)
+// LLVM-NEXT: Property [
+// LLVM-NEXT: aarch64 feature: BTI, PAC
+// LLVM-NEXT: ]
+// LLVM-NEXT: }
+// LLVM-NEXT: }
+// LLVM-NEXT: ]
+
+.section ".note.gnu.property", "a"
+.align 4
+ .long 4 /* Name length is always 4 ("GNU") */
+ .long end - begin /* Data length */
+ .long 5 /* Type: NT_GNU_PROPERTY_TYPE_0 */
+ .asciz "GNU" /* Name */
+ .p2align 3
+begin:
+ /* BTI and PAC property note */
+ .long 0xc0000000 /* Type: GNU_PROPERTY_AARCH64_FEATURE_1_AND */
+ .long 4 /* Data size */
+ .long 3 /* BTI and PAC */
+ .p2align 3 /* Align to 8 byte for 64 bit */
+end:
Modified: llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ELFDumper.cpp?rev=362490&r1=362489&r2=362490&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/ELFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/ELFDumper.cpp Tue Jun 4 04:28:22 2019
@@ -3840,8 +3840,10 @@ static std::string getGNUProperty(uint32
if (DataSize)
OS << format(" <corrupt length: 0x%x>", DataSize);
return OS.str();
+ case GNU_PROPERTY_AARCH64_FEATURE_1_AND:
case GNU_PROPERTY_X86_FEATURE_1_AND:
- OS << "x86 feature: ";
+ OS << ((Type == GNU_PROPERTY_AARCH64_FEATURE_1_AND) ? "aarch64 feature: "
+ : "x86 feature: ");
if (DataSize != 4) {
OS << format("<corrupt length: 0x%x>", DataSize);
return OS.str();
@@ -3851,8 +3853,13 @@ static std::string getGNUProperty(uint32
OS << "<None>";
return OS.str();
}
- DumpBit(GNU_PROPERTY_X86_FEATURE_1_IBT, "IBT");
- DumpBit(GNU_PROPERTY_X86_FEATURE_1_SHSTK, "SHSTK");
+ if (Type == GNU_PROPERTY_AARCH64_FEATURE_1_AND) {
+ DumpBit(GNU_PROPERTY_AARCH64_FEATURE_1_BTI, "BTI");
+ DumpBit(GNU_PROPERTY_AARCH64_FEATURE_1_PAC, "PAC");
+ } else {
+ DumpBit(GNU_PROPERTY_X86_FEATURE_1_IBT, "IBT");
+ DumpBit(GNU_PROPERTY_X86_FEATURE_1_SHSTK, "SHSTK");
+ }
if (PrData)
OS << format("<unknown flags: 0x%x>", PrData);
return OS.str();
More information about the llvm-commits
mailing list