github.com/ader1990/go@v0.0.0-20140630135419-8c24447fa791/src/pkg/runtime/cgo/gcc_amd64.S (about)

     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)
    24  EXT(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  	call *%rcx	/* fn */
    34  #else
    35  	call *%rdi	/* fn */
    36  #endif
    37  
    38  	popq %r15
    39  	popq %r14
    40  	popq %r13
    41  	popq %r12
    42  	popq %rbp
    43  	popq %rbx
    44  	ret
    45  
    46  #ifdef __ELF__
    47  .section .note.GNU-stack,"",@progbits
    48  #endif