Commit 4d269ad1 authored by Chris Ball's avatar Chris Ball Committed by Ian Lance Taylor

runtime: add symbols for Linux syscall numbers on 386/amd64

Matches other architectures by using names for syscalls instead of
numbers directly.

Fixes #20499.

Change-Id: I63d606b0b1fe6fb517fd994a7542a3f38d80dd54
Reviewed-on: https://go-review.googlesource.com/44213
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent 4641d78a
...@@ -24,22 +24,58 @@ ...@@ -24,22 +24,58 @@
//#define INVOKE_SYSCALL CALL 0x10(GS) // non-portable //#define INVOKE_SYSCALL CALL 0x10(GS) // non-portable
#define INVOKE_SYSCALL INT $0x80 #define INVOKE_SYSCALL INT $0x80
#define SYS_exit 1
#define SYS_read 3
#define SYS_write 4
#define SYS_open 5
#define SYS_close 6
#define SYS_getpid 20
#define SYS_access 33
#define SYS_kill 37
#define SYS_brk 45
#define SYS_fcntl 55
#define SYS_munmap 91
#define SYS_socketcall 102
#define SYS_setittimer 104
#define SYS_clone 120
#define SYS_sched_yield 158
#define SYS_rt_sigreturn 173
#define SYS_rt_sigaction 174
#define SYS_rt_sigprocmask 175
#define SYS_sigaltstack 186
#define SYS_ugetrlimit 191
#define SYS_mmap2 192
#define SYS_mincore 218
#define SYS_madvise 219
#define SYS_gettid 224
#define SYS_tkill 238
#define SYS_futex 240
#define SYS_sched_getaffinity 242
#define SYS_set_thread_area 243
#define SYS_exit_group 252
#define SYS_epoll_create 254
#define SYS_epoll_ctl 255
#define SYS_epoll_wait 256
#define SYS_clock_gettime 265
#define SYS_pselect6 308
#define SYS_epoll_create1 329
TEXT runtime·exit(SB),NOSPLIT,$0 TEXT runtime·exit(SB),NOSPLIT,$0
MOVL $252, AX // syscall number MOVL $SYS_exit_group, AX
MOVL code+0(FP), BX MOVL code+0(FP), BX
INVOKE_SYSCALL INVOKE_SYSCALL
INT $3 // not reached INT $3 // not reached
RET RET
TEXT runtime·exit1(SB),NOSPLIT,$0 TEXT runtime·exit1(SB),NOSPLIT,$0
MOVL $1, AX // exit - exit the current os thread MOVL $SYS_exit, AX
MOVL code+0(FP), BX MOVL code+0(FP), BX
INVOKE_SYSCALL INVOKE_SYSCALL
INT $3 // not reached INT $3 // not reached
RET RET
TEXT runtime·open(SB),NOSPLIT,$0 TEXT runtime·open(SB),NOSPLIT,$0
MOVL $5, AX // syscall - open MOVL $SYS_open, AX
MOVL name+0(FP), BX MOVL name+0(FP), BX
MOVL mode+4(FP), CX MOVL mode+4(FP), CX
MOVL perm+8(FP), DX MOVL perm+8(FP), DX
...@@ -51,7 +87,7 @@ TEXT runtime·open(SB),NOSPLIT,$0 ...@@ -51,7 +87,7 @@ TEXT runtime·open(SB),NOSPLIT,$0
RET RET
TEXT runtime·closefd(SB),NOSPLIT,$0 TEXT runtime·closefd(SB),NOSPLIT,$0
MOVL $6, AX // syscall - close MOVL $SYS_close, AX
MOVL fd+0(FP), BX MOVL fd+0(FP), BX
INVOKE_SYSCALL INVOKE_SYSCALL
CMPL AX, $0xfffff001 CMPL AX, $0xfffff001
...@@ -61,7 +97,7 @@ TEXT runtime·closefd(SB),NOSPLIT,$0 ...@@ -61,7 +97,7 @@ TEXT runtime·closefd(SB),NOSPLIT,$0
RET RET
TEXT runtime·write(SB),NOSPLIT,$0 TEXT runtime·write(SB),NOSPLIT,$0
MOVL $4, AX // syscall - write MOVL $SYS_write, AX
MOVL fd+0(FP), BX MOVL fd+0(FP), BX
MOVL p+4(FP), CX MOVL p+4(FP), CX
MOVL n+8(FP), DX MOVL n+8(FP), DX
...@@ -73,7 +109,7 @@ TEXT runtime·write(SB),NOSPLIT,$0 ...@@ -73,7 +109,7 @@ TEXT runtime·write(SB),NOSPLIT,$0
RET RET
TEXT runtime·read(SB),NOSPLIT,$0 TEXT runtime·read(SB),NOSPLIT,$0
MOVL $3, AX // syscall - read MOVL $SYS_read, AX
MOVL fd+0(FP), BX MOVL fd+0(FP), BX
MOVL p+4(FP), CX MOVL p+4(FP), CX
MOVL n+8(FP), DX MOVL n+8(FP), DX
...@@ -85,7 +121,7 @@ TEXT runtime·read(SB),NOSPLIT,$0 ...@@ -85,7 +121,7 @@ TEXT runtime·read(SB),NOSPLIT,$0
RET RET
TEXT runtime·getrlimit(SB),NOSPLIT,$0 TEXT runtime·getrlimit(SB),NOSPLIT,$0
MOVL $191, AX // syscall - ugetrlimit MOVL $SYS_ugetrlimit, AX
MOVL kind+0(FP), BX MOVL kind+0(FP), BX
MOVL limit+4(FP), CX MOVL limit+4(FP), CX
INVOKE_SYSCALL INVOKE_SYSCALL
...@@ -103,7 +139,7 @@ TEXT runtime·usleep(SB),NOSPLIT,$8 ...@@ -103,7 +139,7 @@ TEXT runtime·usleep(SB),NOSPLIT,$8
MOVL AX, 4(SP) MOVL AX, 4(SP)
// pselect6(0, 0, 0, 0, &ts, 0) // pselect6(0, 0, 0, 0, &ts, 0)
MOVL $308, AX MOVL $SYS_pselect6, AX
MOVL $0, BX MOVL $0, BX
MOVL $0, CX MOVL $0, CX
MOVL $0, DX MOVL $0, DX
...@@ -114,31 +150,31 @@ TEXT runtime·usleep(SB),NOSPLIT,$8 ...@@ -114,31 +150,31 @@ TEXT runtime·usleep(SB),NOSPLIT,$8
RET RET
TEXT runtime·gettid(SB),NOSPLIT,$0-4 TEXT runtime·gettid(SB),NOSPLIT,$0-4
MOVL $224, AX // syscall - gettid MOVL $SYS_gettid, AX
INVOKE_SYSCALL INVOKE_SYSCALL
MOVL AX, ret+0(FP) MOVL AX, ret+0(FP)
RET RET
TEXT runtime·raise(SB),NOSPLIT,$12 TEXT runtime·raise(SB),NOSPLIT,$12
MOVL $224, AX // syscall - gettid MOVL $SYS_gettid, AX
INVOKE_SYSCALL INVOKE_SYSCALL
MOVL AX, BX // arg 1 tid MOVL AX, BX // arg 1 tid
MOVL sig+0(FP), CX // arg 2 signal MOVL sig+0(FP), CX // arg 2 signal
MOVL $238, AX // syscall - tkill MOVL $SYS_tkill, AX
INVOKE_SYSCALL INVOKE_SYSCALL
RET RET
TEXT runtime·raiseproc(SB),NOSPLIT,$12 TEXT runtime·raiseproc(SB),NOSPLIT,$12
MOVL $20, AX // syscall - getpid MOVL $SYS_getpid, AX
INVOKE_SYSCALL INVOKE_SYSCALL
MOVL AX, BX // arg 1 pid MOVL AX, BX // arg 1 pid
MOVL sig+0(FP), CX // arg 2 signal MOVL sig+0(FP), CX // arg 2 signal
MOVL $37, AX // syscall - kill MOVL $SYS_kill, AX
INVOKE_SYSCALL INVOKE_SYSCALL
RET RET
TEXT runtime·setitimer(SB),NOSPLIT,$0-12 TEXT runtime·setitimer(SB),NOSPLIT,$0-12
MOVL $104, AX // syscall - setitimer MOVL $SYS_setittimer, AX
MOVL mode+0(FP), BX MOVL mode+0(FP), BX
MOVL new+4(FP), CX MOVL new+4(FP), CX
MOVL old+8(FP), DX MOVL old+8(FP), DX
...@@ -146,7 +182,7 @@ TEXT runtime·setitimer(SB),NOSPLIT,$0-12 ...@@ -146,7 +182,7 @@ TEXT runtime·setitimer(SB),NOSPLIT,$0-12
RET RET
TEXT runtime·mincore(SB),NOSPLIT,$0-16 TEXT runtime·mincore(SB),NOSPLIT,$0-16
MOVL $218, AX // syscall - mincore MOVL $SYS_mincore, AX
MOVL addr+0(FP), BX MOVL addr+0(FP), BX
MOVL n+4(FP), CX MOVL n+4(FP), CX
MOVL dst+8(FP), DX MOVL dst+8(FP), DX
...@@ -156,7 +192,7 @@ TEXT runtime·mincore(SB),NOSPLIT,$0-16 ...@@ -156,7 +192,7 @@ TEXT runtime·mincore(SB),NOSPLIT,$0-16
// func walltime() (sec int64, nsec int32) // func walltime() (sec int64, nsec int32)
TEXT runtime·walltime(SB), NOSPLIT, $32 TEXT runtime·walltime(SB), NOSPLIT, $32
MOVL $265, AX // syscall - clock_gettime MOVL $SYS_clock_gettime, AX
MOVL $0, BX // CLOCK_REALTIME MOVL $0, BX // CLOCK_REALTIME
LEAL 8(SP), CX LEAL 8(SP), CX
MOVL $0, DX MOVL $0, DX
...@@ -173,7 +209,7 @@ TEXT runtime·walltime(SB), NOSPLIT, $32 ...@@ -173,7 +209,7 @@ TEXT runtime·walltime(SB), NOSPLIT, $32
// int64 nanotime(void) so really // int64 nanotime(void) so really
// void nanotime(int64 *nsec) // void nanotime(int64 *nsec)
TEXT runtime·nanotime(SB), NOSPLIT, $32 TEXT runtime·nanotime(SB), NOSPLIT, $32
MOVL $265, AX // syscall - clock_gettime MOVL $SYS_clock_gettime, AX
MOVL $1, BX // CLOCK_MONOTONIC MOVL $1, BX // CLOCK_MONOTONIC
LEAL 8(SP), CX LEAL 8(SP), CX
MOVL $0, DX MOVL $0, DX
...@@ -193,7 +229,7 @@ TEXT runtime·nanotime(SB), NOSPLIT, $32 ...@@ -193,7 +229,7 @@ TEXT runtime·nanotime(SB), NOSPLIT, $32
RET RET
TEXT runtime·rtsigprocmask(SB),NOSPLIT,$0 TEXT runtime·rtsigprocmask(SB),NOSPLIT,$0
MOVL $175, AX // syscall entry MOVL $SYS_rt_sigprocmask, AX
MOVL how+0(FP), BX MOVL how+0(FP), BX
MOVL new+4(FP), CX MOVL new+4(FP), CX
MOVL old+8(FP), DX MOVL old+8(FP), DX
...@@ -205,7 +241,7 @@ TEXT runtime·rtsigprocmask(SB),NOSPLIT,$0 ...@@ -205,7 +241,7 @@ TEXT runtime·rtsigprocmask(SB),NOSPLIT,$0
RET RET
TEXT runtime·rt_sigaction(SB),NOSPLIT,$0 TEXT runtime·rt_sigaction(SB),NOSPLIT,$0
MOVL $174, AX // syscall - rt_sigaction MOVL $SYS_rt_sigaction, AX
MOVL sig+0(FP), BX MOVL sig+0(FP), BX
MOVL new+4(FP), CX MOVL new+4(FP), CX
MOVL old+8(FP), DX MOVL old+8(FP), DX
...@@ -258,7 +294,7 @@ TEXT runtime·cgoSigtramp(SB),NOSPLIT,$0 ...@@ -258,7 +294,7 @@ TEXT runtime·cgoSigtramp(SB),NOSPLIT,$0
JMP runtime·sigtramp(SB) JMP runtime·sigtramp(SB)
TEXT runtime·sigreturn(SB),NOSPLIT,$0 TEXT runtime·sigreturn(SB),NOSPLIT,$0
MOVL $173, AX // rt_sigreturn MOVL $SYS_rt_sigreturn, AX
// Sigreturn expects same SP as signal handler, // Sigreturn expects same SP as signal handler,
// so cannot CALL 0x10(GS) here. // so cannot CALL 0x10(GS) here.
INT $0x80 INT $0x80
...@@ -266,7 +302,7 @@ TEXT runtime·sigreturn(SB),NOSPLIT,$0 ...@@ -266,7 +302,7 @@ TEXT runtime·sigreturn(SB),NOSPLIT,$0
RET RET
TEXT runtime·mmap(SB),NOSPLIT,$0 TEXT runtime·mmap(SB),NOSPLIT,$0
MOVL $192, AX // mmap2 MOVL $SYS_mmap2, AX
MOVL addr+0(FP), BX MOVL addr+0(FP), BX
MOVL n+4(FP), CX MOVL n+4(FP), CX
MOVL prot+8(FP), DX MOVL prot+8(FP), DX
...@@ -283,7 +319,7 @@ TEXT runtime·mmap(SB),NOSPLIT,$0 ...@@ -283,7 +319,7 @@ TEXT runtime·mmap(SB),NOSPLIT,$0
RET RET
TEXT runtime·munmap(SB),NOSPLIT,$0 TEXT runtime·munmap(SB),NOSPLIT,$0
MOVL $91, AX // munmap MOVL $SYS_munmap, AX
MOVL addr+0(FP), BX MOVL addr+0(FP), BX
MOVL n+4(FP), CX MOVL n+4(FP), CX
INVOKE_SYSCALL INVOKE_SYSCALL
...@@ -293,7 +329,7 @@ TEXT runtime·munmap(SB),NOSPLIT,$0 ...@@ -293,7 +329,7 @@ TEXT runtime·munmap(SB),NOSPLIT,$0
RET RET
TEXT runtime·madvise(SB),NOSPLIT,$0 TEXT runtime·madvise(SB),NOSPLIT,$0
MOVL $219, AX // madvise MOVL $SYS_madvise, AX
MOVL addr+0(FP), BX MOVL addr+0(FP), BX
MOVL n+4(FP), CX MOVL n+4(FP), CX
MOVL flags+8(FP), DX MOVL flags+8(FP), DX
...@@ -304,7 +340,7 @@ TEXT runtime·madvise(SB),NOSPLIT,$0 ...@@ -304,7 +340,7 @@ TEXT runtime·madvise(SB),NOSPLIT,$0
// int32 futex(int32 *uaddr, int32 op, int32 val, // int32 futex(int32 *uaddr, int32 op, int32 val,
// struct timespec *timeout, int32 *uaddr2, int32 val2); // struct timespec *timeout, int32 *uaddr2, int32 val2);
TEXT runtime·futex(SB),NOSPLIT,$0 TEXT runtime·futex(SB),NOSPLIT,$0
MOVL $240, AX // futex MOVL $SYS_futex, AX
MOVL addr+0(FP), BX MOVL addr+0(FP), BX
MOVL op+4(FP), CX MOVL op+4(FP), CX
MOVL val+8(FP), DX MOVL val+8(FP), DX
...@@ -317,7 +353,7 @@ TEXT runtime·futex(SB),NOSPLIT,$0 ...@@ -317,7 +353,7 @@ TEXT runtime·futex(SB),NOSPLIT,$0
// int32 clone(int32 flags, void *stack, M *mp, G *gp, void (*fn)(void)); // int32 clone(int32 flags, void *stack, M *mp, G *gp, void (*fn)(void));
TEXT runtime·clone(SB),NOSPLIT,$0 TEXT runtime·clone(SB),NOSPLIT,$0
MOVL $120, AX // clone MOVL $SYS_clone, AX
MOVL flags+0(FP), BX MOVL flags+0(FP), BX
MOVL stk+4(FP), CX MOVL stk+4(FP), CX
MOVL $0, DX // parent tid ptr MOVL $0, DX // parent tid ptr
...@@ -351,7 +387,7 @@ TEXT runtime·clone(SB),NOSPLIT,$0 ...@@ -351,7 +387,7 @@ TEXT runtime·clone(SB),NOSPLIT,$0
INT $3 INT $3
// Initialize AX to Linux tid // Initialize AX to Linux tid
MOVL $224, AX MOVL $SYS_gettid, AX
INVOKE_SYSCALL INVOKE_SYSCALL
MOVL 0(SP), BX // m MOVL 0(SP), BX // m
...@@ -400,7 +436,7 @@ nog: ...@@ -400,7 +436,7 @@ nog:
MOVL $0x1234, 0x1005 MOVL $0x1234, 0x1005
TEXT runtime·sigaltstack(SB),NOSPLIT,$-8 TEXT runtime·sigaltstack(SB),NOSPLIT,$-8
MOVL $186, AX // sigaltstack MOVL $SYS_sigaltstack, AX
MOVL new+0(FP), BX MOVL new+0(FP), BX
MOVL old+4(FP), CX MOVL old+4(FP), CX
INVOKE_SYSCALL INVOKE_SYSCALL
...@@ -483,7 +519,7 @@ TEXT runtime·setldt(SB),NOSPLIT,$32 ...@@ -483,7 +519,7 @@ TEXT runtime·setldt(SB),NOSPLIT,$32
// call set_thread_area // call set_thread_area
MOVL AX, BX // user_desc MOVL AX, BX // user_desc
MOVL $243, AX // syscall - set_thread_area MOVL $SYS_set_thread_area, AX
// We can't call this via 0x10(GS) because this is called from setldt0 to set that up. // We can't call this via 0x10(GS) because this is called from setldt0 to set that up.
INT $0x80 INT $0x80
...@@ -509,12 +545,12 @@ TEXT runtime·setldt(SB),NOSPLIT,$32 ...@@ -509,12 +545,12 @@ TEXT runtime·setldt(SB),NOSPLIT,$32
RET RET
TEXT runtime·osyield(SB),NOSPLIT,$0 TEXT runtime·osyield(SB),NOSPLIT,$0
MOVL $158, AX MOVL $SYS_sched_yield, AX
INVOKE_SYSCALL INVOKE_SYSCALL
RET RET
TEXT runtime·sched_getaffinity(SB),NOSPLIT,$0 TEXT runtime·sched_getaffinity(SB),NOSPLIT,$0
MOVL $242, AX // syscall - sched_getaffinity MOVL $SYS_sched_getaffinity, AX
MOVL pid+0(FP), BX MOVL pid+0(FP), BX
MOVL len+4(FP), CX MOVL len+4(FP), CX
MOVL buf+8(FP), DX MOVL buf+8(FP), DX
...@@ -524,7 +560,7 @@ TEXT runtime·sched_getaffinity(SB),NOSPLIT,$0 ...@@ -524,7 +560,7 @@ TEXT runtime·sched_getaffinity(SB),NOSPLIT,$0
// int32 runtime·epollcreate(int32 size); // int32 runtime·epollcreate(int32 size);
TEXT runtime·epollcreate(SB),NOSPLIT,$0 TEXT runtime·epollcreate(SB),NOSPLIT,$0
MOVL $254, AX MOVL $SYS_epoll_create, AX
MOVL size+0(FP), BX MOVL size+0(FP), BX
INVOKE_SYSCALL INVOKE_SYSCALL
MOVL AX, ret+4(FP) MOVL AX, ret+4(FP)
...@@ -532,7 +568,7 @@ TEXT runtime·epollcreate(SB),NOSPLIT,$0 ...@@ -532,7 +568,7 @@ TEXT runtime·epollcreate(SB),NOSPLIT,$0
// int32 runtime·epollcreate1(int32 flags); // int32 runtime·epollcreate1(int32 flags);
TEXT runtime·epollcreate1(SB),NOSPLIT,$0 TEXT runtime·epollcreate1(SB),NOSPLIT,$0
MOVL $329, AX MOVL $SYS_epoll_create1, AX
MOVL flags+0(FP), BX MOVL flags+0(FP), BX
INVOKE_SYSCALL INVOKE_SYSCALL
MOVL AX, ret+4(FP) MOVL AX, ret+4(FP)
...@@ -540,7 +576,7 @@ TEXT runtime·epollcreate1(SB),NOSPLIT,$0 ...@@ -540,7 +576,7 @@ TEXT runtime·epollcreate1(SB),NOSPLIT,$0
// func epollctl(epfd, op, fd int32, ev *epollEvent) int // func epollctl(epfd, op, fd int32, ev *epollEvent) int
TEXT runtime·epollctl(SB),NOSPLIT,$0 TEXT runtime·epollctl(SB),NOSPLIT,$0
MOVL $255, AX MOVL $SYS_epoll_ctl, AX
MOVL epfd+0(FP), BX MOVL epfd+0(FP), BX
MOVL op+4(FP), CX MOVL op+4(FP), CX
MOVL fd+8(FP), DX MOVL fd+8(FP), DX
...@@ -551,7 +587,7 @@ TEXT runtime·epollctl(SB),NOSPLIT,$0 ...@@ -551,7 +587,7 @@ TEXT runtime·epollctl(SB),NOSPLIT,$0
// int32 runtime·epollwait(int32 epfd, EpollEvent *ev, int32 nev, int32 timeout); // int32 runtime·epollwait(int32 epfd, EpollEvent *ev, int32 nev, int32 timeout);
TEXT runtime·epollwait(SB),NOSPLIT,$0 TEXT runtime·epollwait(SB),NOSPLIT,$0
MOVL $256, AX MOVL $SYS_epoll_wait, AX
MOVL epfd+0(FP), BX MOVL epfd+0(FP), BX
MOVL ev+4(FP), CX MOVL ev+4(FP), CX
MOVL nev+8(FP), DX MOVL nev+8(FP), DX
...@@ -562,7 +598,7 @@ TEXT runtime·epollwait(SB),NOSPLIT,$0 ...@@ -562,7 +598,7 @@ TEXT runtime·epollwait(SB),NOSPLIT,$0
// void runtime·closeonexec(int32 fd); // void runtime·closeonexec(int32 fd);
TEXT runtime·closeonexec(SB),NOSPLIT,$0 TEXT runtime·closeonexec(SB),NOSPLIT,$0
MOVL $55, AX // fcntl MOVL $SYS_fcntl, AX
MOVL fd+0(FP), BX // fd MOVL fd+0(FP), BX // fd
MOVL $2, CX // F_SETFD MOVL $2, CX // F_SETFD
MOVL $1, DX // FD_CLOEXEC MOVL $1, DX // FD_CLOEXEC
...@@ -571,7 +607,7 @@ TEXT runtime·closeonexec(SB),NOSPLIT,$0 ...@@ -571,7 +607,7 @@ TEXT runtime·closeonexec(SB),NOSPLIT,$0
// int access(const char *name, int mode) // int access(const char *name, int mode)
TEXT runtime·access(SB),NOSPLIT,$0 TEXT runtime·access(SB),NOSPLIT,$0
MOVL $33, AX // syscall - access MOVL $SYS_access, AX
MOVL name+0(FP), BX MOVL name+0(FP), BX
MOVL mode+4(FP), CX MOVL mode+4(FP), CX
INVOKE_SYSCALL INVOKE_SYSCALL
...@@ -582,7 +618,7 @@ TEXT runtime·access(SB),NOSPLIT,$0 ...@@ -582,7 +618,7 @@ TEXT runtime·access(SB),NOSPLIT,$0
TEXT runtime·connect(SB),NOSPLIT,$0-16 TEXT runtime·connect(SB),NOSPLIT,$0-16
// connect is implemented as socketcall(NR_socket, 3, *(rest of args)) // connect is implemented as socketcall(NR_socket, 3, *(rest of args))
// stack already should have fd, addr, addrlen. // stack already should have fd, addr, addrlen.
MOVL $102, AX // syscall - socketcall MOVL $SYS_socketcall, AX
MOVL $3, BX // connect MOVL $3, BX // connect
LEAL fd+0(FP), CX LEAL fd+0(FP), CX
INVOKE_SYSCALL INVOKE_SYSCALL
...@@ -593,7 +629,7 @@ TEXT runtime·connect(SB),NOSPLIT,$0-16 ...@@ -593,7 +629,7 @@ TEXT runtime·connect(SB),NOSPLIT,$0-16
TEXT runtime·socket(SB),NOSPLIT,$0-16 TEXT runtime·socket(SB),NOSPLIT,$0-16
// socket is implemented as socketcall(NR_socket, 1, *(rest of args)) // socket is implemented as socketcall(NR_socket, 1, *(rest of args))
// stack already should have domain, type, protocol. // stack already should have domain, type, protocol.
MOVL $102, AX // syscall - socketcall MOVL $SYS_socketcall, AX
MOVL $1, BX // socket MOVL $1, BX // socket
LEAL domain+0(FP), CX LEAL domain+0(FP), CX
INVOKE_SYSCALL INVOKE_SYSCALL
...@@ -603,7 +639,7 @@ TEXT runtime·socket(SB),NOSPLIT,$0-16 ...@@ -603,7 +639,7 @@ TEXT runtime·socket(SB),NOSPLIT,$0-16
// func sbrk0() uintptr // func sbrk0() uintptr
TEXT runtime·sbrk0(SB),NOSPLIT,$0-4 TEXT runtime·sbrk0(SB),NOSPLIT,$0-4
// Implemented as brk(NULL). // Implemented as brk(NULL).
MOVL $45, AX // syscall - brk MOVL $SYS_brk, AX
MOVL $0, BX // NULL MOVL $0, BX // NULL
INVOKE_SYSCALL INVOKE_SYSCALL
MOVL AX, ret+0(FP) MOVL AX, ret+0(FP)
......
...@@ -10,15 +10,51 @@ ...@@ -10,15 +10,51 @@
#include "go_tls.h" #include "go_tls.h"
#include "textflag.h" #include "textflag.h"
#define SYS_read 0
#define SYS_write 1
#define SYS_open 2
#define SYS_close 3
#define SYS_mmap 9
#define SYS_munmap 11
#define SYS_brk 12
#define SYS_rt_sigaction 13
#define SYS_rt_sigprocmask 14
#define SYS_rt_sigreturn 15
#define SYS_access 21
#define SYS_sched_yield 24
#define SYS_mincore 27
#define SYS_madvise 28
#define SYS_setittimer 38
#define SYS_getpid 39
#define SYS_socket 41
#define SYS_connect 42
#define SYS_clone 56
#define SYS_exit 60
#define SYS_kill 62
#define SYS_fcntl 72
#define SYS_getrlimit 97
#define SYS_sigaltstack 131
#define SYS_arch_prctl 158
#define SYS_gettid 186
#define SYS_tkill 200
#define SYS_futex 202
#define SYS_sched_getaffinity 204
#define SYS_epoll_create 213
#define SYS_exit_group 231
#define SYS_epoll_wait 232
#define SYS_epoll_ctl 233
#define SYS_pselect6 270
#define SYS_epoll_create1 291
TEXT runtime·exit(SB),NOSPLIT,$0-4 TEXT runtime·exit(SB),NOSPLIT,$0-4
MOVL code+0(FP), DI MOVL code+0(FP), DI
MOVL $231, AX // exitgroup - force all os threads to exit MOVL $SYS_exit_group, AX
SYSCALL SYSCALL
RET RET
TEXT runtime·exit1(SB),NOSPLIT,$0-4 TEXT runtime·exit1(SB),NOSPLIT,$0-4
MOVL code+0(FP), DI MOVL code+0(FP), DI
MOVL $60, AX // exit - exit the current os thread MOVL $SYS_exit, AX
SYSCALL SYSCALL
RET RET
...@@ -26,7 +62,7 @@ TEXT runtime·open(SB),NOSPLIT,$0-20 ...@@ -26,7 +62,7 @@ TEXT runtime·open(SB),NOSPLIT,$0-20
MOVQ name+0(FP), DI MOVQ name+0(FP), DI
MOVL mode+8(FP), SI MOVL mode+8(FP), SI
MOVL perm+12(FP), DX MOVL perm+12(FP), DX
MOVL $2, AX // syscall entry MOVL $SYS_open, AX
SYSCALL SYSCALL
CMPQ AX, $0xfffffffffffff001 CMPQ AX, $0xfffffffffffff001
JLS 2(PC) JLS 2(PC)
...@@ -36,7 +72,7 @@ TEXT runtime·open(SB),NOSPLIT,$0-20 ...@@ -36,7 +72,7 @@ TEXT runtime·open(SB),NOSPLIT,$0-20
TEXT runtime·closefd(SB),NOSPLIT,$0-12 TEXT runtime·closefd(SB),NOSPLIT,$0-12
MOVL fd+0(FP), DI MOVL fd+0(FP), DI
MOVL $3, AX // syscall entry MOVL $SYS_close, AX
SYSCALL SYSCALL
CMPQ AX, $0xfffffffffffff001 CMPQ AX, $0xfffffffffffff001
JLS 2(PC) JLS 2(PC)
...@@ -48,7 +84,7 @@ TEXT runtime·write(SB),NOSPLIT,$0-28 ...@@ -48,7 +84,7 @@ TEXT runtime·write(SB),NOSPLIT,$0-28
MOVQ fd+0(FP), DI MOVQ fd+0(FP), DI
MOVQ p+8(FP), SI MOVQ p+8(FP), SI
MOVL n+16(FP), DX MOVL n+16(FP), DX
MOVL $1, AX // syscall entry MOVL $SYS_write, AX
SYSCALL SYSCALL
CMPQ AX, $0xfffffffffffff001 CMPQ AX, $0xfffffffffffff001
JLS 2(PC) JLS 2(PC)
...@@ -60,7 +96,7 @@ TEXT runtime·read(SB),NOSPLIT,$0-28 ...@@ -60,7 +96,7 @@ TEXT runtime·read(SB),NOSPLIT,$0-28
MOVL fd+0(FP), DI MOVL fd+0(FP), DI
MOVQ p+8(FP), SI MOVQ p+8(FP), SI
MOVL n+16(FP), DX MOVL n+16(FP), DX
MOVL $0, AX // syscall entry MOVL $SYS_read, AX
SYSCALL SYSCALL
CMPQ AX, $0xfffffffffffff001 CMPQ AX, $0xfffffffffffff001
JLS 2(PC) JLS 2(PC)
...@@ -71,7 +107,7 @@ TEXT runtime·read(SB),NOSPLIT,$0-28 ...@@ -71,7 +107,7 @@ TEXT runtime·read(SB),NOSPLIT,$0-28
TEXT runtime·getrlimit(SB),NOSPLIT,$0-20 TEXT runtime·getrlimit(SB),NOSPLIT,$0-20
MOVL kind+0(FP), DI MOVL kind+0(FP), DI
MOVQ limit+8(FP), SI MOVQ limit+8(FP), SI
MOVL $97, AX // syscall entry MOVL $SYS_getrlimit, AX
SYSCALL SYSCALL
MOVL AX, ret+16(FP) MOVL AX, ret+16(FP)
RET RET
...@@ -93,31 +129,31 @@ TEXT runtime·usleep(SB),NOSPLIT,$16 ...@@ -93,31 +129,31 @@ TEXT runtime·usleep(SB),NOSPLIT,$16
MOVL $0, R10 MOVL $0, R10
MOVQ SP, R8 MOVQ SP, R8
MOVL $0, R9 MOVL $0, R9
MOVL $270, AX MOVL $SYS_pselect6, AX
SYSCALL SYSCALL
RET RET
TEXT runtime·gettid(SB),NOSPLIT,$0-4 TEXT runtime·gettid(SB),NOSPLIT,$0-4
MOVL $186, AX // syscall - gettid MOVL $SYS_gettid, AX
SYSCALL SYSCALL
MOVL AX, ret+0(FP) MOVL AX, ret+0(FP)
RET RET
TEXT runtime·raise(SB),NOSPLIT,$0 TEXT runtime·raise(SB),NOSPLIT,$0
MOVL $186, AX // syscall - gettid MOVL $SYS_gettid, AX
SYSCALL SYSCALL
MOVL AX, DI // arg 1 tid MOVL AX, DI // arg 1 tid
MOVL sig+0(FP), SI // arg 2 MOVL sig+0(FP), SI // arg 2
MOVL $200, AX // syscall - tkill MOVL $SYS_tkill, AX
SYSCALL SYSCALL
RET RET
TEXT runtime·raiseproc(SB),NOSPLIT,$0 TEXT runtime·raiseproc(SB),NOSPLIT,$0
MOVL $39, AX // syscall - getpid MOVL $SYS_getpid, AX
SYSCALL SYSCALL
MOVL AX, DI // arg 1 pid MOVL AX, DI // arg 1 pid
MOVL sig+0(FP), SI // arg 2 MOVL sig+0(FP), SI // arg 2
MOVL $62, AX // syscall - kill MOVL $SYS_kill, AX
SYSCALL SYSCALL
RET RET
...@@ -125,7 +161,7 @@ TEXT runtime·setitimer(SB),NOSPLIT,$0-24 ...@@ -125,7 +161,7 @@ TEXT runtime·setitimer(SB),NOSPLIT,$0-24
MOVL mode+0(FP), DI MOVL mode+0(FP), DI
MOVQ new+8(FP), SI MOVQ new+8(FP), SI
MOVQ old+16(FP), DX MOVQ old+16(FP), DX
MOVL $38, AX // syscall entry MOVL $SYS_setittimer, AX
SYSCALL SYSCALL
RET RET
...@@ -133,7 +169,7 @@ TEXT runtime·mincore(SB),NOSPLIT,$0-28 ...@@ -133,7 +169,7 @@ TEXT runtime·mincore(SB),NOSPLIT,$0-28
MOVQ addr+0(FP), DI MOVQ addr+0(FP), DI
MOVQ n+8(FP), SI MOVQ n+8(FP), SI
MOVQ dst+16(FP), DX MOVQ dst+16(FP), DX
MOVL $27, AX // syscall entry MOVL $SYS_mincore, AX
SYSCALL SYSCALL
MOVL AX, ret+24(FP) MOVL AX, ret+24(FP)
RET RET
...@@ -204,7 +240,7 @@ TEXT runtime·rtsigprocmask(SB),NOSPLIT,$0-28 ...@@ -204,7 +240,7 @@ TEXT runtime·rtsigprocmask(SB),NOSPLIT,$0-28
MOVQ new+8(FP), SI MOVQ new+8(FP), SI
MOVQ old+16(FP), DX MOVQ old+16(FP), DX
MOVL size+24(FP), R10 MOVL size+24(FP), R10
MOVL $14, AX // syscall entry MOVL $SYS_rt_sigprocmask, AX
SYSCALL SYSCALL
CMPQ AX, $0xfffffffffffff001 CMPQ AX, $0xfffffffffffff001
JLS 2(PC) JLS 2(PC)
...@@ -216,7 +252,7 @@ TEXT runtime·sysSigaction(SB),NOSPLIT,$0-36 ...@@ -216,7 +252,7 @@ TEXT runtime·sysSigaction(SB),NOSPLIT,$0-36
MOVQ new+8(FP), SI MOVQ new+8(FP), SI
MOVQ old+16(FP), DX MOVQ old+16(FP), DX
MOVQ size+24(FP), R10 MOVQ size+24(FP), R10
MOVL $13, AX // syscall entry MOVL $SYS_rt_sigaction, AX
SYSCALL SYSCALL
MOVL AX, ret+32(FP) MOVL AX, ret+32(FP)
RET RET
...@@ -354,7 +390,7 @@ sigtrampnog: ...@@ -354,7 +390,7 @@ sigtrampnog:
// The code that cares about the precise instructions used is: // The code that cares about the precise instructions used is:
// https://gcc.gnu.org/viewcvs/gcc/trunk/libgcc/config/i386/linux-unwind.h?revision=219188&view=markup // https://gcc.gnu.org/viewcvs/gcc/trunk/libgcc/config/i386/linux-unwind.h?revision=219188&view=markup
TEXT runtime·sigreturn(SB),NOSPLIT,$0 TEXT runtime·sigreturn(SB),NOSPLIT,$0
MOVQ $15, AX // rt_sigreturn MOVQ $SYS_rt_sigreturn, AX
SYSCALL SYSCALL
INT $3 // not reached INT $3 // not reached
...@@ -366,7 +402,7 @@ TEXT runtime·sysMmap(SB),NOSPLIT,$0 ...@@ -366,7 +402,7 @@ TEXT runtime·sysMmap(SB),NOSPLIT,$0
MOVL fd+24(FP), R8 MOVL fd+24(FP), R8
MOVL off+28(FP), R9 MOVL off+28(FP), R9
MOVL $9, AX // mmap MOVL $SYS_mmap, AX
SYSCALL SYSCALL
CMPQ AX, $0xfffffffffffff001 CMPQ AX, $0xfffffffffffff001
JLS 3(PC) JLS 3(PC)
...@@ -396,7 +432,7 @@ TEXT runtime·callCgoMmap(SB),NOSPLIT,$16 ...@@ -396,7 +432,7 @@ TEXT runtime·callCgoMmap(SB),NOSPLIT,$16
TEXT runtime·sysMunmap(SB),NOSPLIT,$0 TEXT runtime·sysMunmap(SB),NOSPLIT,$0
MOVQ addr+0(FP), DI MOVQ addr+0(FP), DI
MOVQ n+8(FP), SI MOVQ n+8(FP), SI
MOVQ $11, AX // munmap MOVQ $SYS_munmap, AX
SYSCALL SYSCALL
CMPQ AX, $0xfffffffffffff001 CMPQ AX, $0xfffffffffffff001
JLS 2(PC) JLS 2(PC)
...@@ -420,7 +456,7 @@ TEXT runtime·madvise(SB),NOSPLIT,$0 ...@@ -420,7 +456,7 @@ TEXT runtime·madvise(SB),NOSPLIT,$0
MOVQ addr+0(FP), DI MOVQ addr+0(FP), DI
MOVQ n+8(FP), SI MOVQ n+8(FP), SI
MOVL flags+16(FP), DX MOVL flags+16(FP), DX
MOVQ $28, AX // madvise MOVQ $SYS_madvise, AX
SYSCALL SYSCALL
// ignore failure - maybe pages are locked // ignore failure - maybe pages are locked
RET RET
...@@ -434,7 +470,7 @@ TEXT runtime·futex(SB),NOSPLIT,$0 ...@@ -434,7 +470,7 @@ TEXT runtime·futex(SB),NOSPLIT,$0
MOVQ ts+16(FP), R10 MOVQ ts+16(FP), R10
MOVQ addr2+24(FP), R8 MOVQ addr2+24(FP), R8
MOVL val3+32(FP), R9 MOVL val3+32(FP), R9
MOVL $202, AX MOVL $SYS_futex, AX
SYSCALL SYSCALL
MOVL AX, ret+40(FP) MOVL AX, ret+40(FP)
RET RET
...@@ -452,7 +488,7 @@ TEXT runtime·clone(SB),NOSPLIT,$0 ...@@ -452,7 +488,7 @@ TEXT runtime·clone(SB),NOSPLIT,$0
MOVQ gp+24(FP), R9 MOVQ gp+24(FP), R9
MOVQ fn+32(FP), R12 MOVQ fn+32(FP), R12
MOVL $56, AX MOVL $SYS_clone, AX
SYSCALL SYSCALL
// In parent, return. // In parent, return.
...@@ -471,7 +507,7 @@ TEXT runtime·clone(SB),NOSPLIT,$0 ...@@ -471,7 +507,7 @@ TEXT runtime·clone(SB),NOSPLIT,$0
JEQ nog JEQ nog
// Initialize m->procid to Linux tid // Initialize m->procid to Linux tid
MOVL $186, AX // gettid MOVL $SYS_gettid, AX
SYSCALL SYSCALL
MOVQ AX, m_procid(R8) MOVQ AX, m_procid(R8)
...@@ -491,14 +527,14 @@ nog: ...@@ -491,14 +527,14 @@ nog:
// It shouldn't return. If it does, exit that thread. // It shouldn't return. If it does, exit that thread.
MOVL $111, DI MOVL $111, DI
MOVL $60, AX MOVL $SYS_exit, AX
SYSCALL SYSCALL
JMP -3(PC) // keep exiting JMP -3(PC) // keep exiting
TEXT runtime·sigaltstack(SB),NOSPLIT,$-8 TEXT runtime·sigaltstack(SB),NOSPLIT,$-8
MOVQ new+0(FP), DI MOVQ new+0(FP), DI
MOVQ old+8(FP), SI MOVQ old+8(FP), SI
MOVQ $131, AX MOVQ $SYS_sigaltstack, AX
SYSCALL SYSCALL
CMPQ AX, $0xfffffffffffff001 CMPQ AX, $0xfffffffffffff001
JLS 2(PC) JLS 2(PC)
...@@ -517,7 +553,7 @@ TEXT runtime·settls(SB),NOSPLIT,$32 ...@@ -517,7 +553,7 @@ TEXT runtime·settls(SB),NOSPLIT,$32
#endif #endif
MOVQ DI, SI MOVQ DI, SI
MOVQ $0x1002, DI // ARCH_SET_FS MOVQ $0x1002, DI // ARCH_SET_FS
MOVQ $158, AX // arch_prctl MOVQ $SYS_arch_prctl, AX
SYSCALL SYSCALL
CMPQ AX, $0xfffffffffffff001 CMPQ AX, $0xfffffffffffff001
JLS 2(PC) JLS 2(PC)
...@@ -525,7 +561,7 @@ TEXT runtime·settls(SB),NOSPLIT,$32 ...@@ -525,7 +561,7 @@ TEXT runtime·settls(SB),NOSPLIT,$32
RET RET
TEXT runtime·osyield(SB),NOSPLIT,$0 TEXT runtime·osyield(SB),NOSPLIT,$0
MOVL $24, AX MOVL $SYS_sched_yield, AX
SYSCALL SYSCALL
RET RET
...@@ -533,7 +569,7 @@ TEXT runtime·sched_getaffinity(SB),NOSPLIT,$0 ...@@ -533,7 +569,7 @@ TEXT runtime·sched_getaffinity(SB),NOSPLIT,$0
MOVQ pid+0(FP), DI MOVQ pid+0(FP), DI
MOVQ len+8(FP), SI MOVQ len+8(FP), SI
MOVQ buf+16(FP), DX MOVQ buf+16(FP), DX
MOVL $204, AX // syscall entry MOVL $SYS_sched_getaffinity, AX
SYSCALL SYSCALL
MOVL AX, ret+24(FP) MOVL AX, ret+24(FP)
RET RET
...@@ -541,7 +577,7 @@ TEXT runtime·sched_getaffinity(SB),NOSPLIT,$0 ...@@ -541,7 +577,7 @@ TEXT runtime·sched_getaffinity(SB),NOSPLIT,$0
// int32 runtime·epollcreate(int32 size); // int32 runtime·epollcreate(int32 size);
TEXT runtime·epollcreate(SB),NOSPLIT,$0 TEXT runtime·epollcreate(SB),NOSPLIT,$0
MOVL size+0(FP), DI MOVL size+0(FP), DI
MOVL $213, AX // syscall entry MOVL $SYS_epoll_create, AX
SYSCALL SYSCALL
MOVL AX, ret+8(FP) MOVL AX, ret+8(FP)
RET RET
...@@ -549,7 +585,7 @@ TEXT runtime·epollcreate(SB),NOSPLIT,$0 ...@@ -549,7 +585,7 @@ TEXT runtime·epollcreate(SB),NOSPLIT,$0
// int32 runtime·epollcreate1(int32 flags); // int32 runtime·epollcreate1(int32 flags);
TEXT runtime·epollcreate1(SB),NOSPLIT,$0 TEXT runtime·epollcreate1(SB),NOSPLIT,$0
MOVL flags+0(FP), DI MOVL flags+0(FP), DI
MOVL $291, AX // syscall entry MOVL $SYS_epoll_create1, AX
SYSCALL SYSCALL
MOVL AX, ret+8(FP) MOVL AX, ret+8(FP)
RET RET
...@@ -560,7 +596,7 @@ TEXT runtime·epollctl(SB),NOSPLIT,$0 ...@@ -560,7 +596,7 @@ TEXT runtime·epollctl(SB),NOSPLIT,$0
MOVL op+4(FP), SI MOVL op+4(FP), SI
MOVL fd+8(FP), DX MOVL fd+8(FP), DX
MOVQ ev+16(FP), R10 MOVQ ev+16(FP), R10
MOVL $233, AX // syscall entry MOVL $SYS_epoll_ctl, AX
SYSCALL SYSCALL
MOVL AX, ret+24(FP) MOVL AX, ret+24(FP)
RET RET
...@@ -571,7 +607,7 @@ TEXT runtime·epollwait(SB),NOSPLIT,$0 ...@@ -571,7 +607,7 @@ TEXT runtime·epollwait(SB),NOSPLIT,$0
MOVQ ev+8(FP), SI MOVQ ev+8(FP), SI
MOVL nev+16(FP), DX MOVL nev+16(FP), DX
MOVL timeout+20(FP), R10 MOVL timeout+20(FP), R10
MOVL $232, AX // syscall entry MOVL $SYS_epoll_wait, AX
SYSCALL SYSCALL
MOVL AX, ret+24(FP) MOVL AX, ret+24(FP)
RET RET
...@@ -581,7 +617,7 @@ TEXT runtime·closeonexec(SB),NOSPLIT,$0 ...@@ -581,7 +617,7 @@ TEXT runtime·closeonexec(SB),NOSPLIT,$0
MOVL fd+0(FP), DI // fd MOVL fd+0(FP), DI // fd
MOVQ $2, SI // F_SETFD MOVQ $2, SI // F_SETFD
MOVQ $1, DX // FD_CLOEXEC MOVQ $1, DX // FD_CLOEXEC
MOVL $72, AX // fcntl MOVL $SYS_fcntl, AX
SYSCALL SYSCALL
RET RET
...@@ -590,7 +626,7 @@ TEXT runtime·closeonexec(SB),NOSPLIT,$0 ...@@ -590,7 +626,7 @@ TEXT runtime·closeonexec(SB),NOSPLIT,$0
TEXT runtime·access(SB),NOSPLIT,$0 TEXT runtime·access(SB),NOSPLIT,$0
MOVQ name+0(FP), DI MOVQ name+0(FP), DI
MOVL mode+8(FP), SI MOVL mode+8(FP), SI
MOVL $21, AX // syscall entry MOVL $SYS_access, AX
SYSCALL SYSCALL
MOVL AX, ret+16(FP) MOVL AX, ret+16(FP)
RET RET
...@@ -600,7 +636,7 @@ TEXT runtime·connect(SB),NOSPLIT,$0-28 ...@@ -600,7 +636,7 @@ TEXT runtime·connect(SB),NOSPLIT,$0-28
MOVL fd+0(FP), DI MOVL fd+0(FP), DI
MOVQ addr+8(FP), SI MOVQ addr+8(FP), SI
MOVL len+16(FP), DX MOVL len+16(FP), DX
MOVL $42, AX // syscall entry MOVL $SYS_connect, AX
SYSCALL SYSCALL
MOVL AX, ret+24(FP) MOVL AX, ret+24(FP)
RET RET
...@@ -610,7 +646,7 @@ TEXT runtime·socket(SB),NOSPLIT,$0-20 ...@@ -610,7 +646,7 @@ TEXT runtime·socket(SB),NOSPLIT,$0-20
MOVL domain+0(FP), DI MOVL domain+0(FP), DI
MOVL typ+4(FP), SI MOVL typ+4(FP), SI
MOVL prot+8(FP), DX MOVL prot+8(FP), DX
MOVL $41, AX // syscall entry MOVL $SYS_socket, AX
SYSCALL SYSCALL
MOVL AX, ret+16(FP) MOVL AX, ret+16(FP)
RET RET
...@@ -619,7 +655,7 @@ TEXT runtime·socket(SB),NOSPLIT,$0-20 ...@@ -619,7 +655,7 @@ TEXT runtime·socket(SB),NOSPLIT,$0-20
TEXT runtime·sbrk0(SB),NOSPLIT,$0-8 TEXT runtime·sbrk0(SB),NOSPLIT,$0-8
// Implemented as brk(NULL). // Implemented as brk(NULL).
MOVQ $0, DI MOVQ $0, DI
MOVL $12, AX // syscall entry MOVL $SYS_brk, AX
SYSCALL SYSCALL
MOVQ AX, ret+0(FP) MOVQ AX, ret+0(FP)
RET RET
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment