aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-objdump
diff options
context:
space:
mode:
authorAhmed Bougacha <ahmed@bougacha.org>2024-08-20 11:37:12 -0700
committerGitHub <noreply@github.com>2024-08-20 11:37:12 -0700
commitfd4f9520a6a08c3dcf15622e3b887d8f3624fc42 (patch)
treec1edd7a207f523f8e56c28fccf576fca528ab7fb /llvm/tools/llvm-objdump
parentf73050e722dd2e484358d03674eb186f3a2f4799 (diff)
downloadllvm-fd4f9520a6a08c3dcf15622e3b887d8f3624fc42.zip
llvm-fd4f9520a6a08c3dcf15622e3b887d8f3624fc42.tar.gz
llvm-fd4f9520a6a08c3dcf15622e3b887d8f3624fc42.tar.bz2
[AArch64][MachO] Add ptrauth ABI version to arm64e cpusubtype. (#104650)
In a mach_header, the cpusubtype is a 32-bit field, but it's split in 2 subfields: - the low 24 bits containing the cpu subtype proper, (e.g., CPU_SUBTYPE_ARM64E 2) - the high 8 bits containing a capability field used for additional feature flags. Notably, it's only the subtype subfield that participates in fat file slice discrimination: the caps are ignored. arm64e uses the caps subfield to encode a ptrauth ABI version: - 0x80 (CPU_SUBTYPE_PTRAUTH_ABI) denotes a versioned binary - 0x40 denotes a kernel-ABI binary - 0x00-0x0F holds the ptrauth ABI version This teaches the basic obj tools to decode that (or ignore it when unneeded). It also teaches the MachO writer to default to emitting versioned binaries, but with a version of 0 (and without the kernel ABI flag). Modern arm64e requires versioned binaries: a binary with 0x00 caps in cpusubtype is now rejected by the linker and everything after. We can live without the sophistication of specifying the version and kernel ABI for now. Co-authored-by: Francis Visoiu Mistrih <francisvm@apple.com>
Diffstat (limited to 'llvm/tools/llvm-objdump')
-rw-r--r--llvm/tools/llvm-objdump/MachODump.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp
index 0544fc4..b8afb56 100644
--- a/llvm/tools/llvm-objdump/MachODump.cpp
+++ b/llvm/tools/llvm-objdump/MachODump.cpp
@@ -2394,8 +2394,16 @@ static void printMachOUniversalHeaders(const object::MachOUniversalBinary *UB,
outs() << " cpusubtype " << (cpusubtype & ~MachO::CPU_SUBTYPE_MASK)
<< "\n";
}
- if (verbose &&
- (cpusubtype & MachO::CPU_SUBTYPE_MASK) == MachO::CPU_SUBTYPE_LIB64)
+ if (verbose && cputype == MachO::CPU_TYPE_ARM64 &&
+ MachO::CPU_SUBTYPE_ARM64E_IS_VERSIONED_PTRAUTH_ABI(cpusubtype)) {
+ outs() << " capabilities CPU_SUBTYPE_ARM64E_";
+ if (MachO::CPU_SUBTYPE_ARM64E_IS_KERNEL_PTRAUTH_ABI(cpusubtype))
+ outs() << "KERNEL_";
+ outs() << format("PTRAUTH_VERSION %d",
+ MachO::CPU_SUBTYPE_ARM64E_PTRAUTH_VERSION(cpusubtype))
+ << "\n";
+ } else if (verbose && (cpusubtype & MachO::CPU_SUBTYPE_MASK) ==
+ MachO::CPU_SUBTYPE_LIB64)
outs() << " capabilities CPU_SUBTYPE_LIB64\n";
else
outs() << " capabilities "
@@ -8368,7 +8376,17 @@ static void PrintMachHeader(uint32_t magic, uint32_t cputype,
outs() << format(" %10d", cpusubtype & ~MachO::CPU_SUBTYPE_MASK);
break;
}
- if ((cpusubtype & MachO::CPU_SUBTYPE_MASK) == MachO::CPU_SUBTYPE_LIB64) {
+
+ if (cputype == MachO::CPU_TYPE_ARM64 &&
+ MachO::CPU_SUBTYPE_ARM64E_IS_VERSIONED_PTRAUTH_ABI(cpusubtype)) {
+ const char *Format =
+ MachO::CPU_SUBTYPE_ARM64E_IS_KERNEL_PTRAUTH_ABI(cpusubtype)
+ ? " PAK%02d"
+ : " PAC%02d";
+ outs() << format(Format,
+ MachO::CPU_SUBTYPE_ARM64E_PTRAUTH_VERSION(cpusubtype));
+ } else if ((cpusubtype & MachO::CPU_SUBTYPE_MASK) ==
+ MachO::CPU_SUBTYPE_LIB64) {
outs() << " LIB64";
} else {
outs() << format(" 0x%02" PRIx32,