arm64e: set ptrauth ABI subtype on lib.rmeta Mach-O objects#155716
Conversation
|
Some changes occurred in src/doc/unstable-book/src/compiler-flags/branch-protection.md cc @rust-lang/project-exploit-mitigations, @rcvalle These commits modify compiler targets. |
|
r? @adwinwhite rustbot has assigned @adwinwhite. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
r? me |
|
My understanding of the ARM64e situation is that it cannot be solved in |
|
Thanks for pointing this out. I updated the title and description to make the scope clearer. This PR doesn’t provide full Apple arm64e support. It covers the rustc-side ptrauth codegen pieces for Rust’s own codegen paths, and full arm64e support still needs LLVM work. |
|
I’m converting this PR back to draft while I re-check its scope and fix gaps in the current implementation. |
Rust packs rlib metadata into a lib.rmeta archive member encoded as a Mach-O object. For Apple arm64e, extend the existing metadata-object subtype special case from bare CPU_SUBTYPE_ARM64E to CPU_SUBTYPE_ARM64E | CPU_SUBTYPE_PTRAUTH_ABI.
77e2e36 to
8c029d5
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
Thanks, I’ve removed the test. I really appreciate your time reviewing this and your guidance. |
|
Thanks for fixing this! I've shortened the PR description a bit, and added issues that this fixes. @bors r+ rollup |
|
Thanks again for your review! |
…4e-ptrauth-core-diagnostics-2026-04-24-u9836b06, r=madsmtm arm64e: set ptrauth ABI subtype on lib.rmeta Mach-O objects Set `CPU_SUBTYPE_PTRAUTH_ABI` (as well as the existing `CPU_SUBTYPE_ARM64E`) on ARM64e object files that `rustc` creates, to match Clang/LLVM-generated ARM64e objects. This corresponds to `cpusubtype == 0x80000002`. Before this change, rustc emitted the bare `CPU_SUBTYPE_ARM64E` subtype for the metadata wrapper objects / `symbols.o` file, producing `0x00000002`, which can be reported by Apple's linker as `arm64e.old`. Fixes [rust-lang#130085](rust-lang#130085). Fixes [rust-lang#143844](rust-lang#143844). Fixes [rust-lang#150046](rust-lang#150046). Fixes [rust-lang#139218](rust-lang#139218).
…uwer Rollup of 4 pull requests Successful merges: - #152487 (core: drop unmapped ZSTs in array `map`) - #155716 (arm64e: set ptrauth ABI subtype on lib.rmeta Mach-O objects) - #155864 (Fix panic for doc attributes on where predicates) - #155865 (add test for accidentally fixed `binius_field` issue)
…uwer Rollup of 6 pull requests Successful merges: - #154465 (triagebot: Mention 'subtree' in clippy message) - #155355 (Fix pathological performance in trait solver cycles with errors) - #155716 (arm64e: set ptrauth ABI subtype on lib.rmeta Mach-O objects) - #155864 (Fix panic for doc attributes on where predicates) - #155865 (add test for accidentally fixed `binius_field` issue) - #155866 (Render `ConstContext` for diagnostics once)
Rollup merge of #155716 - cypherair:prep/upstream-ready-arm64e-ptrauth-core-diagnostics-2026-04-24-u9836b06, r=madsmtm arm64e: set ptrauth ABI subtype on lib.rmeta Mach-O objects Set `CPU_SUBTYPE_PTRAUTH_ABI` (as well as the existing `CPU_SUBTYPE_ARM64E`) on ARM64e object files that `rustc` creates, to match Clang/LLVM-generated ARM64e objects. This corresponds to `cpusubtype == 0x80000002`. Before this change, rustc emitted the bare `CPU_SUBTYPE_ARM64E` subtype for the metadata wrapper objects / `symbols.o` file, producing `0x00000002`, which can be reported by Apple's linker as `arm64e.old`. Fixes [#130085](#130085). Fixes [#143844](#143844). Fixes [#150046](#150046). Fixes [#139218](#139218).
Good news is we are not blocked on Apple upstreaming LLVM changes anymore. Currently, end-to-end arm64e support for Rust is chiefly blocked on backend Mach-O support which I put up for review here: llvm/llvm-project#188378 I've been able to successfully build and link arm64e Rust applications using that patch as well this commit where I add support for C/C++ interop w/ appropriate pointer signing schemas: oskarwirga@fbcad35 It should be noted however I am not an expert in rustc and that was put together through trial and error :P |
Ohh, nice work! I'll probably be looking into pointer authentication myself soon as part of reviewing #155722, then I'll probably be able to help with getting things landed in |
Set
CPU_SUBTYPE_PTRAUTH_ABI(as well as the existingCPU_SUBTYPE_ARM64E) on ARM64e object files thatrustccreates, to match Clang/LLVM-generated ARM64e objects.This corresponds to
cpusubtype == 0x80000002. Before this change, rustc emitted the bareCPU_SUBTYPE_ARM64Esubtype for the metadata wrapper objects /symbols.ofile, producing0x00000002, which can be reported by Apple's linker asarm64e.old.Fixes rust-lang/rust#130085.
Fixes rust-lang/rust#143844.
Fixes rust-lang/rust#150046.
Fixes rust-lang/rust#139218.