Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any difference between executable binary files between distributions?

Tags:

linux

kernel

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 we can build a universal linux executable file?

like image 718
Mickey Shine Avatar asked Jun 23 '09 01:06

Mickey Shine


People also ask

Is a binary file the same as an executable?

In general, executable -- or ready-to-run -- programs are identified as binary files and given a filename extension such as . bin or .exe. Programmers often talk about an executable program as a binary or will refer to their compiled application files as binaries.

Are all binary files the same?

Two files that are binary compatible will have the same sequence of zeros and ones in the data portion of the file. The file header, however, may be different. The term is used most commonly to state that data files produced by one application are exactly the same as data files produced by another application.

Why is an executable called a binary?

Now, in Linux you'll often hear "binaries" when referring to "binary executable files" - programs. This is because while sources of most programs (written in high-level languages) are plain text, compiled executables are binary.

Is .exe file written in binary?

Executable files contain binary machine code that has been compiled from source code.


1 Answers

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.

like image 200
Sam Liao Avatar answered Oct 02 '22 23:10

Sam Liao