tkrebes / nisyscfg-python

NI System Configuration Python API
MIT License
4 stars 0 forks source link

Fixed library loading issue on Linux #58

Closed tkrebes closed 11 months ago

tkrebes commented 11 months ago

What does this Pull Request accomplish?

Using ctypes.RTLB_GLOBAL flag allows necessary symbols to be loaded.

The Python ctypes docs state the default mode for the CDLL constructor is RTLD_LOCAL. According to the Linux man pages, the dlopen syscall's RTLD_GLOBAL option causes the following loading behavior:

The symbols defined by this library will be made available for symbol resolution of subsequently loaded libraries. [...] External references in the library are resolved using the libraries in that library's dependency list and any other libraries previously opened with the RTLD_GLOBAL flag

Contrast this with RTLD_LOCAL:

This is the converse of RTLD_GLOBAL, and the default if neither flag is specified. Symbols defined in this library are not made available to resolve references in subsequently loaded libraries.

Why should this Pull Request be merged?

On Linux targets, certain functions, namely NISysCfgRestart and and NISysCfgSetSystemImageFromFolder2, do not work when called from the wrapper, failing with the CMD_NOT_SUPPORTED error.

What testing has been done?

Unit test passed