-
Notifications
You must be signed in to change notification settings - Fork 3
/
start.S
49 lines (44 loc) · 1.59 KB
/
start.S
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# APInject
# Copyright (C) 2022 Alexander Pick
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# yes I do horrible things
.intel_syntax noprefix
# This is x86-64 code!
.text
.global _entry_point # create global symbol
.type _entry_point, @function # created symbol is a function
# main: %rdi x
# argc: %rsi
# argv: %rdx
# init: %rcx
# fini: %r8
# rtld_fini: %r9
# stack_end: stack
_entry_point:
xor ebp, ebp
mov r9, rdx # set rtld_fini
pop rsi
and rsp,0xFFFFFFFFFFFFFFF0 # proper align stack
push rax
push rsp
mov rdi, launcher@GOTPCREL[rip] # handing launcher() as main, otherwise older gcc will build a segfaulting binary
mov rdx, 0
mov r8, 0
mov rcx, 0
mov rax, __libc_start_main@GOTPCREL[rip] # calling __libc_start_main
call rax
mov rax, 1 # exit(0), just in case, should never return here
mov rbx, 0
int 0x80