Commit add7b220 authored by Russ Cox's avatar Russ Cox

runtime: fix nacl/386 build

I changed all the NACL_SYSJMP to NACL_SYSCALL in
an earlier CL, but I missed the fact that NACL_SYSCALL
will push another return PC on the stack, so that the
arguments will no longer be in the right place.
Since we have to make our own call, we also have to
copy the arguments. Do that.

Fixes nacl/386 build.

TBR=minux
CC=golang-codereviews
https://golang.org/cl/135050044
parent 948bb915
...@@ -9,25 +9,43 @@ ...@@ -9,25 +9,43 @@
#define NACL_SYSCALL(code) \ #define NACL_SYSCALL(code) \
MOVL $(0x10000 + ((code)<<5)), AX; CALL AX MOVL $(0x10000 + ((code)<<5)), AX; CALL AX
TEXT runtime·exit(SB),NOSPLIT,$0 TEXT runtime·exit(SB),NOSPLIT,$4
MOVL code+0(FP), AX
MOVL AX, 0(SP)
NACL_SYSCALL(SYS_exit) NACL_SYSCALL(SYS_exit)
JMP 0(PC) JMP 0(PC)
TEXT runtime·exit1(SB),NOSPLIT,$0 TEXT runtime·exit1(SB),NOSPLIT,$4
MOVL code+0(FP), AX
MOVL AX, 0(SP)
NACL_SYSCALL(SYS_thread_exit) NACL_SYSCALL(SYS_thread_exit)
RET RET
TEXT runtime·open(SB),NOSPLIT,$0 TEXT runtime·open(SB),NOSPLIT,$12
MOVL name+0(FP), AX
MOVL AX, 0(SP)
MOVL mode+4(FP), AX
MOVL AX, 4(SP)
MOVL perm+8(FP), AX
MOVL AX, 8(SP)
NACL_SYSCALL(SYS_open) NACL_SYSCALL(SYS_open)
MOVL AX, ret+12(FP) MOVL AX, ret+12(FP)
RET RET
TEXT runtime·close(SB),NOSPLIT,$0 TEXT runtime·close(SB),NOSPLIT,$4
MOVL fd+0(FP), AX
MOVL AX, 0(SP)
NACL_SYSCALL(SYS_close) NACL_SYSCALL(SYS_close)
MOVL AX, ret+4(FP) MOVL AX, ret+4(FP)
RET RET
TEXT runtime·read(SB),NOSPLIT,$0 TEXT runtime·read(SB),NOSPLIT,$12
MOVL fd+0(FP), AX
MOVL AX, 0(SP)
MOVL p+4(FP), AX
MOVL AX, 4(SP)
MOVL n+8(FP), AX
MOVL AX, 8(SP)
NACL_SYSCALL(SYS_read) NACL_SYSCALL(SYS_read)
MOVL AX, ret+12(FP) MOVL AX, ret+12(FP)
RET RET
...@@ -43,82 +61,134 @@ TEXT syscall·naclWrite(SB), NOSPLIT, $16-16 ...@@ -43,82 +61,134 @@ TEXT syscall·naclWrite(SB), NOSPLIT, $16-16
MOVL AX, ret+16(FP) MOVL AX, ret+16(FP)
RET RET
TEXT runtime·write(SB),NOSPLIT,$0 TEXT runtime·write(SB),NOSPLIT,$12
MOVL fd+0(FP), AX
MOVL AX, 0(SP)
MOVL p+4(FP), AX
MOVL AX, 4(SP)
MOVL n+8(FP), AX
MOVL AX, 8(SP)
NACL_SYSCALL(SYS_write) NACL_SYSCALL(SYS_write)
MOVL AX, ret+12(FP) MOVL AX, ret+12(FP)
RET RET
TEXT runtime·nacl_exception_stack(SB),NOSPLIT,$0 TEXT runtime·nacl_exception_stack(SB),NOSPLIT,$8
MOVL p+0(FP), AX
MOVL AX, 0(SP)
MOVL size+4(FP), AX
MOVL AX, 4(SP)
NACL_SYSCALL(SYS_exception_stack) NACL_SYSCALL(SYS_exception_stack)
MOVL AX, ret+8(FP) MOVL AX, ret+8(FP)
RET RET
TEXT runtime·nacl_exception_handler(SB),NOSPLIT,$0 TEXT runtime·nacl_exception_handler(SB),NOSPLIT,$8
MOVL fn+0(FP), AX
MOVL AX, 0(SP)
MOVL arg+4(FP), AX
MOVL AX, 4(SP)
NACL_SYSCALL(SYS_exception_handler) NACL_SYSCALL(SYS_exception_handler)
MOVL AX, ret+8(FP) MOVL AX, ret+8(FP)
RET RET
TEXT runtime·nacl_sem_create(SB),NOSPLIT,$0 TEXT runtime·nacl_sem_create(SB),NOSPLIT,$4
MOVL flag+0(FP), AX
MOVL AX, 0(SP)
NACL_SYSCALL(SYS_sem_create) NACL_SYSCALL(SYS_sem_create)
MOVL AX, ret+4(FP) MOVL AX, ret+4(FP)
RET RET
TEXT runtime·nacl_sem_wait(SB),NOSPLIT,$0 TEXT runtime·nacl_sem_wait(SB),NOSPLIT,$4
MOVL sem+0(FP), AX
MOVL AX, 0(SP)
NACL_SYSCALL(SYS_sem_wait) NACL_SYSCALL(SYS_sem_wait)
MOVL AX, ret+4(FP) MOVL AX, ret+4(FP)
RET RET
TEXT runtime·nacl_sem_post(SB),NOSPLIT,$0 TEXT runtime·nacl_sem_post(SB),NOSPLIT,$4
MOVL sem+0(FP), AX
MOVL AX, 0(SP)
NACL_SYSCALL(SYS_sem_post) NACL_SYSCALL(SYS_sem_post)
MOVL AX, ret+4(FP) MOVL AX, ret+4(FP)
RET RET
TEXT runtime·nacl_mutex_create(SB),NOSPLIT,$0 TEXT runtime·nacl_mutex_create(SB),NOSPLIT,$4
MOVL flag+0(FP), AX
MOVL AX, 0(SP)
NACL_SYSCALL(SYS_mutex_create) NACL_SYSCALL(SYS_mutex_create)
MOVL AX, ret+4(FP) MOVL AX, ret+4(FP)
RET RET
TEXT runtime·nacl_mutex_lock(SB),NOSPLIT,$0 TEXT runtime·nacl_mutex_lock(SB),NOSPLIT,$4
MOVL mutex+0(FP), AX
MOVL AX, 0(SP)
NACL_SYSCALL(SYS_mutex_lock) NACL_SYSCALL(SYS_mutex_lock)
MOVL AX, ret+4(FP) MOVL AX, ret+4(FP)
RET RET
TEXT runtime·nacl_mutex_trylock(SB),NOSPLIT,$0 TEXT runtime·nacl_mutex_trylock(SB),NOSPLIT,$4
MOVL mutex+0(FP), AX
MOVL AX, 0(SP)
NACL_SYSCALL(SYS_mutex_trylock) NACL_SYSCALL(SYS_mutex_trylock)
MOVL AX, ret+4(FP) MOVL AX, ret+4(FP)
RET RET
TEXT runtime·nacl_mutex_unlock(SB),NOSPLIT,$0 TEXT runtime·nacl_mutex_unlock(SB),NOSPLIT,$4
MOVL mutex+0(FP), AX
MOVL AX, 0(SP)
NACL_SYSCALL(SYS_mutex_unlock) NACL_SYSCALL(SYS_mutex_unlock)
MOVL AX, ret+4(FP) MOVL AX, ret+4(FP)
RET RET
TEXT runtime·nacl_cond_create(SB),NOSPLIT,$0 TEXT runtime·nacl_cond_create(SB),NOSPLIT,$4
MOVL flag+0(FP), AX
MOVL AX, 0(SP)
NACL_SYSCALL(SYS_cond_create) NACL_SYSCALL(SYS_cond_create)
MOVL AX, ret+4(FP) MOVL AX, ret+4(FP)
RET RET
TEXT runtime·nacl_cond_wait(SB),NOSPLIT,$0 TEXT runtime·nacl_cond_wait(SB),NOSPLIT,$8
MOVL cond+0(FP), AX
MOVL AX, 0(SP)
MOVL n+4(FP), AX
MOVL AX, 4(SP)
NACL_SYSCALL(SYS_cond_wait) NACL_SYSCALL(SYS_cond_wait)
MOVL AX, ret+8(FP) MOVL AX, ret+8(FP)
RET RET
TEXT runtime·nacl_cond_signal(SB),NOSPLIT,$0 TEXT runtime·nacl_cond_signal(SB),NOSPLIT,$4
MOVL cond+0(FP), AX
MOVL AX, 0(SP)
NACL_SYSCALL(SYS_cond_signal) NACL_SYSCALL(SYS_cond_signal)
MOVL AX, ret+4(FP) MOVL AX, ret+4(FP)
RET RET
TEXT runtime·nacl_cond_broadcast(SB),NOSPLIT,$0 TEXT runtime·nacl_cond_broadcast(SB),NOSPLIT,$4
MOVL cond+0(FP), AX
MOVL AX, 0(SP)
NACL_SYSCALL(SYS_cond_broadcast) NACL_SYSCALL(SYS_cond_broadcast)
MOVL AX, ret+4(FP) MOVL AX, ret+4(FP)
RET RET
TEXT runtime·nacl_cond_timed_wait_abs(SB),NOSPLIT,$0 TEXT runtime·nacl_cond_timed_wait_abs(SB),NOSPLIT,$12
MOVL cond+0(FP), AX
MOVL AX, 0(SP)
MOVL lock+4(FP), AX
MOVL AX, 4(SP)
MOVL ts+8(FP), AX
MOVL AX, 8(SP)
NACL_SYSCALL(SYS_cond_timed_wait_abs) NACL_SYSCALL(SYS_cond_timed_wait_abs)
MOVL AX, ret+12(FP) MOVL AX, ret+12(FP)
RET RET
TEXT runtime·nacl_thread_create(SB),NOSPLIT,$0 TEXT runtime·nacl_thread_create(SB),NOSPLIT,$16
MOVL fn+0(FP), AX
MOVL AX, 0(SP)
MOVL stk+4(FP), AX
MOVL AX, 4(SP)
MOVL tls+8(FP), AX
MOVL AX, 8(SP)
MOVL xx+12(FP), AX
MOVL AX, 12(SP)
NACL_SYSCALL(SYS_thread_create) NACL_SYSCALL(SYS_thread_create)
MOVL AX, ret+16(FP) MOVL AX, ret+16(FP)
RET RET
...@@ -126,7 +196,11 @@ TEXT runtime·nacl_thread_create(SB),NOSPLIT,$0 ...@@ -126,7 +196,11 @@ TEXT runtime·nacl_thread_create(SB),NOSPLIT,$0
TEXT runtime·mstart_nacl(SB),NOSPLIT,$0 TEXT runtime·mstart_nacl(SB),NOSPLIT,$0
JMP runtime·mstart(SB) JMP runtime·mstart(SB)
TEXT runtime·nacl_nanosleep(SB),NOSPLIT,$0 TEXT runtime·nacl_nanosleep(SB),NOSPLIT,$8
MOVL ts+0(FP), AX
MOVL AX, 0(SP)
MOVL extra+4(FP), AX
MOVL AX, 4(SP)
NACL_SYSCALL(SYS_nanosleep) NACL_SYSCALL(SYS_nanosleep)
MOVL AX, ret+8(FP) MOVL AX, ret+8(FP)
RET RET
...@@ -173,7 +247,11 @@ TEXT time·now(SB),NOSPLIT,$20 ...@@ -173,7 +247,11 @@ TEXT time·now(SB),NOSPLIT,$20
TEXT syscall·now(SB),NOSPLIT,$0 TEXT syscall·now(SB),NOSPLIT,$0
JMP time·now(SB) JMP time·now(SB)
TEXT runtime·nacl_clock_gettime(SB),NOSPLIT,$0 TEXT runtime·nacl_clock_gettime(SB),NOSPLIT,$8
MOVL arg1+0(FP), AX
MOVL AX, 0(SP)
MOVL arg2+4(FP), AX
MOVL AX, 4(SP)
NACL_SYSCALL(SYS_clock_gettime) NACL_SYSCALL(SYS_clock_gettime)
MOVL AX, ret+8(FP) MOVL AX, ret+8(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