remove external __syscall function and last remaining users

the weak version of __syscall_cp_c was using a tail call to __syscall
to avoid duplicating the 6-argument syscall code inline in small
static-linked programs, but now that __syscall no longer exists, the
inline expansion is no longer duplication.

the syscall.h machinery suppported up to 7 syscall arguments, only via
an external __syscall function, but we presently have no syscall call
points that actually make use of that many, and the kernel only
defines 7-argument calling conventions for arm, powerpc (32-bit), and
sh. if it turns out we need them in the future, they can easily be
added.
This commit is contained in:
Rich Felker 2019-04-10 20:11:19 -04:00
parent 1bcdaeee6e
commit 788d5e24ca
18 changed files with 2 additions and 264 deletions

View File

@ -1,14 +0,0 @@
.global __syscall
.hidden __syscall
.type __syscall,%function
__syscall:
uxtw x8,w0
mov x0,x1
mov x1,x2
mov x2,x3
mov x3,x4
mov x4,x5
mov x5,x6
mov x6,x7
svc 0
ret

View File

@ -1,15 +0,0 @@
.syntax unified
.global __syscall
.hidden __syscall
.type __syscall,%function
__syscall:
mov ip,sp
stmfd sp!,{r4,r5,r6,r7}
mov r7,r0
mov r0,r1
mov r1,r2
mov r2,r3
ldmfd ip,{r3,r4,r5,r6}
svc 0
ldmfd sp!,{r4,r5,r6,r7}
bx lr

View File

@ -1,21 +0,0 @@
.global __syscall
.hidden __syscall
.type __syscall,@function
__syscall:
push %ebx
push %esi
push %edi
push %ebp
mov 20(%esp),%eax
mov 24(%esp),%ebx
mov 28(%esp),%ecx
mov 32(%esp),%edx
mov 36(%esp),%esi
mov 40(%esp),%edi
mov 44(%esp),%ebp
call *%gs:16
pop %ebp
pop %edi
pop %esi
pop %ebx
ret

View File

@ -1,9 +0,0 @@
.global __syscall
.hidden __syscall
.type __syscall,%function
__syscall:
movem.l %d2-%d5,-(%sp)
movem.l 20(%sp),%d0-%d5/%a0
trap #0
movem.l (%sp)+,%d2-%d5
rts

View File

@ -1,14 +0,0 @@
.global __syscall
.hidden __syscall
.type __syscall,@function
__syscall:
addi r12, r5, 0 # Save the system call number
add r5, r6, r0 # Shift the arguments, arg1
add r6, r7, r0 # arg2
add r7, r8, r0 # arg3
add r8, r9, r0 # arg4
add r9, r10, r0 # arg5
lwi r10, r1, 28 # Get arg6.
brki r14, 0x8 # syscall
rtsd r15, 8
nop

View File

@ -1,26 +0,0 @@
.set noreorder
.global __syscall
.hidden __syscall
.type __syscall,@function
__syscall:
move $2, $4
move $4, $5
move $5, $6
move $6, $7
lw $7, 16($sp)
lw $8, 20($sp)
lw $9, 24($sp)
lw $10,28($sp)
subu $sp, $sp, 32
sw $8, 16($sp)
sw $9, 20($sp)
sw $10,24($sp)
sw $2 ,28($sp)
lw $2, 28($sp)
syscall
beq $7, $0, 1f
addu $sp, $sp, 32
subu $2, $0, $2
1: jr $ra
nop

View File

@ -1,19 +0,0 @@
.set noreorder
.global __syscall
.hidden __syscall
.type __syscall,@function
__syscall:
move $2, $4
move $4, $5
move $5, $6
move $6, $7
move $7, $8
move $8, $9
move $9, $10
move $10, $11
syscall
beq $7, $0, 1f
nop
dsubu $2, $0, $2
1: jr $ra
nop

View File

@ -1,19 +0,0 @@
.set noreorder
.global __syscall
.hidden __syscall
.type __syscall,@function
__syscall:
move $2, $4
move $4, $5
move $5, $6
move $6, $7
move $7, $8
move $8, $9
move $9, $10
move $10, $11
syscall
beq $7, $0, 1f
nop
subu $2, $0, $2
1: jr $ra
nop

View File

@ -1,14 +0,0 @@
.global __syscall
.hidden __syscall
.type __syscall,@function
__syscall:
l.ori r11, r3, 0
l.lwz r3, 0(r1)
l.lwz r4, 4(r1)
l.lwz r5, 8(r1)
l.lwz r6, 12(r1)
l.lwz r7, 16(r1)
l.lwz r8, 20(r1)
l.sys 1
l.jr r9
l.nop

View File

@ -1,19 +0,0 @@
.global __syscall
.hidden __syscall
.type __syscall,@function
__syscall:
mr 0, 3 # Save the system call number
mr 3, 4 # Shift the arguments: arg1
mr 4, 5 # arg2
mr 5, 6 # arg3
mr 6, 7 # arg4
mr 7, 8 # arg5
mr 8, 9 # arg6
sc
bnslr+ # return if not summary overflow
#else error:
# return negated value.
neg 3, 3
blr
.end __syscall
.size __syscall, .-__syscall

View File

@ -1,17 +0,0 @@
.global __syscall
.hidden __syscall
.type __syscall,@function
__syscall:
mr 0, 3 # Save the system call number
mr 3, 4 # Shift the arguments: arg1
mr 4, 5 # arg2
mr 5, 6 # arg3
mr 6, 7 # arg4
mr 7, 8 # arg5
mr 8, 9 # arg6
sc
bnslr+ # return if not summary overflow
neg 3, 3 # otherwise error: return negated value.
blr
.end __syscall
.size __syscall, .-__syscall

View File

@ -1,15 +0,0 @@
.global __syscall
.hidden __syscall
.type __syscall, %function
__syscall:
stg %r7, 56(%r15)
lgr %r1, %r2
lgr %r2, %r3
lgr %r3, %r4
lgr %r4, %r5
lgr %r5, %r6
lg %r6, 160(%r15)
lg %r7, 168(%r15)
svc 0
lg %r7, 56(%r15)
br %r14

View File

@ -1,23 +0,0 @@
.global __syscall
.hidden __syscall
.type __syscall, @function
__syscall:
! The kernel syscall entry point documents that the trap number indicates
! the number of arguments being passed, but it then ignores that information.
! Since we do not actually know how many arguments are being passed, we will
! say there are six, since that is the maximum we support here.
mov r4, r3
mov r5, r4
mov r6, r5
mov r7, r6
mov.l @r15, r7
mov.l @(4,r15), r0
mov.l @(8,r15), r1
trapa #31
or r0, r0
or r0, r0
or r0, r0
or r0, r0
or r0, r0
rts
nop

View File

View File

@ -22,27 +22,16 @@
typedef long syscall_arg_t;
#endif
hidden long __syscall_ret(unsigned long), __syscall(syscall_arg_t, ...),
hidden long __syscall_ret(unsigned long),
__syscall_cp(syscall_arg_t, syscall_arg_t, syscall_arg_t, syscall_arg_t,
syscall_arg_t, syscall_arg_t, syscall_arg_t);
#ifdef SYSCALL_NO_INLINE
#define __syscall0(n) (__syscall)(n)
#define __syscall1(n,a) (__syscall)(n,__scc(a))
#define __syscall2(n,a,b) (__syscall)(n,__scc(a),__scc(b))
#define __syscall3(n,a,b,c) (__syscall)(n,__scc(a),__scc(b),__scc(c))
#define __syscall4(n,a,b,c,d) (__syscall)(n,__scc(a),__scc(b),__scc(c),__scc(d))
#define __syscall5(n,a,b,c,d,e) (__syscall)(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e))
#define __syscall6(n,a,b,c,d,e,f) (__syscall)(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e),__scc(f))
#else
#define __syscall1(n,a) __syscall1(n,__scc(a))
#define __syscall2(n,a,b) __syscall2(n,__scc(a),__scc(b))
#define __syscall3(n,a,b,c) __syscall3(n,__scc(a),__scc(b),__scc(c))
#define __syscall4(n,a,b,c,d) __syscall4(n,__scc(a),__scc(b),__scc(c),__scc(d))
#define __syscall5(n,a,b,c,d,e) __syscall5(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e))
#define __syscall6(n,a,b,c,d,e,f) __syscall6(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e),__scc(f))
#endif
#define __syscall7(n,a,b,c,d,e,f,g) (__syscall)(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e),__scc(f),__scc(g))
#define __SYSCALL_NARGS_X(a,b,c,d,e,f,g,h,n,...) n
#define __SYSCALL_NARGS(...) __SYSCALL_NARGS_X(__VA_ARGS__,7,6,5,4,3,2,1,0,)

View File

@ -1,13 +0,0 @@
.global __syscall
.hidden __syscall
.type __syscall,@function
__syscall:
movq %rdi,%rax
movq %rsi,%rdi
movq %rdx,%rsi
movq %rcx,%rdx
movq %r8,%r10
movq %r9,%r8
movq 8(%rsp),%r9
syscall
ret

View File

@ -1,13 +0,0 @@
.global __syscall
.hidden __syscall
.type __syscall,@function
__syscall:
movq %rdi,%rax
movq %rsi,%rdi
movq %rdx,%rsi
movq %rcx,%rdx
movq %r8,%r10
movq %r9,%r8
movq 8(%rsp),%r9
syscall
ret

View File

@ -7,7 +7,7 @@ static long sccp(syscall_arg_t nr,
syscall_arg_t u, syscall_arg_t v, syscall_arg_t w,
syscall_arg_t x, syscall_arg_t y, syscall_arg_t z)
{
return (__syscall)(nr, u, v, w, x, y, z);
return __syscall(nr, u, v, w, x, y, z);
}
weak_alias(sccp, __syscall_cp_c);