]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: change 386 startup convention
authorRuss Cox <rsc@golang.org>
Fri, 8 Mar 2013 03:57:10 +0000 (19:57 -0800)
committerRuss Cox <rsc@golang.org>
Fri, 8 Mar 2013 03:57:10 +0000 (19:57 -0800)
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

src/pkg/runtime/asm_386.s
src/pkg/runtime/rt0_darwin_386.s
src/pkg/runtime/rt0_freebsd_386.s
src/pkg/runtime/rt0_linux_386.s
src/pkg/runtime/rt0_netbsd_386.s
src/pkg/runtime/rt0_openbsd_386.s
src/pkg/runtime/rt0_plan9_386.s
src/pkg/runtime/rt0_windows_386.s
src/pkg/runtime/signal_linux_386.c

index 96f04e0ae90e6a1fcdd1a97586e507a0b75ec16d..375274e0b3a8265197ba6759ebca740971d49e4c 100644 (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
index 30b497f5e7463302330b284cc0bb7b99b37b9061..4b4c1f29422ae40ef023e0d1b0dd1c9d7ee76ddb 100644 (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)
index 3ca981b3a3143aa0c6572d8034a6b2d15f59e9fe..c84482cdbfea190d16b8cdd1cde3e78c3087569d 100644 (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)
-
index 83149540ec42cb1981a8696ab1e41725b3cef955..73cca5d9805bd2f9a15045469aa6b971567d20f2 100644 (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
index 829e4133b8b6926f23714124368b1cc9be3e4ada..b4c029c538dd6c91e88d99832a988231f6abfe61 100644 (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)
index e7e0da78f2f70441fada54d9a9d8ff1376a0bb9a..9c00a733408f48a0802cc07e11c3f06bef05a427 100644 (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)
index 56f3a0f6c72a81f82c3dcc7823c7350bf0ad9987..7af1eae7cb9e79217af6fbb376398d831475f98d 100644 (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
index a06aa787e2e1c312bb95b809427c017eb20a50fc..6e34c6c172adea68b2e91820a357b603c1303e9a 100644 (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
index 9b45ec3bd2e618d1f385b338d2beb0e651ccbcc6..ed9ae3a8e542c0764af61023b10480add8c95a40 100644 (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;