0
Fork 0
mirror of https://codeberg.org/ziglang/zig synced 2026-11-18 07:05:05 +00:00
zig/lib
Geyslan Gregório 503b03daa3 std.os.linux: declare $a3 as an output of mips syscall4 and up
On MIPS, $a3 ($7) carries the fourth argument [1] and returns the
kernel's error flag [2]. The kernel writes the flag on every return,
success included [3]. syscall4 and up declared $7 an input only, so
the compiler assumed it still held the argument after the syscall.
In release builds, a pointer passed as the fourth argument then reads
back as the flag, 0 on success, and using it faults at address 0.

Commit 5b29b4ffa6 ("Fix MIPS inline assembly clobbers") took $7 out of
the clobbers, since an input cannot be one, but never made it an
output.

Add that output, as alpha.zig does for its argument registers [4]
and musl does with "+r" [5]. $7 stays out of the clobbers, because a
register that is input, output and clobber at once can miscompile (#35724).

[1] - https://refspecs.linuxfoundation.org/elf/mipsabi.pdf#page=24
[2] - https://man7.org/linux/man-pages/man2/syscall.2.html
[3] - https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/mips/kernel/scall32-o32.S?h=v7.1#n112
[4] - d893812013/lib/std/os/linux/alpha.zig (L38-L46)
[5] - https://git.musl-libc.org/cgit/musl/tree/arch/mips/syscall_arch.h?h=v1.2.6#n81

closes #37247
History 2026-10-15 19:33:50 +02:00
..
build-web Change usages of fmt.bufPrint* to mem.print* (#36263) 2026-09-01 02:21:28 +02:00
c move wcslen from libzigc to compiler-rt 2026-10-07 00:30:52 +02:00
compiler Maker: guard project id construction with have_manifest 2026-10-14 19:00:42 -07:00
compiler_rt compiler_rt: fix fma rounding and add regression tests 2026-10-14 09:24:42 +02:00
docs Change usages of fmt.bufPrint* to mem.print* (#36263) 2026-09-01 02:21:28 +02:00
include zig cc: update intrinsic headers to LLVM 23 2026-10-07 00:30:51 +02:00
init default to LLVM and ReleaseSafe for fuzzing 2026-10-09 10:14:16 +02:00
libc libc: add darwin header os/os_sync_wait_on_address.h 2026-10-07 00:30:52 +02:00
libcxx libcxx: fix OpenBSD build failure due to missing __get_locale_encoding() 2026-10-07 00:30:52 +02:00
libcxxabi libcxx: add serenity support 2026-10-07 00:30:52 +02:00
libtsan libtsan: update to LLVM 23 2026-10-07 00:30:51 +02:00
libunwind libunwind: update to LLVM 23 2026-10-07 00:30:51 +02:00
lldb test: convert debugger tests to new runner 2026-10-02 09:10:10 -04:00
std std.os.linux: declare $a3 as an output of mips syscall4 and up 2026-10-15 19:33:50 +02:00
c.zig feat(libzigc): add common implementations of pthread_spin_* 2026-04-21 09:03:06 +02:00
compiler_rt.zig move wcslen from libzigc to compiler-rt 2026-10-07 00:30:52 +02:00
fuzzer.zig Change usages of fmt.bufPrint* to mem.print* (#36263) 2026-09-01 02:21:28 +02:00
ubsan_rt.zig std: support loongarch backend 2026-08-09 11:10:26 +08:00
zig.h x86_64: llvm 23 changed the windows abi :( 2026-10-07 00:30:52 +02:00