about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorrofl0r <retnyg@gmx.net>2014-01-07 22:53:38 +0100
committerrofl0r <retnyg@gmx.net>2014-02-23 11:09:16 +0100
commit664cd341921007cea52c8891f27ce35927dca378 (patch)
treeb6aa7594609a40616db8458f879dfdb0dddf4b7c /src
parent323272db175204b951f119dae4bd99ef05e20f13 (diff)
downloadmusl-664cd341921007cea52c8891f27ce35927dca378.tar.gz
musl-664cd341921007cea52c8891f27ce35927dca378.tar.xz
musl-664cd341921007cea52c8891f27ce35927dca378.zip
x32 port (diff against vanilla x86_64)
Diffstat (limited to 'src')
-rw-r--r--src/fenv/x32/fenv.s52
-rw-r--r--src/ldso/x32/start.s22
-rw-r--r--src/math/x32/acosl.s2
-rw-r--r--src/math/x32/asinl.s2
-rw-r--r--src/math/x32/atan2l.s4
-rw-r--r--src/math/x32/atanl.s2
-rw-r--r--src/math/x32/exp2l.s42
-rw-r--r--src/math/x32/expl.s32
-rw-r--r--src/math/x32/fabsl.s2
-rw-r--r--src/math/x32/floorl.s18
-rw-r--r--src/math/x32/fmodl.s4
-rw-r--r--src/math/x32/llrintl.s6
-rw-r--r--src/math/x32/log10l.s2
-rw-r--r--src/math/x32/log1pl.s4
-rw-r--r--src/math/x32/log2l.s2
-rw-r--r--src/math/x32/logl.s2
-rw-r--r--src/math/x32/lrintl.s6
-rw-r--r--src/math/x32/remainderl.s4
-rw-r--r--src/math/x32/rintl.s2
-rw-r--r--src/math/x32/sqrtl.s2
-rw-r--r--src/process/x32/vfork.s2
-rw-r--r--src/signal/x32/restore.s2
-rw-r--r--src/thread/x32/__set_thread_area.s2
-rw-r--r--src/thread/x32/__unmapself.s4
-rw-r--r--src/thread/x32/clone.s6
-rw-r--r--src/thread/x32/syscall_cp.s6
26 files changed, 120 insertions, 114 deletions
diff --git a/src/fenv/x32/fenv.s b/src/fenv/x32/fenv.s
index b5aeaf4f..45310465 100644
--- a/src/fenv/x32/fenv.s
+++ b/src/fenv/x32/fenv.s
@@ -8,14 +8,14 @@ feclearexcept:
 	test %eax,%ecx
 	jz 1f
 	fnclex
-1:	stmxcsr -8(%rsp)
+1:	stmxcsr -8(%esp)
 	and $0x3f,%eax
-	or %eax,-8(%rsp)
-	test %ecx,-8(%rsp)
+	or %eax,-8(%esp)
+	test %ecx,-8(%esp)
 	jz 1f
 	not %ecx
-	and %ecx,-8(%rsp)
-	ldmxcsr -8(%rsp)
+	and %ecx,-8(%esp)
+	ldmxcsr -8(%esp)
 1:	xor %eax,%eax
 	ret
 
@@ -23,9 +23,9 @@ feclearexcept:
 .type feraiseexcept,@function
 feraiseexcept:
 	and $0x3f,%edi
-	stmxcsr -8(%rsp)
-	or %edi,-8(%rsp)
-	ldmxcsr -8(%rsp)
+	stmxcsr -8(%esp)
+	or %edi,-8(%esp)
+	ldmxcsr -8(%esp)
 	xor %eax,%eax
 	ret
 
@@ -35,15 +35,15 @@ __fesetround:
 	push %rax
 	xor %eax,%eax
 	mov %edi,%ecx
-	fnstcw (%rsp)
-	andb $0xf3,1(%rsp)
-	or %ch,1(%rsp)
-	fldcw (%rsp)
-	stmxcsr (%rsp)
+	fnstcw (%esp)
+	andb $0xf3,1(%esp)
+	or %ch,1(%esp)
+	fldcw (%esp)
+	stmxcsr (%esp)
 	shl $3,%ch
-	andb $0x9f,1(%rsp)
-	or %ch,1(%rsp)
-	ldmxcsr (%rsp)
+	andb $0x9f,1(%esp)
+	or %ch,1(%esp)
+	ldmxcsr (%esp)
 	pop %rcx
 	ret
 
