linux: stack-area handling with recent Linux kernels

We moved the stack-area segment 128 MiB behind text and data to comply
with assumptions in the kernel ELF loader.

This commit also reenables static binaries on linux and removes the
unused stack_area.stdlib.ld script.

Fixes #2521
This commit is contained in:
Christian Helmuth 2017-09-18 10:09:40 +02:00
parent ff800af820
commit ddfd3c0d7e
6 changed files with 19 additions and 25 deletions

View File

@ -42,7 +42,7 @@ INC_DIR += $(REP_DIR)/src/core/include \
LD_TEXT_ADDR ?= 0x01000000
LD_SCRIPT_STATIC = $(BASE_DIR)/src/ld/genode.ld \
$(call select_from_repositories,src/ld/stack_area.nostdlib.ld)
$(call select_from_repositories,src/ld/stack_area.ld)
include $(GEN_CORE_DIR)/version.inc

View File

@ -31,7 +31,7 @@ namespace Genode {
* Stack area base address
*
* Please update platform-specific files after changing these
* functions, e.g., 'base-linux/src/ld/stack_area.*.ld'.
* functions, e.g., 'base-linux/src/ld/stack_area.ld'.
*/
static addr_t stack_area_virtual_base() {
return align_addr((addr_t)&_stack_area_start, 20); }

View File

@ -18,10 +18,17 @@ PHDRS
SECTIONS
{
. = 0x40000000;
_stack_area_start = .;
/*
* Since Linux loads ldso page aligned, we align the stack area after
* 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.
*/
. = 0x8000000; /* 128 MiB */
_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.
*/
.stack_area : { . += 0x10100000; } : stack_area

View File

@ -1,19 +0,0 @@
/*
* \brief Linux-specific linker script additions (STDLIB = yes)
* \author Christian Helmuth
* \date 2010-09-22
*/
/*
* Copyright (C) 2010-2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
SECTIONS
{
. = 0x40000000;
_stack_area_start = .;
.stack_area : { . += 0x10000000; }
}

View File

@ -27,7 +27,8 @@ symbol.map: $(BASE_DIR)/lib/symbols/ld
ifneq ($(filter linux, $(SPECS)),)
ENTRY_POINT = _start_initial_stack
LD_OPT += -T$(call select_from_repositories,src/ld/stack_area.nostdlib.ld) \
LD_SCRIPT_SO = $(BASE_DIR)/src/ld/genode_rel.ld \
-T$(call select_from_repositories,src/ld/stack_area.ld) \
ifneq ($(filter x86_32, $(SPECS)),)
LD_OPT += -T$(DIR)/linux-32.ld

View File

@ -63,7 +63,12 @@ CXX_LINK_OPT += $(CC_MARCH)
#
# Generic linker script for statically linked binaries
#
ifneq ($(filter linux, $(SPECS)),)
LD_SCRIPT_STATIC ?= $(BASE_DIR)/src/ld/genode.ld \
$(call select_from_repositories,src/ld/stack_area.ld)
else
LD_SCRIPT_STATIC ?= $(BASE_DIR)/src/ld/genode.ld
endif
include $(BASE_DIR)/mk/generic.mk
include $(BASE_DIR)/mk/base-libs.mk