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
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
// 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)
// 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)
-
// 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
// 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)
// 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)
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
// 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
#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;