[llvm] [PAC][llvm-readobj][AArch64][ELF] Support `GNU_PROPERTY_AARCH64_FEATURE_PAUTH` (PR #85231)

Daniil Kovalev via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 25 00:27:05 PDT 2024


================
@@ -5098,6 +5098,86 @@ template <class ELFT> void GNUELFDumper<ELFT>::printAddrsig() {
   }
 }
 
+template <class ELFT>
+static bool printAArch64PAuthABICoreInfo(raw_ostream &OS, uint32_t DataSize,
+                                         ArrayRef<uint8_t> Desc) {
+  OS << "    AArch64 PAuth ABI core info: ";
+  // DataSize - size without padding, Desc.size() - size with padding
+  if (DataSize != 16) {
+    OS << format("<corrupted size: expected 16, got %d>", DataSize);
+    return false;
+  }
+
+  uint64_t Platform =
+      support::endian::read64<ELFT::TargetEndianness>(Desc.data() + 0);
+  uint64_t Version =
+      support::endian::read64<ELFT::TargetEndianness>(Desc.data() + 8);
+
+  std::string PlatformDesc = [Platform]() {
+    switch (Platform) {
+    case AARCH64_PAUTH_PLATFORM_INVALID:
+      return "invalid";
+    case AARCH64_PAUTH_PLATFORM_BAREMETAL:
+      return "baremetal";
+    case AARCH64_PAUTH_PLATFORM_LLVM_LINUX:
+      return "llvm_linux";
+    default:
+      return "unknown";
+    }
+  }();
+
+  std::string VersionDesc = [Platform, Version]() -> std::string {
+    if (Platform != AARCH64_PAUTH_PLATFORM_LLVM_LINUX)
+      return "";
+    if (Version >= (1 << (AARCH64_PAUTH_PLATFORM_LLVM_LINUX_VERSION_LAST + 1)))
+      return "unknown";
+    return std::string("") +
+           ((Version &
+             (1 << AARCH64_PAUTH_PLATFORM_LLVM_LINUX_VERSION_INTRINSICS))
+                ? ""
+                : "!") +
+           "PointerAuthIntrinsics, " +
+           ((Version & (1 << AARCH64_PAUTH_PLATFORM_LLVM_LINUX_VERSION_CALLS))
+                ? ""
+                : "!") +
+           "PointerAuthCalls, " +
+           ((Version & (1 << AARCH64_PAUTH_PLATFORM_LLVM_LINUX_VERSION_RETURNS))
+                ? ""
+                : "!") +
+           "PointerAuthReturns, " +
+           ((Version &
+             (1 << AARCH64_PAUTH_PLATFORM_LLVM_LINUX_VERSION_AUTHTRAPS))
+                ? ""
+                : "!") +
+           "PointerAuthAuthTraps, " +
+           ((Version &
+             (1 << AARCH64_PAUTH_PLATFORM_LLVM_LINUX_VERSION_VPTRADDRDISCR))
+                ? ""
+                : "!") +
+           "PointerAuthVTPtrAddressDiscrimination, " +
+           ((Version &
+             (1 << AARCH64_PAUTH_PLATFORM_LLVM_LINUX_VERSION_VPTRTYPEDISCR))
+                ? ""
+                : "!") +
+           "PointerAuthVTPtrTypeDiscrimination, " +
+           ((Version &
+             (1 << AARCH64_PAUTH_PLATFORM_LLVM_LINUX_VERSION_INITFINI))
+                ? ""
+                : "!") +
+           "PointerAuthInitFini";
----------------
kovdan01 wrote:

I'm not sure if I got your question - all the flag names are always part of the description, we just add '!' for those which are not set. As for me, it's more clear for a user than only including in the description flags which are set and not including those which are not set - in this case, the user is not aware which flags are available and does not know which features are disabled.

Please let me know if I miss something.

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


More information about the llvm-commits mailing list