[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:25:28 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]() {
----------------
kovdan01 wrote:

Thanks for suggestion. I've switched to `const char *` since we later use `PlatformDesc` as an argument for `format(...)` and expect it to be null-terminated. Storing null-terminated strings as `const char *` when we don't need anything except the pointer itself looks more clear in this context than calling `.data()` on `StringRef` and keeping in mind that in this particular case the `StringRef`'s content is also null-terminated (while it's not guaranteed in other cases).

See 8b562626454a9f6f9f9e41b8f84e17535924104d

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


More information about the llvm-commits mailing list