Skip to content

Commit f9d65c4

Browse files
committed
Enhance guidance on dlclose/dlopen
1 parent 400be89 commit f9d65c4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

fmi-guide/3___packaging.adoc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,11 @@ Furthermore, in case of failure, automatic linking is unlikely to provide user-u
167167
Note that simple calls to `LoadLibrary` or `LoadLibraryEx` on Windows, without specifying the full path to the library are also not going to work in general, for the same reasons:
168168
The search path will be based on the location of the importer executable and not the FMU DLL.
169169

170-
Note also that on Linux, `dlclose` is not guaranteed to unload the shared object with newer compilers and might require the compiler flag `-fno-gnu-unique` to enforce actual unloading of the shared object.
170+
Importers should consider using flags like `RTLD_LOCAL` on POSIX platforms with `dlopen`, to avoid symbols from loaded shared objects being resolved against other loaded shared objects (i.e. other FMUs) by accident.
171+
172+
Note that for POSIX platforms, like Linux, `dlclose` is not required to unload a shared object, but it can, as specified in IEEE Std 1003.1-2017 (and earlier).
173+
In particular, shared objects compiled with GCC without the flag `-fno-gnu-unique`, can be marked as unloadable, and thus will not generally be unloaded upon `dlclose`.
174+
In many instances shared objects loaded with `RTLD_GLOBAL` cannot unload until all relocations of other objects to symbols in the shared object have been unloaded.
171175

172176
=== Interaction between FMU and Importer
173177

0 commit comments

Comments
 (0)