A question about dlopen implementation

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
alix
Posts: 12
Joined: Tue Nov 13, 2012 3:56 pm

A question about dlopen implementation

Post by alix »

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.
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: A question about dlopen implementation

Post by bluemoon »

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.
The exact memory address for the loaded module is open to implementation.
Post Reply