forked from SerenityOS/serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
crt0.cpp
50 lines (38 loc) · 965 Bytes
/
crt0.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* 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" {
extern size_t __stack_chk_guard;
extern bool s_global_initializers_ran;
int main(int, char**, char**);
// Tell the compiler that this may be called from somewhere else.
int _entry(int argc, char** argv, char** env) __attribute__((used));
void _start(int, char**, char**) __attribute__((used));
NAKED void _start(int, char**, char**)
{
asm(
"push $0\n"
"jmp _entry@plt\n");
}
int _entry(int argc, char** argv, char** env)
{
environ = env;
__environ_is_malloced = false;
__begin_atexit_locking();
s_global_initializers_ran = true;
_init();
int status = main(argc, argv, environ);
exit(status);
return 20150614;
}
}
#endif