snapkitty
hardware
x86-64-asm
snapkitty-twin-mars-asm / asm /bootstrap.asm
SNAPKITTYWEST's picture
push from SNAPKITTYWEST/snapkitty-twin-mars-asm
42fb483 verified
Raw History Blame Contribute Delete
522 Bytes
; bootstrap.asm — _start: parse argc/argv/envp, call main, exit
; OBSERVED: ELF64 entry point, System V AMD64 ABI stack layout
%include "include/syscall.inc"
section .text
global _start
extern main
_start:
; On entry: rsp -> argc, rsp+8 -> argv[0], ...
pop rdi ; argc
mov rsi, rsp ; argv
lea rdx, [rsp + rdi*8 + 8] ; envp
; Align stack to 16 bytes before call
and rsp, ~0xF
sub rsp, 8
call main
; exit(rax)
mov rdi, rax
mov rax, SYS_EXIT_GROUP
syscall