I have a server and a client written in C. I try to load a shared library in the server and then pass library function pointers to the client. This way I can change the library without have to compile the client.
Because of every process has its own separate memory space, I wonder if it is possible to load a shared library on a shared memory, pass the function pointers and map the shared memory on the client and then make the client execute the code of the library loaded by the server.
By definition shared library is shared, so two processes will use same physical memory for library’s code segment. So instead of making up some dodgy schemes you can just pass the names of the library and function from server to client and client will get function address using
dlopen()+dlsym().Please note that in this case there will be two copies of data segments (if library has some global or static variables), e.g. if server sets some
staticvariable inside the library function, it’s value won’t change for the client.