diff options
Diffstat (limited to 'src')
l--------- | src/user_bootstrap/elfload.c | 1 | ||||
l--------- | src/user_bootstrap/elfload.h | 1 | ||||
-rw-r--r-- | src/user_bootstrap/linker.ld | 6 | ||||
-rw-r--r-- | src/user_bootstrap/main.c | 16 | ||||
l--------- | src/user_bootstrap/syscall.c | 1 | ||||
l--------- | src/user_bootstrap/syscall.s | 1 |
6 files changed, 13 insertions, 13 deletions
diff --git a/src/user_bootstrap/elfload.c b/src/user_bootstrap/elfload.c deleted file mode 120000 index 75a5cb2..0000000 --- a/src/user_bootstrap/elfload.c +++ /dev/null @@ -1 +0,0 @@ -../user/lib/elfload.c
\ No newline at end of file diff --git a/src/user_bootstrap/elfload.h b/src/user_bootstrap/elfload.h deleted file mode 120000 index 5b09fdc..0000000 --- a/src/user_bootstrap/elfload.h +++ /dev/null @@ -1 +0,0 @@ -../user/lib/elfload.h
\ No newline at end of file diff --git a/src/user_bootstrap/linker.ld b/src/user_bootstrap/linker.ld index f2c9d24..917388c 100644 --- a/src/user_bootstrap/linker.ld +++ b/src/user_bootstrap/linker.ld @@ -3,6 +3,11 @@ OUTPUT_FORMAT("binary") SECTIONS { + /* Not an ELF, but we need this to link with elfreloc.c. + * Not that we need to link with it, it's just easier that way */ + _DYNAMIC = 0; + _image_base = 0; + . = 2M; .text BLOCK(4K) : ALIGN(4K) { @@ -18,6 +23,7 @@ SECTIONS *(.data) } + . = ALIGN(32); /* seems to be necessary? */ _initrd = .; /* is just appended onto the end of the binary */ . += 2M; diff --git a/src/user_bootstrap/main.c b/src/user_bootstrap/main.c index 52d7058..8fed3ce 100644 --- a/src/user_bootstrap/main.c +++ b/src/user_bootstrap/main.c @@ -1,19 +1,12 @@ #include <shared/flags.h> #include <shared/mem.h> #include <shared/syscalls.h> -#include <user_bootstrap/elfload.h> +#include <user/lib/elfload.h> extern char _bss_start; extern char _bss_end; extern char _initrd; -/* libc stubs */ -int printf(const char *fmt, ...) {(void)fmt; return 0;} -void *malloc(size_t size) {(void)size; _syscall_exit(1);} -void free(void *ptr) {(void)ptr;} -int file_read(libc_file *f, char *buf, size_t len) {(void)f; (void)buf; (void)len; _syscall_exit(1);} - - static void *tar_find(void *tar, const char *path); static int oct_parse(char *str, size_t len); @@ -26,6 +19,7 @@ static void *tar_find(void *tar, const char *path) { if (0 != memcmp(tar + off + 257, "ustar", 5)) return NULL; // not a metadata sector, end of archive + _klogf("%s", tar + off); size = oct_parse(tar + off + 124, 11); if (0 == memcmp(tar + off, path, path_len) && *(char*)(tar + off + path_len) == '\0') @@ -52,12 +46,16 @@ int main(void) { _syscall_memflag(&_bss_start, &_bss_end - &_bss_start, MEMFLAG_PRESENT); void *init = tar_find(&_initrd, "init.elf"); + if (!init) { + _klogf("couldn't find init.elf\n"); + _syscall_exit(0); + } void (*entry)(void*) = elf_partialexec(init); if (entry) { // TODO dynamically link initrd entry(&_initrd); } else { - _syscall_debug_klog("bootstrap failed", sizeof("bootstrap failed")); + _klogf("couldn't execute init.elf\n"); } _syscall_exit(0); } diff --git a/src/user_bootstrap/syscall.c b/src/user_bootstrap/syscall.c deleted file mode 120000 index c6d5b0f..0000000 --- a/src/user_bootstrap/syscall.c +++ /dev/null @@ -1 +0,0 @@ -../user/lib/syscall.c
\ No newline at end of file diff --git a/src/user_bootstrap/syscall.s b/src/user_bootstrap/syscall.s deleted file mode 120000 index ac2e0f9..0000000 --- a/src/user_bootstrap/syscall.s +++ /dev/null @@ -1 +0,0 @@ -../user/lib/syscall.s
\ No newline at end of file |