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:
parent
1b96e8a7e1
commit
c962240922
|
@ -1,5 +0,0 @@
|
||||||
LIBS += syscall
|
|
||||||
|
|
||||||
include $(BASE_DIR)/lib/mk/startup.inc
|
|
||||||
|
|
||||||
vpath crt0.s $(REP_DIR)/src/platform/arm
|
|
|
@ -1,5 +0,0 @@
|
||||||
LIBS += syscall
|
|
||||||
|
|
||||||
include $(BASE_DIR)/lib/mk/startup.inc
|
|
||||||
|
|
||||||
vpath crt0.s $(REP_DIR)/src/platform/x86_32
|
|
|
@ -1,5 +0,0 @@
|
||||||
LIBS += syscall
|
|
||||||
|
|
||||||
include $(BASE_DIR)/lib/mk/startup.inc
|
|
||||||
|
|
||||||
vpath crt0.s $(REP_DIR)/src/platform/x86_64
|
|
|
@ -19,11 +19,9 @@
|
||||||
#include <linux_syscalls.h>
|
#include <linux_syscalls.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Define 'lx_environ' pointer that is supposed to be initialized by the
|
* Define 'lx_environ' pointer.
|
||||||
* startup code.
|
|
||||||
*/
|
*/
|
||||||
__attribute__((weak)) char **lx_environ = (char **)0;
|
char **lx_environ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,6 +34,20 @@ static inline void main_thread_bootstrap()
|
||||||
{
|
{
|
||||||
using namespace Genode;
|
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 */
|
/* reserve context area */
|
||||||
Genode::addr_t base = Native_config::context_area_virtual_base();
|
Genode::addr_t base = Native_config::context_area_virtual_base();
|
||||||
Genode::size_t size = Native_config::context_area_virtual_size();
|
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:
|
|
|
@ -3,4 +3,6 @@ SRC_CC += _main.cc
|
||||||
|
|
||||||
REP_INC_DIR += src/platform
|
REP_INC_DIR += src/platform
|
||||||
|
|
||||||
|
LIBS += syscall
|
||||||
|
|
||||||
vpath _main.cc $(BASE_DIR)/src/platform
|
vpath _main.cc $(BASE_DIR)/src/platform
|
||||||
|
|
|
@ -26,15 +26,8 @@ _start:
|
||||||
.initial_sp: .word __initial_sp
|
.initial_sp: .word __initial_sp
|
||||||
.stack_high: .word _stack_high
|
.stack_high: .word _stack_high
|
||||||
|
|
||||||
/*--------------------------------------------------*/
|
|
||||||
.data
|
|
||||||
.globl __dso_handle
|
.globl __dso_handle
|
||||||
__dso_handle:
|
__dso_handle: .long 0
|
||||||
.long 0
|
|
||||||
|
|
||||||
.globl __initial_sp
|
|
||||||
__initial_sp:
|
|
||||||
.long 0
|
|
||||||
|
|
||||||
/*--- .bss (non-initialized data) ------------------*/
|
/*--- .bss (non-initialized data) ------------------*/
|
||||||
.section ".bss"
|
.section ".bss"
|
||||||
|
@ -46,10 +39,6 @@ _stack_low:
|
||||||
.globl _stack_high
|
.globl _stack_high
|
||||||
_stack_high:
|
_stack_high:
|
||||||
|
|
||||||
/*
|
/* initial value of the SP register */
|
||||||
* Symbol referenced by ldso's crt0.s, which is needed by base-hw only.
|
.globl __initial_sp
|
||||||
* It is defined here merely to resolve the symbol for non-base-hw
|
__initial_sp: .space 4
|
||||||
* platforms.
|
|
||||||
*/
|
|
||||||
.globl _main_utcb
|
|
||||||
_main_utcb: .long 0
|
|
||||||
|
|
|
@ -33,16 +33,8 @@ _start:
|
||||||
.ascii "_main() returned."
|
.ascii "_main() returned."
|
||||||
2: jmp 1b
|
2: jmp 1b
|
||||||
|
|
||||||
|
|
||||||
/*--------------------------------------------------*/
|
|
||||||
.data
|
|
||||||
.globl __dso_handle
|
.globl __dso_handle
|
||||||
__dso_handle:
|
__dso_handle: .long 0
|
||||||
.long 0
|
|
||||||
|
|
||||||
.globl __initial_sp
|
|
||||||
__initial_sp:
|
|
||||||
.long 0
|
|
||||||
|
|
||||||
/*--- .eh_frame (exception frames) -----------------*/
|
/*--- .eh_frame (exception frames) -----------------*/
|
||||||
/*
|
/*
|
||||||
|
@ -59,3 +51,7 @@ _stack_low:
|
||||||
.space 64*1024
|
.space 64*1024
|
||||||
.global _stack_high
|
.global _stack_high
|
||||||
_stack_high:
|
_stack_high:
|
||||||
|
|
||||||
|
/* initial value of the ESP register */
|
||||||
|
.globl __initial_sp
|
||||||
|
__initial_sp: .space 4
|
||||||
|
|
|
@ -36,17 +36,8 @@ _start:
|
||||||
.ascii "_main() returned."
|
.ascii "_main() returned."
|
||||||
2: jmp 1b
|
2: jmp 1b
|
||||||
|
|
||||||
|
|
||||||
/*--------------------------------------------------*/
|
|
||||||
.data
|
|
||||||
.p2align 8
|
|
||||||
.globl __dso_handle
|
.globl __dso_handle
|
||||||
__dso_handle:
|
__dso_handle: .quad 0
|
||||||
.quad 0
|
|
||||||
|
|
||||||
.globl __initial_sp
|
|
||||||
__initial_sp:
|
|
||||||
.quad 0
|
|
||||||
|
|
||||||
/*--- .eh_frame (exception frames) -----------------*/
|
/*--- .eh_frame (exception frames) -----------------*/
|
||||||
/*
|
/*
|
||||||
|
@ -63,3 +54,7 @@ _stack_low:
|
||||||
.space 64*1024
|
.space 64*1024
|
||||||
.global _stack_high
|
.global _stack_high
|
||||||
_stack_high:
|
_stack_high:
|
||||||
|
|
||||||
|
/* initial value of the RSP register */
|
||||||
|
.globl __initial_sp
|
||||||
|
__initial_sp: .space 8
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
SRC_S = crt0.s
|
|
||||||
|
|
||||||
vpath crt0.s $(REP_DIR)/src/lib/ldso/arm/linux
|
|
|
@ -1,6 +1,6 @@
|
||||||
SRC_CC = parent_cap.cc binary_name.cc
|
SRC_CC = parent_cap.cc binary_name.cc
|
||||||
|
|
||||||
LIBS = ldso_crt0_lx
|
LIBS = ldso_crt0
|
||||||
|
|
||||||
vpath parent_cap.cc $(REP_DIR)/src/lib/ldso/arch/linux
|
vpath parent_cap.cc $(REP_DIR)/src/lib/ldso/arch/linux
|
||||||
vpath binary_name.cc $(REP_DIR)/src/lib/ldso/arch/linux
|
vpath binary_name.cc $(REP_DIR)/src/lib/ldso/arch/linux
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
SRC_S = crt0.s
|
|
||||||
|
|
||||||
vpath crt0.s $(REP_DIR)/src/lib/ldso/x86_32/linux/
|
|
|
@ -1,3 +0,0 @@
|
||||||
SRC_S = crt0.s
|
|
||||||
|
|
||||||
vpath crt0.s $(REP_DIR)/src/lib/ldso/x86_64/linux/
|
|
|
@ -17,9 +17,6 @@
|
||||||
.globl _start_ldso
|
.globl _start_ldso
|
||||||
_start_ldso:
|
_start_ldso:
|
||||||
|
|
||||||
ldr r2, .initial_utcb
|
|
||||||
str r0, [r2]
|
|
||||||
|
|
||||||
ldr r2, .initial_sp
|
ldr r2, .initial_sp
|
||||||
str sp, [r2]
|
str sp, [r2]
|
||||||
|
|
||||||
|
@ -29,5 +26,4 @@ _start_ldso:
|
||||||
|
|
||||||
.initial_sp: .word __initial_sp
|
.initial_sp: .word __initial_sp
|
||||||
.stack_high: .word _stack_high
|
.stack_high: .word _stack_high
|
||||||
.initial_utcb: .word _main_utcb
|
|
||||||
|
|
||||||
|
|
|
@ -1,58 +0,0 @@
|
||||||
/*
|
|
||||||
* \brief Startup code for ld.lib.so (linux_arm)
|
|
||||||
* \author Christian Prochaska
|
|
||||||
* \date 2012-07-06
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) 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) -------------------------*/
|
|
||||||
.section ".text.crt0"
|
|
||||||
|
|
||||||
.globl _start_ldso
|
|
||||||
_start_ldso:
|
|
||||||
|
|
||||||
ldr sl, .L_GOT
|
|
||||||
.L_GOT_OFF:
|
|
||||||
add sl, pc, sl
|
|
||||||
|
|
||||||
ldr r1, .initial_sp
|
|
||||||
ldr r1, [sl, r1]
|
|
||||||
str sp, [r1]
|
|
||||||
|
|
||||||
/*
|
|
||||||
* environ = &argv[argc + 1]
|
|
||||||
* in Genode argc is always 1
|
|
||||||
*/
|
|
||||||
add sp, sp,#12
|
|
||||||
ldr r1, .lx_environ
|
|
||||||
ldr r1, [sl, r1]
|
|
||||||
str sp, [r1]
|
|
||||||
|
|
||||||
/* XXX Switch to our own stack. */
|
|
||||||
ldr r1, .stack_high
|
|
||||||
ldr sp, [sl, r1]
|
|
||||||
|
|
||||||
/* relocate ldso */
|
|
||||||
mov r1, #0
|
|
||||||
bl init_rtld
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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
|
|
||||||
|
|
||||||
.L_GOT: .word _GLOBAL_OFFSET_TABLE_ - (.L_GOT_OFF + 8)
|
|
||||||
.initial_sp: .word __initial_sp(GOT)
|
|
||||||
.lx_environ: .word lx_environ(GOT)
|
|
||||||
.stack_high: .word _stack_high(GOT)
|
|
|
@ -13,7 +13,7 @@
|
||||||
#ifndef _ARM__CALL_MAIN_H_
|
#ifndef _ARM__CALL_MAIN_H_
|
||||||
#define _ARM__CALL_MAIN_H_
|
#define _ARM__CALL_MAIN_H_
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restore SP from initial sp and jump to entry function
|
* Restore SP from initial sp and jump to entry function
|
||||||
*/
|
*/
|
||||||
void call_main(void (*func)(void))
|
void call_main(void (*func)(void))
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#ifndef _X86_32__CALL_MAIN_H_
|
#ifndef _X86_32__CALL_MAIN_H_
|
||||||
#define _X86_32__CALL_MAIN_H_
|
#define _X86_32__CALL_MAIN_H_
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restore SP from initial sp and jump to entry function
|
* Restore SP from initial sp and jump to entry function
|
||||||
*/
|
*/
|
||||||
void call_main(void (*func)(void))
|
void call_main(void (*func)(void))
|
||||||
|
|
|
@ -88,6 +88,8 @@ int main(int argc, char **argv)
|
||||||
void *sp = setup_stack(binary, (long)fd);
|
void *sp = setup_stack(binary, (long)fd);
|
||||||
|
|
||||||
printf("Starting ldso ...\n");
|
printf("Starting ldso ...\n");
|
||||||
|
|
||||||
|
/* this is usually '_start' */
|
||||||
func_ptr_type main_func = _rtld(sp, &exit_proc, &objp);
|
func_ptr_type main_func = _rtld(sp, &exit_proc, &objp);
|
||||||
|
|
||||||
/* DEBUGGING
|
/* DEBUGGING
|
||||||
|
|
|
@ -1,54 +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_ldso
|
|
||||||
_start_ldso:
|
|
||||||
|
|
||||||
/* set global offset table the taditional way */
|
|
||||||
call 3f
|
|
||||||
3:
|
|
||||||
popl %ebx;
|
|
||||||
addl $_GLOBAL_OFFSET_TABLE_+ (. - 3b), %ebx
|
|
||||||
|
|
||||||
movl %esp, __initial_sp@GOTOFF(%ebx)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* environ = &argv[argc + 1]
|
|
||||||
* in Genode argc is always 1
|
|
||||||
*/
|
|
||||||
popl %eax /* argc */
|
|
||||||
popl %eax /* argv[0] */
|
|
||||||
popl %eax /* NULL */
|
|
||||||
movl %esp, lx_environ@GOTOFF(%ebx)
|
|
||||||
|
|
||||||
/* XXX Switch to our own stack. */
|
|
||||||
leal _stack_high@GOTOFF(%ebx), %esp
|
|
||||||
|
|
||||||
/* relocate ldso */
|
|
||||||
call init_rtld
|
|
||||||
|
|
||||||
/* 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
|
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
/*
|
|
||||||
* \brief Startup code for ldso 64Bit-Linux version
|
|
||||||
* \author Christian Helmuth
|
|
||||||
* \author Sebastian Sumpf
|
|
||||||
* \date 2011-05-10
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2011-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_ldso
|
|
||||||
_start_ldso:
|
|
||||||
|
|
||||||
/* initialize GLOBAL OFFSET TABLE */
|
|
||||||
leaq _GLOBAL_OFFSET_TABLE_(%rip),%r15
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
call init_rtld
|
|
||||||
|
|
||||||
/* Clear the base pointer so that stack backtraces will work. */
|
|
||||||
xorq %rbp,%rbp
|
|
||||||
|
|
||||||
/* 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
|
|
Loading…
Reference in New Issue