scc-patches

scc patches
Log | Files | Refs | README

0008-lib-c-Update-gensys.sh-for-i386-linux.patch (2131B)


      1 From 54c5eea3ef22e2cea52b4422eda17a4523dec8a9 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 08/11] [lib/c] Update gensys.sh for i386/linux
      5 
      6 ---
      7  src/libc/arch/i386/linux/gensys.sh   | 53 ++++++++++++++++++++++++----
      8  src/libc/arch/i386/linux/syscall.lst | 21 +++++------
      9  2 files changed, 58 insertions(+), 16 deletions(-)
     10 
     11 diff --git a/src/libc/arch/i386/linux/gensys.sh b/src/libc/arch/i386/linux/gensys.sh
     12 index 35ab4752..c1d9711b 100755
     13 --- a/src/libc/arch/i386/linux/gensys.sh
     14 +++ b/src/libc/arch/i386/linux/gensys.sh
     15 @@ -1,20 +1,61 @@
     16  #!/bin/sh
     17 -#
     18 -# This job is very easy because app and kernel ABI are identical
     19 -# until the 4th parameter, so we only have to set the syscall
     20 -# number in eax
     21  
     22  sed 's/[ 	]*#.*//
     23       /^$/d' syscall.lst |
     24 -while read num name
     25 +while read num name noper
     26  do
     27  cat <<EOF > $name.s
     28  	.file	"$name.s"
     29  
     30  	.globl	$name
     31  $name:
     32 +EOF
     33 +
     34 +if test $noper -eq 0
     35 +then
     36 +cat <<EOF >> $name.s
     37  	movl	\$$num,%eax
     38 -	syscall
     39 +	int	\$0x80
     40 +EOF
     41 +
     42 +elif test $noper -eq 1
     43 +then
     44 +cat <<EOF >> $name.s
     45 +	pushl	%ebp
     46 +	movl	%esp,%ebp
     47 +	movl	8(%ebp),%ebx
     48 +	movl	\$$num,%eax
     49 +	int	\$0x80
     50 +	popl	%ebp
     51 +EOF
     52 +
     53 +elif test $noper -eq 2
     54 +then
     55 +cat <<EOF >> $name.s
     56 +	pushl	%ebp
     57 +	movl	%esp,%ebp
     58 +	movl	8(%ebp),%ebx
     59 +	movl	12(%ebp),%ecx
     60 +	movl	\$$num,%eax
     61 +	int	\$0x80
     62 +	popl	%ebp
     63 +EOF
     64 +
     65 +elif test $noper -eq 3
     66 +then
     67 +cat <<EOF >> $name.s
     68 +	pushl	%ebp
     69 +	movl	%esp,%ebp
     70 +	movl	8(%ebp),%ebx
     71 +	movl	12(%ebp),%ecx
     72 +	movl	16(%ebp),%edx
     73 +	movl	\$$num,%eax
     74 +	int	\$0x80
     75 +	popl	%ebp
     76 +EOF
     77 +fi
     78 +cat <<EOF >> $name.s
     79  	jmp	_cerrno
     80  EOF
     81  done
     82 +
     83 diff --git a/src/libc/arch/i386/linux/syscall.lst b/src/libc/arch/i386/linux/syscall.lst
     84 index 743bf682..b3152e1e 100644
     85 --- a/src/libc/arch/i386/linux/syscall.lst
     86 +++ b/src/libc/arch/i386/linux/syscall.lst
     87 @@ -1,10 +1,11 @@
     88 -#number name
     89 -3	_read
     90 -5	_open
     91 -6	_close
     92 -19	_lseek
     93 -45	_brk
     94 -67	_sigaction
     95 -20	_getpid
     96 -1	_Exit
     97 -37	_kill
     98 +#number	name		num_of_op
     99 +4	_write		3
    100 +3	_read		3
    101 +5	_open		2
    102 +6	_close		1
    103 +19	_lseek		3
    104 +45	_brk		1
    105 +67	_sigaction	3
    106 +20	_getpid		0
    107 +1	_Exit		1
    108 +37	_kill		2
    109 -- 
    110 2.23.0
    111