2020-01-18 05:38:21 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 05:38:21 -03:00
|
|
|
*/
|
|
|
|
|
|
2019-12-20 16:51:50 -03:00
|
|
|
#include <AK/Types.h>
|
2019-02-22 05:21:54 -03:00
|
|
|
#include <assert.h>
|
2018-10-30 22:09:11 -03:00
|
|
|
#include <stdio.h>
|
2019-02-22 05:21:54 -03:00
|
|
|
#include <stdlib.h>
|
2020-08-11 20:58:50 -03:00
|
|
|
#include <sys/internals.h>
|
|
|
|
|
#include <unistd.h>
|
2018-10-22 09:06:22 -03:00
|
|
|
|
2021-04-17 13:38:32 -03:00
|
|
|
#ifndef _DYNAMIC_LOADER
|
2019-02-15 09:30:48 -02:00
|
|
|
extern "C" {
|
|
|
|
|
|
2021-07-16 18:30:01 -03:00
|
|
|
extern size_t __stack_chk_guard;
|
2022-01-23 10:47:10 -03:00
|
|
|
extern bool s_global_initializers_ran;
|
2021-01-02 09:27:35 -03:00
|
|
|
|
2019-09-12 16:43:32 -03:00
|
|
|
int main(int, char**, char**);
|
2018-10-22 09:06:22 -03:00
|
|
|
|
2020-08-11 19:07:34 -03:00
|
|
|
// Tell the compiler that this may be called from somewhere else.
|
2021-09-05 11:08:13 -03:00
|
|
|
int _entry(int argc, char** argv, char** env) __attribute__((used));
|
|
|
|
|
void _start(int, char**, char**) __attribute__((used));
|
2020-08-11 19:07:34 -03:00
|
|
|
|
2021-07-11 10:57:56 -03:00
|
|
|
NAKED void _start(int, char**, char**)
|
|
|
|
|
{
|
|
|
|
|
asm(
|
|
|
|
|
"push $0\n"
|
|
|
|
|
"jmp _entry@plt\n");
|
|
|
|
|
}
|
2021-07-08 19:58:43 -03:00
|
|
|
|
|
|
|
|
int _entry(int argc, char** argv, char** env)
|
2018-10-22 09:06:22 -03:00
|
|
|
{
|
2019-02-21 21:55:22 -03:00
|
|
|
environ = env;
|
2019-05-16 08:04:47 -03:00
|
|
|
__environ_is_malloced = false;
|
2021-11-06 08:49:26 -03:00
|
|
|
__begin_atexit_locking();
|
2018-10-30 22:09:11 -03:00
|
|
|
|
2022-01-23 10:47:10 -03:00
|
|
|
s_global_initializers_ran = true;
|
|
|
|
|
|
2019-03-27 08:48:21 -03:00
|
|
|
_init();
|
|
|
|
|
|
2019-09-12 16:43:32 -03:00
|
|
|
int status = main(argc, argv, environ);
|
2018-10-31 13:50:43 -03:00
|
|
|
|
2019-02-22 05:21:54 -03:00
|
|
|
exit(status);
|
2018-10-22 09:06:22 -03:00
|
|
|
|
|
|
|
|
return 20150614;
|
|
|
|
|
}
|
2019-02-15 09:30:48 -02:00
|
|
|
}
|
2021-04-17 13:38:32 -03:00
|
|
|
#endif
|