diff --git a/repos/base-linux/lib/mk/base.mk b/repos/base-linux/lib/mk/base.mk index fa6bb32e2e..c5b12b8384 100644 --- a/repos/base-linux/lib/mk/base.mk +++ b/repos/base-linux/lib/mk/base.mk @@ -9,4 +9,4 @@ include $(REP_DIR)/lib/mk/base.inc LIBS += startup SRC_CC += thread.cc thread_myself.cc thread_linux.cc SRC_CC += capability_space.cc capability_raw.cc - +SRC_CC += attach_stack_area.cc diff --git a/repos/base-linux/src/include/base/internal/platform_env.h b/repos/base-linux/src/include/base/internal/platform_env.h index 627a73c6ac..c6b10dd093 100644 --- a/repos/base-linux/src/include/base/internal/platform_env.h +++ b/repos/base-linux/src/include/base/internal/platform_env.h @@ -118,6 +118,11 @@ class Genode::Platform_env : public Platform_env_base, constexpr static size_t _emergency_ram_size() { return 8*1024; } Ram_dataspace_capability _emergency_ram_ds; + /** + * Attach stack area to local address space (for non-hybrid components) + */ + void _attach_stack_area(); + public: /** diff --git a/repos/base-linux/src/lib/base/attach_stack_area.cc b/repos/base-linux/src/lib/base/attach_stack_area.cc new file mode 100644 index 0000000000..0a712b6925 --- /dev/null +++ b/repos/base-linux/src/lib/base/attach_stack_area.cc @@ -0,0 +1,29 @@ +/* + * \brief Attach stack area to local address space + * \author Norman Feske + * \date 2016-07-06 + * + * This function resides in a distinct compilation unit because it is not + * used for hybrid components where the Genode::Thread API is implemented + * via POSIX threads. + */ + +/* + * Copyright (C) 2016 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. + */ + +/* base-internal includes */ +#include + +using namespace Genode; + + +void Platform_env::_attach_stack_area() +{ + _local_pd_session._address_space.attach_at(_local_pd_session._stack_area.dataspace(), + stack_area_virtual_base(), + stack_area_virtual_size()); +} diff --git a/repos/base-linux/src/lib/base/platform_env.cc b/repos/base-linux/src/lib/base/platform_env.cc index 7e5cbeaa76..77fd27abe6 100644 --- a/repos/base-linux/src/lib/base/platform_env.cc +++ b/repos/base-linux/src/lib/base/platform_env.cc @@ -154,10 +154,7 @@ Platform_env::Platform_env() _heap(Platform_env_base::ram_session(), Platform_env_base::rm_session()), _emergency_ram_ds(ram_session()->alloc(_emergency_ram_size())) { - /* attach stack area to local address space */ - _local_pd_session._address_space.attach_at(_local_pd_session._stack_area.dataspace(), - stack_area_virtual_base(), - stack_area_virtual_size()); + _attach_stack_area(); env_stack_area_region_map = &_local_pd_session._stack_area; env_stack_area_ram_session = ram_session(); diff --git a/repos/base-linux/src/lib/lx_hybrid/lx_hybrid.cc b/repos/base-linux/src/lib/lx_hybrid/lx_hybrid.cc index df99981049..bc61b845de 100644 --- a/repos/base-linux/src/lib/lx_hybrid/lx_hybrid.cc +++ b/repos/base-linux/src/lib/lx_hybrid/lx_hybrid.cc @@ -21,6 +21,7 @@ /* base-internal includes */ #include #include +#include /** @@ -525,3 +526,17 @@ Thread::~Thread() /* inform core about the killed thread */ _cpu_session->kill_thread(_thread_cap); } + + +/****************** + ** Platform_env ** + ******************/ + +void Platform_env::_attach_stack_area() +{ + /* + * Omit attaching the stack area to the local address space for hybrid + * components. Otherwise, it may collide with the (randomized) loading + * locations of shared objects or the binary. + */ +}