diff options
| author | hachem <im@hachem.wtf> | 2026-10-12 23:08:48 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-10-12 23:08:48 +0200 |
| commit | 6a5543bb8f1f535ca49737bcd7be0cafca3b2a08 (patch) | |
| tree | bb137b732a1d122aeace46c550733f4793d84601 /sysroot/usr/lib/libc/crt0.c | |
| parent | 59794d0b999e544a94230d9562bf2b99d2ed74c7 (diff) | |
Diffstat (limited to 'sysroot/usr/lib/libc/crt0.c')
| -rw-r--r-- | sysroot/usr/lib/libc/crt0.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/sysroot/usr/lib/libc/crt0.c b/sysroot/usr/lib/libc/crt0.c new file mode 100644 index 0000000..16c3a94 --- /dev/null +++ b/sysroot/usr/lib/libc/crt0.c @@ -0,0 +1,28 @@ +#include <stdlib.h> + +extern int main(int argc, char** argv); + +void _start(const char* arg, unsigned long arglen) +{ + static char arg_buffer[256]; + char* argv[3]; + int argc = 1; + argv[0] = ""; + + if (arglen > 0) + { + unsigned long count = arglen; + if (count > sizeof(arg_buffer) - 1) + count = sizeof(arg_buffer) - 1; + for (unsigned long i = 0; i < count; i++) + arg_buffer[i] = arg[i]; + arg_buffer[count] = 0; + argv[1] = arg_buffer; + argc = 2; + } + else + argv[1] = NULL; + + argv[argc] = NULL; + exit(main(argc, argv)); +} |
