Is it possible to load a library from memory instead of from the filesystem on mac/gcc?
With windows I'm using MemoryModule but it's obviously not cross-platform compatible.
Is it possible to load a library from memory instead of from the filesystem on mac/gcc?
With windows I'm using MemoryModule but it's obviously not cross-platform compatible.
First things first, to do this I advise you use read the OS X ABI Dynamic Loader Reference.
To do this, you must use the NSCreateObjectFileImageFromMemory API.
Make sure to abide by the requirement that
vm_allocate
is used for the memory block containing the module.Once you acquire the object file image, you must use NSLinkModule function to link the module into the program.
After linking, don't forget to clean up by calling the NSDestroyObjectFileImage function.
Note that while these functions are deprecated, there is no substitute (to the best of my knowledge) using the suggested alternative
dlopen
et. al.