[lld] [lld][AArch64][ELF][PAC] Support AUTH relocations and AUTH ELF marking (PR #72714)

Daniil Kovalev via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 8 02:48:42 PST 2024


================
@@ -2619,6 +2623,42 @@ static uint32_t getAndFeatures() {
   return ret;
 }
 
+static void getAArch64PauthInfo() {
+  auto it = std::find_if(
+      ctx.objectFiles.begin(), ctx.objectFiles.end(),
+      [](const ELFFileBase *f) { return !f->aarch64PauthAbiTag.empty(); });
+  if (it == ctx.objectFiles.end())
+    return;
+
+  ctx.aarch64PauthAbiTag = (*it)->aarch64PauthAbiTag;
+  StringRef f1 = (*it)->getName();
+  for (ELFFileBase *f : ctx.objectFiles) {
+    StringRef f2 = f->getName();
+    ArrayRef<uint8_t> d1 = ctx.aarch64PauthAbiTag;
+    ArrayRef<uint8_t> d2 = f->aarch64PauthAbiTag;
+    if (d2.empty()) {
+      auto helper = [](StringRef report, const Twine &msg) {
+        if (report == "warning")
+          warn(msg);
+        else if (report == "error")
+          error(msg);
+      };
+
+      helper(config->zPauthReport,
+             f2.str() + " has no AArch64 PAuth compatibility info while " +
+                 f1.str() +
+                 " has one; either all or no input files must have it");
+      continue;
+    }
+    if (!std::equal(d1.begin(), d1.end(), d2.begin(), d2.end()))
+      errorOrWarn(
+          "incompatible values of AArch64 PAuth compatibility info found"
+          "\n" +
+          f1 + ": 0x" + toHex(ArrayRef(d1.data(), d1.size())) + "\n" + f2 +
----------------
kovdan01 wrote:

Since `Twine::utohexstr` accepts `uint64_t` while we need to display a byte range, I've passed the second `LowerCase=true` parameter to `toHex` invocation. See b215b0d60ac0c2ac29aeb318da7c95725be6ef86


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


More information about the llvm-commits mailing list