[lld] [llvm] [lld][AArch64][Build Attributes] Add support for converting AArch64 Build Attributes to GNU Properties (PR #131990)

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 11 10:23:24 PDT 2025


================
@@ -207,6 +209,51 @@ static void updateSupportedARMFeatures(Ctx &ctx,
   ctx.arg.armHasThumb2ISA |= thumb && *thumb >= ARMBuildAttrs::AllowThumb32;
 }
 
+struct AArch64BuildAttrSubsections {
+  struct PauthSubSection {
+    unsigned tagPlatform = 0;
+    unsigned tagSchema = 0;
+  } pauth;
+  struct FAndBSubSection {
+    unsigned tagBTI = 0;
+    unsigned tagPAC = 0;
+    unsigned tagGCS = 0;
+  } fAndB;
+};
+
+static AArch64BuildAttrSubsections
+extractBuildAttributesSubsections(const AArch64AttributeParser &attributes) {
+
+  AArch64BuildAttrSubsections subSections;
+  subSections.pauth.tagPlatform =
+      attributes
+          .getAttributeValue("aeabi_pauthabi",
+                             llvm::AArch64BuildAttributes::TAG_PAUTH_PLATFORM)
+          .value_or(0);
+  subSections.pauth.tagSchema =
+      attributes
+          .getAttributeValue("aeabi_pauthabi",
+                             llvm::AArch64BuildAttributes::TAG_PAUTH_SCHEMA)
+          .value_or(0);
+  subSections.fAndB.tagBTI =
+      attributes
+          .getAttributeValue("aeabi_feature_and_bits",
+                             llvm::AArch64BuildAttributes::TAG_FEATURE_BTI)
+          .value_or(0);
+  subSections.fAndB.tagPAC =
----------------
smithp35 wrote:

In my alternative proposal this would be something like:
```
if (auto val = attributes.getAttributeValue(""aeabi_feature_and_bits",
                             llvm::AArch64BuildAttributes::TAG_FEATURE_BTI).value_or(0))
  subSections.fAndB.andFeatures |= 1 << val;
```
Could even simplify the code further as the only difference between the code for each feature bit is the `TAG_FEATURE_*` so you could extract into a lambda and pass in the `TAG_FEATURE_*` as a parameter. 

https://github.com/llvm/llvm-project/pull/131990


More information about the llvm-commits mailing list