-6

Suppose you have an ARM embedded device and a x64 based laptop. Both systems are running GNU/Linux. If you decide to copy the "ls" binary from the laptop to the embedded device and run it on the embedded, will it work? Explain your reasoning.

bertieb
  • 7,543

2 Answers2

6

Suppose you have an ARM embedded device and a x64 based laptop. Both systems are running GNU/Linux.

OK.

If you decide to copy the "ls" binary from the laptop to the embedded device and run it on the embedded, will it work?

This is where it gets tricky. It obviously won't run as is; the instruction sets are completely different.

However, it can be made to run.

The obvious choice is some form of virtualization or emulation. By emulating the CPU and surrounding support circuitry, you can run any executable binary, as long as you can write an emulator that is close enough to the original hardware and firmware to produce the result you are after.

This is done all the time; it's how old Sega or Nintendo games, Apple ][ software, and whatnot can be made to run on modern PCs. When the target platform has considerably more processing power than the origin platform, and given sufficiently detailed documentation of the hardware and firmware, emulation is often relatively easy. Consider this IBM 5150 emulator written in Javascript that runs inside your web browser for an example. Cross-compilation and emulation is a relatively common approach when developing software for embedded platforms.

Another alternative would be to translate the machine code to the target (the ARM-based device, in this case) architecture using a compiler. Depending on the degree of difference between the architectures, that could be trivial or it could be very hard. It would be particularly problematic if the surrounding circuitry is largely different; for example, a video game that relies on the game console's specialized sprite and sound handling hardware probably won't translate easily to a platform that doesn't have those features.

The real question is: why would you want to do something like this in the first place?

Using a binary natively built for the target platform will, when available, almost certainly be the easiest solution.

user
  • 30,336
1

No. Because the binary file was compiled for another processor. It's based in Intel x86 instruction set, and won't make sense for an ARM or any other processor for that matter.

drkblog
  • 2,665