Is there any difference between executable binary files between distributions?

后端 未结 5 1120
甜味超标
甜味超标 2021-02-08 11:23

As all Linux distributions use the same kernel, is there any difference between their executable binary files?

If yes, what are the main differences? Or does that mean w

5条回答
  •  别那么骄傲
    2021-02-08 12:23

    All Linux distributions use the same binary format ELF, but there is still some differences:

    1. different cpu arch use different instruction set.
    2. the same cpu arch may use different ABI, ABI defines how to use the register file, how to call/return a routine. Different ABI can not work together.
    3. Even on same arch, same ABI, this still does not mean we can copy one binary file in a distribution to another. Since most binary files are not statically linked, so they depends on the libraries under the distribution, which means different distribution may use different versions or different compilation configuration of libraries.

    So if you want your program to run on all distribution, you may have to statically link a version that depends on the kernel's syscall only, even this you can only run a specified arch.

    If you really want to run a program on any arch, then you have to compile binaries for all arches, and use a shell script to start up the right one.

提交回复
热议问题