summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/Makefile4
-rw-r--r--service/arch/x86_64/dynamic.c (renamed from service/dynamic_x86_64.c)0
-rw-r--r--service/arch/x86_64/rtld_link.S (renamed from service/start_x86_64.S)31
-rw-r--r--service/arch/x86_64/start.S30
4 files changed, 34 insertions, 31 deletions
diff --git a/service/Makefile b/service/Makefile
index d6e762d..1a4e400 100644
--- a/service/Makefile
+++ b/service/Makefile
@@ -4,7 +4,7 @@ LDFLAGS += -z max-page-size=4096 --export-dynamic -pic \
-z separate-code -pie -Bsymbolic -shared \
-z noexecstack -g
-VPATH := ../lib
+VPATH := ../lib arch/x86_64/
TARGET := kjarna.os
.DEFAULT: $(TARGET)
@@ -15,7 +15,7 @@ CFLAGS += -fPIC -fvisibility=hidden -mgeneral-regs-only
LDSCRIPT := kc.ld
-CRT_OBJS := start_x86_64.o dynamic_x86_64.o elf64.o kjarna.o
+CRT_OBJS := start.o rtld_link.o dynamic.o elf64.o kjarna.o
LIB_OBJS := memcmp.o memcpy.o memmove.o memset.o string.o stdio.o \
printf.o
APP_OBJS := main.o
diff --git a/service/dynamic_x86_64.c b/service/arch/x86_64/dynamic.c
index 02538ec..02538ec 100644
--- a/service/dynamic_x86_64.c
+++ b/service/arch/x86_64/dynamic.c
diff --git a/service/start_x86_64.S b/service/arch/x86_64/rtld_link.S
index 19db34f..7300a18 100644
--- a/service/start_x86_64.S
+++ b/service/arch/x86_64/rtld_link.S
@@ -1,34 +1,7 @@
-#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
+.extern kc_dynamic_link
+
.hidden _rtld_link
.global _rtld_link
.type _rtld_link, @function
diff --git a/service/arch/x86_64/start.S b/service/arch/x86_64/start.S
new file mode 100644
index 0000000..a9d5ada
--- /dev/null
+++ b/service/arch/x86_64/start.S
@@ -0,0 +1,30 @@
+.section .text.start
+
+.extern kc_image_base;
+.extern _DYNAMIC;
+.extern kc_dynamic_init;
+.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
+