提交 664cd341 编写于 作者: R rofl0r

x32 port (diff against vanilla x86_64)

上级 323272db
#define _Addr long
#define _Int64 long
#define _Reg long
#define _Addr int
#define _Int64 long long
#define _Reg long long
TYPEDEF __builtin_va_list va_list;
TYPEDEF __builtin_va_list __isoc_va_list;
#ifndef __cplusplus
TYPEDEF int wchar_t;
TYPEDEF long wchar_t;
#endif
TYPEDEF unsigned wint_t;
......@@ -18,8 +18,8 @@ TYPEDEF float float_t;
TYPEDEF double double_t;
#endif
TYPEDEF long time_t;
TYPEDEF long suseconds_t;
TYPEDEF long long time_t;
TYPEDEF long long suseconds_t;
TYPEDEF struct { union { int __i[14]; unsigned long __s[7]; } __u; } pthread_attr_t;
TYPEDEF struct { union { int __i[10]; void *__p[5]; } __u; } pthread_mutex_t;
......
......@@ -7,8 +7,8 @@ struct ipc_perm
gid_t cgid;
mode_t mode;
int __ipc_perm_seq;
long __pad1;
long __pad2;
long long __pad1;
long long __pad2;
};
#define IPC_64 0
#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
|| defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
#define PAGE_SIZE 4096
#define LONG_BIT 64
#define LONG_BIT 32
#endif
#define LONG_MAX 0x7fffffffffffffffL
#define LONG_MAX 0x7fffffffL
#define LLONG_MAX 0x7fffffffffffffffLL
......@@ -5,9 +5,12 @@ struct msqid_ds
time_t msg_rtime;
time_t msg_ctime;
unsigned long msg_cbytes;
long __unused1;
msgqnum_t msg_qnum;
long __unused2;
msglen_t msg_qbytes;
long __unused3;
pid_t msg_lspid;
pid_t msg_lrpid;
unsigned long __unused[2];
unsigned long long __unused[2];
};
#undef __WORDSIZE
#define __WORDSIZE 64
#define __WORDSIZE 32
#define R15 0
#define R14 1
#define R13 2
......
typedef unsigned long __jmp_buf[8];
typedef unsigned long long __jmp_buf[8];
......@@ -10,16 +10,24 @@ struct shmid_ds
pid_t shm_cpid;
pid_t shm_lpid;
unsigned long shm_nattch;
unsigned long __pad1;
unsigned long __pad2;
unsigned long __pad0;
unsigned long long __pad1;
unsigned long long __pad2;
};
struct shminfo {
unsigned long shmmax, shmmin, shmmni, shmseg, shmall, __unused[4];
unsigned long shmmax, __pad0, shmmin, __pad1, shmmni, __pad2,
shmseg, __pad3, shmall, __pad4;
unsigned long long __unused[4];
};
struct shm_info {
int __used_ids;
unsigned long shm_tot, shm_rss, shm_swp;
unsigned long __swap_attempts, __swap_successes;
};
int __pad_ids;
unsigned long shm_tot, __pad0, shm_rss, __pad1, shm_swp, __pad2;
unsigned long __swap_attempts, __pad3, __swap_successes, __pad4;
}
#ifdef __GNUC__
__attribute__((__aligned__(8)))
#endif
;
......@@ -42,12 +42,12 @@ typedef struct _fpstate {
unsigned padding[24];
} *fpregset_t;
struct sigcontext {
unsigned long r8, r9, r10, r11, r12, r13, r14, r15;
unsigned long rdi, rsi, rbp, rbx, rdx, rax, rcx, rsp, rip, eflags;
unsigned long long r8, r9, r10, r11, r12, r13, r14, r15;
unsigned long long rdi, rsi, rbp, rbx, rdx, rax, rcx, rsp, rip, eflags;
unsigned short cs, gs, fs, __pad0;
unsigned long err, trapno, oldmask, cr2;
unsigned long long err, trapno, oldmask, cr2;
struct _fpstate *fpstate;
unsigned long __reserved1[8];
unsigned long long __reserved1[8];
};
typedef struct {
gregset_t gregs;
......@@ -56,7 +56,7 @@ typedef struct {
} mcontext_t;
#else
typedef struct {
unsigned long __space[32];
unsigned long long __space[32];
} mcontext_t;
#endif
......@@ -66,7 +66,7 @@ typedef struct __ucontext {
stack_t uc_stack;
mcontext_t uc_mcontext;
sigset_t uc_sigmask;
unsigned long __fpregs_mem[64];
unsigned long long __fpregs_mem[64];
} ucontext_t;
#define SA_NOCLDSTOP 1
......
......@@ -18,5 +18,5 @@ struct stat {
struct timespec st_atim;
struct timespec st_mtim;
struct timespec st_ctim;
long __unused[3];
long long __unused[3];
};
......@@ -12,9 +12,9 @@ typedef uint32_t uint_fast32_t;
#define UINT_FAST16_MAX UINT32_MAX
#define UINT_FAST32_MAX UINT32_MAX
#define INTPTR_MIN INT64_MIN
#define INTPTR_MAX INT64_MAX
#define UINTPTR_MAX UINT64_MAX
#define PTRDIFF_MIN INT64_MIN
#define PTRDIFF_MAX INT64_MAX
#define SIZE_MAX UINT64_MAX
#define INTPTR_MIN INT32_MIN
#define INTPTR_MAX INT32_MAX
#define UINTPTR_MAX UINT32_MAX
#define PTRDIFF_MIN INT32_MIN
#define PTRDIFF_MAX INT32_MAX
#define SIZE_MAX UINT32_MAX
此差异已折叠。
#include <sys/syscall.h>
long __syscall_cp_internal(volatile void*, long long, long long, long long, long long,
long long, long long, long long);
struct __timespec { long long tv_sec; long tv_nsec; };
struct __timespec_kernel { long long tv_sec; long long tv_nsec; };
#define __tsc(X) ((struct __timespec*)(unsigned long)(X))
long __syscall_cp_asm (volatile void * foo, long long n, long long a1, long long a2, long long a3,
long long a4, long long a5, long long a6) {
switch (n) {
case SYS_mq_timedsend: case SYS_mq_timedreceive: case SYS_pselect6:
if(a5) a5 = (unsigned long) (&(struct __timespec_kernel) {
.tv_sec = __tsc(a5)->tv_sec, .tv_nsec = __tsc(a5)->tv_nsec});
break;
case SYS_futex:
if(a4) a4 = (unsigned long) (&(struct __timespec_kernel) {
.tv_sec = __tsc(a4)->tv_sec, .tv_nsec = __tsc(a4)->tv_nsec});
if(n == SYS_futex) break;
case SYS_clock_nanosleep:
case SYS_rt_sigtimedwait: case SYS_ppoll:
if(a3) a3 = (unsigned long) (&(struct __timespec_kernel) {
.tv_sec = __tsc(a3)->tv_sec, .tv_nsec = __tsc(a3)->tv_nsec});
break;
case SYS_nanosleep:
if(a1) a1 = (unsigned long) (&(struct __timespec_kernel) {
.tv_sec = __tsc(a1)->tv_sec, .tv_nsec = __tsc(a1)->tv_nsec});
if(a2) a2 = (unsigned long) (&(struct __timespec_kernel) {
.tv_sec = __tsc(a2)->tv_sec, .tv_nsec = __tsc(a2)->tv_nsec});
break;
}
return __syscall_cp_internal(foo, n, a1, a2, a3, a4, a5, a6);
}
#define __SYSCALL_LL_E(x) (x)
#define __SYSCALL_LL_O(x) (x)
static __inline long __syscall0(long n)
#define __scc(X) sizeof(1?(X):0ULL) < 8 ? (unsigned long) (X) : (long long) (X)
#define syscall_arg_t long long
struct __timespec { long long tv_sec; long tv_nsec; };
struct __timespec_kernel { long long tv_sec; long long tv_nsec; };
#define __tsc(X) ((struct __timespec*)(unsigned long)(X))
static __inline long __syscall0(long long n)
{
unsigned long ret;
__asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n) : "rcx", "r11", "memory");
return ret;
}
static __inline long __syscall1(long n, long a1)
static __inline long __syscall1(long long n, long long a1)
{
unsigned long ret;
__asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n), "D"(a1) : "rcx", "r11", "memory");
return ret;
}
static __inline long __syscall2(long n, long a1, long a2)
static __inline long __syscall2(long long n, long long a1, long long a2)
{
unsigned long ret;
struct __timespec *ts2 = 0;
switch (n) {
case SYS_nanosleep:
if(a1) a1 = (unsigned long) (&(struct __timespec_kernel) {
.tv_sec = __tsc(a1)->tv_sec, .tv_nsec = __tsc(a1)->tv_nsec});
break;
case SYS_clock_settime:
if(a2) a2 = (unsigned long) (&(struct __timespec_kernel) {
.tv_sec = __tsc(a2)->tv_sec, .tv_nsec = __tsc(a2)->tv_nsec});
}
__asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n), "D"(a1), "S"(a2)
: "rcx", "r11", "memory");
: "rcx", "r11", "memory");
return ret;
}
static __inline long __syscall3(long n, long a1, long a2, long a3)
static __inline long __syscall3(long long n, long long a1, long long a2, long long a3)
{
unsigned long ret;
__asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n), "D"(a1), "S"(a2),
......@@ -31,32 +47,75 @@ static __inline long __syscall3(long n, long a1, long a2, long a3)
return ret;
}
static __inline long __syscall4(long n, long a1, long a2, long a3, long a4)
static __inline long __syscall4(long long n, long long a1, long long a2, long long a3,
long long a4)
{
unsigned long ret;
register long r10 __asm__("r10") = a4;
register long long r10 __asm__("r10") = a4;
switch (n) {
case SYS_futex:
if((a2 & (~128 /* FUTEX_PRIVATE_FLAG */)) == 0 /* FUTEX_WAIT */) {
if(r10) r10 = (unsigned long) (&(struct __timespec_kernel) {
.tv_sec = __tsc(r10)->tv_sec, .tv_nsec = __tsc(r10)->tv_nsec});
}
break;
case SYS_utimensat:
if(a3) a3 = (unsigned long) ((struct __timespec_kernel[2]) {
[0] = {.tv_sec = __tsc(a3)[0].tv_sec, .tv_nsec = __tsc(a3)[0].tv_nsec},
[1] = {.tv_sec = __tsc(a3)[1].tv_sec, .tv_nsec = __tsc(a3)[1].tv_nsec},
});
break;
case SYS_clock_nanosleep:
case SYS_rt_sigtimedwait: case SYS_ppoll:
if(a3) a3 = (unsigned long) (&(struct __timespec_kernel) {
.tv_sec = __tsc(a3)->tv_sec, .tv_nsec = __tsc(a3)->tv_nsec});
}
__asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n), "D"(a1), "S"(a2),
"d"(a3), "r"(r10): "rcx", "r11", "memory");
"d"(a3), "r"(r10): "rcx", "r11", "memory");
return ret;
}
static __inline long __syscall5(long n, long a1, long a2, long a3, long a4, long a5)
static __inline long __syscall5(long long n, long long a1, long long a2, long long a3,
long long a4, long long a5)
{
unsigned long ret;
register long r10 __asm__("r10") = a4;
register long r8 __asm__("r8") = a5;
register long long r10 __asm__("r10") = a4;
register long long r8 __asm__("r8") = a5;
switch (n) {
case SYS_futex:
if((a2 & (~128 /* FUTEX_PRIVATE_FLAG */)) == 0 /* FUTEX_WAIT */) {
if(r10) r10 = (unsigned long) (&(struct __timespec_kernel) {
.tv_sec = __tsc(r10)->tv_sec, .tv_nsec = __tsc(r10)->tv_nsec});
}
break;
case SYS_mq_timedsend: case SYS_mq_timedreceive:
if(r8) r8 = (unsigned long) (&(struct __timespec_kernel) {
.tv_sec = __tsc(r8)->tv_sec, .tv_nsec = __tsc(r8)->tv_nsec});
}
__asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n), "D"(a1), "S"(a2),
"d"(a3), "r"(r10), "r"(r8) : "rcx", "r11", "memory");
"d"(a3), "r"(r10), "r"(r8) : "rcx", "r11", "memory");
return ret;
}
static __inline long __syscall6(long n, long a1, long a2, long a3, long a4, long a5, long a6)
static __inline long __syscall6(long long n, long long a1, long long a2, long long a3,
long long a4, long long a5, long long a6)
{
unsigned long ret;
register long r10 __asm__("r10") = a4;
register long r8 __asm__("r8") = a5;
register long r9 __asm__("r9") = a6;
register long long r10 __asm__("r10") = a4;
register long long r8 __asm__("r8") = a5;
register long long r9 __asm__("r9") = a6;
switch (n) {
case SYS_futex:
if((a2 & (~128 /* FUTEX_PRIVATE_FLAG */)) == 0 /* FUTEX_WAIT */) {
if(r10) r10 = (unsigned long) (&(struct __timespec_kernel) {
.tv_sec = __tsc(r10)->tv_sec, .tv_nsec = __tsc(r10)->tv_nsec});
}
break;
case SYS_pselect6:
if(r8) r8 = (unsigned long) (&(struct __timespec_kernel) {
.tv_sec = __tsc(r8)->tv_sec, .tv_nsec = __tsc(r8)->tv_nsec});
}
__asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n), "D"(a1), "S"(a2),
"d"(a3), "r"(r10), "r"(r8), "r"(r9) : "rcx", "r11", "memory");
"d"(a3), "r"(r10), "r"(r8), "r"(r9) : "rcx", "r11", "memory");
return ret;
}
......@@ -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
......
.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
......@@ -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)
......
.global asinl
.type asinl,@function
asinl:
fldt 8(%rsp)
fldt 8(%esp)
1: fld %st(0)
fld1
fsub %st(0),%st(1)
......
.global atan2l
.type atan2l,@function
atan2l:
fldt 8(%rsp)
fldt 24(%rsp)
fldt 8(%esp)
fldt 24(%esp)
fpatan
ret
.global atanl
.type atanl,@function
atanl:
fldt 8(%rsp)
fldt 8(%esp)
fld1
fpatan
ret
.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
......@@ -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
.global fabsl
.type fabsl,@function
fabsl:
fldt 8(%rsp)
fldt 8(%esp)
fabs
ret
.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
.global fmodl
.type fmodl,@function
fmodl:
fldt 24(%rsp)
fldt 8(%rsp)
fldt 24(%esp)
fldt 8(%esp)
1: fprem
fstsw %ax
sahf
......
.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
......@@ -2,6 +2,6 @@
.type log10l,@function
log10l:
fldlg2
fldt 8(%rsp)
fldt 8(%esp)
fyl2x
ret
.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
......
......@@ -2,6 +2,6 @@
.type log2l,@function
log2l:
fld1
fldt 8(%rsp)
fldt 8(%esp)
fyl2x
ret
......@@ -2,6 +2,6 @@
.type logl,@function
logl:
fldln2
fldt 8(%rsp)
fldt 8(%esp)
fyl2x
ret
.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
.global remainderl
.type remainderl,@function
remainderl:
fldt 24(%rsp)
fldt 8(%rsp)
fldt 24(%esp)
fldt 8(%esp)
1: fprem1
fstsw %ax
sahf
......
.global rintl
.type rintl,@function
rintl:
fldt 8(%rsp)
fldt 8(%esp)
frndint
ret
.global sqrtl
.type sqrtl,@function
sqrtl: fldt 8(%rsp)
sqrtl: fldt 8(%esp)
fsqrt
ret
......@@ -5,7 +5,7 @@
__vfork:
vfork:
pop %rdx
mov $58,%eax
mov $0x4000003a,%eax /* SYS_vfork */
syscall
push %rdx
mov %rax,%rdi
......
......@@ -4,5 +4,5 @@
.type __restore,@function
__restore_rt:
__restore:
movl $15, %eax
movl $0x40000201, %eax /* SYS_rt_sigreturn */
syscall
......@@ -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
......@@ -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) */
......@@ -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
.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:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册