syscall_linux_amd64.S raw

   1  // Syscall6 for Linux amd64.
   2  //
   3  // func Syscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr)
   4  //
   5  // LLVM calling convention ({i64,i64,i64} return in registers):
   6  //   Args:    rdi=num  rsi=a1  rdx=a2  rcx=a3  r8=a4  r9=a5  [rsp+8]=a6
   7  //   Returns: rax=r1   rdx=r2  rcx=errno
   8  //
   9  // Linux syscall convention:
  10  //   rax=num  rdi=a1  rsi=a2  rdx=a3  r10=a4  r8=a5  r9=a6
  11  //   Returns: rax  (clobbers rcx, r11)
  12  
  13  .text
  14  .globl "internal/runtime/syscall.Syscall6"
  15  .type "internal/runtime/syscall.Syscall6", @function
  16  "internal/runtime/syscall.Syscall6":
  17      movq    %rdi, %rax          // num -> rax
  18      movq    %rsi, %rdi          // a1 -> rdi
  19      movq    %rdx, %rsi          // a2 -> rsi
  20      movq    %rcx, %rdx          // a3 -> rdx
  21      movq    %r8, %r10           // a4 -> r10
  22      movq    %r9, %r8            // a5 -> r8
  23      movq    8(%rsp), %r9        // a6 -> r9
  24      syscall
  25      cmpq    $-4095, %rax
  26      jb      .Lok_amd64
  27      negq    %rax
  28      movq    %rax, %rcx          // errno (positive)
  29      movq    $-1, %rax           // r1 = -1
  30      xorq    %rdx, %rdx          // r2 = 0
  31      ret
  32  .Lok_amd64:
  33      xorq    %rcx, %rcx          // errno = 0
  34      ret
  35  .size "internal/runtime/syscall.Syscall6", . - "internal/runtime/syscall.Syscall6"
  36  
  37  .section ".note.GNU-stack","",@progbits
  38