Answer the question
In order to leave comments, you need to log in
Is it possible to "rebuild" executable file for a different architecture?
The question does not let me fall asleep - is it possible to somehow contrive and rebuild the executable file of one architecture, for example, x64, into another, for example, x86 or armv7, in order to run it on the iPad.
Why does it seem to me that this may be possible:
1. From the executable file, you can get x86 assembler
2. ???
3. We get the armv6 assembler
4. we assemble the
armv6 into a binary
As for step 2 -
gcc knows how to compile the code for both architectures
Is it possible for an hour to convert the code in one assembler into code in the other
but there is a mapping between them, possibly complicated due to the mutual influence of commands on each other, but still
Or is it impossible?
ps if this has already been implemented, please give a link
pps very interesting where to read and understand what I'm wrong if so
thanks
If you have the opportunity to write an article on this topic, it would be absolutely great
Answer the question
In order to leave comments, you need to log in
possibly. this utility is a virtual machine. accordingly, it is enough to build an emulator of this processor (for example) bochs on a different architecture. however, no one promises high performance.
Well, if the program does not use any system calls (input / output, for example), then you can try. Hello world will not be rebuilt. :)
Generally speaking, this is impossible (impossibility is implied due to the infinitely huge complexity). To be more precise, your recompilation option comes down to a complete analysis of the disassembled code and, having obtained the exact algorithm of work, rewriting it in assembler for a different architecture (for a different OS-processor combination).
From experience, I can say that even in high-level languages, rewriting code for a different architecture can be difficult. And to do this at the level of assembly code - you won’t even wish your enemy.
If you want, I can describe in more detail the possible pitfalls, problems, and so on.
It is possible, but not necessary. This thing is called Recompilation, but it makes sense only from the point of view of emulation optimization. In any case, it turns out not a full-fledged binary, but emulation, albeit recompiled and more optimal than processor emulation.
Moral: Do you want the right software to run on your shovel? Use free software, it can't have such problems.
Theoretically possible, but very difficult.
Processors have different architectures (instruction sets, number of registers).
Operating systems have different system calls (i.e. what needs to be done to print a character to the console, for example).
Theoretically, you can try to decompile the program into a (relatively) high-level language, and then compile it again. For example, Java is decompiled. Free program - very difficult
Some virtual machines do something like this, analyzing code on the go and generating code for the current architecture - by analogy with JIT (or that's what it is called).
If the OS is Linux, then qemu can emulate the desired processor and translate system calls. apt-get install qemu-user.
Theoretically, it is impossible because the assembler is written on the instructions of the processor and different processors have different instructions.
It's like saying there is a program in C++, but let's run it in Pascal. The cycles are almost the same everywhere.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question