Skip to content

codegen/link(macho): PIE Mach-O executable writer + rebase stream (Apple Silicon arm64 exec) #1722

Description

@octalide

Part of #1718. Blocks the aarch64 leg of #1680.

What

macOS arm64 (Apple Silicon) refuses to exec a non-PIE main executable — proven on
macos-14 in #1718 (the linker even forces PIE: -no_pie ignored for arm64). mach
emits a non-PIE fixed-absolute image (__TEXT at 0xfffff000, empty rebase stream),
so its arm64 darwin binaries are Killed: 9 at exec. This issue makes mach emit a
genuine PIE Mach-O executable so the darwin self-host runs on Apple Silicon.

The investigation (#1718) already prototyped the cheap parts and ruled out the
expensive alternatives — keep raw svc (no libSystem syscall routing), classic
LC_DYLD_INFO rebase (no chained fixups), zero dylib dependency. The prototypes live
on branch invel/1718-scope (env-gated LC_MAIN/LC_BUILD_VERSION/LC_UUID/MH_PIE
toggles in emit_dyn_exec); use them as the starting point.

Scope:

Acceptance

  • A mach-built aarch64-darwin PIE executable execs on a macos-14 runner (no
    Killed: 9); the native a→b→c darwin fixpoint converges and mach test . passes
    on Apple Silicon. Validate via infra: CD-authored darwin release build (x86_64 + aarch64, native fixpoint) #1680's workflow_dispatch.
  • The rebase stream is well-formed (llvm-objdump/otool: MH_PIE, LC_MAIN,
    LC_DYLD_INFO rebase opcodes resolve to the right addresses); the ad-hoc signature
    still validates.
  • x86_64-darwin, linux, and windows output unaffected; the linux self-host fixpoint
    stays byte-identical and mach test . green.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:codegenIR/middle-end, isel, regalloc, frame, encoders, inline asmarea:linklinker, object formats, target/ABI plumbingfeaturenew capability, or an extension of an existing onetarget:darwinmacOS-specific behavior or work

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions