Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What part (specifically) of a native executable makes it non-portable?

This sounds like a daft question at first, but bear with me.

It is common knowledge that binaries for one CPU architecture do not run on others. So for example it is impossible to run (without a compatibility layer of some kind), an x86 binary on a sparc64 chip. The instruction sets are different, so clearly that will not work.

But when the binary is for the same CPU, but for a different operating system, which part of the code prevents execution from being possible. For example, running an x86 Solaris binary on an x86 Linux box. I am assuming that there is some kind of platform specific stub which relates to the run-time linker or process scheduler?

I would be interested to know. Thanks.

like image 586
Edd Barrett Avatar asked May 31 '09 15:05

Edd Barrett


1 Answers

There are a number of reasons. The main ones, ordered in "distance from the metal" are:

  1. The operating systems may have different binary formats for executable files. In this case you will not be able to load the binary in the first place.
  2. The program may use another method to indicate they wish to place a system call (e.g. INT21 vs INT80).
  3. The program may rely on system calls that are not present in the other OS (e.g. dlopen())
  4. The program may rely on the standard library not present on the other OS.
  5. The program may rely on other libraries that are not available on the other OS.

Of course there are many more ways a program running in an unexpected environment can fail spectacularly.

like image 168
drxzcl Avatar answered Nov 15 '22 09:11

drxzcl