[lld] [llvm] [lld][AArch64][Build Attributes] Add support for AArch64 Build Attributes (PR #142637)

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 4 01:48:59 PDT 2025


================
@@ -539,6 +540,42 @@ uint32_t ObjFile<ELFT>::getSectionIndex(const Elf_Sym &sym) const {
       this);
 }
 
+template <class ELFT>
+static void
+handleAArch64BAAndGnuProperties(ObjFile<ELFT> *file, Ctx &ctx, bool hasGP,
+                                const AArch64BuildAttrSubsections &baInfo,
+                                const GnuPropertiesInfo &gpInfo) {
+  if (hasGP) {
+    // Check for data mismatch
+    if (gpInfo.pauthAbiCoreInfo) {
+      if (baInfo.Pauth.TagPlatform != gpInfo.pauthAbiCoreInfo->platform)
+        Err(ctx)
+            << file
+            << " Pauth Data mismatch: file contains both GNU properties and "
+               "AArch64 build attributes sections with different Pauth data";
+    }
+    if (baInfo.AndFeatures != gpInfo.andFeatures)
+      Err(ctx) << file
+               << " Features Data mismatch: file contains both GNU "
+                  "properties and AArch64 build attributes sections with "
+                  "different And Features data";
+  } else {
+    // Write missing data
----------------
smithp35 wrote:

There's a bit in the BuildAttributes spec to handle this case. Starting at https://github.com/ARM-software/abi-aa/pull/230/files#diff-9563b0c9eccaf2fd9c6dd704c6ef00fbe7b531657e220c0324523391da355d1cR1030 and also https://github.com/ARM-software/abi-aa/pull/230/files#diff-9563b0c9eccaf2fd9c6dd704c6ef00fbe7b531657e220c0324523391da355d1cR1053

Essentially a build attributes of TagPlatform 0, TagSchema 1 maps to an explicit GNU Properties section of 0, 0. 

I think the simplest way of handling this would be to change TagPlatform 0, TagSchema 1 (which would pass the if test) to an aarch64PauthAbiCoreInfo of (0, 0).

Would likely need the comment updating. Something like:
```
Build Attributes default to a value of 0 when not present. A (TagPlatform, TagSchema) of (0, 0) maps to no PAuth property present. A (TagPlatform, TagSchema) of (0, 1) maps to an explicit PAuth property of platform = 0, version = 0.
```

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


More information about the llvm-commits mailing list