When a source file has been compiled to an object file or executable the
options used to compile it are no longer obvious. The file
command looks at the contents of an object file or executable and
determines some of its characteristics, such as whether it was compiled
with dynamic or static linking.
For example, here is the result of the file
command for a typical
executable:
$ file a.out a.out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
The output shows that the executable file is dynamically linked, and compiled for the Intel 386 and compatible processors. A full explanation of the output is shown below:
ELF
¶The internal format of the executable file (ELF stands for “Executable and Linking Format”, other formats such as COFF “Common Object File Format” are used on some older operating systems (e.g. MS-DOS)).
32-bit
¶The word size (for some platforms this would be 64-bit).
LSB
¶Compiled for a platform with least significant byte first word-ordering, such as Intel and AMD x86 processors (the alternative MSB most significant byte first is used by other processors, such as the Motorola 680x0)42. Some processors such as Itanium and MIPS support both LSB and MSB orderings.
Intel 80386
The processor the executable file was compiled for.
version 1 (SYSV)
¶This is the version of the internal format of the file.
dynamically linked
The executable uses shared libraries (statically linked
indicates
programs linked statically, for example using the -static option)
not stripped
¶The executable contains a symbol table (this can be removed with the
strip
command).
The file
command can also be used on object files, where it
gives similar output. The POSIX standard43 for Unix systems defines the behavior
of the file
command.
The MSB and LSB orderings are also known as big-endian and little-endian respectively (the terms originate from Jonathan Swift’s satire “Gulliver’s Travels”, 1727).
POSIX.1 (2003 edition), IEEE Std 1003.1-2003.