[llvm] [PAC][llvm-readobj][AArch64][ELF] Support `GNU_PROPERTY_AARCH64_FEATURE_PAUTH` (PR #85231)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 23 22:09:33 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("") +
----------------
MaskRay wrote:
Define a std::string, then do
```
if (...)
Desc += ...
if (...)
Desc += ...
```
is likely more readable
https://github.com/llvm/llvm-project/pull/85231
More information about the llvm-commits
mailing list