4 ms·
Can this be used practically to recompile a binary from one platform (e.g. Intel) to another (e.g. ARM)? It would be interesting to compare the performance with
by amelius 8y ago
Can this be used practically to recompile a binary from one platform (e.g. Intel) to another (e.g. ARM)? It would be interesting to compare the performance with an emulator like QEMU.
- krylon 8y agoI have been thinking about this for a while now - on the one had, as somebody who has never tried anything like this and has no intention of ever doing so, it sounds like a really good idea. On the other hand, if it was such a good idea, why aren't people doing that already instead of paying the performance penalty for emulation over and over?
- imtringued 8y agoThere are a few billion reasons why it doesn't work. Indirect calls and jumps are usually the most common one because they can only be resolved while the program is running. Then there is self modifying code, most commonly because the executable was packed with UPX or equivalent. Then there is the fact that contrary to popular opinion emulators aren't forbidden from using JIT compilers which cache commonly executed code. The JIT may take some time to run but it's a negligible portion of total CPU time. Then there is the problem that the userbase for running emulated software just doesn't exist or is incredibly small. People and businesses are completely fine with running x86 only software on x86 hardware. The effort spent on building a super advanced emulator should instead be spent on making the new platform easier to develop for and ensuring more software is supported natively.
- krylon 8y agoThank you for the explanation!
- rhn_mk1 8y ago> Indirect calls and jumps are usually the most common one because they can only be resolved while the program is running. and > emulators aren't forbidden from using JIT compilers work together also in reverse: decompilers are not forbidden from running the code being analyzed, and a re-compiler could use a JIT in order to work around some more dynamic issues.
- j16sdiz 8y agoQEMU can use dynamic binary translation.
- jcranmer 8y agoIf your goal is to move across different ISAs, then dynamic binary translation is always going to be better than static translation. The problem you're going to run into is that any imprecision in the static analysis is going to explode into problems. If the two architectures have differently-sized pointers, you are clearly screwed before you start. Any value that contains a pointer now has to have its size adjusted, so if you misidentify a pointer as an integer (or vice versa), problems abound. Compilers have a hard time with that, and they get to have the programmer literally tell them what things are pointers.