summaryrefslogtreecommitdiff
path: root/src/user/lib/_start2.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/lib/_start2.c')
-rw-r--r--src/user/lib/_start2.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/user/lib/_start2.c b/src/user/lib/_start2.c
index 6d1431f..0582dde 100644
--- a/src/user/lib/_start2.c
+++ b/src/user/lib/_start2.c
@@ -1,13 +1,30 @@
#include <camellia/syscalls.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
#include <user/lib/elfload.h>
int main(int argc, char **argv, char **envp);
+__attribute__((visibility("hidden")))
+extern char _image_base[];
+
+const char *shortname(const char *path) {
+ if (!path) return "unknown program";
+ const char *slash = strrchr(path, '/');
+ if (slash) return slash + 1;
+ return path;
+}
+
_Noreturn void _start2(struct execdata *ed) {
+ const char *progname;
elf_selfreloc();
__setinitialcwd(ed->cwd);
+
+ progname = shortname(ed->argv[0]);
+ setprogname(progname);
+ _klogf("_start2 %s 0x%x", progname, _image_base);
+
exit(main(ed->argc, ed->argv, ed->envp));
}