Serenity Operating System
at master 55 lines 1.0 kB view raw
1/* 2 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#include <AK/Types.h> 8#include <assert.h> 9#include <stdio.h> 10#include <stdlib.h> 11#include <sys/internals.h> 12#include <unistd.h> 13 14#ifndef _DYNAMIC_LOADER 15extern "C" { 16 17extern uintptr_t __stack_chk_guard; 18extern bool s_global_initializers_ran; 19 20int main(int, char**, char**); 21 22// Tell the compiler that this may be called from somewhere else. 23int _entry(int argc, char** argv, char** env) __attribute__((used)); 24void _start(int, char**, char**) __attribute__((used)); 25 26NAKED void _start(int, char**, char**) 27{ 28# ifdef AK_ARCH_AARCH64 29 asm( 30 "bl _entry\n"); 31# else 32 asm( 33 "push $0\n" 34 "jmp _entry@plt\n"); 35# endif 36} 37 38int _entry(int argc, char** argv, char** env) 39{ 40 environ = env; 41 __environ_is_malloced = false; 42 __begin_atexit_locking(); 43 44 s_global_initializers_ran = true; 45 46 _init(); 47 48 int status = main(argc, argv, environ); 49 50 exit(status); 51 52 return 20150614; 53} 54} 55#endif