Hi all,

On macOS/arm64, TCC lays named stack arguments (those spilling past x0–x7 /
v0–v7) into generic AAPCS64 8-byte slots, but Apple's ABI packs them at
natural size/alignment. A clang-compiled caller and a TCC-compiled callee
then disagree on every stack arg after the first, silently corrupting
sub-8-byte scalars (int8/16/32) and floats.

Minimal repro: a function with 10 int args returns a garbage 10th arg
across a clang to TCC boundary. The patch packs named non-struct integer
and float/double stack args at natural size in arm64_pcs_aux, stores
the exact width in gfunc_call, and rounds the va_list base up to 8 in
gfunc_prolog (the variadic region stays 8-aligned).

All changes are gated on TCC_TARGET_MACHO; variadic args, HFAs and structs
keep the existing path and all existing tests plus my new ones are passing.

Happy to adjust. I haven't contributed here before so if this is the wrong
avenue please let me know.

Thanks,
Matt

Attachment: 0001-arm64-pack-named-stack-arguments-per-Apple-AArch64-A.patch
Description: Binary data

_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to