blob: 8a634f52271d033f719a16674a41dba17a09634d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
// Copyright (c) 2020 Johannes Stoelp
#include <asm/unistd.h>
.intel_syntax noprefix
.section .text, "ax", @progbits
.global dl_start
dl_start:
// $rsp is guaranteed to be 16-byte aligned.
// Clear $rbp as specified by the SysV AMD64 ABI.
xor rbp, rbp
// Load pointer to process context prepared by execve(2) syscall as
// specified in the SysV AMD64 ABI.
// Save pointer in $rdi which is the arg0 (int/ptr) register.
lea rdi, [rsp]
// Stack frames must be 16-byte aligned before control is transfered to the
// callees entry point.
call dl_entry
// Call exit(1) syscall to indicate error, dl_entry should not return.
mov rdi, 1
mov rax, __NR_exit
syscall
|