aboutsummaryrefslogtreecommitdiff
path: root/test.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Move cmake targets into sub directoriesRalf Habacker2020-09-141-687/+0
|
* Relicense to MITRamiro Polla2020-08-301-11/+15
| | | | | | The licensing note in the configure script has been reworked, similarly to how libvpx did it (they were also based on FFmpeg's configure script and also use a more permissive license).
* Add test which check that dlopen() can open same files as open()Pali Rohár2019-09-121-0/+93
| | | | | This ensures that dlopen() expects filenames encoded in same codepage as WinAPI's open() function.
* Fix more gcc warningsPali Rohár2019-07-261-6/+10
| | | | | ISO C90 forbids mixed declarations and code ISO C++ forbids converting a string constant to 'char*'
* Fix gcc warning: ISO C forbids return between function pointer and void *Pali Rohár2019-07-251-31/+31
| | | | | | | | | | | | | | | | Instead of using compiler specific pragma to disable particular warning, rewrite code which cast from function pointer to data pointer according to POSIX dlopen() documentation. This also fix compile warning under MSVC. According to the ISO C standard, casting between function pointers and 'void *', as done above, produces undefined results. POSIX.1-2003 and POSIX.1-2008 accepted this state of affairs and proposed the following workaround: *(void **) (&cosine) = dlsym(handle, "cos"); This (clumsy) cast conforms with the ISO C standard and will avoid any compiler warnings.
* Fix gcc warning: comparison between signed and unsigned integer expressionsPali Rohár2019-07-251-3/+4
| | | | | GetTempPathA() returns DWORD (32/64bit unsigned integer) and not int (32 signed integer).
* Turn off GUI error messages around LoadLibraryA also in testPali Rohár2019-06-111-0/+7
| | | | Otherwise running test show GUI error messages which needs to be closed.
* Add test for non-library filePali Rohár2019-05-231-0/+61
|
* Add tests for non-existent file and file with too long namePali Rohár2019-05-231-0/+50
|
* Test that dlerror() returns non-NULL error for failed callsPali Rohár2019-05-231-20/+37
|
* Implement support for dlsym() with RTLD_DEFAULT and RTLD_NEXTPali Rohár2019-02-141-0/+60
| | | | | | | | | | | | | | | | | | | dlsym() with RTLD_DEFAULT handle behaves in same way like with global handle returned by dlopen() with NULL file name. dlsym() with RTLD_NEXT handle search for next loaded module which provides specified symbol. "Next" means module which in EnumProcessModules() result after the module which called dlsym(). To get caller function of dlsym() use _ReturnAddress() intrinsic. To get module where is caller function use the fact that HMODULE is the same value as the module's base address. When compiling under gcc, defines _ReturnAddress() macro via gcc's builtin as it does not provide MSC's specific _ReturnAddress() intrinsic. Added tests demonstrate that both RTLD_DEFAULT and RTLD_NEXT are working as expected.
* Fix resolving global symbols when LoadLibrary() is called after dlopen()Pali Rohár2019-02-141-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Usage of first_automatic_object cache is wrong. This cache is filled by all loaded DLL files (either implicitly or explicitly with LoadLibrary() call) by EnumProcessModules() call at first usage of dlopen(). So dlsym() can resolve global symbols only if they were loaded prior to dlopen() call. Any future usage of LoadLibrary() does not include newly loaded DLLs into first_automatic_object cache. To fix this problem, first_automatic_object cache is fully removed and EnumProcessModules() call is issued directly in dlsym() call. As EnumProcessModules() returns all DLLs, included those which were loaded by dlopen() with RTLD_LOCAL, it may break RTLD_LOCAL support. To address this problem switch linked-list of all loaded DLLs with RTLD_GLOBAL to linked-list of all loaded DLLs with RTLD_LOCAL flag. And then skip modules from EnumProcessModules() which are in linked-list. Also in WinAPI all DLLs loaded by LoadLibrary() behaves like RTLD_GLOBAL. So above change is compatible with this behavior. There may be another problem. Before retrieving HMODULE for DLL filename (which is done by LoadLibrary()), it is not possible to detect if DLL was already loaded by RTLD_LOCAL or not. And after calling LoadLibrary() it is not possible to know if DLL was loaded either by dlsym() with RTLD_LOCAL or by LoadLibrary() (which is equivalent to RTLD_GLOBAL). To address this problem, compare number of loaded modules (counted by EnumProcessModules()) before and after LoadLibrary() called from dlsym(). If number does not change it means that DLL was already loaded. So based on this result either add or remove HMODULE from linked-list of RTLD_LOCAL modules. Added test demonstrate usage of: global = dlopen(NULL, RTLD_GLOBAL); /* global handle */ LoadLibrary("library.dll"); /* this provides function */ function = dlsym(global, "function"); /* resolve function from library.dll */
* Fix bug in dlerror second consecutive callSilvio2017-05-011-0/+15
| | | | | | | | | | | | | According to the specs, a second consecutive call to dlerror should always return NULL . This was the case in dlfcn-win32 before https://github.com/dlfcn-win32/dlfcn-win32/pull/20 introduce a regression that caused dlerror to crash on the second consecutive call. In this commit the issue is fixed as suggested in https://github.com/dlfcn-win32/dlfcn-win32/issues/34 and a regression test has been added.
* Add testing of CMake exported targetsSilvio2017-03-051-0/+1
|
* Fix tests in Visual Studio 2015Silvio2017-03-051-7/+9
| | | | | | | | For checking the loading of symbols from the global handle, the printf symbol was loaded, but since Visual Studio 2015 printf is defined as a inline function. To fix this, the test has been modified to load the symbol of the fwrite function.
* Add linked modules to a separate global listTimothy Gu2015-03-151-1/+30
| | | | Fixes #2.
* Check for memory leak when _DEBUG is definedTimothy Gu2015-03-151-0/+17
|
* test: add trying to load nonexistent symbols testTimothy Gu2014-02-101-1/+82
|
* test: add forgotten testTimothy Gu2014-02-101-1/+27
| | | | "Open library again (without closing it first) with RTLD_GLOBAL"
* test: more updates and fixesTimothy Gu2014-02-101-37/+43
|
* test.c: make errors stand outTimothy Gu2014-02-101-20/+21
|
* License stuffTimothy Gu2014-02-101-4/+5
|
* Fix local symbol in global handle testTimothy Gu2014-01-221-3/+3
|
* test.c: return 1 if errorTimothy Gu2014-01-221-0/+27
|
* Cosmetics: white spaceRamiro Polla2007-06-291-5/+5
|
* Initial RevisionRamiro Polla2007-06-281-0/+157