How can I add a symbol to process symbol table dynamically on linux? For example, suppose I parse a script and determine that it has some methods which I then want to add into global address space so that they can be accessed by shared libraries loaded afterwards. What I then want to do is add a function pointer to a stub function that will call the script function and return the result (in C). But I want to say "add 'foo' pointing to &mygenericstub to global symbol table".. so when I then do dlopen() on an .so file with RTLD_GLOBAL flag, it will be able to call 'foo' as though it was a normal C function in the global namespace..
The idea is rather simple: to extend functionality of dynamic linker for that single process to also include names from scripts (but not just having an entry point function that takes a string argument for the script function to be called - but rather making the dynamic linking process transparent to other shared objects that may be loaded later). The idea would be not to modify existing table, but rather to map a new table as an extension to existing one (maybe this can somehow be done using mmap but I don't know what to map and how to extend it). Basically something similar to dlopen with the "global" option that works for dynamic names would be interesting.