mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-18 15:18:20 +00:00
crt0 cleanup
- use the generic 'crt0.s' for Linux - move the read-only '__dso_handle' definition into the '.text' section - move the '__initial_sp' definition into the '.bss' section - remove the '_main_utcb' definition Part of #766.
This commit is contained in:
committed by
Norman Feske
parent
1b96e8a7e1
commit
c962240922
@ -19,11 +19,9 @@
|
||||
#include <linux_syscalls.h>
|
||||
|
||||
/*
|
||||
* Define 'lx_environ' pointer that is supposed to be initialized by the
|
||||
* startup code.
|
||||
* Define 'lx_environ' pointer.
|
||||
*/
|
||||
__attribute__((weak)) char **lx_environ = (char **)0;
|
||||
|
||||
char **lx_environ;
|
||||
|
||||
|
||||
/**
|
||||
@ -36,6 +34,20 @@ static inline void main_thread_bootstrap()
|
||||
{
|
||||
using namespace Genode;
|
||||
|
||||
extern Genode::addr_t *__initial_sp;
|
||||
|
||||
/*
|
||||
* Initialize the 'lx_environ' pointer
|
||||
*
|
||||
* environ = &argv[argc + 1]
|
||||
* __initial_sp[0] = argc (always 1 in Genode)
|
||||
* __initial_sp[1] = argv[0]
|
||||
* __initial_sp[2] = NULL
|
||||
* __initial_sp[3] = environ
|
||||
*
|
||||
*/
|
||||
lx_environ = (char**)&__initial_sp[3];
|
||||
|
||||
/* reserve context area */
|
||||
Genode::addr_t base = Native_config::context_area_virtual_base();
|
||||
Genode::size_t size = Native_config::context_area_virtual_size();
|
||||
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* \brief Startup code for Genode applications
|
||||
* \author Christian Helmuth
|
||||
* \author Christian Prochaska
|
||||
* \date 2006-07-06
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2006-2012 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) -------------------------*/
|
||||
.text
|
||||
|
||||
.globl _start
|
||||
_start:
|
||||
|
||||
ldr r1,=__initial_sp
|
||||
str sp,[r1]
|
||||
|
||||
/*
|
||||
* environ = &argv[argc + 1]
|
||||
* in Genode argc is always 1
|
||||
*/
|
||||
add sp,sp,#12
|
||||
ldr r1,=lx_environ
|
||||
str sp,[r1]
|
||||
|
||||
/* XXX Switch to our own stack. */
|
||||
ldr sp,=_stack_high
|
||||
|
||||
/* Clear the frame pointer and the link register so that stack backtraces will work. */
|
||||
mov fp,#0
|
||||
mov lr,#0
|
||||
|
||||
/* Jump into init C code */
|
||||
b _main
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
.data
|
||||
.globl __dso_handle
|
||||
__dso_handle:
|
||||
.long 0
|
||||
|
||||
.globl __initial_sp
|
||||
__initial_sp:
|
||||
.long 0
|
||||
|
||||
/*--- .eh_frame (exception frames) -----------------*/
|
||||
/*
|
||||
.section .eh_frame,"aw"
|
||||
.globl __EH_FRAME_BEGIN__
|
||||
__EH_FRAME_BEGIN__:
|
||||
*/
|
||||
|
||||
/*--- .bss (non-initialized data) ------------------*/
|
||||
.bss
|
||||
.p2align 4
|
||||
.globl _stack_low
|
||||
_stack_low:
|
||||
.space 64*1024
|
||||
.globl _stack_high
|
||||
_stack_high:
|
@ -1,70 +0,0 @@
|
||||
/*
|
||||
* \brief Startup code for Genode applications
|
||||
* \author Christian Helmuth
|
||||
* \date 2006-07-06
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2006-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) -------------------------*/
|
||||
.text
|
||||
|
||||
.globl _start
|
||||
_start:
|
||||
|
||||
movl %esp, __initial_sp
|
||||
/*
|
||||
* environ = &argv[argc + 1]
|
||||
* in Genode argc is always 1
|
||||
*/
|
||||
popl %eax /* argc */
|
||||
popl %eax /* argv[0] */
|
||||
popl %eax /* NULL */
|
||||
movl %esp, lx_environ
|
||||
|
||||
/* XXX Switch to our own stack. */
|
||||
movl $_stack_high,%esp
|
||||
|
||||
/* Clear the base pointer so that stack backtraces will work. */
|
||||
xorl %ebp,%ebp
|
||||
|
||||
/* Jump into init C code */
|
||||
call _main
|
||||
|
||||
/* We should never get here since _main does not return */
|
||||
1: int $3
|
||||
jmp 2f
|
||||
.ascii "_main() returned."
|
||||
2: jmp 1b
|
||||
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
.data
|
||||
.globl __dso_handle
|
||||
__dso_handle:
|
||||
.long 0
|
||||
|
||||
.globl __initial_sp
|
||||
__initial_sp:
|
||||
.long 0
|
||||
|
||||
/*--- .eh_frame (exception frames) -----------------*/
|
||||
/*
|
||||
.section .eh_frame,"aw"
|
||||
.globl __EH_FRAME_BEGIN__
|
||||
__EH_FRAME_BEGIN__:
|
||||
*/
|
||||
|
||||
/*--- .bss (non-initialized data) ------------------*/
|
||||
.bss
|
||||
.p2align 4
|
||||
.globl _stack_low
|
||||
_stack_low:
|
||||
.space 64*1024
|
||||
.globl _stack_high
|
||||
_stack_high:
|
@ -1,74 +0,0 @@
|
||||
/*
|
||||
* \brief Startup code for Genode applications
|
||||
* \author Christian Helmuth
|
||||
* \date 2006-07-06
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2006-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) -------------------------*/
|
||||
.text
|
||||
|
||||
.globl _start
|
||||
_start:
|
||||
|
||||
movq __initial_sp@GOTPCREL(%rip), %rax
|
||||
movq %rsp, (%rax)
|
||||
/*
|
||||
* environ = &argv[argc + 1]
|
||||
* in Genode argc is always 1
|
||||
*/
|
||||
popq %rax /* argc */
|
||||
popq %rax /* argv[0] */
|
||||
popq %rax /* NULL */
|
||||
movq lx_environ@GOTPCREL(%rip), %rax
|
||||
movq %rsp, (%rax)
|
||||
|
||||
/* XXX Switch to our own stack. */
|
||||
leaq _stack_high@GOTPCREL(%rip), %rax
|
||||
movq (%rax), %rsp
|
||||
|
||||
/* Clear the base pointer so that stack backtraces will work. */
|
||||
xorq %rbp,%rbp
|
||||
|
||||
/* Jump into init C code */
|
||||
callq _main
|
||||
|
||||
/* We should never get here since _main does not return */
|
||||
1: int $3
|
||||
jmp 2f
|
||||
.ascii "_main() returned."
|
||||
2: jmp 1b
|
||||
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
.data
|
||||
.p2align 8
|
||||
.globl __dso_handle
|
||||
__dso_handle:
|
||||
.quad 0
|
||||
|
||||
.globl __initial_sp
|
||||
__initial_sp:
|
||||
.quad 0
|
||||
|
||||
/*--- .eh_frame (exception frames) -----------------*/
|
||||
/*
|
||||
.section .eh_frame,"aw"
|
||||
.globl __EH_FRAME_BEGIN__
|
||||
__EH_FRAME_BEGIN__:
|
||||
*/
|
||||
|
||||
/*--- .bss (non-initialized data) ------------------*/
|
||||
.bss
|
||||
.p2align 8
|
||||
.globl _stack_low
|
||||
_stack_low:
|
||||
.space 64*1024
|
||||
.globl _stack_high
|
||||
_stack_high:
|
Reference in New Issue
Block a user