@@ -51,7 +51,7 @@ __fesetround:
 .type fegetround,@function
 fegetround:
 	push %rax
-	stmxcsr (%rsp)
+	stmxcsr (%esp)
 	pop %rax
 	shr $3,%eax
 	and $0xc00,%eax
@@ -61,27 +61,27 @@ fegetround:
 .type fegetenv,@function
 fegetenv:
 	xor %eax,%eax
-	fnstenv (%rdi)
-	stmxcsr 28(%rdi)
+	fnstenv (%edi)
+	stmxcsr 28(%edi)
 	ret
 
 .global fesetenv
 .type fesetenv,@function
 fesetenv:
 	xor %eax,%eax
-	inc %rdi
+	inc %edi
 	jz 1f
-	fldenv -1(%rdi)
-	ldmxcsr 27(%rdi)
+	fldenv -1(%edi)
+	ldmxcsr 27(%edi)
 	ret
 1:	push %rax
 	push %rax
 	pushq $0xffff
 	pushq $0x37f
-	fldenv (%rsp)
+	fldenv (%esp)
 	pushq $0x1f80
-	ldmxcsr (%rsp)
-	add $40,%rsp
+	ldmxcsr (%esp)
+	add $40,%esp
 	ret
 
 .global fetestexcept
@@ -89,7 +89,7 @@ fesetenv:
 fetestexcept:
 	and $0x3f,%edi
 	push %rax
-	stmxcsr (%rsp)
+	stmxcsr (%esp)
 	pop %rsi
 	fnstsw %ax
 	or %esi,%eax
diff --git a/src/ldso/x32/start.s b/src/ldso/x32/start.s
index 80c1d08d..0fcf46dc 100644
--- a/src/ldso/x32/start.s
+++ b/src/ldso/x32/start.s
@@ -1,16 +1,24 @@
 .text
 .global _start
 _start:
-	mov (%rsp),%rdi
-	lea 8(%rsp),%rsi
+	mov (%rsp),%rdi  /* move argc into 1st argument slot */
+	lea 4(%rsp),%rsi /* move argv into 2nd argument slot */
 	call __dynlink
-	pop %rdi
+	/* in case the dynlinker was called directly, it sets the "consumed"
+	   argv values to -1. so we must loop over the array as long as -1
+	   is in the top argv slot, decrement argc, and then set the stackpointer
+	   to the new argc as well as argc's new value.
+	   as the x32 abi has longs in the argv array, we cannot use push/pop.*/
+	movl (%rsp),%edi /* copy argc into edi */
+	xor %rdx,%rdx /* we use rdx as an offset to the current argv member */
 1:	dec %edi
-	pop %rsi
-	cmp $-1,%rsi
+	addl $4, %edx
+	movl (%rsp, %rdx), %esi
+	cmp $-1,%esi
 	jz 1b
 	inc %edi
-	push %rsi
-	push %rdi
+	subl $4, %edx
+	lea (%rsp, %rdx), %rsp /* set rsp to new argv[-1] */
+	movl %edi, (%rsp)      /* write new argc there */
 	xor %edx,%edx
 	jmp *%rax
diff --git a/src/math/x32/acosl.s b/src/math/x32/acosl.s
index 88e01b49..1abca12e 100644
--- a/src/math/x32/acosl.s
+++ b/src/math/x32/acosl.s
@@ -3,7 +3,7 @@
 .global acosl
 .type acosl,@function
 acosl:
-	fldt 8(%rsp)
+	fldt 8(%esp)
 1:	fld %st(0)
 	fld1
 	fsub %st(0),%st(1)
diff --git a/src/math/x32/asinl.s b/src/math/x32/asinl.s
index ed212d9a..7fe9f127 100644
--- a/src/math/x32/asinl.s
+++ b/src/math/x32/asinl.s
@@ -1,7 +1,7 @@
 .global asinl
 .type asinl,@function
 asinl:
-	fldt 8(%rsp)
+	fldt 8(%esp)
 1:	fld %st(0)
 	fld1
 	fsub %st(0),%st(1)
diff --git a/src/math/x32/atan2l.s b/src/math/x32/atan2l.s
index e5f0a3de..1ead0788 100644
--- a/src/math/x32/atan2l.s
+++ b/src/math/x32/atan2l.s
@@ -1,7 +1,7 @@
 .global atan2l
 .type atan2l,@function
 atan2l:
