0b64328944
For a main thread a thread object is created by the CRT0 before _main gets called so that _main can already run in a generic environment that, e.g., catches stack overflows as a page-fault instead of corrupting the BSS. Additionally dynamic programs have only one CRT0 - the one of the LDSO - which does the initialization for both LDSO and program. ref #989
52 lines
1.1 KiB
ArmAsm
52 lines
1.1 KiB
ArmAsm
/**
|
|
* \brief Startup code for Genode applications on ARM
|
|
* \author Norman Feske
|
|
* \author Martin Stein
|
|
* \date 2007-04-28
|
|
*/
|
|
|
|
/*
|
|
* Copyright (C) 2007-2013 Genode Labs GmbH
|
|
*
|
|
* This file is part of the Genode OS framework, which is distributed
|
|
* under the terms of the GNU General Public License version 2.
|
|
*/
|
|
|
|
|
|
/**************************
|
|
** .text (program code) **
|
|
**************************/
|
|
|
|
.section ".text.crt0"
|
|
|
|
/* linker entry-point */
|
|
.globl _start_ldso
|
|
_start_ldso:
|
|
|
|
/* make initial value of some registers available to higher-level code */
|
|
ldr r2, =__initial_sp
|
|
str sp, [r2]
|
|
|
|
/*
|
|
* Install initial temporary environment that is replaced later by the
|
|
* environment that init_main_thread creates.
|
|
*/
|
|
ldr sp, =_stack_high
|
|
|
|
/* let init_rtld relocate linker */
|
|
bl init_rtld
|
|
|
|
/* create proper environment for the main thread */
|
|
bl init_main_thread
|
|
|
|
/* apply environment that was created by init_main_thread */
|
|
ldr sp, =init_main_thread_result
|
|
ldr sp, [sp]
|
|
|
|
/* call init C code */
|
|
bl _main
|
|
|
|
/* this should never be reached since _main should never return */
|
|
_catch_main_return:
|
|
b _catch_main_return
|