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