can a .so file be used directly from memory?
ive a .so file stored in a (char *) is there any way i could load functions from it directly? without writing it to disk?
it can be done in windows (dll files) by using some c implementation to use LoadLibrary and GetProcAddress on a dll stored in memory (char *), so i was wondering if such thing exists or possible on linux with dlopen and dlsym? thanks. |
Well, the simplest thing would be to open a tmp file, and write the .so file to it, do what you gotta do, and then remove it.
If that particular piece of code has to be so confidential, make it a part of the binary itself. |
The trick is that there is executable code in the library. The char array is in a data-only space, and code in a data segment is not executable. An interesting question is how a userspace application coerces the appropriate pieces of the shared object library to load into an appropriate code space.
--- rod. |
i dont think its related to the executable sections (.text in this case) the whole problem lies on mapping it to memory as .so file (like dlopen does) and obtain its file descriptot, the rest i guess is easy
|
basically its the ld-linux that hooks up static libraries to running programs. my guess would be that you'd have to take its source and modify it to do what you want.
|
Quote:
It sounds like you are simply trying to replicate the work of a linking loader. Why not have the the existing loader do this? It works on files, though, not on in-memory images. If you export the in-memory image as a virtual file (fuse), then it could be operated on by a conventional loader. --- rod. |
All times are GMT -5. The time now is 09:11 PM. |