Hacker News new | past | comments | ask | show | jobs | submit login

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.



That means you can't copy the executable after executing once and have it run on Windows, correct?


Probably the rewriting is only done on the program loaded into RAM?


No, 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.


Hmm, possibly, though that wouldn't really make sense, why not just execute itself at that point?


Ah thank you. And I presume the qemu part is optional, used only when the target platform is non x86?




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: