diff options
author | Filippo ARCIDIACONO <filippo.arcidiacono@st.com> | 2012-01-23 17:01:58 +0100 |
---|---|---|
committer | Carmelo Amoroso <carmelo.amoroso@st.com> | 2012-02-07 17:11:47 +0100 |
commit | ac33828db194ddd8dc112439cf0d1d935e4e1452 (patch) | |
tree | 30ed7a63a428c242c4036c586c61b26eef0a0af1 /test/dlopen/testscope.c | |
parent | cf068ce38bc17230fd60adb10b4cf70ead7e7cd0 (diff) |
tests:libdl: add a new test for symbol scope issue in dlclose
Test case to trigger an issue raised by the new symbol scope design,
that was erroneously removing local symbol scope from the global one
too early while dl-closing a shared library.
Based on original test-case by Khem Raj
Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono@st.com>
Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
Reported-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'test/dlopen/testscope.c')
-rw-r--r-- | test/dlopen/testscope.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/dlopen/testscope.c b/test/dlopen/testscope.c new file mode 100644 index 000000000..90e079885 --- /dev/null +++ b/test/dlopen/testscope.c @@ -0,0 +1,29 @@ +#include <dlfcn.h> +#include <stdio.h> +#include <stdlib.h> + +#define LIBNAME "libA.so" +int main(int argc, char **argv) +{ + void *libA; + void (*libAfn)(void); + char *error; + + libA = dlopen(LIBNAME, RTLD_LAZY); + if (!libA) { + fprintf(stderr, "Could not open ./%s: %s\n", LIBNAME, dlerror()); + exit(1); + } + + libAfn = dlsym(libA, "libA_func"); + if ((error = dlerror()) != NULL) { + fprintf(stderr, "Could not locate symbol 'libA_func': %s\n", error); + exit(1); + } + + libAfn(); + + dlclose(libA); + + return EXIT_SUCCESS; +} |