Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AArch64][ELF][llvm-readobj] Support the GCS .note.gnu.property bit #75065

Merged
merged 1 commit into from
Dec 13, 2023

Conversation

john-brawn-arm
Copy link
Collaborator

This bit was added to the AArch64 ABI by ARM-software/abi-aa#231.

@llvmbot
Copy link
Member

llvmbot commented Dec 11, 2023

@llvm/pr-subscribers-llvm-binary-utilities

Author: None (john-brawn-arm)

Changes

This bit was added to the AArch64 ABI by ARM-software/abi-aa#231.


Full diff: https://github.com/llvm/llvm-project/pull/75065.diff

3 Files Affected:

  • (modified) llvm/include/llvm/BinaryFormat/ELF.h (+1)
  • (modified) llvm/test/tools/llvm-readobj/ELF/AArch64/aarch64-note-gnu-property.s (+4-4)
  • (modified) llvm/tools/llvm-readobj/ELFDumper.cpp (+1)
diff --git a/llvm/include/llvm/BinaryFormat/ELF.h b/llvm/include/llvm/BinaryFormat/ELF.h
index 40c795410f95a..da38f6ef064f9 100644
--- a/llvm/include/llvm/BinaryFormat/ELF.h
+++ b/llvm/include/llvm/BinaryFormat/ELF.h
@@ -1693,6 +1693,7 @@ enum : unsigned {
 enum : unsigned {
   GNU_PROPERTY_AARCH64_FEATURE_1_BTI = 1 << 0,
   GNU_PROPERTY_AARCH64_FEATURE_1_PAC = 1 << 1,
+  GNU_PROPERTY_AARCH64_FEATURE_1_GCS = 1 << 2,
 };
 
 // x86 processor feature bits.
diff --git a/llvm/test/tools/llvm-readobj/ELF/AArch64/aarch64-note-gnu-property.s b/llvm/test/tools/llvm-readobj/ELF/AArch64/aarch64-note-gnu-property.s
index 872a3f150fdf6..377e6f93448ca 100644
--- a/llvm/test/tools/llvm-readobj/ELF/AArch64/aarch64-note-gnu-property.s
+++ b/llvm/test/tools/llvm-readobj/ELF/AArch64/aarch64-note-gnu-property.s
@@ -5,7 +5,7 @@
 // GNU: Displaying notes found in: .note.gnu.property
 // GNU-NEXT:   Owner                 Data size	Description
 // GNU-NEXT:   GNU                   0x00000010	NT_GNU_PROPERTY_TYPE_0 (property note)
-// GNU-NEXT:     Properties:    aarch64 feature: BTI, PAC
+// GNU-NEXT:     Properties:    aarch64 feature: BTI, PAC, GCS
 
 // LLVM:      Notes [
 // LLVM-NEXT:   NoteSection {
@@ -17,7 +17,7 @@
 // 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:         aarch64 feature: BTI, PAC, GCS
 // LLVM-NEXT:       ]
 // LLVM-NEXT:     }
 // LLVM-NEXT:   }
@@ -30,9 +30,9 @@
   .asciz "GNU"      /* Name */
   .p2align 3
 begin:
-  /* BTI and PAC property note */
+  /* BTI, PAC, and GCS property note */
   .long 0xc0000000  /* Type: GNU_PROPERTY_AARCH64_FEATURE_1_AND */
   .long 4           /* Data size */
-  .long 3           /* BTI and PAC */
+  .long 7           /* BTI, PAC, GCS */
   .p2align 3        /* Align to 8 byte for 64 bit */
 end:
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 85d5ab68b495c..5eeab11456d0c 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -5129,6 +5129,7 @@ static std::string getGNUProperty(uint32_t Type, uint32_t DataSize,
     if (Type == GNU_PROPERTY_AARCH64_FEATURE_1_AND) {
       DumpBit(GNU_PROPERTY_AARCH64_FEATURE_1_BTI, "BTI");
       DumpBit(GNU_PROPERTY_AARCH64_FEATURE_1_PAC, "PAC");
+      DumpBit(GNU_PROPERTY_AARCH64_FEATURE_1_GCS, "GCS");
     } else {
       DumpBit(GNU_PROPERTY_X86_FEATURE_1_IBT, "IBT");
       DumpBit(GNU_PROPERTY_X86_FEATURE_1_SHSTK, "SHSTK");

Copy link
Collaborator

@jh7370 jh7370 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks okay to me, but probably worth @smithp35 confirming he's happy before this gets merged.

Copy link
Collaborator

@smithp35 smithp35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. This matches the specification.

@john-brawn-arm john-brawn-arm merged commit d293a35 into llvm:main Dec 13, 2023
5 checks passed
@john-brawn-arm john-brawn-arm deleted the gcs_bit branch December 13, 2023 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants