x86_64.S (806B)
1 # Syscall numbers https://www.chromium.org/chromium-os/developer-library/reference/linux-constants/syscalls/#x86_64-64-bit 2 3 #include "NR_x86_64.h" 4 5 .intel_syntax noprefix 6 7 .global start 8 9 .text 10 11 start: # start is the entry point known to the linker 12 mov edi, [rsp] # get argc from the stack 13 lea rsi, [rsp+8] # take the address of argv from the stack 14 lea rdx, [rsp+16] # take the address of envp from the stack 15 call main # %edi, %rsi, %rdx are the three args (of which first two are C standard) to main 16 mov rdi, rax 17 jmp exit 18 19 .macro extern_alias, name 20 .global \name 21 \name: 22 .endm 23 24 .macro extern, name 25 .section .text.\name 26 extern_alias \name 27 .endm 28 29 .macro _syscall, num, impl 30 mov rax, \num 31 push r11 32 mov r10, rcx 33 syscall 34 pop r11 35 ret 36 .endm 37 38 #define SYS(x) _syscall __NR_##x 39 40 #include "syscalls.h"