libnds
|
Helpers to load dynamic libraries. More...
#include <stdio.h>
Functions | |
int | dlclose (void *handle) |
Frees all memory used by a dynamic library. | |
char * | dlerror (void) |
Returns a user-readable error string. | |
void * | dlmembase (void *handle) |
Returns a pointer to the base address of the code loaded with the library. | |
void * | dlopen (const char *file, int mode) |
Loads a dynamic library (in DSL format) into RAM. | |
void * | dlopen_FILE (FILE *f, int mode) |
Loads a dynamic library (in DSL format) into RAM from a FILE handle. | |
void * | dlsym (void *handle, const char *name) |
Returns a pointer to the requested symbol. | |
Helpers to load dynamic libraries.
The functions in this file allow the user to load DSL (Nintendo DS Loadable) files. They are a simplified version of ELF files created by dsltool
, which is a tool included in BlocksDS.
int dlclose | ( | void * | handle | ) |
char * dlerror | ( | void | ) |
Returns a user-readable error string.
It clears the error string after being called.
void * dlmembase | ( | void * | handle | ) |
Returns a pointer to the base address of the code loaded with the library.
The purpose of this function is to print this address to be used when debugging the code with emulators. You must provide this address when loading the elf file of the library. For example, with the GDB command line:
Note that this is a libnds-specific function.
handle | The handle returned by dlopen(). |
void * dlopen | ( | const char * | file, |
int | mode | ||
) |
Loads a dynamic library (in DSL format) into RAM.
file | Path of the DSL file. |
mode | Mode in which the file will be opened. Currently, the only mode supported is RTLD_NOW | RTLD_LOCAL . Also, RTLD_LOCAL is the default setting, so it isn't required to specify it explicitly. |
void * dlopen_FILE | ( | FILE * | f, |
int | mode | ||
) |
Loads a dynamic library (in DSL format) into RAM from a FILE handle.
The handle must be opened before dlopen_FILE() is called and it must be closed after dlopen_FILE() returns. It isn't needed after the library has been loaded.
For example, you can use this to load a dynamic library that you have already loaded to RAM. You can use fmemopen()
on the buffer where the library is stored and pass the resulting handle to dlopen_FILE()
.
f | Open file handle to the DSL library file. |
mode | Mode in which the file will be opened. Currently, the only mode supported is RTLD_NOW | RTLD_LOCAL . Also, RTLD_LOCAL is the default setting, so it isn't required to specify it explicitly. |
void * dlsym | ( | void * | handle, |
const char * | name | ||
) |
Returns a pointer to the requested symbol.
handle | The handle returned by dlopen(). |
name | The name of the requested symbol. |