3 ms·
It turns out to be impossible to create a file that is simultaneously a valid ELF and Windows PE. The solution to this is to make a file that is simultaneously
by tbodt 6y ago
It turns out to be impossible to create a file that is simultaneously a valid ELF and Windows PE. The solution to this is to make a file that is simultaneously a valid PE and shell script, and have the shell script overwrite the start of the file with an ELF header and re-exec itself.
- krackers 6y agoAh thank you. And I presume the qemu part is optional, used only when the target platform is non x86?
- StavrosK 6y agoThat means you can't copy the executable after executing once and have it run on Windows, correct?
- shandor 6y agoProbably the rewriting is only done on the program loaded into RAM?
- StavrosK 6y agoHmm, possibly, though that wouldn't really make sense, why not just execute itself at that point?
- yjftsjthsd-h 6y agoNo, there's a discussion upthread about running on Darwin that specifically says you have to run as `bash ./foo` first time and `./foo` thereafter because it overwrites on disk.