From 043b3358a91a5e9bef707fd3720f60552e0b9569 Mon Sep 17 00:00:00 2001 From: Timothy Gu Date: Mon, 10 Feb 2014 03:35:19 +0000 Subject: test: add forgotten test "Open library again (without closing it first) with RTLD_GLOBAL" --- test.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/test.c b/test.c index 8977fbc..b8f6c9e 100644 --- a/test.c +++ b/test.c @@ -49,7 +49,6 @@ * - Get symbol from library through library object <- works * - Run function if it worked * - Get symbol from library through global object <- fails - * - Run function if it worked * - Open library again (without closing it first) with RTLD_GLOBAL * - Get symbol from library through global object <- works * - Close library @@ -167,6 +166,33 @@ int main() else printf( "SUCCESS\tDid not get local symbol from global handle.\n" ); + library = dlopen( "testdll.dll", RTLD_GLOBAL ); + if( !library ) + { + error = dlerror( ); + printf( "ERROR\tCould not open library globally without closing it first: %s\n", error ? error : "" ); + CLOSE_LIB; + CLOSE_GLOBAL; + RETURN_ERROR; + } + else + printf( "SUCCESS\tOpened library globally without closing it first: %p\n", library ); + + function = dlsym( global, "function" ); + if( !function ) + { + error = dlerror( ); + printf( "ERROR\tCould not get symbol from global handle: %s\n", + error ? error : "" ); + CLOSE_LIB; + CLOSE_GLOBAL; + RETURN_ERROR; + } + else + printf( "SUCCESS\tGot symbol from global handle: %p\n", function ); + + RUNFUNC; + ret = dlclose( library ); if( ret ) { -- cgit v1.2.3-55-g6feb