Commit cf3f7712 authored by Ian Lance Taylor's avatar Ian Lance Taylor

runtime: unify amd64 -buildmode=exe entry point code

All of the amd64 entry point code is the same except for Plan 9.
Unify it all into asm_amd64.s.

Change-Id: Id47ce3a7bb2bb0fd48f326a2d88ed18b17dee456
Reviewed-on: https://go-review.googlesource.com/69292
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: 's avatarAustin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent e29efbcb
...@@ -7,6 +7,21 @@ ...@@ -7,6 +7,21 @@
#include "funcdata.h" #include "funcdata.h"
#include "textflag.h" #include "textflag.h"
// _rt0_amd64 is common startup code for most amd64 systems when using
// internal linking. This is the entry point for the program from the
// kernel for an ordinary -buildmode=exe program. The stack holds the
// number of arguments and the C-style argv.
TEXT _rt0_amd64(SB),NOSPLIT,$-8
MOVQ 0(SP), DI // argc
LEAQ 8(SP), SI // argv
JMP runtime·rt0_go(SB)
// main is common startup code for most amd64 systems when using
// external linking. The C startup code will call the symbol "main"
// passing argc and argv in the usual C ABI registers DI and SI.
TEXT main(SB),NOSPLIT,$-8
JMP runtime·rt0_go(SB)
TEXT runtime·rt0_go(SB),NOSPLIT,$0 TEXT runtime·rt0_go(SB),NOSPLIT,$0
// copy arguments forward on an even stack // copy arguments forward on an even stack
MOVQ DI, AX // argc MOVQ DI, AX // argc
......
...@@ -5,10 +5,7 @@ ...@@ -5,10 +5,7 @@
#include "textflag.h" #include "textflag.h"
TEXT _rt0_amd64_android(SB),NOSPLIT,$-8 TEXT _rt0_amd64_android(SB),NOSPLIT,$-8
MOVQ 0(SP), DI // argc JMP _rt0_amd64(SB)
LEAQ 8(SP), SI // argv
MOVQ $main(SB), AX
JMP AX
TEXT _rt0_amd64_android_lib(SB),NOSPLIT,$0 TEXT _rt0_amd64_android_lib(SB),NOSPLIT,$0
MOVQ $1, DI // argc MOVQ $1, DI // argc
......
...@@ -5,10 +5,7 @@ ...@@ -5,10 +5,7 @@
#include "textflag.h" #include "textflag.h"
TEXT _rt0_amd64_darwin(SB),NOSPLIT,$-8 TEXT _rt0_amd64_darwin(SB),NOSPLIT,$-8
LEAQ 8(SP), SI // argv JMP _rt0_amd64(SB)
MOVQ 0(SP), DI // argc
MOVQ $main(SB), AX
JMP AX
// When linking with -shared, this symbol is called when the shared library // When linking with -shared, this symbol is called when the shared library
// is loaded. // is loaded.
...@@ -73,7 +70,3 @@ DATA _rt0_amd64_darwin_lib_argc<>(SB)/8, $0 ...@@ -73,7 +70,3 @@ DATA _rt0_amd64_darwin_lib_argc<>(SB)/8, $0
GLOBL _rt0_amd64_darwin_lib_argc<>(SB),NOPTR, $8 GLOBL _rt0_amd64_darwin_lib_argc<>(SB),NOPTR, $8
DATA _rt0_amd64_darwin_lib_argv<>(SB)/8, $0 DATA _rt0_amd64_darwin_lib_argv<>(SB)/8, $0
GLOBL _rt0_amd64_darwin_lib_argv<>(SB),NOPTR, $8 GLOBL _rt0_amd64_darwin_lib_argv<>(SB),NOPTR, $8
TEXT main(SB),NOSPLIT,$-8
MOVQ $runtime·rt0_go(SB), AX
JMP AX
...@@ -5,11 +5,4 @@ ...@@ -5,11 +5,4 @@
#include "textflag.h" #include "textflag.h"
TEXT _rt0_amd64_dragonfly(SB),NOSPLIT,$-8 TEXT _rt0_amd64_dragonfly(SB),NOSPLIT,$-8
LEAQ 8(DI), SI // argv JMP _rt0_amd64(SB)
MOVQ 0(DI), DI // argc
MOVQ $main(SB), AX
JMP AX
TEXT main(SB),NOSPLIT,$-8
MOVQ $runtime·rt0_go(SB), AX
JMP AX
...@@ -4,12 +4,8 @@ ...@@ -4,12 +4,8 @@
#include "textflag.h" #include "textflag.h"
// On FreeBSD argc/argv are passed in DI, not SP, so we can't use _rt0_amd64.
TEXT _rt0_amd64_freebsd(SB),NOSPLIT,$-8 TEXT _rt0_amd64_freebsd(SB),NOSPLIT,$-8
LEAQ 8(DI), SI // argv LEAQ 8(DI), SI // argv
MOVQ 0(DI), DI // argc MOVQ 0(DI), DI // argc
MOVQ $main(SB), AX JMP runtime·rt0_go(SB)
JMP AX
TEXT main(SB),NOSPLIT,$-8
MOVQ $runtime·rt0_go(SB), AX
JMP AX
...@@ -5,10 +5,7 @@ ...@@ -5,10 +5,7 @@
#include "textflag.h" #include "textflag.h"
TEXT _rt0_amd64_linux(SB),NOSPLIT,$-8 TEXT _rt0_amd64_linux(SB),NOSPLIT,$-8
LEAQ 8(SP), SI // argv JMP _rt0_amd64(SB)
MOVQ 0(SP), DI // argc
MOVQ $main(SB), AX
JMP AX
// When building with -buildmode=c-shared, this symbol is called when the shared // When building with -buildmode=c-shared, this symbol is called when the shared
// library is loaded. // library is loaded.
...@@ -68,7 +65,3 @@ DATA _rt0_amd64_linux_lib_argc<>(SB)/8, $0 ...@@ -68,7 +65,3 @@ DATA _rt0_amd64_linux_lib_argc<>(SB)/8, $0
GLOBL _rt0_amd64_linux_lib_argc<>(SB),NOPTR, $8 GLOBL _rt0_amd64_linux_lib_argc<>(SB),NOPTR, $8
DATA _rt0_amd64_linux_lib_argv<>(SB)/8, $0 DATA _rt0_amd64_linux_lib_argv<>(SB)/8, $0
GLOBL _rt0_amd64_linux_lib_argv<>(SB),NOPTR, $8 GLOBL _rt0_amd64_linux_lib_argv<>(SB),NOPTR, $8
TEXT main(SB),NOSPLIT,$-8
MOVQ $runtime·rt0_go(SB), AX
JMP AX
...@@ -5,11 +5,4 @@ ...@@ -5,11 +5,4 @@
#include "textflag.h" #include "textflag.h"
TEXT _rt0_amd64_netbsd(SB),NOSPLIT,$-8 TEXT _rt0_amd64_netbsd(SB),NOSPLIT,$-8
LEAQ 8(SP), SI // argv JMP _rt0_amd64(SB)
MOVQ 0(SP), DI // argc
MOVQ $main(SB), AX
JMP AX
TEXT main(SB),NOSPLIT,$-8
MOVQ $runtime·rt0_go(SB), AX
JMP AX
...@@ -5,11 +5,4 @@ ...@@ -5,11 +5,4 @@
#include "textflag.h" #include "textflag.h"
TEXT _rt0_amd64_openbsd(SB),NOSPLIT,$-8 TEXT _rt0_amd64_openbsd(SB),NOSPLIT,$-8
LEAQ 8(SP), SI // argv JMP _rt0_amd64(SB)
MOVQ 0(SP), DI // argc
MOVQ $main(SB), AX
JMP AX
TEXT main(SB),NOSPLIT,$-8
MOVQ $runtime·rt0_go(SB), AX
JMP AX
...@@ -5,11 +5,4 @@ ...@@ -5,11 +5,4 @@
#include "textflag.h" #include "textflag.h"
TEXT _rt0_amd64_solaris(SB),NOSPLIT,$-8 TEXT _rt0_amd64_solaris(SB),NOSPLIT,$-8
LEAQ 8(SP), SI // argv JMP _rt0_amd64(SB)
MOVQ 0(SP), DI // argc
MOVQ $main(SB), AX
JMP AX
TEXT main(SB),NOSPLIT,$-8
MOVQ $runtime·rt0_go(SB), AX
JMP AX
...@@ -7,10 +7,7 @@ ...@@ -7,10 +7,7 @@
#include "textflag.h" #include "textflag.h"
TEXT _rt0_amd64_windows(SB),NOSPLIT,$-8 TEXT _rt0_amd64_windows(SB),NOSPLIT,$-8
LEAQ 8(SP), SI // argv JMP _rt0_amd64(SB)
MOVQ 0(SP), DI // argc
MOVQ $main(SB), AX
JMP AX
// When building with -buildmode=(c-shared or c-archive), this // When building with -buildmode=(c-shared or c-archive), this
// symbol is called. For dynamic libraries it is called when the // symbol is called. For dynamic libraries it is called when the
...@@ -42,7 +39,3 @@ TEXT _rt0_amd64_windows_lib_go(SB),NOSPLIT,$0 ...@@ -42,7 +39,3 @@ TEXT _rt0_amd64_windows_lib_go(SB),NOSPLIT,$0
MOVQ $0, SI MOVQ $0, SI
MOVQ $runtime·rt0_go(SB), AX MOVQ $runtime·rt0_go(SB), AX
JMP AX JMP AX
TEXT main(SB),NOSPLIT,$-8
MOVQ $runtime·rt0_go(SB), AX
JMP AX
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