genode/repos/base/lib/mk/ld-platform.inc
Norman Feske 4da52517c1 Simpify startup of dynamically linked binaries
This patch removes the component_entry_point library, which used to
proved a hook for the libc to intercept the call of the
'Component::construct' function. The mechansim has several shortcomings
(see the discussion in the associated issue) and was complex. So we
eventually discarded the approach in favor of the explicit handling of
the startup.

A regular Genode component provides a 'Component::construct' function,
which is determined by the dynamic linker via a symbol lookup.
For the time being, the dynamic linker falls back to looking up a 'main'
function if no 'Component::construct' function could be found.

The libc provides an implementation of 'Component::construct', which
sets up the libc's task handling and finally call the function
'Libc::Component::construct' from the context of the appllication task.
This function is expected to be provided by the libc-using application.
Consequently, Genode components that use the libc have to implement the
'Libc::Component::construct' function.

The new 'posix' library provides an implementation of
'Libc::Component::construct' that calls a main function. Hence, POSIX
programs that merely use the POSIX API merely have to add 'posix' to the
'LIBS' declaration in their 'target.mk' file. Their execution starts at
'main'.

Issue #2199
2017-01-13 13:06:52 +01:00

45 lines
1.0 KiB
Makefile

SHARED_LIB = yes
DIR = $(BASE_DIR)/src/lib/ldso
LIB_IS_DYNAMIC_LINKER = yes
include $(BASE_DIR)/mk/base-libs.mk
LIBS = $(BASE_LIBS)
SRC_CC = main.cc test.cc exception.cc dependency.cc debug.cc \
shared_object.cc
SRC_S = jmp_slot.s
INC_DIR += $(DIR)/include
INC_DIR += $(BASE_DIR)/src/include
LD_OPT += -Bsymbolic-functions --version-script=symbol.map
#
# Generate symbol map from the ABI
#
$(LIB).lib.so: symbol.map
symbol.map: $(MAKEFILE_LIST)
symbol.map: $(BASE_DIR)/lib/symbols/ld
$(MSG_CONVERT)$@
$(VERBOSE)(echo -e "{\n\tglobal:";\
sed -n "s/^\(\w\+\) .*/\t\t\1;/p" $<;\
echo -e "\tlocal: *;\n};") > $@
ifneq ($(filter linux, $(SPECS)),)
ENTRY_POINT = _start_initial_stack
LD_OPT += -T$(call select_from_repositories,src/ld/stack_area.nostdlib.ld) \
ifneq ($(filter x86_32, $(SPECS)),)
LD_OPT += -T$(DIR)/linux-32.ld
endif
else
ENTRY_POINT = _start
LD_OPT += -T$(DIR)/linker.ld
endif
vpath %.cc $(DIR)
# vi:ft=make