About
An object file is an specific operating system format that packages an object code with related metadata to create:
There is several known format that have a common api.
It's a file that is not directly executable.
Common Format
Object file formats are structured as separate sections of data, each section containing a certain type of data. These sections are known as segments due to the term memory segment.
When a program is loaded into memory by a loader, the loader allocates various memory segment of the object file, and thus are usually known by the same names.
Structure:
- Header (descriptive and control information)
- Code segment (CS) (“text segment”, executable code)
- Data segment (DS) (initialized static variables)
- Read-only data segment (rodata, initialized static constants)
- BSS segment: see Assembly - BSS section, segment (uninitialized static data, both variables and constants).
- External definitions and references for linking
- Debugging information
When the program (executable or library) is loaded into memory, static variables are stored:
- if initialized, in the data segment of the program's address space
- if uninitialized, in the BSS segment
In real mode, the registers CS, DS, SS, and ES point to the currently used program code segment (CS), the current data segment (DS), the current stack segment (SS), and one extra segment determined by the programmer (ES).
Format
- a.out (Linux and BSD)
- AIF
- COFF
- CMD
- COM
- ECOFF
- GOFF
- Hunk
- Mach-O
- MZ
- NE
- OMF
- OS/360
- PE
- PEF
- XCOFF
- 16-bit and 32-bit OBJ (OMF) format,
- Win32 and Win64.
API
The GNU Project's wiki/Binary File Descriptor library (BFD library) provides a common API for the manipulation of object files in a variety of formats.
Debugger/ Decompiler
- Decompiler - Snowman - Reads ELF, Mach-O, and PE file formats.