-	fldt 8(%rsp)
-	fldt 24(%rsp)
+	fldt 8(%esp)
+	fldt 24(%esp)
 	fpatan
 	ret
diff --git a/src/math/x32/atanl.s b/src/math/x32/atanl.s
index df76de5d..f475fe0e 100644
--- a/src/math/x32/atanl.s
+++ b/src/math/x32/atanl.s
@@ -1,7 +1,7 @@
 .global atanl
 .type atanl,@function
 atanl:
-	fldt 8(%rsp)
+	fldt 8(%esp)
 	fld1
 	fpatan
 	ret
diff --git a/src/math/x32/exp2l.s b/src/math/x32/exp2l.s
index 0d6cd563..d9f4d6ed 100644
--- a/src/math/x32/exp2l.s
+++ b/src/math/x32/exp2l.s
@@ -1,11 +1,11 @@
 .global expm1l
 .type expm1l,@function
 expm1l:
-	fldt 8(%rsp)
+	fldt 8(%esp)
 	fldl2e
 	fmulp
-	movl $0xc2820000,-4(%rsp)
-	flds -4(%rsp)
+	movl $0xc2820000,-4(%esp)
+	flds -4(%esp)
 	fucomp %st(1)
 	fnstsw %ax
 	sahf
@@ -35,21 +35,21 @@ expm1l:
 .global exp2l
 .type exp2l,@function
 exp2l:
-	fldt 8(%rsp)
+	fldt 8(%esp)
 1:	fld %st(0)
-	sub $16,%rsp
-	fstpt (%rsp)
-	mov 8(%rsp),%ax
+	sub $16,%esp
+	fstpt (%esp)
+	mov 8(%esp),%ax
 	and $0x7fff,%ax
 	cmp $0x3fff+13,%ax
 	jb 4f             # |x| < 8192
 	cmp $0x3fff+15,%ax
 	jae 3f            # |x| >= 32768
-	fsts (%rsp)
-	cmpl $0xc67ff800,(%rsp)
+	fsts (%esp)
+	cmpl $0xc67ff800,(%esp)
 	jb 2f             # x > -16382
-	movl $0x5f000000,(%rsp)
-	flds (%rsp)       # 0x1p63
+	movl $0x5f000000,(%esp)
+	flds (%esp)       # 0x1p63
 	fld %st(1)
 	fsub %st(1)
 	faddp
@@ -57,10 +57,10 @@ exp2l:
 	fnstsw
 	sahf
 	je 2f             # x - 0x1p63 + 0x1p63 == x
-	movl $1,(%rsp)
-	flds (%rsp)       # 0x1p-149
+	movl $1,(%esp)
+	flds (%esp)       # 0x1p-149
 	fdiv %st(1)
-	fstps (%rsp)      # raise underflow
+	fstps (%esp)      # raise underflow
 2:	fld1
 	fld %st(1)
 	frndint
@@ -70,21 +70,21 @@ exp2l:
 	faddp             # 2^(x-rint(x))
 1:	fscale
 	fstp %st(1)
-	add $16,%rsp
+	add $16,%esp
 	ret
 3:	xor %eax,%eax
 4:	cmp $0x3fff-64,%ax
 	fld1
 	jb 1b             # |x| < 0x1p-64
-	fstpt (%rsp)
-	fistl 8(%rsp)
-	fildl 8(%rsp)
+	fstpt (%esp)
+	fistl 8(%esp)
+	fildl 8(%esp)
 	fsubrp %st(1)
-	addl $0x3fff,8(%rsp)
+	addl $0x3fff,8(%esp)
 	f2xm1
 	fld1
 	faddp             # 2^(x-rint(x))
-	fldt (%rsp)       # 2^rint(x)
+	fldt (%esp)       # 2^rint(x)
 	fmulp
-	add $16,%rsp
+	add $16,%esp
 	ret
diff --git a/src/math/x32/expl.s b/src/math/x32/expl.s
index 3add810d..aabea45e 100644
--- a/src/math/x32/expl.s
+++ b/src/math/x32/expl.s
@@ -6,11 +6,11 @@
 .global expl
 .type expl,@function
 expl:
-	fldt 8(%rsp)
+	fldt 8(%esp)
 
 		# interesting case: 0x1p-32 <= |x| < 16384
 		# check if (exponent|0x8000) is in [0xbfff-32, 0xbfff+13]
-	mov 16(%rsp), %ax
+	mov 16(%esp), %ax
 	or $0x8000, %ax
 	sub $0xbfdf, %ax
 	cmp $45, %ax
@@ -29,29 +29,29 @@ expl:
 		# should be 0x1.71547652b82fe178p0L == 0x3fff b8aa3b29 5c17f0bc
 		# it will be wrong on non-nearest rounding mode
 2:	fldl2e
-	subq $48, %rsp
+	sub $48, %esp
 		# hi = log2e_hi*x
 		# 2^hi = exp2l(hi)
 	fmul %st(1),%st
 	fld %st(0)
-	fstpt (%rsp)
-	fstpt 16(%rsp)
-	fstpt 32(%rsp)
+	fstpt (%esp)
+	fstpt 16(%esp)
+	fstpt 32(%esp)
 	call exp2l
 		# if 2^hi == inf return 2^hi
 	fld %st(0)
-	fstpt (%rsp)
-	cmpw $0x7fff, 8(%rsp)
+	fstpt (%esp)
+	cmpw $0x7fff, 8(%esp)
 	je 1f
-	fldt 32(%rsp)
-	fldt 16(%rsp)
+	fldt 32(%esp)
+	fldt 16(%esp)
 		# fpu stack: 2^hi x hi
 		# exact mult: x*log2e
 	fld %st(1)
 		# c = 0x1p32+1
 	movq $0x41f0000000100000,%rax
 	pushq %rax
-	fldl (%rsp)
+	fldl (%esp)
 		# xh = x - c*x + c*x
 		# xl = x - xh
 	fmulp
@@ -63,7 +63,7 @@ expl:
 		# yh = log2e_hi - c*log2e_hi + c*log2e_hi
 	movq $0x3ff7154765200000,%rax
 	pushq %rax
-	fldl (%rsp)
+	fldl (%esp)
 		# fpu stack: 2^hi x hi xh xl yh
 		# lo = hi - xh*yh + xl*yh
 	fld %st(2)
@@ -74,7 +74,7 @@ expl:
 		# yl = log2e_hi - yh
 	movq $0x3de705fc2f000000,%rax
 	pushq %rax
-	fldl (%rsp)
+	fldl (%esp)
 		# fpu stack: 2^hi x lo xh xl yl
 		# lo += xh*yl + xl*yl
 	fmul %st, %st(2)
@@ -87,8 +87,8 @@ expl:
 	pushq %rax
 	movq $0x82f0025f2dc582ee,%rax
 	pushq %rax
-	fldt (%rsp)
-	addq $40,%rsp
+	fldt (%esp)
+	add $40,%esp
 		# fpu stack: 2^hi x lo log2e_lo
 		# lo += log2e_lo*x
 		# return 2^hi + 2^hi (2^lo - 1)
@@ -97,5 +97,5 @@ expl:
 	f2xm1
 	fmul %st(1), %st
 	faddp
-1:	addq $48, %rsp
+1:	add $48, %esp
 	ret
diff --git a/src/math/x32/fabsl.s b/src/math/x32/fabsl.s
index 4e7ab525..4f215df5 100644
--- a/src/math/x32/fabsl.s
+++ b/src/math/x32/fabsl.s
@@ -1,6 +1,6 @@
 .global fabsl
 .type fabsl,@function
 fabsl:
-	fldt 8(%rsp)
+	fldt 8(%esp)
 	fabs
 	ret
diff --git a/src/math/x32/floorl.s b/src/math/x32/floorl.s
index 80da4660..78dcb6da 100644
--- a/src/math/x32/floorl.s
+++ b/src/math/x32/floorl.s
@@ -1,27 +1,27 @@
 .global floorl
 .type floorl,@function
 floorl:
-	fldt 8(%rsp)
+	fldt 8(%esp)
 1:	mov $0x7,%al
-1:	fstcw 8(%rsp)
-	mov 9(%rsp),%ah
-	mov %al,9(%rsp)
-	fldcw 8(%rsp)
+1:	fstcw 8(%esp)
+	mov 9(%esp),%ah
+	mov %al,9(%esp)
+	fldcw 8(%esp)
 	frndint
-	mov %ah,9(%rsp)
-	fldcw 8(%rsp)
+	mov %ah,9(%esp)
+	fldcw 8(%esp)
 	ret
 
 .global ceill
 .type ceill,@function
 ceill:
-	fldt 8(%rsp)
+	fldt 8(%esp)
 	mov $0xb,%al
 	jmp 1b
 
 .global truncl
 .type truncl,@function
 truncl:
-	fldt 8(%rsp)
+	fldt 8(%esp)
 	mov $0xf,%al
 	jmp 1b
diff --git a/src/math/x32/fmodl.s b/src/math/x32/fmodl.s
index ca81e60c..9e4378ab 100644
--- a/src/math/x32/fmodl.s
+++ b/src/math/x32/fmodl.s
@@ -1,8 +1,8 @@
 .global fmodl
 .type fmodl,@function
 fmodl:
-	fldt 24(%rsp)
-	fldt 8(%rsp)
+	fldt 24(%esp)
+	fldt 8(%esp)
 1:	fprem
 	fstsw %ax
 	sahf
diff --git a/src/math/x32/llrintl.s b/src/math/x32/llrintl.s
index 1ec0817d..09386079 100644
--- a/src/math/x32/llrintl.s
+++ b/src/math/x32/llrintl.s
@@ -1,7 +1,7 @@
 .global llrintl
 .type llrintl,@function
 llrintl:
-	fldt 8(%rsp)
-	fistpll 8(%rsp)
-	mov 8(%rsp),%rax
+	fldt 8(%esp)
+	fistpll 8(%esp)
+	mov 8(%esp),%rax
 	ret
diff --git a/src/math/x32/log10l.s b/src/math/x32/log10l.s
index 48ea4af7..ef5bea3f 100644
--- a/src/math/x32/log10l.s
+++ b/src/math/x32/log10l.s
@@ -2,6 +2,6 @@
 .type log10l,@function
 log10l:
 	fldlg2
-	fldt 8(%rsp)
+	fldt 8(%esp)
 	fyl2x
 	ret
diff --git a/src/math/x32/log1pl.s b/src/math/x32/log1pl.s
index 955c9dbf..2e64fd4b 100644
--- a/src/math/x32/log1pl.s
+++ b/src/math/x32/log1pl.s
@@ -1,10 +1,10 @@
 .global log1pl
 .type log1pl,@function
 log1pl:
-	mov 14(%rsp),%eax
+	mov 14(%esp),%eax
 	fldln2
 	and $0x7fffffff,%eax
-	fldt 8(%rsp)
+	fldt 8(%esp)
 	cmp $0x3ffd9400,%eax
 	ja 1f
 	fyl2xp1
diff --git a/src/math/x32/log2l.s b/src/math/x32/log2l.s
index ba08b9fb..bf88e8e2 100644
--- a/src/math/x32/log2l.s
+++ b/src/math/x32/log2l.s
@@ -2,6 +2,6 @@
 .type log2l,@function
 log2l:
 	fld1
-	fldt 8(%rsp)
+	fldt 8(%esp)
 	fyl2x
 	ret
diff --git a/src/math/x32/logl.s b/src/math/x32/logl.s
index 20dd1f81..eff64506 100644
--- a/src/math/x32/logl.s
+++ b/src/math/x32/logl.s
@@ -2,6 +2,6 @@
 .type logl,@function
 logl:
 	fldln2
-	fldt 8(%rsp)
+	fldt 8(%esp)
 	fyl2x
 	ret
diff --git a/src/math/x32/lrintl.s b/src/math/x32/lrintl.s
index d587b12b..ee97d1cf 100644
--- a/src/math/x32/lrintl.s
+++ b/src/math/x32/lrintl.s
@@ -1,7 +1,7 @@
 .global lrintl
 .type lrintl,@function
 lrintl:
-	fldt 8(%rsp)
-	fistpll 8(%rsp)
-	mov 8(%rsp),%rax
+	fldt 8(%esp)
+	fistpll 8(%esp)
+	mov 8(%esp),%rax
 	ret
diff --git a/src/math/x32/remainderl.s b/src/math/x32/remainderl.s
index 75c12374..c97f68ad 100644
--- a/src/math/x32/remainderl.s
+++ b/src/math/x32/remainderl.s
@@ -1,8 +1,8 @@
 .global remainderl
 .type remainderl,@function
 remainderl:
-	fldt 24(%rsp)
-	fldt 8(%rsp)
+	fldt 24(%esp)
+	fldt 8(%esp)
 1:	fprem1
 	fstsw %ax
 	sahf
diff --git a/src/math/x32/rintl.s b/src/math/x32/rintl.s
index 64e663cd..be1d2fa7 100644
--- a/src/math/x32/rintl.s
+++ b/src/math/x32/rintl.s
@@ -1,6 +1,6 @@
 .global rintl
 .type rintl,@function
 rintl:
