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

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 2 09:21:58 PDT 2025


================
@@ -537,6 +538,52 @@ 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 ||
+          baInfo.Pauth.TagSchema != gpInfo.pauthAbiCoreInfo->version)
+        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
+    // We can only know when Pauth is missing.
+    // Unlike AArch64 Build Attributes, GNU properties does not give a way to
+    // distinguish between no-value given to value of '0' given.
+    if (baInfo.Pauth.TagPlatform || baInfo.Pauth.TagSchema) {
+      // According to the BuildAttributes specification 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 ('Invalid').
+      if (baInfo.Pauth.TagPlatform == 0 && baInfo.Pauth.TagSchema == 1) {
----------------
smithp35 wrote:

LLVM coding style usually does not put in the braces for single statements.
```
if (baInfo.Pauth.TagPlatform == 0 && baInfo.Pauth.TagSchema == 1)
  file->aarch64PauthAbiCoreInfo = {0, 0};
else
  file->aarch64PauthAbiCoreInfo = {baInfo.Pauth.TagPlatform, baInfo.Pauth.TagSchema};  
```

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


More information about the llvm-commits mailing list