From 7c1b847a49aea3e00b86843cb77a1585e7955201 Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Mon, 25 Jan 2016 21:27:44 +0100 Subject: add $ORIGIN test-case Signed-off-by: Leonid Lisovskiy Signed-off-by: Waldemar Brodkorb --- test/dlopen/tst-origin.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 test/dlopen/tst-origin.c (limited to 'test/dlopen/tst-origin.c') diff --git a/test/dlopen/tst-origin.c b/test/dlopen/tst-origin.c new file mode 100644 index 000000000..a12be415b --- /dev/null +++ b/test/dlopen/tst-origin.c @@ -0,0 +1,37 @@ +#include +#include +#include +#include + +#ifdef __UCLIBC__ +extern void _dlinfo(void); +#endif + +int main(int argc, char **argv) { + void *h1, *h2; + int (*mydltest)(const char *s); + char *error; + + h1 = dlopen ("libtest31.so", RTLD_LAZY); + if (!h1) { + fprintf(stderr, "Could not open libtest31.so: %s\n", dlerror()); + exit(1); + } + + h2 = dlopen ("libtest31.so", RTLD_NOLOAD); + if (!h2) { + fprintf(stderr, "Could not open libtest31.so(RTLD_NOLOAD): %s\n", dlerror()); + exit(1); + } + + mydltest = dlsym(h1, "dltest"); + if ((error = dlerror()) != NULL) { + fprintf(stderr, "Could not locate symbol 'dltest': %s\n", error); + exit(1); + } + + dlclose(h2); + dlclose(h1); + + return EXIT_SUCCESS; +} -- cgit v1.2.3