- publishing free software manuals
An Introduction to GCC - for the GNU compilers gcc and g++
by Brian J. Gough, foreword by Richard M. Stallman
Paperback (6"x9"), 144 pages
ISBN 0954161793
RRP £12.95 ($19.95)

"An excellent introduction... fills a much-needed niche in the marketplace" --- Association of C and C++ Users book review (Issue 16-4, August 2004) Get a printed copy>>>

12.1 Identifying files

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:

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)).
The word size (for some platforms this would be 64-bit).
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)(36). 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 standard(37) for Unix systems defines the behavior of the file command.

ISBN 0954161793An Introduction to GCC - for the GNU compilers gcc and g++See the print edition