-	fldt 8(%rsp)
+	fldt 8(%esp)
 	frndint
 	ret
diff --git a/src/math/x32/sqrtl.s b/src/math/x32/sqrtl.s
index 23cd687d..8d70856e 100644
--- a/src/math/x32/sqrtl.s
+++ b/src/math/x32/sqrtl.s
@@ -1,5 +1,5 @@
 .global sqrtl
 .type sqrtl,@function
-sqrtl:	fldt 8(%rsp)
+sqrtl:	fldt 8(%esp)
 	fsqrt
 	ret
diff --git a/src/process/x32/vfork.s b/src/process/x32/vfork.s
index 27af46f5..1039f0f2 100644
--- a/src/process/x32/vfork.s
+++ b/src/process/x32/vfork.s
@@ -5,7 +5,7 @@
 __vfork:
 vfork:
 	pop %rdx
-	mov $58,%eax
+	mov $0x4000003a,%eax /* SYS_vfork */
 	syscall
 	push %rdx
 	mov %rax,%rdi
diff --git a/src/signal/x32/restore.s b/src/signal/x32/restore.s
index 682af2dd..27cd3cef 100644
--- a/src/signal/x32/restore.s
+++ b/src/signal/x32/restore.s
@@ -4,5 +4,5 @@
 .type __restore,@function
 __restore_rt:
 __restore:
-	movl $15, %eax
+	movl $0x40000201, %eax /* SYS_rt_sigreturn */
 	syscall
diff --git a/src/thread/x32/__set_thread_area.s b/src/thread/x32/__set_thread_area.s
index f3ff4f61..94bc3630 100644
--- a/src/thread/x32/__set_thread_area.s
+++ b/src/thread/x32/__set_thread_area.s
@@ -5,6 +5,6 @@
 __set_thread_area:
 	mov %rdi,%rsi           /* shift for syscall */
 	movl $0x1002,%edi       /* SET_FS register */
-	movl $158,%eax          /* set fs segment to */
+	movl $0x4000009e,%eax          /* set fs segment to */
 	syscall                 /* arch_prctl(SET_FS, arg)*/
 	ret
diff --git a/src/thread/x32/__unmapself.s b/src/thread/x32/__unmapself.s
index e2689e65..d9254601 100644
--- a/src/thread/x32/__unmapself.s
+++ b/src/thread/x32/__unmapself.s
@@ -3,8 +3,8 @@
 .global __unmapself
 .type   __unmapself,@function
 __unmapself:
-	movl $11,%eax   /* SYS_munmap */
+	movl $0x4000000b,%eax   /* SYS_munmap */
 	syscall         /* munmap(arg2,arg3) */
 	xor %rdi,%rdi   /* exit() args: always return success */
-	movl $60,%eax   /* SYS_exit */
+	movl $0x4000003c,%eax   /* SYS_exit */
 	syscall         /* exit(0) */
diff --git a/src/thread/x32/clone.s b/src/thread/x32/clone.s
index ee59903a..eed46151 100644
--- a/src/thread/x32/clone.s
+++ b/src/thread/x32/clone.s
@@ -2,8 +2,7 @@
 .global __clone
 .type   __clone,@function
 __clone:
-	xor %eax,%eax
-	mov $56,%al
+	movl $0x40000038,%eax /* SYS_clone */
 	mov %rdi,%r11
 	mov %rdx,%rdi
 	mov %r8,%rdx
@@ -20,8 +19,7 @@ __clone:
 	pop %rdi
 	call *%r9
 	mov %eax,%edi
-	xor %eax,%eax
-	mov $60,%al
+	movl $0x4000003c,%eax /* SYS_exit */
 	syscall
 	hlt
 1:	ret
diff --git a/src/thread/x32/syscall_cp.s b/src/thread/x32/syscall_cp.s
index 788c53cc..70605c19 100644
--- a/src/thread/x32/syscall_cp.s
+++ b/src/thread/x32/syscall_cp.s
@@ -1,7 +1,7 @@
 .text
-.global __syscall_cp_asm
-.type   __syscall_cp_asm,@function
-__syscall_cp_asm:
+.global __syscall_cp_internal
+.type   __syscall_cp_internal,@function
+__syscall_cp_internal:
 
 .global __cp_begin
 __cp_begin: