Dynamic Dynamic Loader logo

Dynamic Dynamic Loader (DDL) Project

NMSU

HOME

EVENT TOOL FRAMEWORK

DOCUMENTATION

DOWNLOAD

WRAPPER REDIRECTION

TABLE BASED REDIRECTION

REDIRECTION USING TCL

C++ REDIRECTION

FAQ

RESEARCH GROUP

PUBLICATIONS

FUTURE DIRECTIONS



Back to PLEASE Lab



Event Tool Framework Documentation

Event Tool Framework Documentation

Call Sequence of Hooks

The hooks (callback functions) in the loader are called in the following sequence :

1. _dl_redirect_init()
        This function is called once, before the "main" function is called.

2. _dl_redirect_isactive()
      
This function is called once before the resolution of each function symbol. If this function returns 0 then no redirection takes place for that function.

3. _dl_redirect_lookup()
        This function is called once for each function symbol resolution. This function is called only if some non-zero value was returned by  _dl_redirect_isactive() function for that symbol.

4. _dl_redirect_definition()
         This function is called after _dl_redirect_lookup() is called.

5. _dl_redirect_offset()
        This function is called after _dl_redirect_definition().


Environment Variables

We need to set some environment variables before executing any program with our ddl. We can store these variables in a file and then source that file before executing the loader.


LD_REDIRECT
This is used to control whether or not the dynamic linker should be trying to access some redirection code. If this is not set, the dynamic linker behaves exactly as it normally does, without looking for or accessing any external code. If this is set, then the linker will expect to be able to call the callback functions (hooks).
If this variable is set to be a NULL string, Redirection Library will not read any specification file. Otherwise it will try to read the specification file pointed by the LD_REDIRECT environmental variable. It may also contain path of the specification file.
e.g.
setenv LD_REDIRECT "file:`pwd`/wrapper_redirection/redirect.input"

LD_WRAP_LIB
This is used to specify the path of libraries which contain wrapper functions. We can add more than one library by colon-separaters.
e.g.
setenv LD_WRAP_LIB "`pwd`/wrapper_redirection/libwrap.so.0.0"

LD_PRELOAD
This should contain the path of event dispatcher library.
e.g.
setenv LD_PRELOAD "`pwd`/libeventdispatch.so"


LD_LIBRARY_PATH
This is a colon-separated list of directories in which to search for shared libraries.
e.g.
setenv LD_LIBRARY_PATH "`pwd`:/usr/X11R6/lib:${LD_LIBRARY_PATH}:/lib:/usr/lib"

LD_WRAP_LIB
This is a colon-separated list of wrapper files(.so files). It may also have path before each file.
e.g.
setenv LD_WRAP_LIB "`pwd`/libstringtable.so:wrappers.so"

LD_NOVERSIONS
If this is set, loader will turn off any version dependent lookup of functions. This is not a loader specified environmental variable. We defined it to turn off version dependent lookup.
e.g.
setenv LD_NOVERSIONS TRUE
LD_TOOLFILE
This environmental variable points to a file which has list of tools to be loaded.
e.g.
setenv LD_TOOLFILE "`pwd`/tools.input"

Specification File Format

Put keyword "LINK".
On next line put <orig_funcname> <orig_libname> <new_funcname> <new_libname>
new_libname must be present and must have new_funcname symbol in it.
new_libname can't be "main". Try "unknown"
Put keyword "END_LINK" on new line.

Put keyword "TABLE".
On next line put <tablename> <jumptable_funcname> <table_libname>
On next line put <orig_funcname> <orig_libname>
table_libname must be present and must have jumptable_funcname symbol in it.
Put keyword "END_TABLE" on new line.

Tools file format

This file should contains names and complete paths of the libraries of tools. The first entry should always be the master tool.
e.g.
/home/trutta2/srg/projects/dynamic-loader/nabbas/ddl-framework/Redirection_Library/libredirect.so.0.0
/home/trutta2/srg/projects/dynamic-loader/nabbas/ddl-framework/Redirection_Library/libsampletool.so