ladybird/LibC/entry.cpp
Andreas Kling a1b63bb6d4 Bootloader: Locate the kernel's data segment and clear it.
This was a constant source of stupid bugs and I kept postponing it because
I wasn't in the mood to write assembly code. Until now! :^)
2019-02-06 16:02:10 +01:00

40 lines
706 B
C++

#include <stdio.h>
#include <string.h>
#include <Kernel/Syscall.h>
#include <AK/StringImpl.h>
extern "C" int main(int, char**);
int errno;
char** environ;
extern "C" void __malloc_init();
extern "C" void __stdio_init();
extern "C" int _start()
{
errno = 0;
__stdio_init();
__malloc_init();
int status = 254;
int argc;
char** argv;
int rc = syscall(SC_get_arguments, &argc, &argv);
if (rc < 0)
goto epilogue;
rc = syscall(SC_get_environment, &environ);
if (rc < 0)
goto epilogue;
status = main(argc, argv);
fflush(stdout);
fflush(stderr);
epilogue:
syscall(SC_exit, status);
// Birger's birthday <3
return 20150614;
}