1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 07:44:59 +00:00
serenity/Userland/Libraries/LibC/crt0.cpp
Sönke Holz e7c8ff3839 LibC: Clean up crt0
We already set these variables and call `_init` in the dynamic linker.
As we don't care about static binaries, remove these assignments and the
call to `_init` from `_entry`.

The function referenced by DT_INIT is also not necessarily called
`_init`, so directly calling `_init` is not really correct.

`s_global_initializers_ran` and `__stack_chk_guard` are unused, so
remove them.
2023-10-12 15:20:50 +02:00

48 lines
883 B
C++

/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/Types.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/internals.h>
#include <unistd.h>
#ifndef _DYNAMIC_LOADER
extern "C" {
int main(int, char**, char**);
// Tell the compiler that this may be called from somewhere else.
int _entry(int argc, char** argv) __attribute__((used));
void _start(int, char**, char**) __attribute__((used));
NAKED void _start(int, char**, char**)
{
# if ARCH(AARCH64)
asm(
"mov x29, 0\n"
"mov x30, 0\n"
"bl _entry\n");
# else
asm(
"push $0\n"
"jmp _entry@plt\n");
# endif
}
int _entry(int argc, char** argv)
{
__begin_atexit_locking();
int status = main(argc, argv, environ);
exit(status);
return 20150614;
}
}
#endif