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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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_allocateis 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
dlopenet. al.