summaryrefslogtreecommitdiff
path: root/kjarna_runtime/start_x86_64.S
diff options
context:
space:
mode:
authorAda Christine <adachristine18@gmail.com>2024-02-22 20:05:51 +0000
committerAda Christine <adachristine18@gmail.com>2024-02-22 20:05:51 +0000
commitaec58be40927ec0b2a0e6742396f880d52ce38b5 (patch)
tree5336b9966808a6d0706e7469d239d1dbc11cb3e2 /kjarna_runtime/start_x86_64.S
parente97aa65fc42f08fe666a9a21b69d05ab17231920 (diff)
kjarna runtime
Diffstat (limited to 'kjarna_runtime/start_x86_64.S')
-rw-r--r--kjarna_runtime/start_x86_64.S57
1 files changed, 57 insertions, 0 deletions
diff --git a/kjarna_runtime/start_x86_64.S b/kjarna_runtime/start_x86_64.S
new file mode 100644
index 0000000..f7725c6
--- /dev/null
+++ b/kjarna_runtime/start_x86_64.S
@@ -0,0 +1,57 @@
+#include <kc.h>
+
+.section .text.start
+
+.extern kjarna_entry
+
+.hidden _start
+.global _start
+.type _start, @function
+_start:
+ push %rbp
+ push %rdi
+ push %rsi
+ mov %rsp, %rbp
+ and $-0x10, %rsp
+ lea kc_image_base(%rip), %rdi
+ lea _DYNAMIC(%rip), %rsi
+ call kc_dynamic_init
+ mov %rbp, %rsp
+ pop %rsi
+ pop %rdi
+ mov %rsp, %rbp
+ and $-0x10, %rsp
+ call kjarna_entry
+ mov %rbp, %rsp
+ pop %rbp
+ ret
+.size _start, . - _start
+
+.section .text
+
+.hidden _rtld_link
+.global _rtld_link
+.type _rtld_link, @function
+_rtld_link:
+ push %rbp
+ mov %rsp, %rbp
+ push %rdx
+ push %rsi
+ push %rdi
+ mov 8(%rbp), %rdi
+ mov 16(%rbp), %rsi
+ push %rbp
+ mov %rsp, %rbp
+ and $-0x10, %rsp
+ call kc_dynamic_link
+ mov %rbp, %rsp
+ pop %rbp
+ pop %rdi
+ pop %rsi
+ pop %rdx
+ mov %rbp, %rsp
+ pop %rbp
+ add $0x10, %rsp
+ jmp *(%rax)
+.size _rtld_link, . - _rtld_link
+