Save/Load data segment of Dynamically loaded Shared Object library
Our application uses a dynamically loaded shared object library (codec library) to compress and decompress audio streams.
There happens to be several static and global variables in this shared object library. Hence it is not possible to process two interleaved unrelated media streams using this shared object codec library because each stream corrupts/changes the contents of these static/global variables.
Is there a way through which a context save (save contents of data segment of shared object) and a context load (load previously saved contents of data segment of shared object)operation can be performed on the shared object library. This way the context for each media stream can be saved and loaded before and after processing the "other" media stream respectively.
Thanks in advance.
Thank you for your response.
Yes that is a possibility, but it turns out that what you are suggesting is a rather cumbersome solution for us. These shared objects are generated from third party code. Not all global symbols are exported by the shared object. And it is rather tedious to go through 50+ files to determined all global/ static declarations and export them.
This is the reason why we are looking for an approach where the entire data segment of the shared object can be saved/reloaded.
Thanks and Regards,
You could read /proc/self/smaps to find the writable 4KB pages that were mapped by the act of loading the .so.
Those are effectively what you seem to mean by "data segment" of the shared object, but
If the code in the shared object allocates and deallocates any objects from the heap, the shared objects "data segment" would contain only pointers to those heap objects. If you saved/restored/swapped just the "data segment" you would be corrupting the heap any time you save/restore across a boundary of allocate or deallocate on the heap.
|All times are GMT -5. The time now is 09:31 AM.|