From: Szabolcs Nagy Date: Mon, 27 Jan 2014 13:17:28 +0000 (+0100) Subject: add tls_init_dlopen test and fix tls_align_dlopen.mk so it is run properly X-Git-Url: http://nsz.repo.hu/git/?p=libc-test;a=commitdiff_plain;h=164c1f02358efafd3cd23697d890c579c8733e65 add tls_init_dlopen test and fix tls_align_dlopen.mk so it is run properly --- diff --git a/src/functional/tls_align_dlopen.c b/src/functional/tls_align_dlopen.c index 709964e..77a7b93 100644 --- a/src/functional/tls_align_dlopen.c +++ b/src/functional/tls_align_dlopen.c @@ -12,7 +12,7 @@ int main() unsigned long addr; } *t; - h = dlopen("./tls_align_dso.so", RTLD_LAZY); + h = dlopen("src/functional/tls_align_dso.so", RTLD_LAZY); if (!h) t_error("dlopen failed\n"); t = dlsym(h, "t"); diff --git a/src/functional/tls_align_dlopen.mk b/src/functional/tls_align_dlopen.mk index bd5b740..6632623 100644 --- a/src/functional/tls_align_dlopen.mk +++ b/src/functional/tls_align_dlopen.mk @@ -1,2 +1,2 @@ -$(N).BINS=$(B)/$(N).exe +$(N).BINS:=$(B)/$(N).exe $(B)/$(N).err: $(B)/$(D)/tls_align_dso.so diff --git a/src/functional/tls_init_dlopen.c b/src/functional/tls_init_dlopen.c new file mode 100644 index 0000000..ef3d10a --- /dev/null +++ b/src/functional/tls_init_dlopen.c @@ -0,0 +1,24 @@ +#include +#include +#include "test.h" + +int main() +{ + void *h; + char *(*f)(void); + char *s; + + h = dlopen("src/functional/tls_init_dso.so", RTLD_NOW|RTLD_GLOBAL); + if (!h) + t_error("dlopen failed: %s\n", dlerror()); + f = dlsym(h, "gettls"); + if (!f) + t_error("dlsym failed: %s\n", dlerror()); + s = f(); + if (!s) + t_error("tls was not initialized at dlopen\n"); + if (strcmp(s, "foobar")!=0) + t_error("tls was not initialized correctly at dlopen (got \"%s\", want \"foobar\"\n", s); + + return t_status; +} diff --git a/src/functional/tls_init_dlopen.mk b/src/functional/tls_init_dlopen.mk new file mode 100644 index 0000000..f6435b8 --- /dev/null +++ b/src/functional/tls_init_dlopen.mk @@ -0,0 +1,2 @@ +$(N).BINS:=$(B)/$(N).exe +$(B)/$(N).err: $(B)/$(D)/tls_init_dso.so diff --git a/src/functional/tls_init_dso.c b/src/functional/tls_init_dso.c new file mode 100644 index 0000000..eff1a58 --- /dev/null +++ b/src/functional/tls_init_dso.c @@ -0,0 +1,8 @@ +static char buf[] = "foobar"; +__thread char *tls = buf; + +char *gettls() +{ + return tls; +} + diff --git a/src/functional/tls_init_dso.mk b/src/functional/tls_init_dso.mk new file mode 100644 index 0000000..2b1c25b --- /dev/null +++ b/src/functional/tls_init_dso.mk @@ -0,0 +1,2 @@ +$(N).BINS:= +$(N).LIBS:=$(B)/$(N).so