Unbreak the lang/go port by switching from the old __tfork syscall that no

longer exists, to the current __tfork syscall. Also use __set_tcb instead
of sysarch.

ok sthen@
This commit is contained in:
jsing 2013-03-12 09:57:10 +00:00
parent 73bb1be303
commit 61de7b7719
5 changed files with 88 additions and 45 deletions

View File

@ -1,10 +1,11 @@
# $OpenBSD: Makefile,v 1.8 2013/03/11 11:20:27 espie Exp $
# $OpenBSD: Makefile,v 1.9 2013/03/12 09:57:10 jsing Exp $
ONLY_FOR_ARCHS = amd64 i386
COMMENT = Go programming language
VERSION = 1.0.3
REVISION = 0
EXTRACT_SUFX = .src.tar.gz
DISTNAME = go${VERSION}
PKGNAME = go-${VERSION}

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-src_cmd_ld_elf_c,v 1.1 2012/09/19 21:10:38 sthen Exp $
--- src/cmd/ld/elf.c.orig Thu Jun 14 04:23:38 2012
+++ src/cmd/ld/elf.c Mon Sep 17 11:38:32 2012
@@ -348,20 +348,16 @@ elfwriteinterp(vlong stridx)
$OpenBSD: patch-src_cmd_ld_elf_c,v 1.2 2013/03/12 09:57:11 jsing Exp $
--- src/cmd/ld/elf.c.orig Mon Sep 24 05:43:12 2012
+++ src/cmd/ld/elf.c Sun Nov 18 02:37:55 2012
@@ -351,20 +351,16 @@ elfwriteinterp(vlong stridx)
return sh->size;
}
@ -29,7 +29,7 @@ $OpenBSD: patch-src_cmd_ld_elf_c,v 1.1 2012/09/19 21:10:38 sthen Exp $
sh->addr = startva + resoff - n;
sh->off = resoff - n;
sh->size = n;
@@ -369,8 +365,9 @@ elfnetbsdsig(ElfShdr *sh, uint64 startva, uint64 resof
@@ -372,8 +368,9 @@ elfnetbsdsig(ElfShdr *sh, uint64 startva, uint64 resof
return n;
}
@ -41,7 +41,7 @@ $OpenBSD: patch-src_cmd_ld_elf_c,v 1.1 2012/09/19 21:10:38 sthen Exp $
ElfShdr *sh = nil;
int i;
@@ -378,15 +375,79 @@ elfwritenetbsdsig(vlong stridx) {
@@ -381,15 +378,79 @@ elfwritenetbsdsig(vlong stridx) {
if(shdr[i]->name == stridx)
sh = shdr[i];
if(sh == nil)

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-src_pkg_runtime_sys_openbsd_386_s,v 1.2 2012/04/15 13:37:27 jsing Exp $
--- src/pkg/runtime/sys_openbsd_386.s.orig Wed Mar 28 15:49:26 2012
+++ src/pkg/runtime/sys_openbsd_386.s Fri Mar 2 02:14:56 2012
$OpenBSD: patch-src_pkg_runtime_sys_openbsd_386_s,v 1.3 2013/03/12 09:57:11 jsing Exp $
--- src/pkg/runtime/sys_openbsd_386.s.orig Mon Sep 24 05:43:12 2012
+++ src/pkg/runtime/sys_openbsd_386.s Sun Nov 18 02:56:11 2012
@@ -12,14 +12,16 @@
TEXT runtime·exit(SB),7,$-4
MOVL $1, AX
@ -50,7 +50,7 @@ $OpenBSD: patch-src_pkg_runtime_sys_openbsd_386_s,v 1.2 2012/04/15 13:37:27 jsin
TEXT runtime·sigtramp(SB),7,$44
get_tls(CX)
@@ -174,40 +184,46 @@ TEXT runtime·sigtramp(SB),7,$44
@@ -174,45 +184,51 @@ TEXT runtime·sigtramp(SB),7,$44
MOVL AX, 4(SP) // arg 1 - sigcontext
MOVL $103, AX // sys_sigreturn
INT $0x80
@ -63,7 +63,7 @@ $OpenBSD: patch-src_pkg_runtime_sys_openbsd_386_s,v 1.2 2012/04/15 13:37:27 jsin
- MOVL flags+8(SP), AX
- MOVL stack+12(SP), CX
+// int32 tfork_thread(void *stack, M *m, G *g, void (*fn)(void));
+TEXT runtime·tfork_thread(SB),7,$20
+TEXT runtime·tfork_thread(SB),7,$24
// Copy m, g, fn off parent stack for use by child.
+ MOVL stack+4(FP), CX
@ -78,18 +78,22 @@ $OpenBSD: patch-src_pkg_runtime_sys_openbsd_386_s,v 1.2 2012/04/15 13:37:27 jsin
+ MOVL fn+16(FP), SI
MOVL SI, 8(CX)
MOVL $1234, 12(CX)
MOVL CX, SI
- MOVL CX, SI
+ LEAL 8(SP), AX
+ MOVL mm+8(FP), DX
+ LEAL m_procid(CX), DX
+
+ LEAL 12(SP), AX
+ MOVL $0, 0(AX) // tf_tcb
+ MOVL $0, 4(AX) // tf_tid
+ MOVL $0, 8(AX) // tf_flags
+ MOVL DX, 4(AX) // tf_tid
+ MOVL CX, 8(AX) // tf_stack
+
MOVL $0, 0(SP) // syscall gap
- MOVL AX, 4(SP) // arg 1 - flags
- MOVL $251, AX // sys_rfork
+ MOVL AX, 4(SP) // arg 1 - params
+ MOVL $328, AX // sys___tfork
+ MOVL $12, 8(SP) // arg 2 - psize
+ MOVL $8, AX // sys___tfork
INT $0x80
- // Return if rfork syscall failed
@ -111,9 +115,26 @@ $OpenBSD: patch-src_pkg_runtime_sys_openbsd_386_s,v 1.2 2012/04/15 13:37:27 jsin
+ MOVL AX, 0(DX)
RET
// In child, on new stack.
@@ -286,7 +302,7 @@ TEXT runtime·settls(SB),7,$16
MOVL $165, AX // sys_sysarch
- // In child, on new stack.
- MOVL SI, SP
-
// Paranoia: check that SP is as we expect.
MOVL 12(SP), BP
CMPL BP, $1234
@@ -277,16 +293,14 @@ TEXT runtime·setldt(SB),7,$8
TEXT runtime·settls(SB),7,$16
// adjust for ELF: wants to use -8(GS) and -4(GS) for g and m
- MOVL 20(SP), CX
+ MOVL tlsbase+0(FP), CX
ADDL $8, CX
- MOVL CX, 0(CX)
MOVL $0, 0(SP) // syscall gap
- MOVL $9, 4(SP) // I386_SET_GSBASE (machine/sysarch.h)
- MOVL CX, 8(SP) // pointer to base
- MOVL $165, AX // sys_sysarch
+ MOVL CX, 4(SP) // arg 1 - pointer to base
+ MOVL $329, AX // sys___set_tcb
INT $0x80
JCC 2(PC)
- MOVL $0xf1, 0xf1 // crash
@ -121,7 +142,7 @@ $OpenBSD: patch-src_pkg_runtime_sys_openbsd_386_s,v 1.2 2012/04/15 13:37:27 jsin
RET
TEXT runtime·osyield(SB),7,$-4
@@ -295,12 +311,12 @@ TEXT runtime·osyield(SB),7,$-4
@@ -295,12 +309,12 @@ TEXT runtime·osyield(SB),7,$-4
RET
TEXT runtime·thrsleep(SB),7,$-4

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-src_pkg_runtime_sys_openbsd_amd64_s,v 1.2 2012/04/15 13:37:27 jsing Exp $
--- src/pkg/runtime/sys_openbsd_amd64.s.orig Wed Mar 28 15:49:26 2012
+++ src/pkg/runtime/sys_openbsd_amd64.s Fri Mar 2 02:03:18 2012
@@ -8,20 +8,23 @@
$OpenBSD: patch-src_pkg_runtime_sys_openbsd_amd64_s,v 1.3 2013/03/12 09:57:11 jsing Exp $
--- src/pkg/runtime/sys_openbsd_amd64.s.orig Mon Sep 24 05:43:12 2012
+++ src/pkg/runtime/sys_openbsd_amd64.s Sun Nov 18 03:23:21 2012
@@ -8,20 +8,25 @@
#include "zasm_GOOS_GOARCH.h"
@ -23,11 +23,13 @@ $OpenBSD: patch-src_pkg_runtime_sys_openbsd_amd64_s,v 1.2 2012/04/15 13:37:27 js
+ MOVQ fn+24(FP), R12
- MOVL $251, AX // sys_rfork
+ LEAQ 8(SP), DI
+ MOVQ $0, 0(DI) // tf_tcb
+ MOVQ $0, 8(DI) // tf_tid
+ MOVL $0, 16(DI) // tf_flags
+ MOVL $328, AX // sys___tfork
+ LEAQ m_procid(R8), AX
+ MOVQ SP, DI // arg 1 - params
+ MOVQ $0, 0(DI) // tf_tcb
+ MOVQ AX, 8(DI) // tf_tid
+ MOVQ SI, 16(DI) // tf_stack
+ MOVQ $24, SI // arg 2 - psize
+ MOVL $8, AX // sys___tfork
SYSCALL
- // Return if rfork syscall failed
@ -35,7 +37,22 @@ $OpenBSD: patch-src_pkg_runtime_sys_openbsd_amd64_s,v 1.2 2012/04/15 13:37:27 js
JCC 3(PC)
NEGL AX
RET
@@ -53,7 +56,8 @@ TEXT runtime·rfork_thread(SB),7,$0
@@ -31,14 +36,6 @@ TEXT runtime·rfork_thread(SB),7,$0
JEQ 2(PC)
RET
- // In child, on new stack.
- MOVQ SI, SP
-
- // Initialize m->procid to thread ID
- MOVL $299, AX // sys_getthrid
- SYSCALL
- MOVQ AX, m_procid(R8)
-
// Set FS to point at m->tls.
LEAQ m_tls(R8), DI
CALL runtime·settls(SB)
@@ -53,7 +50,8 @@ TEXT runtime·rfork_thread(SB),7,$0
CALL R12
// It shouldn't return. If it does, exit
@ -45,7 +62,7 @@ $OpenBSD: patch-src_pkg_runtime_sys_openbsd_amd64_s,v 1.2 2012/04/15 13:37:27 js
SYSCALL
JMP -3(PC) // keep exiting
@@ -67,14 +71,15 @@ TEXT runtime·thrsleep(SB),7,$0
@@ -67,14 +65,15 @@ TEXT runtime·thrsleep(SB),7,$0
MOVL 16(SP), SI // arg 2 - clock_id
MOVQ 24(SP), DX // arg 3 - tp
MOVQ 32(SP), R10 // arg 4 - lock
@ -63,7 +80,7 @@ $OpenBSD: patch-src_pkg_runtime_sys_openbsd_amd64_s,v 1.2 2012/04/15 13:37:27 js
SYSCALL
RET
@@ -83,13 +88,14 @@ TEXT runtime·exit(SB),7,$-8
@@ -83,13 +82,14 @@ TEXT runtime·exit(SB),7,$-8
MOVL 8(SP), DI // arg 1 - exit status
MOVL $1, AX // sys_exit
SYSCALL
@ -81,7 +98,7 @@ $OpenBSD: patch-src_pkg_runtime_sys_openbsd_amd64_s,v 1.2 2012/04/15 13:37:27 js
RET
TEXT runtime·write(SB),7,$-8
@@ -140,7 +146,7 @@ TEXT time·now(SB), 7, $32
@@ -140,7 +140,7 @@ TEXT time·now(SB), 7, $32
MOVL $116, AX // sys_gettimeofday
SYSCALL
MOVQ 8(SP), AX // sec
@ -90,7 +107,7 @@ $OpenBSD: patch-src_pkg_runtime_sys_openbsd_amd64_s,v 1.2 2012/04/15 13:37:27 js
// sec is in AX, usec in DX
MOVQ AX, sec+0(FP)
@@ -154,7 +160,7 @@ TEXT runtime·nanotime(SB),7,$32
@@ -154,7 +154,7 @@ TEXT runtime·nanotime(SB),7,$32
MOVL $116, AX // sys_gettimeofday
SYSCALL
MOVQ 8(SP), AX // sec
@ -99,7 +116,7 @@ $OpenBSD: patch-src_pkg_runtime_sys_openbsd_amd64_s,v 1.2 2012/04/15 13:37:27 js
// sec is in AX, usec in DX
// return nsec in AX
@@ -170,9 +176,19 @@ TEXT runtime·sigaction(SB),7,$-8
@@ -170,9 +170,19 @@ TEXT runtime·sigaction(SB),7,$-8
MOVL $46, AX
SYSCALL
JCC 2(PC)
@ -120,7 +137,7 @@ $OpenBSD: patch-src_pkg_runtime_sys_openbsd_amd64_s,v 1.2 2012/04/15 13:37:27 js
TEXT runtime·sigtramp(SB),7,$64
get_tls(BX)
@@ -226,7 +242,7 @@ TEXT runtime·munmap(SB),7,$0
@@ -226,7 +236,7 @@ TEXT runtime·munmap(SB),7,$0
MOVL $73, AX // sys_munmap
SYSCALL
JCC 2(PC)
@ -129,7 +146,7 @@ $OpenBSD: patch-src_pkg_runtime_sys_openbsd_amd64_s,v 1.2 2012/04/15 13:37:27 js
RET
TEXT runtime·sigaltstack(SB),7,$-8
@@ -235,7 +251,7 @@ TEXT runtime·sigaltstack(SB),7,$-8
@@ -235,20 +245,17 @@ TEXT runtime·sigaltstack(SB),7,$-8
MOVQ $288, AX // sys_sigaltstack
SYSCALL
JCC 2(PC)
@ -138,8 +155,15 @@ $OpenBSD: patch-src_pkg_runtime_sys_openbsd_amd64_s,v 1.2 2012/04/15 13:37:27 js
RET
// set tls base to DI
@@ -248,7 +264,7 @@ TEXT runtime·settls(SB),7,$8
MOVQ $165, AX // sys_sysarch
-TEXT runtime·settls(SB),7,$8
+TEXT runtime·settls(SB),7,$0
// adjust for ELF: wants to use -16(FS) and -8(FS) for g and m
ADDQ $16, DI
- MOVQ DI, 0(SP)
- MOVQ SP, SI
- MOVQ $12, DI // AMD64_SET_FSBASE (machine/sysarch.h)
- MOVQ $165, AX // sys_sysarch
+ MOVQ $329, AX // sys___settcb
SYSCALL
JCC 2(PC)
- MOVL $0xf1, 0xf1 // crash
@ -147,7 +171,7 @@ $OpenBSD: patch-src_pkg_runtime_sys_openbsd_amd64_s,v 1.2 2012/04/15 13:37:27 js
RET
TEXT runtime·sysctl(SB),7,$0
@@ -260,7 +276,7 @@ TEXT runtime·sysctl(SB),7,$0
@@ -260,7 +267,7 @@ TEXT runtime·sysctl(SB),7,$0
MOVQ 48(SP), R9 // arg 6 - newlen
MOVQ $202, AX // sys___sysctl
SYSCALL

View File

@ -1,4 +1 @@
# $OpenBSD: systrace.filter,v 1.2 2012/07/04 15:20:31 sthen Exp $
# Go programs (including go_bootstrap) currently need sysarch().
native-sysarch: permit
native-compat_o51___tfork: permit
# $OpenBSD: systrace.filter,v 1.3 2013/03/12 09:57:11 jsing Exp $