You can simply use dlsym()for this purpose. You just need to export all the characters to a dynamic symbol table. Link the binary to gcc -rdynamicfor this.
Example:
#include <stdio.h>
#include <dlfcn.h>
void foo (void) {
puts("foo");
}
int main (void) {
void (*foo)(void) = dlsym(NULL, "foo");
foo();
return 0;
}
Compile with: gcc -rdynamic -O2 dl.c -o dl -ldl
$ ./dl
foo
$
source
share