On windows I map a PE file to memory, fix the import table, and call the entry-point in a new thread to turn an exe into a "DLL". I need to do the same on linux, but I am not familiar with library and executable loading. What would be the best method to achieve this, what should I look into? Thank you
Asked
Active
Viewed 76 times
0
-
Does this answer your question? [building a .so that is also an executable](https://stackoverflow.com/questions/1449987/building-a-so-that-is-also-an-executable) – Dúthomhas Jan 30 '23 at 20:50
-
Similar concept, however, I am not able to recompile the executable. Also, dlopen seems to not even allow loading PIE files as it throws error "cannot dynamically load position-independent executable" when I attempt it – Zachary Washburn Jan 30 '23 at 20:55
-
Not possible. The "cannot dynamically load position-independent executable" error is for a [reason](https://patchwork.ozlabs.org/project/glibc/patch/20190312130235.8E82C89CE49C@oldenburg2.str.redhat.com/). – n. m. could be an AI Jan 30 '23 at 21:11
-
@n.m. well considering the functionality was there before, and I found examples of people using it before the change. I suppose I'll have to bytepatch the check out of glibc. Or write a mapper like I did for windows. "not possible" is never true in computers... – Zachary Washburn Jan 30 '23 at 21:13
-
The maintainers of glibc decided that it is not possible for them to make the functionality work properly, and it needs to be removed. You do whatever. – n. m. could be an AI Jan 30 '23 at 21:25
-
1@ZacharyWashburn *"not possible" is never true in computers...* Let us know when you outsmart Turing and win a Nobel prize for solving the halting problem. – Andrew Henle Jan 30 '23 at 21:42
-
What will this buy you that fork/exec does not? The point of running the code in a thread would be to be able to share data in memory, but if your file was built to be a standalone executable, then it isn't going to be expecting to do that. – Nate Eldredge Jan 30 '23 at 22:09
-
@NateEldredge Shared memory addressing primarily – Zachary Washburn Jan 30 '23 at 22:18