dlopen testcase
cover dlopen testcase
The test binary was actually linked as a xenomai binary, so the test did not actually cover the "cold" init phase.
Turns out that in fact dlclose will not truly work, because we lack destructors for the init functions of the so called setup_descriptors.
So first revert the patch introducing destructors. We do not have code to destruct, dont even pretent by addressing a fraction of the whole problem.
Second change the linker flags and make the testcase cover cold init. Remove the calls to dlclose() and the re-dlopen(), because that is not actually supported.
And last but not least, make sure a dlclose() will not actually work on xenomai libs.
Henning Schild (3):
Revert "boilerplate/setup: introduce destructors for __setup_call" smokey/dlopen: fix testcase
build: link dlopen libs with "nodelete"
configure.ac | 1 + include/boilerplate/setup.h | 7 ------- lib/boilerplate/setup.c | 6 ------ testsuite/smokey/dlopen/Makefile.am | 8 +------- testsuite/smokey/dlopen/dlopentest.c | 9 --------- testsuite/smokey/dlopen/libalchemy-test.c | 2 +- 6 files changed, 3 insertions(+), 30 deletions(-)
Signature · 1 line
2.16.1
PATCH 1/3 Revert "boilerplate/setup: introduce destructors for __setup_call"
In fact we would need real destructors for all setup_descriptor s. Stop pretending that we know how to dlclose or destruct.
This reverts commit 5511e76040444af875ae1bb099c13a25b16336fc.
--- include/boilerplate/setup.h | 7 ------- lib/boilerplate/setup.c | 6 ------ 2 files changed, 13 deletions(-)
include/boilerplate/setup.h +0 -7
@@ -78,16 +78,10 @@ struct setup_descriptor {#define __early_ctor __attribute__ ((constructor(210)))#define __bootstrap_ctor __attribute__ ((constructor(220))) -#define __setup_dtor __attribute__ ((destructor(200))) -#define __setup_call (__name, __id) \ static __setup_ctor void __declare_ ## __name(void) \ { \ __register_setup_call(&(__name), __id); \ -} \ -static __setup_dtor void __undeclare_ ## __name(void) \ -{ \ - __unregister_setup_call(&(__name), __id); \ }#define core_setup_call (__name) __setup_call(__name, 0)
@@ -102,7 +96,6 @@ extern "C" {#endif void __register_setup_call (struct setup_descriptor *p,int id); -void __unregister_setup_call (struct setup_descriptor *p,int id);extern pid_t __node_id;
lib/boilerplate/setup.c +0 -6
@@ -701,12 +701,6 @@ void __register_setup_call(struct setup_descriptor *p, int id)pvlist_prepend (&p->__reserved.next, &setup_list); } -void __unregister_setup_call (struct setup_descriptor *p,int id) -{ -pvlist_remove (&p->__reserved.next); -} - -const char *get_program_name (void ) {return basename (__base_setup_data.arg0 ?:"program" );
Signature · 1 line
2.16.1
PATCH 2/3 smokey/dlopen: fix testcase
In reply to Henning SchildThe intention of another binary and fork/exec was to have a binary is not a xenoami-binary already, to actually test dlopen. Unfortunately a copy-paste mistake in Makefile.am resulted in dlopentest being a xenomai application already. Therefore the dlopens tested something they where not supposed to.
Change Makefile.am to make dlopentest a truly non-xenomai binary. And change what it is testing accordingly. We do not support dlclose so do not test it anymore.
--- testsuite/smokey/dlopen/Makefile.am | 8 +------- testsuite/smokey/dlopen/dlopentest.c | 9 --------- testsuite/smokey/dlopen/libalchemy-test.c | 2 +- 3 files changed, 2 insertions(+), 17 deletions(-)
testsuite/smokey/dlopen/Makefile.am +1 -7
@@ -42,16 +42,10 @@ test_PROGRAMS = dlopentest dlopentest_SOURCES = dlopentest.c dlopentest_CPPFLAGS = \ - @XENO_USER_CFLAGS@ \ -Wno-format-security \ - -DXENO_TEST_DIR='"$(XENO_TEST_DIR)"' \ - -I$(top_srcdir)/include - -dlopentest_LDFLAGS = @XENO_AUTOINIT_LDFLAGS@ $(XENO_POSIX_WRAPPERS) + -DXENO_TEST_DIR='"$(XENO_TEST_DIR)"' dlopentest_LDADD = \ - @XENO_CORE_LDADD@ \ - @XENO_USER_LDADD@ \ -ldl noinst_LIBRARIES = libdlopen.a
testsuite/smokey/dlopen/dlopentest.c +0 -9
@@ -75,14 +75,5 @@ int main(int argc, char *const argv[])if (ret)error (1 , errno,"libposix_func: %s" ,strerror (-ret)); -if (dlclose (handlep)) -fprintf (stderr,"%s" ,dlerror ()); -if (dlclose (handlea)) -fprintf (stderr,"%s" ,dlerror ()); - -setenv ("XENO_TEST_DLOPEN_NO_INIT" ,"1" ,1 ); - ret =my_dlcall ("libalchemy-test.so" ,"libalchemy_func" , &handlea); -assert (ret ==ENOMEM ); -return 0 ; }
testsuite/smokey/dlopen/libalchemy-test.c +1 -1
@@ -33,7 +33,7 @@ static size_t def_mem_pool_size = SIZE_MAX;static int alchemy_tune (void ) { -if (getenv ("XENO_TEST_DLOPEN_NO_INIT" ) || ran_init) +if (ran_init)return 0 ; def_mem_pool_size =get_config_tunable (mem_pool_size);set_config_tunable (mem_pool_size,2 *def_mem_pool_size);
Signature · 1 line
2.16.1
PATCH 3/3 build: link dlopen libs with "nodelete"
In reply to Henning SchildThis way a dlclose() will not unmap the libs memory anymore. A real dlclose() will not work anyways because we lack destructors for all the stuff we initialize in setup_descriptor->init().
--- configure.ac | 1 + 1 file changed, 1 insertion(+)
configure.ac +1 -0
@@ -685,6 +685,7 @@ AC_MSG_RESULT(${CONFIG_XENO_LIBS_DLOPEN:-no}) if test x$CONFIG_XENO_LIBS_DLOPEN = xy; then AC_DEFINE(CONFIG_XENO_LIBS_DLOPEN,1,[config]) AC_DEFINE_UNQUOTED(CONFIG_XENO_TLS_MODEL,"global-dynamic",[TLS model]) + XENO_LIB_LDFLAGS="-Wl,-z -Wl,nodelete" else AC_DEFINE_UNQUOTED(CONFIG_XENO_TLS_MODEL,"initial-exec",[TLS model]) XENO_LIB_LDFLAGS="-Wl,-z -Wl,nodlopen"
Signature · 1 line
2.16.1