diff --git a/base/src/platform/arm/crt0.s b/base/src/platform/arm/crt0.s index 1c05769a1f..0c211993c9 100644 --- a/base/src/platform/arm/crt0.s +++ b/base/src/platform/arm/crt0.s @@ -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 diff --git a/base/src/platform/x86_32/crt0.s b/base/src/platform/x86_32/crt0.s index cc5530f9a9..35986d9a8b 100644 --- a/base/src/platform/x86_32/crt0.s +++ b/base/src/platform/x86_32/crt0.s @@ -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 diff --git a/base/src/platform/x86_64/crt0.s b/base/src/platform/x86_64/crt0.s index 4412be3233..c193df2269 100644 --- a/base/src/platform/x86_64/crt0.s +++ b/base/src/platform/x86_64/crt0.s @@ -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 diff --git a/os/lib/mk/arm/ldso_crt0.mk b/os/lib/mk/arm/ldso_crt0.mk deleted file mode 100644 index 5ced36b483..0000000000 --- a/os/lib/mk/arm/ldso_crt0.mk +++ /dev/null @@ -1,3 +0,0 @@ -SRC_S = crt0.s - -vpath crt0.s $(REP_DIR)/src/lib/ldso/arm diff --git a/os/lib/mk/codezero/ldso-arch.mk b/os/lib/mk/codezero/ldso-arch.mk index 1a4e9e0719..a805b3d313 100644 --- a/os/lib/mk/codezero/ldso-arch.mk +++ b/os/lib/mk/codezero/ldso-arch.mk @@ -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 diff --git a/os/lib/mk/ldso-arch.mk b/os/lib/mk/ldso-arch.mk index 27fb5894bc..217ff2423c 100644 --- a/os/lib/mk/ldso-arch.mk +++ b/os/lib/mk/ldso-arch.mk @@ -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 diff --git a/os/lib/mk/linux/ldso-arch.mk b/os/lib/mk/linux/ldso-arch.mk index 862721c229..223dea4ab7 100644 --- a/os/lib/mk/linux/ldso-arch.mk +++ b/os/lib/mk/linux/ldso-arch.mk @@ -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 diff --git a/os/lib/mk/nova/ldso-arch.mk b/os/lib/mk/nova/ldso-arch.mk index e32fe85aa6..f452b270df 100644 --- a/os/lib/mk/nova/ldso-arch.mk +++ b/os/lib/mk/nova/ldso-arch.mk @@ -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 diff --git a/os/lib/mk/pistachio/ldso-arch.mk b/os/lib/mk/pistachio/ldso-arch.mk index 723cdf6a9b..2e9b9f0c13 100644 --- a/os/lib/mk/pistachio/ldso-arch.mk +++ b/os/lib/mk/pistachio/ldso-arch.mk @@ -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 diff --git a/os/lib/mk/x86_32/ldso_crt0.mk b/os/lib/mk/x86_32/ldso_crt0.mk deleted file mode 100644 index 4ba8cbcfde..0000000000 --- a/os/lib/mk/x86_32/ldso_crt0.mk +++ /dev/null @@ -1,3 +0,0 @@ -SRC_S = crt0.s - -vpath crt0.s $(REP_DIR)/src/lib/ldso/x86_32/ diff --git a/os/lib/mk/x86_64/ldso_crt0.mk b/os/lib/mk/x86_64/ldso_crt0.mk deleted file mode 100644 index 7ecddd750b..0000000000 --- a/os/lib/mk/x86_64/ldso_crt0.mk +++ /dev/null @@ -1,3 +0,0 @@ -SRC_S = crt0.s - -vpath crt0.s $(REP_DIR)/src/lib/ldso/x86_64/ diff --git a/os/src/lib/ldso/arm/crt0.s b/os/src/lib/ldso/arm/crt0.s deleted file mode 100644 index 62d930fc57..0000000000 --- a/os/src/lib/ldso/arm/crt0.s +++ /dev/null @@ -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 diff --git a/os/src/lib/ldso/target.inc b/os/src/lib/ldso/target.inc index b72fb59815..8aac802ffe 100644 --- a/os/src/lib/ldso/target.inc +++ b/os/src/lib/ldso/target.inc @@ -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,) diff --git a/os/src/lib/ldso/x86_32/crt0.s b/os/src/lib/ldso/x86_32/crt0.s deleted file mode 100644 index f2245ba80b..0000000000 --- a/os/src/lib/ldso/x86_32/crt0.s +++ /dev/null @@ -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 diff --git a/os/src/lib/ldso/x86_64/crt0.s b/os/src/lib/ldso/x86_64/crt0.s deleted file mode 100644 index 28650d8959..0000000000 --- a/os/src/lib/ldso/x86_64/crt0.s +++ /dev/null @@ -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