This preview shows page 1. Sign up to view the full content.
Unformatted text preview: erver dynamically loads and links the appropriate function and then calls it directly, as opposed to using fork and execve to run the function in the context of a child process. The function remains in the server’s address space, so subsequent requests can be handled at the cost of a simple function call. This can have a signiﬁcant impact on the throughput of a busy site. Further, existing functions can be updated and new functions can be added at run-time, without stopping the server. Linux and Solaris systems provide a simple interface to the dynamic linker that allows application programs to load and link shared libraries at run time.
#include <dlfcn.h> void *dlopen(const char *filename, int flag);
returns: ptr to handle if OK, NULL on error 7.12. *POSITION-INDEPENDENT CODE (PIC) 377 The dlopen function loads and links the shared library filename. The external symbols in filename are resolved using libraries previously opened with the RTLD GLOBAL ﬂag. If the current executable was compiled with the -rdynamic ﬂag, then its global symbols are also available for symbol resolution. The flag argument must include either RTLD NOW, which tells the linker to resolve references to external symbols immediately, or the RTLD LAZY ﬂag, which instructs the linker to defer symbol resolution until code from the l...
View Full Document