From 324af5d76942d68ca06f02a15c993e7a5475d514 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Wed, 5 Feb 2014 14:58:37 +0100 Subject: [PATCH] os: make program ctors and dtors visible to LDSO This is needed later when eliminating the need for a startup lib in dynamic programs to enable LDSO to call ctors and dtors of the program. Issue #1042 --- base/mk/prg.mk | 6 ++++++ os/src/platform/genode_dyn.dl | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 os/src/platform/genode_dyn.dl diff --git a/base/mk/prg.mk b/base/mk/prg.mk index 898a074d1d..eec62acdd9 100644 --- a/base/mk/prg.mk +++ b/base/mk/prg.mk @@ -115,6 +115,12 @@ ifeq ($(SHARED_LIBS),) LD_SCRIPTS := $(LD_SCRIPT_STATIC) FILTER_DEPS := $(DEPS:.lib=) else + +# +# Add a list of symbols that shall always be added to the dynsym section +# +LD_OPT += --dynamic-list=$(call select_from_repositories,src/platform/genode_dyn.dl) + LD_SCRIPTS := $(LD_SCRIPT_DYN) LD_CMD += -Wl,--dynamic-linker=$(DYNAMIC_LINKER).lib.so \ -Wl,--eh-frame-hdr diff --git a/os/src/platform/genode_dyn.dl b/os/src/platform/genode_dyn.dl new file mode 100644 index 0000000000..21eab9d305 --- /dev/null +++ b/os/src/platform/genode_dyn.dl @@ -0,0 +1,16 @@ +/* + * Symbols that shall always be added to the section '.dynsym' + */ +{ + /* + * The ctors and dtors symbols are not used by a dynamic program as such + * programs have no '_main' function. Hence the linker doesn't add them to + * the dynsym section by itself. However, we need to lookup the ctors and + * dtors arrays of the dynamic program in LDSO, which is why we must + * explicitely add them to the dynsym section. + */ + _ctors_start; + _ctors_end; + _dtors_start; + _dtors_end; +};