From cadd8266b02035065559ddd27aa0b37051bf16e9 Mon Sep 17 00:00:00 2001 From: Ada Christine Date: Sat, 24 Feb 2024 00:28:22 +0000 Subject: remove dead file, rename main --- kjarna_runtime/Makefile | 2 +- kjarna_runtime/kc_main.c | 26 -------------------------- kjarna_runtime/main.c | 26 ++++++++++++++++++++++++++ kjarna_runtime/reloc_x86_64.c | 42 ------------------------------------------ 4 files changed, 27 insertions(+), 69 deletions(-) delete mode 100644 kjarna_runtime/kc_main.c create mode 100644 kjarna_runtime/main.c delete mode 100644 kjarna_runtime/reloc_x86_64.c (limited to 'kjarna_runtime') diff --git a/kjarna_runtime/Makefile b/kjarna_runtime/Makefile index 855f479..be3cd90 100644 --- a/kjarna_runtime/Makefile +++ b/kjarna_runtime/Makefile @@ -17,7 +17,7 @@ LDSCRIPT := kc.ld CRT_OBJS := start_x86_64.o dynamic_x86_64.o elf64.o LIB_OBJS := memcmp.o memcpy.o memmove.o memset.o string.o -APP_OBJS := kc_main.o +APP_OBJS := main.o OBJS := $(CRT_OBJS) $(LIB_OBJS) $(APP_OBJS) diff --git a/kjarna_runtime/kc_main.c b/kjarna_runtime/kc_main.c deleted file mode 100644 index acfcdc1..0000000 --- a/kjarna_runtime/kc_main.c +++ /dev/null @@ -1,26 +0,0 @@ -#include - -extern int write(int, void *, size_t); - -int main(int argc, char **argv) -{ - (void)argc; - (void)argv; - - write(1, "hello, runtime world!\r\n", -1); - - while (1); - - return 0; -} - -struct kjarna_entry_params *entry_params; - -int kjarna_entry(struct kjarna_entry_params *params) -{ - entry_params = params; - entry_params->interface->write(1, "hello, entry world\r\n", -1); - - return main(params->argc, params->argv); -} - diff --git a/kjarna_runtime/main.c b/kjarna_runtime/main.c new file mode 100644 index 0000000..acfcdc1 --- /dev/null +++ b/kjarna_runtime/main.c @@ -0,0 +1,26 @@ +#include + +extern int write(int, void *, size_t); + +int main(int argc, char **argv) +{ + (void)argc; + (void)argv; + + write(1, "hello, runtime world!\r\n", -1); + + while (1); + + return 0; +} + +struct kjarna_entry_params *entry_params; + +int kjarna_entry(struct kjarna_entry_params *params) +{ + entry_params = params; + entry_params->interface->write(1, "hello, entry world\r\n", -1); + + return main(params->argc, params->argv); +} + diff --git a/kjarna_runtime/reloc_x86_64.c b/kjarna_runtime/reloc_x86_64.c deleted file mode 100644 index 63dc6e7..0000000 --- a/kjarna_runtime/reloc_x86_64.c +++ /dev/null @@ -1,42 +0,0 @@ -#include - -#define STARTCODE __attribute__((section(".text.start"))) - -STARTCODE -static void do_rela(void *base, Elf64_Rela *rela) -{ - union - { - Elf_Byte word8; - Elf64_Half word16; - Elf64_Word word32; - Elf64_Xword word64; - } - *fixup; - - switch (ELF64_R_TYPE(rela->r_info)) - { - case R_X86_64_JUMP_SLOT: - fixup = (void *)(rela->r_offset + (uintptr_t)base); - fixup->word64 += (uintptr_t)base; - break; - case R_X86_64_RELATIVE: - fixup = (void *)(rela->r_offset + (uintptr_t)base); - fixup->word64 = (rela->r_addend + (uintptr_t)base); - break; - default: - break; - } -} - -STARTCODE -void kc_reloc(void *base, Elf64_Rela *entries, size_t size, size_t entsize) -{ - // perform the actual relocation - - for (size_t i = 0; entries && (i < size / entsize); i++) - { - do_rela(base, &entries[i]); - } -} - -- cgit v1.3.1-1-g115d