3 ms·
Actually, can you go the other way, using an executable as a shared library? Here's my usage scenario: I want to test a subset of the code in a large binary. O
by dale_glass 4y ago
Actually, can you go the other way, using an executable as a shared library?
Here's my usage scenario: I want to test a subset of the code in a large binary. One thing I could do is to build a test program from a subset of the application's sources, and then call the required code for the test. But that gets laborious in a large codebase.
So could one hack around that, by somehow turning the binary into a shared library, and telling LD to ignore the fact that there's a main() in there, and replace it with a different one?
- jevinskie 4y agoYou can use dylibify for MachO and, IIRC, Witchcraft Compiler Collection for ELF. https://github.com/jevinskie/dylibify/blob/jev/main/dylibify.m https://github.com/jevinskie/dylibify/blob/jev/main/dylibify...
- Kamq 4y agoThat's the first part of the article. Yes, yes you can as long as the symbols are exported and you do a little magic. So, yes with the standard C toolchain. For other languages/stacks/whatever you're using, it would probably depend on your tooling.