Question

Let's say I created an object file from a hello.c on an x86 computer, then sent that file to an ARM computer. Would it be able to build an executable out of the received object file? Assuming we are using gcc.


Note:

I am aware of cross-compiling as a well-known method for basically the same end result, but was curious of this specific scenario.

I'm also aware of this question, but wanted to mainly stress on different CPU architectures and same compiler as I did not find those points clear with my modest understanding.

Was it helpful?

Solution

There is no standard for what an object file contains. Some may contain machine instructions already, others may be platform independent. So if at all, it depends on your specific compiler and thus becomes an application specific question.

For example, the ELF-header contains information on CPU and ABI the binary was compiled for and this unfortunately ends the discussion already.

OTHER TIPS

You can rely on that it will not work! You simply can never execute x86 code on a arm cpu. This is independent of any meta information which is placed in the object file like in ELF. The object file contains executable code and a arm cpu can never execute a binary created for a different cpu.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top