libdragon
Loading...
Searching...
No Matches
dlfcn.h
Go to the documentation of this file.
1
7#ifndef __LIBDRAGON_DLFCN_H
8#define __LIBDRAGON_DLFCN_H
9
11#define RTLD_LAZY 0x0
13#define RTLD_NOW 0x0
15#define RTLD_GLOBAL 0x1
17#define RTLD_LOCAL 0x0
19#define RTLD_NODELETE 0x2
21#define RTLD_NOLOAD 0x4
22
24#define RTLD_DEFAULT ((void *)-1)
26#define RTLD_NEXT ((void *)-2)
27
29typedef struct {
31 const char *dli_fname;
33 void *dli_fbase;
35 const char *dli_sname;
37 void *dli_saddr;
38} Dl_info;
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44// Embedded GDB script to auto-load DSO symbols
45#ifndef N64_DSO
47asm(
48".pushsection \".debug_gdb_scripts\", \"MS\",@progbits,1\n"
49".byte 4\n"
50".ascii \"gdb.inlined-script-dso-autoload\\n\"\n"
51".ascii \"import gdb\\n\"\n"
52".ascii \"class BreakpointDsoLoad(gdb.Breakpoint):\\n\"\n"
53".ascii \" def stop(self):\\n\"\n"
54".ascii \" frame = gdb.selected_frame()\\n\"\n"
55".ascii \" src_elf = gdb.execute('printf \\\"%s\\\", module->src_elf', False, True)\\n\"\n"
56".ascii \" prog_base = int(gdb.execute('printf \\\"%x\\\", module->prog_base', False, True), 16)\\n\"\n"
57".ascii \" print(\\\"Loading overlay: \\\", src_elf, \\\"(text:\\\", hex(prog_base), \\\")\\\")\\n\"\n"
58".ascii \" gdb.execute(\\\"add-symbol-file -readnow \\\" + src_elf + \\\" \\\" + hex(prog_base), False, True)\\n\"\n"
59".ascii \" return False\\n\"\n"
60".ascii \"class BreakpointDsoFree(gdb.Breakpoint):\\n\"\n"
61".ascii \" def stop(self):\\n\"\n"
62".ascii \" frame = gdb.selected_frame()\\n\"\n"
63".ascii \" src_elf = gdb.execute('printf \\\"%s\\\", module->src_elf', False, True)\\n\"\n"
64".ascii \" prog_base = int(gdb.execute('printf \\\"%x\\\", module->prog_base', False, True), 16)\\n\"\n"
65".ascii \" print(\\\"Unloading overlay: \\\", src_elf, \\\"(text:\\\", hex(prog_base), \\\")\\\")\\n\"\n"
66".ascii \" gdb.execute(\\\"remove-symbol-file -a \\\" + hex(prog_base), False, True)\\n\"\n"
67".ascii \" return False\\n\"\n"
68".ascii \"bp_load = BreakpointDsoLoad(\\\"__dl_insert_module\\\")\\n\"\n"
69".ascii \"bp_load.silent = True\\n\"\n"
70".ascii \"bl_free = BreakpointDsoFree(\\\"__dl_remove_module\\\")\\n\"\n"
71".ascii \"bl_free.silent = True\\n\"\n"
72".byte 0\n"
73".popsection\n"
74);
76#endif
77
85void *dlopen(const char *filename, int mode);
86
94void *dlsym(void *handle, const char *symbol);
95
102int dlclose(void *handle);
103
111int dladdr(const void *addr, Dl_info *info);
112
118char *dlerror(void);
119
120#ifdef __cplusplus
121}
122#endif
123
124#endif
void * dli_saddr
Exact address of symbol named in dli_sname.
Definition dlfcn.h:37
const char * dli_sname
Name of symbol whose definition overlaps addr.
Definition dlfcn.h:35
const char * dli_fname
Pathname of shared object that contains address.
Definition dlfcn.h:31
void * dli_fbase
Base address at which shared object is loaded.
Definition dlfcn.h:33
dl_addr info structure
Definition dlfcn.h:29
void * dlopen(const char *filename, int mode)
Open dynamic library.
Definition dlfcn.c:402
char * dlerror(void)
Return last error that occurred in dynamic linker.
Definition dlfcn.c:631
void * dlsym(void *handle, const char *symbol)
Grab symbol from loaded dynamic library.
Definition dlfcn.c:467
int dladdr(const void *addr, Dl_info *info)
Convert address to symbol.
Definition dlfcn.c:596
int dlclose(void *handle)
Close loaded dynamic library.
Definition dlfcn.c:570