ldso: use generic CRT0 files

Issue #1042
This commit is contained in:
Martin Stein 2014-02-05 15:15:39 +01:00 committed by Norman Feske
parent 324af5d769
commit 8d21064b5e
15 changed files with 12 additions and 206 deletions

View File

@ -33,6 +33,9 @@
*/
ldr sp, =_stack_high
/* if this is the dynamic linker, init_rtld relocates the linker */
bl init_rtld
/* create proper environment for main thread */
bl init_main_thread

View File

@ -34,6 +34,9 @@
*/
leal _stack_high, %esp
/* if this is the dynamic linker, init_rtld relocates the linker */
call init_rtld
/* create proper environment for the main thread */
call init_main_thread

View File

@ -38,6 +38,9 @@
leaq _stack_high@GOTPCREL(%rip),%rax
movq (%rax), %rsp
/* if this is the dynamic linker, init_rtld relocates the linker */
call init_rtld
/* create proper environment for the main thread */
call init_main_thread

View File

@ -1,3 +0,0 @@
SRC_S = crt0.s
vpath crt0.s $(REP_DIR)/src/lib/ldso/arm

View File

@ -1,6 +1,6 @@
SRC_CC = parent_cap.cc binary_name.cc
SRC_C = dummy.c
LIBS = ldso_crt0 syscall
LIBS = syscall
vpath parent_cap.cc $(REP_DIR)/src/lib/ldso/arch
vpath binary_name.cc $(REP_DIR)/src/lib/ldso/arch

View File

@ -1,5 +1,4 @@
SRC_CC = parent_cap.cc binary_name.cc
LIBS = ldso_crt0
vpath parent_cap.cc $(REP_DIR)/src/lib/ldso/arch
vpath binary_name.cc $(REP_DIR)/src/lib/ldso/arch

View File

@ -1,6 +1,4 @@
SRC_CC = parent_cap.cc binary_name.cc
LIBS = ldso_crt0
vpath parent_cap.cc $(REP_DIR)/src/lib/ldso/arch/linux
vpath binary_name.cc $(REP_DIR)/src/lib/ldso/arch/linux

View File

@ -1,5 +1,4 @@
SRC_CC = parent_cap.cc binary_name.cc
LIBS = ldso_crt0
vpath parent_cap.cc $(REP_DIR)/src/lib/ldso/arch/nova
vpath binary_name.cc $(REP_DIR)/src/lib/ldso/arch

View File

@ -1,5 +1,5 @@
SRC_CC = parent_cap.cc binary_name.cc
LIBS = ldso_crt0 l4
LIBS = l4
vpath parent_cap.cc $(REP_DIR)/src/lib/ldso/arch
vpath binary_name.cc $(REP_DIR)/src/lib/ldso/arch

View File

@ -1,3 +0,0 @@
SRC_S = crt0.s
vpath crt0.s $(REP_DIR)/src/lib/ldso/x86_32/

View File

@ -1,3 +0,0 @@
SRC_S = crt0.s
vpath crt0.s $(REP_DIR)/src/lib/ldso/x86_64/

View File

@ -1,51 +0,0 @@
/**
* \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

View File

@ -33,7 +33,7 @@ else
LINK_ADDRESS = 0x30000
endif
ENTRY_POINT = _start_ldso
ENTRY_POINT = _start
D_OPTS += IN_RTLD __BSD_VISIBLE=1 LINK_ADDRESS=$(LINK_ADDRESS) $(RENAME_FUNCS)
D_OPTS += $(if $(DEBUG),DEBUG,)

View File

@ -1,72 +0,0 @@
/**
* \brief Startup code for ld.lib.so (x86-32)
* \author Christian Helmuth
* \author Sebastian Sumpf
* \author Martin Stein
* \date 2011-05-03
*/
/*
* 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
/* linker entry-point */
.global _start_ldso
_start_ldso:
/*
* Initialize GOT pointer in EBX.
*
* The follwing statement causes a text relocation which will be ignored
* by ldso itself, this is necessary since we don't have a valid stack
* pointer at this moment so a 'call' in order to retrieve our IP and thus
* calculate the GOT-position in the traditional manner is not possible on
* x86.
*/
3:
movl $., %ebx
addl $_GLOBAL_OFFSET_TABLE_ + (. - 3b) , %ebx
/* make initial value of some registers available to higher-level code */
movl %esp, __initial_sp@GOTOFF(%ebx)
movl %eax, __initial_ax@GOTOFF(%ebx)
movl %edi, __initial_di@GOTOFF(%ebx)
/*
* Install initial temporary environment that is replaced later by the
* environment that init_main_thread creates.
*/
leal _stack_high@GOTOFF(%ebx), %esp
/* let init_rtld relocate LDSO */
call init_rtld
/* create proper environment for the main thread */
call init_main_thread
/* apply environment that was created by init_main_thread */
movl init_main_thread_result, %esp
/* clear the base pointer so that stack backtraces will work */
xor %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

View File

@ -1,67 +0,0 @@
/*
* \brief Startup code for ldso 64Bit version
* \author Christian Helmuth
* \author Sebastian Sumpf
* \author Martin Stein
* \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
/* linker entry-point */
.globl _start_ldso
_start_ldso:
/* initialize global offset table */
leaq _GLOBAL_OFFSET_TABLE_(%rip),%r15
/* make initial value of some registers available to higher-level code */
movq __initial_ax@GOTPCREL(%rip), %rbx
movq %rax, (%rbx)
movq __initial_di@GOTPCREL(%rip), %rbx
movq %rdi, (%rbx)
movq __initial_sp@GOTPCREL(%rip), %rax
movq %rsp, (%rax)
/*
* Install initial temporary environment that is replaced later by the
* environment that init_main_thread creates.
*/
leaq _stack_high@GOTPCREL(%rip),%rax
movq (%rax), %rsp
/* let init_rtld relocate LDSO */
call init_rtld
/* create proper environment for the main thread */
call init_main_thread
/* apply environment that was created by init_main_thread */
movq init_main_thread_result@GOTPCREL(%rip), %rax
movq (%rax), %rsp
/* 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