Skip to content

fix(os/darwin): load aarch64 syscall operands with ldr, not mov#317

Merged
octalide merged 1 commit into
devfrom
fix/315-darwin-aarch64-syscall-asm
Jun 28, 2026
Merged

fix(os/darwin): load aarch64 syscall operands with ldr, not mov#317
octalide merged 1 commit into
devfrom
fix/315-darwin-aarch64-syscall-asm

Conversation

@octalide

Copy link
Copy Markdown
Collaborator

The darwin aarch64 syscall wrappers in src/system/os/darwin/shared.mach moved the syscall number and arguments into registers with mov xN, {operand}. Those operands bind to stack slots, but arm64 mov only accepts a register or immediate source, so the encoder rejected them:

error: encode: inline-asm 'mov' source must be a register or immediate

This failed compilation for --target darwin-aarch64 before linking.

Fix: switch every slot-bound source to ldr, mirroring the linux aarch64 syscall path (which already uses ldr xN, {aN}). Covers syscall0..syscall6 plus the fork/vfork wrappers, which carried the same mov x16, {n}.

The x86_64 wrappers (mov rdi, {a0}) are left untouched — x86 mov accepts a memory source. The arch-specific pipe wrapper in aarch64.mach already uses an immediate (mov x16, 42), which is valid, so it is unchanged.

Closes #315

🤖 Generated with Claude Code

the darwin aarch64 syscall wrappers moved the syscall number and
arguments into registers with 'mov xN, {operand}', but those operands
bind to stack slots and arm64 'mov' only accepts a register or immediate
source, so the encoder rejected them with 'inline-asm mov source must be
a register or immediate'. switch every slot-bound source to 'ldr',
mirroring the linux aarch64 path. covers syscall0..6 plus the fork/vfork
wrappers, which carried the same 'mov x16, {n}'. x86_64 wrappers are
untouched (x86 mov takes a memory source).

Closes #315
@octalide octalide marked this pull request as ready for review June 28, 2026 20:09
@octalide octalide merged commit 803ca2c into dev Jun 28, 2026
2 checks passed
@octalide octalide deleted the fix/315-darwin-aarch64-syscall-asm branch June 28, 2026 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

system/os/darwin: aarch64 syscall wrappers use 'mov xN, {aN}' (slot-bound source) — fails inline-asm encode

1 participant