aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/MachOObjectFile.cpp
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/lib/Object/MachOObjectFile.cpp
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/lib/Object/MachOObjectFile.cpp')
-rw-r--r--llvm/lib/Object/MachOObjectFile.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp
index e2d1723..bd9b5dd1 100644
--- a/llvm/lib/Object/MachOObjectFile.cpp
+++ b/llvm/lib/Object/MachOObjectFile.cpp
@@ -134,7 +134,7 @@ static unsigned getCPUType(const MachOObjectFile &O) {
}
static unsigned getCPUSubType(const MachOObjectFile &O) {
- return O.getHeader().cpusubtype;
+ return O.getHeader().cpusubtype & ~MachO::CPU_SUBTYPE_MASK;
}
static uint32_t