diff options
author | dzwdz | 2022-07-26 00:14:30 +0200 |
---|---|---|
committer | dzwdz | 2022-07-26 00:14:30 +0200 |
commit | 8c977b5cea3f2e76205bd0ed666db06a84e05f6a (patch) | |
tree | 01c0bd1ffd0afe82604fa949020b929a9d41cfdb /src/user_bootstrap/main.c | |
parent | 4e4496e993942fc5361f2e4ab23798ea6a4d78b9 (diff) |
user_bootstrap: link against user/lib
I have no idea why I didn't do this right from the start, it makes
this whole thing much easier.
Diffstat (limited to 'src/user_bootstrap/main.c')
-rw-r--r-- | src/user_bootstrap/main.c | 16 |
1 files changed, 7 insertions, 9 deletions
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); } |