scc-patches

scc patches
Log | Files | Refs | README

0006-lib-c-Update-gensys.sh-for-i386-linux.patch (2140B)


      1 From b63172114813e193f5e8c037ae1a5b3c0fa564b5 Mon Sep 17 00:00:00 2001
      2 From: zerous Naveen Narayanan <zerous@nocebo.space>
      3 Date: Fri, 1 Nov 2019 17:50:14 +0100
      4 Subject: [PATCH 06/10] [lib/c] Update gensys.sh for i386/linux
      5 
      6 awk script generates code that sets the respective registers with
      7 parameters for i386 syscalls.
      8 ---
      9  src/libc/arch/i386/linux/gensys.sh   | 35 ++++++++++++++--------------
     10  src/libc/arch/i386/linux/syscall.lst | 21 +++++++++--------
     11  2 files changed, 28 insertions(+), 28 deletions(-)
     12 
     13 diff --git a/src/libc/arch/i386/linux/gensys.sh b/src/libc/arch/i386/linux/gensys.sh
     14 index 35ab4752..d2ca7b48 100755
     15 --- a/src/libc/arch/i386/linux/gensys.sh
     16 +++ b/src/libc/arch/i386/linux/gensys.sh
     17 @@ -1,20 +1,19 @@
     18  #!/bin/sh
     19 -#
     20 -# This job is very easy because app and kernel ABI are identical
     21 -# until the 4th parameter, so we only have to set the syscall
     22 -# number in eax
     23  
     24 -sed 's/[ 	]*#.*//
     25 -     /^$/d' syscall.lst |
     26 -while read num name
     27 -do
     28 -cat <<EOF > $name.s
     29 -	.file	"$name.s"
     30 -
     31 -	.globl	$name
     32 -$name:
     33 -	movl	\$$num,%eax
     34 -	syscall
     35 -	jmp	_cerrno
     36 -EOF
     37 -done
     38 +awk ' { syscall=$2
     39 +	fname=$2".s"
     40 +	noper=$3
     41 +	if (NR > 1) {
     42 +		printf "\t.file\t\"fname\"\n\t.globl\t%s\n%s:\n", syscall, syscall > fname
     43 +		printf "\tpushl\t%%ebp\n\tmovl\t%%esp,%%ebp\n" >> fname
     44 +		if (noper > 0)
     45 +			printf "\tmovl\t8(%%ebp),%%ebx\n" >> fname
     46 +		if (noper > 1)
     47 +			printf "\tmovl\t12(%%ebp),%%ecx\n" >> fname
     48 +		if (noper > 2)
     49 +			printf "\tmovl\t16(%%ebp),%%edx\n" >> fname
     50 +		printf "\tmovl\t%d,%%eax\n\tint\t$0x80\n", noper >> fname
     51 +		printf "\tpopl\t%%ebp\n" >> fname
     52 +		printf "\tjmp\t_cerrno\n" >> fname
     53 +	}
     54 +      } ' syscall.lst
     55 diff --git a/src/libc/arch/i386/linux/syscall.lst b/src/libc/arch/i386/linux/syscall.lst
     56 index 743bf682..b3152e1e 100644
     57 --- a/src/libc/arch/i386/linux/syscall.lst
     58 +++ b/src/libc/arch/i386/linux/syscall.lst
     59 @@ -1,10 +1,11 @@
     60 -#number name
     61 -3	_read
     62 -5	_open
     63 -6	_close
     64 -19	_lseek
     65 -45	_brk
     66 -67	_sigaction
     67 -20	_getpid
     68 -1	_Exit
     69 -37	_kill
     70 +#number	name		num_of_op
     71 +4	_write		3
     72 +3	_read		3
     73 +5	_open		2
     74 +6	_close		1
     75 +19	_lseek		3
     76 +45	_brk		1
     77 +67	_sigaction	3
     78 +20	_getpid		0
     79 +1	_Exit		1
     80 +37	_kill		2
     81 -- 
     82 2.23.0
     83