mirror of
https://github.com/golang/go
synced 2024-11-22 22:20:03 -07:00
runtime: change amd64 startup convention
Now the default startup is that the program begins at _rt0_amd64_$GOOS, which sets DI = argc, SI = argv and jumps to _rt0_amd64. This makes the _rt0_amd64 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. R=golang-dev, devon.odell, minux.ma CC=golang-dev https://golang.org/cl/7525043
This commit is contained in:
parent
cf8434fa31
commit
36b414f639
@ -6,8 +6,8 @@
|
||||
|
||||
TEXT _rt0_amd64(SB),7,$-8
|
||||
// copy arguments forward on an even stack
|
||||
MOVQ 0(DI), AX // argc
|
||||
LEAQ 8(DI), BX // argv
|
||||
MOVQ DI, AX // argc
|
||||
MOVQ SI, BX // argv
|
||||
SUBQ $(4*8+7), SP // 2args 2auto
|
||||
ANDQ $~15, SP
|
||||
MOVQ AX, 16(SP)
|
||||
|
@ -2,9 +2,12 @@
|
||||
// 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_amd64_darwin(SB),7,$-8
|
||||
MOVQ $_rt0_amd64(SB), AX
|
||||
MOVQ SP, DI
|
||||
LEAQ 8(SP), SI // argv
|
||||
MOVQ 0(SP), DI // argc
|
||||
MOVQ $main(SB), AX
|
||||
JMP AX
|
||||
|
||||
TEXT main(SB),7,$-8
|
||||
MOVQ $_rt0_amd64(SB), AX
|
||||
JMP AX
|
||||
|
@ -2,8 +2,12 @@
|
||||
// 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_amd64_freebsd(SB),7,$-8
|
||||
MOVQ $_rt0_amd64(SB), DX
|
||||
JMP DX
|
||||
LEAQ 8(DI), SI // argv
|
||||
MOVQ 0(DI), DI // argc
|
||||
MOVQ $main(SB), AX
|
||||
JMP AX
|
||||
|
||||
TEXT main(SB),7,$-8
|
||||
MOVQ $_rt0_amd64(SB), AX
|
||||
JMP AX
|
||||
|
@ -2,9 +2,12 @@
|
||||
// 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_amd64_linux(SB),7,$-8
|
||||
MOVQ $_rt0_amd64(SB), AX
|
||||
MOVQ SP, DI
|
||||
LEAQ 8(SP), SI // argv
|
||||
MOVQ 0(SP), DI // argc
|
||||
MOVQ $main(SB), AX
|
||||
JMP AX
|
||||
|
||||
TEXT main(SB),7,$-8
|
||||
MOVQ $_rt0_amd64(SB), AX
|
||||
JMP AX
|
||||
|
@ -2,7 +2,12 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
TEXT _rt0_amd64_netbsd(SB),7,$-8
|
||||
MOVQ $_rt0_amd64(SB), DX
|
||||
MOVQ SP, DI
|
||||
JMP DX
|
||||
TEXT _rt0_amd64_openbsd(SB),7,$-8
|
||||
LEAQ 8(SP), SI // argv
|
||||
MOVQ 0(SP), DI // argc
|
||||
MOVQ $main(SB), AX
|
||||
JMP AX
|
||||
|
||||
TEXT main(SB),7,$-8
|
||||
MOVQ $_rt0_amd64(SB), AX
|
||||
JMP AX
|
||||
|
@ -3,6 +3,11 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
TEXT _rt0_amd64_openbsd(SB),7,$-8
|
||||
MOVQ $_rt0_amd64(SB), DX
|
||||
MOVQ SP, DI
|
||||
JMP DX
|
||||
LEAQ 8(SP), SI // argv
|
||||
MOVQ 0(SP), DI // argc
|
||||
MOVQ $main(SB), AX
|
||||
JMP AX
|
||||
|
||||
TEXT main(SB),7,$-8
|
||||
MOVQ $_rt0_amd64(SB), AX
|
||||
JMP AX
|
||||
|
@ -2,9 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
TEXT _rt0_amd64_plan9(SB),7, $0
|
||||
TEXT _rt0_amd64_plan9(SB),7,$-8
|
||||
LEAQ 8(SP), SI // argv
|
||||
MOVQ 0(SP), DI // argc
|
||||
MOVQ $_rt0_amd64(SB), AX
|
||||
MOVQ SP, DI
|
||||
JMP AX
|
||||
|
||||
DATA runtime·isplan9(SB)/4, $1
|
||||
|
@ -4,9 +4,14 @@
|
||||
|
||||
#include "zasm_GOOS_GOARCH.h"
|
||||
|
||||
TEXT _rt0_amd64_windows(SB),7,$-8
|
||||
TEXT _rt0_amd64_darwin(SB),7,$-8
|
||||
LEAQ 8(SP), SI // argv
|
||||
MOVQ 0(SP), DI // argc
|
||||
MOVQ $main(SB), AX
|
||||
JMP AX
|
||||
|
||||
TEXT main(SB),7,$-8
|
||||
MOVQ $_rt0_amd64(SB), AX
|
||||
MOVQ SP, DI
|
||||
JMP AX
|
||||
|
||||
DATA runtime·iswindows(SB)/4, $1
|
||||
|
Loading…
Reference in New Issue
Block a user