libdragon
Loading...
Searching...
No Matches
Files | Macros | Functions | Variables
Dynamic linker subsystem

Interface to libdl-style dynamic linker. More...

Files

file  dlfcn.c
 Dynamic linker subsystem.
 
file  dlfcn.h
 Dynamic linker subsystem.
 

Macros

#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.
 

Functions

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.
 

Variables

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.
 

Detailed Description

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.

Function Documentation

◆ __dl_insert_module()

void __dl_insert_module ( dl_module_t module)

Insert module into module list.

This function is non-static to help debuggers support overlays.

Parameters
modulePointer to module

◆ __dl_remove_module()

void __dl_remove_module ( dl_module_t module)

Remove module from module list.

This function is non-static to help debuggers support overlays.

Parameters
modulePointer to module

◆ dlopen()

void * dlopen ( const char *  filename,
int  mode 
)

Open dynamic library.

Parameters
filenamePath to dynamic library
modeFlags 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
handleDynamic library handle to search symbol from
symbolName of symbol to search for
Returns
Pointer to symbol

◆ dlclose()

int dlclose ( void *  handle)

Close loaded dynamic library.

Parameters
handleDynamic library handle to close
Returns
Whether an error occurred

◆ dladdr()

int dladdr ( const void *  addr,
Dl_info info 
)

Convert address to symbol.

Parameters
addrAddress to search
infoInfo of symbol found
Returns
Zero on success and non-zero on failure

◆ dlerror()

char * dlerror ( void  )

Return last error that occurred in dynamic linker.

Returns
String describing last error occurring in dynamic linker

Variable Documentation

◆ __dl_lookup_module

module_lookup_func __dl_lookup_module

Module resolver.

Module lookup function.