Interface to libdl-style dynamic linker.
More...
|
file | dlfcn.c |
| Dynamic linker subsystem.
|
|
file | dlfcn.h |
| Dynamic linker subsystem.
|
|
|
#define | PTR_ROUND_UP(ptr, d) ((void *)ROUND_UP((uintptr_t)(ptr), (d))) |
| Macro to round up pointer.
|
|
#define | PTR_DECODE(base, ptr) ((void*)(((uint8_t*)(base)) + (uintptr_t)(ptr))) |
| Macro to add base to pointer.
|
|
|
void | __register_frame_info (void *ptr, void *object) |
| Function to register exception frames.
|
|
void | __deregister_frame_info (void *ptr) |
| Function to unregister exception frames.
|
|
void | __cxa_finalize (void *dso) |
| Function to run atexit destructors for a module.
|
|
void | __dl_insert_module (dl_module_t *module) |
| Insert module into module list.
|
|
void | __dl_remove_module (dl_module_t *module) |
| Remove module from module list.
|
|
void * | dlopen (const char *filename, int mode) |
| Open dynamic library.
|
|
void * | dlsym (void *handle, const char *symbol) |
| Grab symbol from loaded dynamic library.
|
|
int | dlclose (void *handle) |
| Close loaded dynamic library.
|
|
int | dladdr (const void *addr, Dl_info *info) |
| Convert address to symbol.
|
|
char * | dlerror (void) |
| Return last error that occurred in dynamic linker.
|
|
|
demangle_func | __dl_demangle_func |
| Demangler function.
|
|
module_lookup_func | __dl_lookup_module |
| Module resolver.
|
|
dl_module_t * | __dl_list_head |
| Module list head.
|
|
dl_module_t * | __dl_list_tail |
| Module list tail.
|
|
size_t | __dl_num_loaded_modules |
| Number of loaded modules.
|
|
Interface to libdl-style dynamic linker.
The dynamic linker subsystem allows users to load code from the program's DragonFS filesystem (see dfs.h). Code is stored in a custom dynamically linked format (extension of .dso) to allow for loading and running code placed at arbitrary memory addresses and resolving external references to the main executable and other dynamically linked modules. External references are resolved by name with symbol tables provided by each dynamically linked module and are also provided by a file in the rompak (MSYM) (see rompak_internal.h) for the main executable.
To access this system, one must first call dlopen to load a dynamically linked module and return a handle to the module. Then, one can all dlsym to access functions and variables exported from this module with the returned handle. This function can also access symbols that are in the global symbol table with the special handle RTLD_DEFAULT. Once one is done with the module, one can call dlclose to close the module.
◆ __dl_insert_module()
Insert module into module list.
This function is non-static to help debuggers support overlays.
- Parameters
-
◆ __dl_remove_module()
Remove module from module list.
This function is non-static to help debuggers support overlays.
- Parameters
-
◆ dlopen()
void * dlopen |
( |
const char * |
filename, |
|
|
int |
mode |
|
) |
| |
Open dynamic library.
- Parameters
-
filename | Path to dynamic library |
mode | Flags for loading dynamic library |
- Returns
- Handle for loaded dynamic library
◆ dlsym()
void * dlsym |
( |
void * |
handle, |
|
|
const char * |
symbol |
|
) |
| |
Grab symbol from loaded dynamic library.
- Parameters
-
handle | Dynamic library handle to search symbol from |
symbol | Name of symbol to search for |
- Returns
- Pointer to symbol
◆ dlclose()
int dlclose |
( |
void * |
handle | ) |
|
Close loaded dynamic library.
- Parameters
-
handle | Dynamic library handle to close |
- Returns
- Whether an error occurred
◆ dladdr()
int dladdr |
( |
const void * |
addr, |
|
|
Dl_info * |
info |
|
) |
| |
Convert address to symbol.
- Parameters
-
addr | Address to search |
info | Info of symbol found |
- Returns
- Zero on success and non-zero on failure
◆ dlerror()
Return last error that occurred in dynamic linker.
- Returns
- String describing last error occurring in dynamic linker
◆ __dl_lookup_module
module_lookup_func __dl_lookup_module |
Module resolver.
Module lookup function.