Hello all,
i'm trying to create a plugin system with the C language.
I am able to load the libs and get the functions I need, then I put them in a function pointer array to use them later.
There is a main source file and an additional one which is dedicated to plugins:
Code:
/**main.c**/
void (*init_proto_chain[20])(void *);
void init_protos(){
(init_proto_chain[i])(data);
}
Code:
/**plugins.c**/
extern (*init_proto_chain[20])(void*);
void load_plugins(){
handle = dlsym("...libhttp.so",RTLD_NOW);
void *func = dlsym(handle, "test");
init_proto_chain[j] = ((void (*) (void *))func;
}
When I try to use any of the functions in the main code, I get a segfault and when I use gdb I can see there is nothing at the function address.
Yet, if I call "test()" by dereferencing func or init_proto_chain[j] when in load_plugins, it's working and the function pointer is valid.
Thanks in advance for any help.