summaryrefslogtreecommitdiff
path: root/src/syscall
diff options
context:
space:
mode:
authorMichael Hudson-Doyle <michael.hudson@canonical.com>2015-11-17 20:00:20 +1300
committerMichael Hudson-Doyle <michael.hudson@canonical.com>2015-11-17 20:22:47 +0000
commit90e26f52c6d2012d293ebfe8d272f03462213045 (patch)
tree26b7e5bdb7f0a84e20d48cfa4d8b2430a016f821 /src/syscall
parentf4a9bd87ba84ce900dd2ba97974c48a0f4a01047 (diff)
downloadgo-git-90e26f52c6d2012d293ebfe8d272f03462213045.tar.gz
runtime, syscall: use int $0x80 to invoke syscalls on android/386
golang.org/cl/16796 broke android/386 by assuming behaviour specific to glibc's dynamic linker. Copy bionic by using int $0x80 to invoke syscalls on android/386 as the old alternative (CALL *runtime_vdso(SB)) cannot be compiled without text relocations, which we want to get rid of on android. Also remove "CALL *runtime_vdso(SB)" variant from the syscall package. Change-Id: I6c01849f8dcbd073d000ddc8f13948a836b8b261 Reviewed-on: https://go-review.googlesource.com/16996 TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Crawshaw <crawshaw@golang.org> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Diffstat (limited to 'src/syscall')
-rw-r--r--src/syscall/asm_linux_386.s27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/syscall/asm_linux_386.s b/src/syscall/asm_linux_386.s
index ec7487b4b9..c94060571b 100644
--- a/src/syscall/asm_linux_386.s
+++ b/src/syscall/asm_linux_386.s
@@ -12,6 +12,19 @@
// func Syscall(trap uintptr, a1, a2, a3 uintptr) (r1, r2, err uintptr);
// Trap # in AX, args in BX CX DX SI DI, return in AX
+// Most linux systems use glibc's dynamic linker, which puts the
+// __kernel_vsyscall vdso helper at 0x10(GS) for easy access from position
+// independent code and setldt in runtime does the same in the statically
+// linked case. Android, however, uses bionic's dynamic linker, which does not
+// save the helper anywhere, and so the only way to invoke a syscall from
+// position independent code is boring old int $0x80 (which is also what
+// bionic's syscall wrappers use).
+#ifdef GOOS_android
+#define INVOKE_SYSCALL INT $0x80
+#else
+#define INVOKE_SYSCALL CALL 0x10(GS)
+#endif
+
TEXT ·Syscall(SB),NOSPLIT,$0-28
CALL runtime·entersyscall(SB)
MOVL trap+0(FP), AX // syscall entry
@@ -20,7 +33,7 @@ TEXT ·Syscall(SB),NOSPLIT,$0-28
MOVL a3+12(FP), DX
MOVL $0, SI
MOVL $0, DI
- CALL *runtime·_vdso(SB)
+ INVOKE_SYSCALL
CMPL AX, $0xfffff001
JLS ok
MOVL $-1, r1+16(FP)
@@ -46,7 +59,7 @@ TEXT ·Syscall6(SB),NOSPLIT,$0-40
MOVL a4+16(FP), SI
MOVL a5+20(FP), DI
MOVL a6+24(FP), BP
- CALL *runtime·_vdso(SB)
+ INVOKE_SYSCALL
CMPL AX, $0xfffff001
JLS ok6
MOVL $-1, r1+28(FP)
@@ -70,7 +83,7 @@ TEXT ·RawSyscall(SB),NOSPLIT,$0-28
MOVL a3+12(FP), DX
MOVL $0, SI
MOVL $0, DI
- CALL *runtime·_vdso(SB)
+ INVOKE_SYSCALL
CMPL AX, $0xfffff001
JLS ok1
MOVL $-1, r1+16(FP)
@@ -93,7 +106,7 @@ TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
MOVL a4+16(FP), SI
MOVL a5+20(FP), DI
MOVL a6+24(FP), BP
- CALL *runtime·_vdso(SB)
+ INVOKE_SYSCALL
CMPL AX, $0xfffff001
JLS ok2
MOVL $-1, r1+28(FP)
@@ -119,7 +132,7 @@ TEXT ·socketcall(SB),NOSPLIT,$0-36
MOVL $0, DX
MOVL $0, SI
MOVL $0, DI
- CALL *runtime·_vdso(SB)
+ INVOKE_SYSCALL
CMPL AX, $0xfffff001
JLS oksock
MOVL $-1, n+28(FP)
@@ -142,7 +155,7 @@ TEXT ·rawsocketcall(SB),NOSPLIT,$0-36
MOVL $0, DX
MOVL $0, SI
MOVL $0, DI
- CALL *runtime·_vdso(SB)
+ INVOKE_SYSCALL
CMPL AX, $0xfffff001
JLS oksock1
MOVL $-1, n+28(FP)
@@ -168,7 +181,7 @@ TEXT ·seek(SB),NOSPLIT,$0-28
MOVL offset_lo+4(FP), DX
LEAL newoffset_lo+16(FP), SI // result pointer
MOVL whence+12(FP), DI
- CALL *runtime·_vdso(SB)
+ INVOKE_SYSCALL
CMPL AX, $0xfffff001
JLS okseek
MOVL $-1, newoffset_lo+16(FP)