scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit d4cfe5537eec4ef65c227c5642ce72bb34596490
parent 13ffe40c6024950d7a7ed1c80b8083714b92ea1c
Author: Lennart Jablonka <humm@ljabl.com>
Date:   Thu,  9 Apr 2026 14:03:49 +0000

fix syscalls on OpenBSD

* sys_lseek got a new syscall number in revision 1.221 of
/usr/src/sys/kern/syscalls.master (2021-12-23); the old one was
dropped in 1.241 (2023-02-11).  Oh, but the old syscall number was
199, not 198, so I don't think this ever worked.

* For some time now, locations doing syscalls have to be marked using
either pinsyscalls(2) or .openbsd.syscalls sections, otherwise the
process is killed.  For comparison, see the PINSYSCALL macro in
/usr/src/lib/libc/arch/DEFS.h and its use in the SYSTRAP macro in
/usr/src/lib/libc/arch/amd64/SYS.h (for example).

Diffstat:
Msrc/libc/arch/amd64/openbsd/gensys.sh | 10+++++++---
Msrc/libc/arch/amd64/openbsd/syscall.lst | 2+-
2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/libc/arch/amd64/openbsd/gensys.sh b/src/libc/arch/amd64/openbsd/gensys.sh @@ -20,12 +20,16 @@ $name: ;; esac` movq \$$num,%rax - syscall - jb 1f +1: syscall + jb 2f retq -1: movq %rax,(errno) +2: movq %rax,(errno) movq \$-1,%rax retq + + .section .openbsd.syscalls, "a", @progbits + .long 1b + .long $num EOF done diff --git a/src/libc/arch/amd64/openbsd/syscall.lst b/src/libc/arch/amd64/openbsd/syscall.lst @@ -17,4 +17,4 @@ 67 _gettimeofday 2 122 _kill 2 128 _rename 2 -198 _lseek 3 +166 _lseek 3