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 @@
#include "funcdata.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
// copy arguments forward on an even stack
MOVQ DI, AX // argc
......
......@@ -5,10 +5,7 @@
#include "textflag.h"
TEXT _rt0_amd64_android(SB),NOSPLIT,$-8
MOVQ 0(SP), DI // argc
LEAQ 8(SP), SI // argv
MOVQ $main(SB), AX
JMP AX
JMP _rt0_amd64(SB)
TEXT _rt0_amd64_android_lib(SB),NOSPLIT,$0
MOVQ $1, DI // argc
......
......@@ -5,10 +5,7 @@
#include "textflag.h"
TEXT _rt0_amd64_darwin(SB),NOSPLIT,$-8
LEAQ 8(SP), SI // argv
MOVQ 0(SP), DI // argc
MOVQ $main(SB), AX
JMP AX
JMP _rt0_amd64(SB)
// When linking with -shared, this symbol is called when the shared library
// is loaded.
......@@ -73,7 +70,3 @@ DATA _rt0_amd64_darwin_lib_argc<>(SB)/8, $0
GLOBL _rt0_amd64_darwin_lib_argc<>(SB),NOPTR, $8
DATA _rt0_amd64_darwin_lib_argv<>(SB)/8, $0
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 @@
#include "textflag.h"
TEXT _rt0_amd64_dragonfly(SB),NOSPLIT,$-8
LEAQ 8(DI), SI // argv
MOVQ 0(DI), DI // argc
MOVQ $main(SB), AX
JMP AX
TEXT main(SB),NOSPLIT,$-8
MOVQ $runtime·rt0_go(SB), AX
JMP AX
JMP _rt0_amd64(SB)
......@@ -4,12 +4,8 @@
#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
LEAQ 8(DI), SI // argv
MOVQ 0(DI), DI // argc
MOVQ $main(SB), AX
JMP AX
TEXT main(SB),NOSPLIT,$-8
MOVQ $runtime·rt0_go(SB), AX
JMP AX
JMP runtime·rt0_go(SB)
......@@ -5,10 +5,7 @@
#include "textflag.h"
TEXT _rt0_amd64_linux(SB),NOSPLIT,$-8
LEAQ 8(SP), SI // argv
MOVQ 0(SP), DI // argc
MOVQ $main(SB), AX
JMP AX
JMP _rt0_amd64(SB)
// When building with -buildmode=c-shared, this symbol is called when the shared
// library is loaded.
......@@ -68,7 +65,3 @@ DATA _rt0_amd64_linux_lib_argc<>(SB)/8, $0
GLOBL _rt0_amd64_linux_lib_argc<>(SB),NOPTR, $8
DATA _rt0_amd64_linux_lib_argv<>(SB)/8, $0
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 @@
#include "textflag.h"
TEXT _rt0_amd64_netbsd(SB),NOSPLIT,$-8
LEAQ 8(SP), SI // argv
MOVQ 0(SP), DI // argc
MOVQ $main(SB), AX
JMP AX
TEXT main(SB),NOSPLIT,$-8
MOVQ $runtime·rt0_go(SB), AX
JMP AX
JMP _rt0_amd64(SB)
......@@ -5,11 +5,4 @@
#include "textflag.h"
TEXT _rt0_amd64_openbsd(SB),NOSPLIT,$-8
LEAQ 8(SP), SI // argv
MOVQ 0(SP), DI // argc
MOVQ $main(SB), AX
JMP AX
TEXT main(SB),NOSPLIT,$-8
MOVQ $runtime·rt0_go(SB), AX
JMP AX
JMP _rt0_amd64(SB)
......@@ -5,11 +5,4 @@
#include "textflag.h"
TEXT _rt0_amd64_solaris(SB),NOSPLIT,$-8
LEAQ 8(SP), SI // argv
MOVQ 0(SP), DI // argc
MOVQ $main(SB), AX
JMP AX
TEXT main(SB),NOSPLIT,$-8
MOVQ $runtime·rt0_go(SB), AX
JMP AX
JMP _rt0_amd64(SB)
......@@ -7,10 +7,7 @@
#include "textflag.h"
TEXT _rt0_amd64_windows(SB),NOSPLIT,$-8
LEAQ 8(SP), SI // argv
MOVQ 0(SP), DI // argc
MOVQ $main(SB), AX
JMP AX
JMP _rt0_amd64(SB)
// When building with -buildmode=(c-shared or c-archive), this
// symbol is called. For dynamic libraries it is called when the
......@@ -42,7 +39,3 @@ TEXT _rt0_amd64_windows_lib_go(SB),NOSPLIT,$0
MOVQ $0, SI
MOVQ $runtime·rt0_go(SB), 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