1
0
mirror of https://github.com/golang/go synced 2024-11-22 18:14:42 -07:00

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
This commit is contained in:
Russ Cox 2013-03-07 19:57:10 -08:00
parent b6e0d39a34
commit dfc22e29ec
9 changed files with 66 additions and 18 deletions

View File

@ -6,8 +6,8 @@
TEXT _rt0_386(SB),7,$0
// copy arguments forward on an even stack
MOVL 0(SP), AX // argc
LEAL 4(SP), BX // argv
MOVL argc+0(FP), AX
MOVL argv+4(FP), BX
SUBL $128, SP // plenty of scratch
ANDL $~15, SP
MOVL AX, 120(SP) // save argc, argv away

View File

@ -2,7 +2,13 @@
// Use of this source code is governed by a BSD-style
// 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)

View File

@ -2,8 +2,13 @@
// Use of this source code is governed by a BSD-style
// 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)

View File

@ -2,11 +2,17 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Darwin and Linux use the same linkage to main
TEXT _rt0_386_linux(SB),7,$0
TEXT _rt0_386_linux(SB),7,$8
MOVL 8(SP), AX
LEAL 12(SP), BX
MOVL AX, 0(SP)
MOVL BX, 4(SP)
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
INT $0x80

View File

@ -2,5 +2,13 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
TEXT _rt0_386_netbsd(SB),7,$0
JMP _rt0_386(SB)
TEXT _rt0_386_netbsd(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 main(SB),7,$0
JMP _rt0_386(SB)

View File

@ -2,5 +2,13 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
TEXT _rt0_386_openbsd(SB),7,$0
JMP _rt0_386(SB)
TEXT _rt0_386_openbsd(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 main(SB),7,$0
JMP _rt0_386(SB)

View File

@ -26,6 +26,13 @@ argv_fix:
LOOP argv_fix
CALL runtime·asminit(SB)
MOVL 0(SP), AX
LEAL 4(SP), BX
PUSHL BX
PUSHL AX
PUSHL $-1
JMP _rt0_386(SB)
DATA runtime·isplan9(SB)/4, $1

View File

@ -2,8 +2,17 @@
// Use of this source code is governed by a BSD-style
// 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)
DATA runtime·iswindows(SB)/4, $1
GLOBL runtime·iswindows(SB), $4

View File

@ -155,9 +155,8 @@ extern uint32 runtime·_vdso;
#pragma textflag 7
void
runtime·linux_setup_vdso(int32 argc, void *argv_list)
runtime·linux_setup_vdso(int32 argc, byte **argv)
{
byte **argv = &argv_list;
byte **envp;
uint32 *auxv;