Hi all!
On 21/12/2018 15:20, Lev Olshvang wrote:
[...]
> I have an executable (C++) which is the exclusive user of the some shared
> library that it uses only during the initialization phase.
>
> I would like to free memory used by this shared library, because I am running
> on embedded system.
>
> How can I achieve this?
>
> I know that dlopen() will load shared library, and hope that following
> dlclose() will free this lib memory.
>
> 1. Still I do not know what method should be used to make dynamic linker
> look again into executable and resolve symbols of the newly appeared symbols ?
There is no such method TTBOMK. Since the linker (and thus the shared
loader) do not know of this library, they can't do anything (see below).
The C++ application has to resolve the symbols with dlsym() (after a
successful dlopen()) and call it with an appropriate type cast.
After dlclose(), the pointers from dlasym() are invalid (obviously - as
the lib is gone/unmapped).
> 2. And how to tell the dynamic linker ld-linux.so to postpone the symbol
> resolution until dlopen() will load the library?
Do not mention that library (when linking the application).
> 3. Whether to compile and link executable with this library or leave
> unresolved symbols?
You do not call the functions directly (and you cannot as the linker
cannot resolve them anyways as the linker doesn't know the library).
MfG,
Bernd
--
Bernd Petrovitsch Email : [email protected]
LUGA : http://www.luga.at
_______________________________________________
Kernelnewbies mailing list
[email protected]
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies