Commit dfc22e29 authored by Russ Cox's avatar Russ Cox

runtime: change 386 startup convention

Now the default startup is that the program begins at _rt0_386_$GOOS,
which behaves as if calling main(argc, argv). Main jumps to _rt0_386.

This makes the _rt0_386 entry match the expected semantics for
the standard C "main" function, which we can now provide for use when
linking against a standard C library.

386 analogue of https://golang.org/cl/7525043

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7551045
parent b6e0d39a
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
TEXT _rt0_386(SB),7,$0 TEXT _rt0_386(SB),7,$0
// copy arguments forward on an even stack // copy arguments forward on an even stack
MOVL 0(SP), AX // argc MOVL argc+0(FP), AX
LEAL 4(SP), BX // argv MOVL argv+4(FP), BX
SUBL $128, SP // plenty of scratch SUBL $128, SP // plenty of scratch
ANDL $~15, SP ANDL $~15, SP
MOVL AX, 120(SP) // save argc, argv away MOVL AX, 120(SP) // save argc, argv away
......
...@@ -2,7 +2,13 @@ ...@@ -2,7 +2,13 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// Darwin and Linux use the same linkage to main TEXT _rt0_386_darwin(SB),7,$8
MOVL 8(SP), AX
LEAL 12(SP), BX
MOVL AX, 0(SP)
MOVL BX, 4(SP)
CALL main(SB)
INT $3
TEXT _rt0_386_darwin(SB),7,$0 TEXT main(SB),7,$0
JMP _rt0_386(SB) JMP _rt0_386(SB)
...@@ -2,8 +2,13 @@ ...@@ -2,8 +2,13 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// Darwin and Linux use the same linkage to main TEXT _rt0_386_freebsd(SB),7,$8
MOVL 8(SP), AX
LEAL 12(SP), BX
MOVL AX, 0(SP)
MOVL BX, 4(SP)
CALL main(SB)
INT $3
TEXT _rt0_386_freebsd(SB),7,$0 TEXT main(SB),7,$0
JMP _rt0_386(SB) JMP _rt0_386(SB)
...@@ -2,11 +2,17 @@ ...@@ -2,11 +2,17 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// Darwin and Linux use the same linkage to main TEXT _rt0_386_linux(SB),7,$8
MOVL 8(SP), AX
TEXT _rt0_386_linux(SB),7,$0 LEAL 12(SP), BX
MOVL AX, 0(SP)
MOVL BX, 4(SP)
CALL runtime·linux_setup_vdso(SB) CALL runtime·linux_setup_vdso(SB)
JMP _rt0_386(SB) CALL main(SB)
INT $3
TEXT main(SB),7,$0
JMP _rt0_386(SB)
TEXT _fallback_vdso(SB),7,$0 TEXT _fallback_vdso(SB),7,$0
INT $0x80 INT $0x80
......
...@@ -2,5 +2,13 @@ ...@@ -2,5 +2,13 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
TEXT _rt0_386_netbsd(SB),7,$0 TEXT _rt0_386_netbsd(SB),7,$8
JMP _rt0_386(SB) MOVL 8(SP), AX
LEAL 12(SP), BX
MOVL AX, 0(SP)
MOVL BX, 4(SP)
CALL main(SB)
INT $3
TEXT main(SB),7,$0
JMP _rt0_386(SB)
...@@ -2,5 +2,13 @@ ...@@ -2,5 +2,13 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
TEXT _rt0_386_openbsd(SB),7,$0 TEXT _rt0_386_openbsd(SB),7,$8
JMP _rt0_386(SB) MOVL 8(SP), AX
LEAL 12(SP), BX
MOVL AX, 0(SP)
MOVL BX, 4(SP)
CALL main(SB)
INT $3
TEXT main(SB),7,$0
JMP _rt0_386(SB)
...@@ -26,6 +26,13 @@ argv_fix: ...@@ -26,6 +26,13 @@ argv_fix:
LOOP argv_fix LOOP argv_fix
CALL runtime·asminit(SB) CALL runtime·asminit(SB)
MOVL 0(SP), AX
LEAL 4(SP), BX
PUSHL BX
PUSHL AX
PUSHL $-1
JMP _rt0_386(SB) JMP _rt0_386(SB)
DATA runtime·isplan9(SB)/4, $1 DATA runtime·isplan9(SB)/4, $1
......
...@@ -2,8 +2,17 @@ ...@@ -2,8 +2,17 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
TEXT _rt0_386_windows(SB),7,$0 TEXT _rt0_386_windows(SB),7,$12
MOVL 12(SP), AX
LEAL 16(SP), BX
MOVL AX, 4(SP)
MOVL BX, 8(SP)
MOVL $-1, 0(SP) // return PC for main
JMP main(SB)
TEXT main(SB),7,$0
JMP _rt0_386(SB) JMP _rt0_386(SB)
DATA runtime·iswindows(SB)/4, $1 DATA runtime·iswindows(SB)/4, $1
GLOBL runtime·iswindows(SB), $4 GLOBL runtime·iswindows(SB), $4
...@@ -155,9 +155,8 @@ extern uint32 runtime·_vdso; ...@@ -155,9 +155,8 @@ extern uint32 runtime·_vdso;
#pragma textflag 7 #pragma textflag 7
void void
runtime·linux_setup_vdso(int32 argc, void *argv_list) runtime·linux_setup_vdso(int32 argc, byte **argv)
{ {
byte **argv = &argv_list;
byte **envp; byte **envp;
uint32 *auxv; uint32 *auxv;
......
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