Hello,
While designing my shared library facilities a question came to my mind about dlopen. Until now i'm managing a list of shared libraries and i map them to process space if they are needed (ELF relocation, etc...) The virtual layout of a process is the following:
[KERNEL_SPACE(<=512MB): PROCESS_CODE+HEAP--->................<---PROCESS_STACK:LIB1,LIB2...]
Is dlopen is expected to open a library and make it available in the process heap? I would be surprised if it is not the case.
A question about dlopen implementation
Re: A question about dlopen implementation
Code: Select all
man dlopen
dlopen() examines the file specified by path. If the file is compatible with the current
process and has not already been loaded into the current process, it is loaded and linked. After being
linked, if it contains any initializer functions, they are called, before dlopen() returns. dlopen()
can load dynamic libraries and bundles. It returns a handle that can be used with dlsym() and
dlclose(). A second call to dlopen() with the same path will return the same handle, but the internal
reference count for the handle will be incremented. Therefore all dlopen() calls should be balanced
with a dlclose() call.