title: How to get Shared Object in Shared Memory
body: <p>Our app depends on an external, 3rd party-supplied configuration (including custom driving/decision making functions) loadable as .so file.</p>
  
  <p>Independently, it cooperates with external CGI modules using a chunk of shared memory, where almost all of its volatile state is kept, so that the external modules can read it and modify it where applicable.</p>
  
  <p>The problem is the CGI modules require a lot of the permanent config data from the .so as well, and the main app performs a whole lot of entirely unnecessary copying between the two memory areas to make the data available. The idea is to make the whole Shared Object to load into Shared Memory, and make it directly available to the CGI. The problem is: how?</p>
  
  <ul>
  <li>dlopen and dlsym don't provide any facilities for assigning where to load the SO file.</li>
  <li>we tried shmat(). It seems to work only until some external CGI actually tries to access the shared memory. Then the area pointed to appears just as private as if it was never shared. Maybe we're doing something wrong?</li>
  <li>loading the .so in each script that needs it is out of question. The sheer size of the structure, connected with frequency of calls (some of the scripts are called once a second to generate live updates), and this being an embedded app make it no-go.</li>
  <li>simply memcpy()'ing the .so into shm is not good either - some structures and all functions are interconnected through pointers.</li>
  </ul>