...

Text file src/runtime/cgo/gcc_amd64.S

Documentation: runtime/cgo

		 1// Copyright 2009 The Go Authors. All rights reserved.
		 2// Use of this source code is governed by a BSD-style
		 3// license that can be found in the LICENSE file.
		 4
		 5/*
		 6 * Apple still insists on underscore prefixes for C function names.
		 7 */
		 8#if defined(__APPLE__)
		 9#define EXT(s) _##s
		10#else
		11#define EXT(s) s
		12#endif
		13
		14/*
		15 * void crosscall_amd64(void (*fn)(void))
		16 *
		17 * Calling into the 6c tool chain, where all registers are caller save.
		18 * Called from standard x86-64 ABI, where %rbx, %rbp, %r12-%r15
		19 * are callee-save so they must be saved explicitly.
		20 * The standard x86-64 ABI passes the three arguments m, g, fn
		21 * in %rdi, %rsi, %rdx.
		22 */
		23.globl EXT(crosscall_amd64)
		24EXT(crosscall_amd64):
		25	pushq %rbx
		26	pushq %rbp
		27	pushq %r12
		28	pushq %r13
		29	pushq %r14
		30	pushq %r15
		31
		32#if defined(_WIN64)
		33	movq %r8, %rdi	/* arg of setg_gcc */
		34	call *%rdx	/* setg_gcc */
		35	call *%rcx	/* fn */
		36#else
		37	movq %rdi, %rbx
		38	movq %rdx, %rdi	/* arg of setg_gcc */
		39	call *%rsi	/* setg_gcc */
		40	call *%rbx	/* fn */
		41#endif
		42
		43	popq %r15
		44	popq %r14
		45	popq %r13
		46	popq %r12
		47	popq %rbp
		48	popq %rbx
		49	ret
		50
		51#ifdef __ELF__
		52.section .note.GNU-stack,"",@progbits
		53#endif

View as plain text