From: H. Peter Anvin Date: Wed, 6 Jan 2016 00:43:50 +0000 (-0800) Subject: i386: remove special handling of socketcall X-Git-Tag: archive/raspbian/2.0.4-14+rpi1^2~11 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=4398f16d7120726deac0667aef58ec5431133ec0;p=klibc.git i386: remove special handling of socketcall As of kernel 4.3, i386 now has direct system calls for sockets, so drop the special handling for i386 socketcall. If built on older kernels, it will still generate socketcall stubs although they will be less efficient. Signed-off-by: H. Peter Anvin [bwh: Backported to 2.0.4: adjust context] Gbp-Pq: Name klibc-i386-remove-special-handling-of-socketcall.patch --- diff --git a/usr/klibc/arch/i386/Kbuild b/usr/klibc/arch/i386/Kbuild index 1642374..f1b5ad2 100644 --- a/usr/klibc/arch/i386/Kbuild +++ b/usr/klibc/arch/i386/Kbuild @@ -2,7 +2,7 @@ # klibc .o files for i386 # -klib-y := archinit.o socketcall.o setjmp.o syscall.o varsyscall.o +klib-y := archinit.o setjmp.o syscall.o varsyscall.o klib-y += open.o openat.o vfork.o klib-y += libgcc/__ashldi3.o libgcc/__ashrdi3.o libgcc/__lshrdi3.o klib-y += libgcc/__muldi3.o libgcc/__negdi2.o diff --git a/usr/klibc/arch/i386/socketcall.S b/usr/klibc/arch/i386/socketcall.S deleted file mode 100644 index 44e2004..0000000 --- a/usr/klibc/arch/i386/socketcall.S +++ /dev/null @@ -1,55 +0,0 @@ -# -# socketcall.S -# -# Socketcalls use the following convention: -# %eax = __NR_socketcall -# %ebx = socketcall number -# %ecx = pointer to arguments (up to 6) -# - -#include - -#ifdef __i386__ - - .text - .align 4 - .globl __socketcall_common - .type __socketcall_common, @function - -__socketcall_common: - xchgl %ebx,(%esp) # The stub passes the socketcall # on stack - -#ifdef _REGPARM - pushl 16(%esp) # Arg 6 - pushl 16(%esp) # Arg 5 - pushl 16(%esp) # Arg 4 - pushl %ecx - pushl %edx - pushl %eax - movl %esp,%ecx -#else - leal 8(%esp),%ecx # Arguments already contiguous on-stack -#endif - - movl $__NR_socketcall,%eax - call *__syscall_entry - -#ifdef _REGPARM - addl $6*4, %esp -#endif - - cmpl $-4095,%eax # Error return? - - popl %ebx - - jb 1f - - negl %eax - movl %eax,errno - orl $-1,%eax # Return -1 -1: - ret - - .size __socketcall_common,.-__socketcall_common - -#endif diff --git a/usr/klibc/socketcalls.pl b/usr/klibc/socketcalls.pl index 3dac096..9df5949 100644 --- a/usr/klibc/socketcalls.pl +++ b/usr/klibc/socketcalls.pl @@ -42,44 +42,27 @@ while ( defined($line = ) ) { $nargs = $i; print " \\\n\t${name}.o"; - if ( $arch eq 'i386' ) { - open(OUT, "> ${outputdir}/${name}.S") - or die "$0: Cannot open ${outputdir}/${name}.S\n"; + open(OUT, "> ${outputdir}/${name}.c") + or die "$0: Cannot open ${outputdir}/${name}.c\n"; - print OUT "#include \n"; - print OUT "\n"; - print OUT "\t.text\n"; - print OUT "\t.align 4\n"; - print OUT "\t.globl ${name}\n"; - print OUT "\t.type ${name},\@function\n"; - print OUT "${name}:\n"; - print OUT "\tpushl \$SYS_\U${name}\n"; - print OUT "\tjmp __socketcall_common\n"; - print OUT "\t.size ${name},.-${name}\n"; - close(OUT); - } else { - open(OUT, "> ${outputdir}/${name}.c") - or die "$0: Cannot open ${outputdir}/${name}.c\n"; - - print OUT "#include \"socketcommon.h\"\n"; - print OUT "\n"; - print OUT "#if _KLIBC_SYS_SOCKETCALL || !defined(__NR_${name})\n\n"; + print OUT "#include \"socketcommon.h\"\n"; + print OUT "\n"; + print OUT "#if _KLIBC_SYS_SOCKETCALL || !defined(__NR_${name})\n\n"; - print OUT "extern long __socketcall(int, const unsigned long *);\n\n"; + print OUT "extern long __socketcall(int, const unsigned long *);\n\n"; - print OUT "$type $name (", join(', ', @cargs), ")\n"; - print OUT "{\n"; - print OUT " unsigned long args[$nargs];\n"; - for ( $i = 0 ; $i < $nargs ; $i++ ) { - print OUT " args[$i] = (unsigned long)a$i;\n"; - } - print OUT " return ($type) __socketcall(SYS_\U${name}\E, args);\n"; - print OUT "}\n\n"; + print OUT "$type $name (", join(', ', @cargs), ")\n"; + print OUT "{\n"; + print OUT " unsigned long args[$nargs];\n"; + for ( $i = 0 ; $i < $nargs ; $i++ ) { + print OUT " args[$i] = (unsigned long)a$i;\n"; + } + print OUT " return ($type) __socketcall(SYS_\U${name}\E, args);\n"; + print OUT "}\n\n"; - print OUT "#endif\n"; + print OUT "#endif\n"; - close(OUT); - } + close(OUT); } else { die "$file:$.: Could not parse input\n"; }