diff options
Diffstat (limited to 'community/go/fix-musl.patch')
-rw-r--r-- | community/go/fix-musl.patch | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/community/go/fix-musl.patch b/community/go/fix-musl.patch new file mode 100644 index 0000000000..e70200118e --- /dev/null +++ b/community/go/fix-musl.patch @@ -0,0 +1,70 @@ +From 0f783bde485796c8e97789d285c825024d1ca8e4 Mon Sep 17 00:00:00 2001 +From: Shenghou Ma <minux@golang.org> +Date: Tue, 23 Feb 2016 01:26:50 -0500 +Subject: [PATCH] runtime, syscall: switch linux/386 to use int 0x80 + +Like bionic, musl also doesn't provide vsyscall helper in %gs:0x10, +and as int $0x80 is as fast as calling %gs:0x10, just use int $0x80 +always. + +Fixes #14476. + +Change-Id: I00ec8652060700e0a3c9b524bfe3c16a810263f6 +--- + +diff --git a/src/runtime/sys_linux_386.s b/src/runtime/sys_linux_386.s +index 1a3aaf0..29ebd5e 100644 +--- a/src/runtime/sys_linux_386.s ++++ b/src/runtime/sys_linux_386.s +@@ -12,16 +12,17 @@ + + // 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 this file 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 ++// independent code and setldt in runtime does the same in the statically ++// linked case. However, systems that use alternative libc such as Android's ++// bionic and musl, do 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 syscall wrappers in bionic/musl use). ++// ++// The benchmarks also showed that using int $0x80 is as fast as calling ++// *%gs:0x10 even on CPUs more than 6 years old. See https://golang.org/cl/16996 ++// for the benchmark program and raw data. ++//#define INVOKE_SYSCALL CALL 0x10(GS) // non-portable + #define INVOKE_SYSCALL INT $0x80 +-#else +-#define INVOKE_SYSCALL CALL 0x10(GS) +-#endif + + TEXT runtime·exit(SB),NOSPLIT,$0 + MOVL $252, AX // syscall number +diff --git a/src/syscall/asm_linux_386.s b/src/syscall/asm_linux_386.s +index c940605..d5b1022 100644 +--- a/src/syscall/asm_linux_386.s ++++ b/src/syscall/asm_linux_386.s +@@ -12,18 +12,9 @@ + // 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 ++// See ../runtime/sys_linux_386.s for rationales. ++//#define INVOKE_SYSCALL CALL 0x10(GS) // non-portable + #define INVOKE_SYSCALL INT $0x80 +-#else +-#define INVOKE_SYSCALL CALL 0x10(GS) +-#endif + + TEXT ·Syscall(SB),NOSPLIT,$0-28 + CALL runtime·entersyscall(SB) |