Object file
Encyclopedia
An object file is a file containing relocatable format machine code
that is usually not directly executable. Object files are produced by an assembler, compiler
, or other language translator, and used as input to the linker.
Additionally, object files may contain metadata
such as information to resolve symbolic cross-references between different modules, relocation
information, stack unwinding information, comments
, program symbols
, debugging or profiling information. A linker is typically used to generate an executable
or library by combining parts of object files.
used for the storage of object code and related data typically produced by a compiler
or assembler.
There are many different object file formats; originally each type of computer had its own unique format, but with the advent of Unix
and other portable
operating systems, some formats, such as COFF
and ELF
have been defined and used on different kinds of systems. It is possible for the same file format to be used both as linker input and output, and thus as the library and executable file format.
The design and/or choice of an object file format is a key part of overall system design. It affects the performance of the linker and thus programmer
turnaround while developing. If the format is used for executables, the design also affects the time programs take to begin running, and thus the responsiveness
for users. Most object file formats are structured as blocks of data, each block containing a certain type of data (see Memory segmentation). These blocks can be paged
in as needed by the virtual memory
system, needing no further processing to be ready to use.
Debugging information may either be an integral part of the object file format, as in COFF
, or a semi-independent format which may be used with several object formats, such as stabs
or DWARF
.
The GNU Project
's Binary File Descriptor library (BFD library) provides a common API for the manipulation of object files in a variety of formats.
Types of data supported by typical object file formats:
Machine code
Machine code or machine language is a system of impartible instructions executed directly by a computer's central processing unit. Each instruction performs a very specific task, typically either an operation on a unit of data Machine code or machine language is a system of impartible instructions...
that is usually not directly executable. Object files are produced by an assembler, compiler
Compiler
A compiler is a computer program that transforms source code written in a programming language into another computer language...
, or other language translator, and used as input to the linker.
Additionally, object files may contain metadata
Metadata
The term metadata is an ambiguous term which is used for two fundamentally different concepts . Although the expression "data about data" is often used, it does not apply to both in the same way. Structural metadata, the design and specification of data structures, cannot be about data, because at...
such as information to resolve symbolic cross-references between different modules, relocation
Relocation (computer science)
"Relocation is the process of assigning load addresses to various parts of [a] program and adjusting the code and data in the program to reflect the assigned addresses."...
information, stack unwinding information, comments
Comment (computer programming)
In computer programming, a comment is a programming language construct used to embed programmer-readable annotations in the source code of a computer program. Those annotations are potentially significant to programmers but typically ignorable to compilers and interpreters. Comments are usually...
, program symbols
Debug symbol
A debug symbol is information that expresses which programming-language constructs generated a specific piece of machine code in a given executable module. Sometimes the symbolic information is compiled together with the module's binary file, or distributed in separate file, or simply discarded...
, debugging or profiling information. A linker is typically used to generate an executable
Executable
In computing, an executable file causes a computer "to perform indicated tasks according to encoded instructions," as opposed to a data file that must be parsed by a program to be meaningful. These instructions are traditionally machine code instructions for a physical CPU...
or library by combining parts of object files.
Object file formats
An object file format is a computer file formatFile format
A file format is a particular way that information is encoded for storage in a computer file.Since a disk drive, or indeed any computer storage, can store only bits, the computer must have some way of converting information to 0s and 1s and vice-versa. There are different kinds of formats for...
used for the storage of object code and related data typically produced by a compiler
Compiler
A compiler is a computer program that transforms source code written in a programming language into another computer language...
or assembler.
There are many different object file formats; originally each type of computer had its own unique format, but with the advent of Unix
Unix
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...
and other portable
Porting
In computer science, porting is the process of adapting software so that an executable program can be created for a computing environment that is different from the one for which it was originally designed...
operating systems, some formats, such as COFF
COFF
The Common Object File Format is a specification of a format for executable, object code, and shared library computer files used on Unix systems...
and ELF
Executable and Linkable Format
In computing, the Executable and Linkable Format is a common standard file format for executables, object code, shared libraries, and core dumps. First published in the System V Application Binary Interface specification, and later in the Tool Interface Standard, it was quickly accepted among...
have been defined and used on different kinds of systems. It is possible for the same file format to be used both as linker input and output, and thus as the library and executable file format.
The design and/or choice of an object file format is a key part of overall system design. It affects the performance of the linker and thus programmer
Programmer
A programmer, computer programmer or coder is someone who writes computer software. The term computer programmer can refer to a specialist in one area of computer programming or to a generalist who writes code for many kinds of software. One who practices or professes a formal approach to...
turnaround while developing. If the format is used for executables, the design also affects the time programs take to begin running, and thus the responsiveness
Responsiveness
Responsiveness as a concept of computer science refers to the specific ability of a functional unit to complete assigned tasks within a given time, but also may incorporate the ability of an artificial intelligence system to understand and carry out its tasks in a timely fashion. It is one of the...
for users. Most object file formats are structured as blocks of data, each block containing a certain type of data (see Memory segmentation). These blocks can be paged
Paging
In computer operating systems, paging is one of the memory-management schemes by which a computer can store and retrieve data from secondary storage for use in main memory. In the paging memory-management scheme, the operating system retrieves data from secondary storage in same-size blocks called...
in as needed by the virtual memory
Virtual memory
In computing, virtual memory is a memory management technique developed for multitasking kernels. This technique virtualizes a computer architecture's various forms of computer data storage , allowing a program to be designed as though there is only one kind of memory, "virtual" memory, which...
system, needing no further processing to be ready to use.
Debugging information may either be an integral part of the object file format, as in COFF
COFF
The Common Object File Format is a specification of a format for executable, object code, and shared library computer files used on Unix systems...
, or a semi-independent format which may be used with several object formats, such as stabs
Stabs
stabs is a debugging data format for storing information about computer programs for use by symbolic and source-level debuggers...
or DWARF
DWARF
DWARF is a widely used, standardized debugging data format. DWARF was originally designed along with Executable and Linkable Format , although it is independent of object file formats...
.
The GNU Project
GNU Project
The GNU Project is a free software, mass collaboration project, announced on September 27, 1983, by Richard Stallman at MIT. It initiated GNU operating system development in January, 1984...
's Binary File Descriptor library (BFD library) provides a common API for the manipulation of object files in a variety of formats.
Types of data supported by typical object file formats:
- BSS (Block Started by Symbol)
- Text segment
- Data segmentData segmentA data segment is a portion of virtual address space of a program, which contains the global variables and static variables that are initialized by the programmer...