diff options
author | johannst <johannes.stoelp@gmail.com> | 2021-04-28 23:08:45 +0200 |
---|---|---|
committer | johannst <johannes.stoelp@gmail.com> | 2021-04-28 23:08:45 +0200 |
commit | d367355eb4c3569d422034b69737d8dc7022e13e (patch) | |
tree | f9f6768228235f4712466d65edeb0b745d904833 /04_dynld_nostd/dynld.S | |
parent | cf97ecd5b52c2f7a8953fd1674742d46fd15418a (diff) | |
parent | fc137e7d0263a0fe908ca1a150e34a9c8b9902d4 (diff) | |
download | dynld-d367355eb4c3569d422034b69737d8dc7022e13e.tar.gz dynld-d367355eb4c3569d422034b69737d8dc7022e13e.zip |
Merge branch 'dev04'
Diffstat (limited to '04_dynld_nostd/dynld.S')
-rw-r--r-- | 04_dynld_nostd/dynld.S | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/04_dynld_nostd/dynld.S b/04_dynld_nostd/dynld.S new file mode 100644 index 0000000..8a634f5 --- /dev/null +++ b/04_dynld_nostd/dynld.S @@ -0,0 +1,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 |