ld: load dynamic linker at static address on Linux

* move stack area to static address at beginning of binary
* set ELF type of linker from shared to executable

fixes #3479
This commit is contained in:
Sebastian Sumpf 2019-08-20 14:32:01 +02:00 committed by Christian Helmuth
parent 468270f6e9
commit 2fc6cedcc0
2 changed files with 16 additions and 11 deletions

View File

@ -1,5 +1,5 @@
/*
* \brief Linux-specific linker script additions (STDLIB = no)
* \brief Linux-specific linker script additions
* \author Christian Helmuth
* \date 2010-09-22
*/
@ -19,17 +19,13 @@ PHDRS
SECTIONS
{
/*
* The virtual gap between start of text segment (0x0) and stack area
* must be sufficiently large to hold either the entire dynamic linker (text +
* data) or core (0x1000000 + text + data). Note, core-linux includes 80 MiB
* core-local memory in the BSS.
* Start of Linux binary and stack area
*/
. = 0x8000000; /* 128 MiB */
. = 0x40000000; /* 1GB */
_stack_area_start = .;
/*
* Since Linux loads ldso page-aligned, we align the stack area after
* loading to a 1 MiB boundary, therefore we reserve one MiB more here.
* 256 MB
*/
.stack_area : { . += 0x10100000; } : stack_area
.stack_area : { . += 0x10000000; } : stack_area
}

View File

@ -30,13 +30,22 @@ symbol.map: $(BASE_DIR)/lib/symbols/ld
ifneq ($(filter linux, $(SPECS)),)
ENTRY_POINT = _start_initial_stack
LD_SCRIPT_SO = $(BASE_DIR)/src/ld/genode_rel.ld \
-T$(call select_from_repositories,src/ld/stack_area.ld) \
LD_SCRIPT_SO = $(call select_from_repositories,src/ld/stack_area.ld) \
-T$(BASE_DIR)/src/ld/genode_rel.ld
ifneq ($(filter x86_32, $(SPECS)),)
LD_OPT += -T$(DIR)/linux-32.ld
endif
#
# set dynamic linker ELF type to executable
#
ifeq ($(called_from_lib_mk),yes)
$(LIB).lib.so.stripped: postprocess.tag
postprocess.tag: $(LIB).lib.so
$(VERBOSE)printf "\x02" | dd of=$(LIB).lib.so bs=1 seek=16 count=1 conv=notrunc
endif
else
ENTRY_POINT = _start
LD_OPT += -T$(DIR)/linker.ld