scc

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

commit a1184978d322ef887ac233416df8fcbbbaa3cd8e
parent fe20c94e63837f6864cdc001e746027fcb19eac0
Author: zerous Naveen Narayanan <zerous@nocebo.space>
Date:   Wed,  4 Sep 2019 00:28:47 +0200

Add gensys.sh and syscall.lst for i386

Diffstat:
Msrc/libc/arch/i386/linux/Makefile | 20++++++++++++++++++--
Asrc/libc/arch/i386/linux/gensys.sh | 20++++++++++++++++++++
Asrc/libc/arch/i386/linux/syscall.lst | 11+++++++++++
3 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/src/libc/arch/i386/linux/Makefile b/src/libc/arch/i386/linux/Makefile @@ -3,15 +3,31 @@ PROJECTDIR =../../../../.. include $(PROJECTDIR)/scripts/rules.mk include ../../../rules.mk -OBJS = crt.o +OBJS =\ + _Exit.o\ + _close.o\ + _open.o\ + _read.o\ + _write.o\ + _lseek.o\ + _brk.o\ + _sigaction.o\ + _getpid.o\ + _Exit.o\ + _kill.o\ + crt.o\ -all: +all: syscall $(MAKE) objs objs: $(OBJS) crt.o: ../crt-posix.s +syscall: syscall.lst + gensys.sh syscall.lst + touch syscall + clean: rm -f `awk '/[0-9]* _/ {print $$2".s"}' syscall.lst` rm -f syscall _sys_errlist.c diff --git a/src/libc/arch/i386/linux/gensys.sh b/src/libc/arch/i386/linux/gensys.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# +# This job is very easy because app and kernel ABI are identical +# until the 4th parameter, so we only have to set the syscall +# number in eax + +sed 's/[ ]*#.*// + /^$/d' syscall.lst | +while read num name +do +cat <<EOF > $name.s + .file "$name.s" + + .globl $name +$name: + movl \$$num,%eax + syscall + jmp _cerrno +EOF +done diff --git a/src/libc/arch/i386/linux/syscall.lst b/src/libc/arch/i386/linux/syscall.lst @@ -0,0 +1,11 @@ +#number name +3 _read +4 _write +5 _open +6 _close +19 _lseek +45 _brk +67 _sigaction +20 _getpid +1 _Exit +37 _kill