Formats Object files, also known as assemblies, are files which contain machine code that is output by an assembler. There are 3 main attributes an object file can have: executable, shared, and relocatable. An executable object file is called a program, a shared object file is called a library, and a relocatable object file is called a module. Programs are able to be executed standalone whereas libraries only provide functionality to programs. Modules are combined, or linked, together to make programs, libraries, or other modules. Each object file is divided into one or more stubs, each of which containing one or more sections. For example, a Microsoft .EXE executable normally consists of 2 stubs. The first is a DOS stub and the second is a Portable Executable stub. The DOS stub has 2 sections, .text and .rel.text. The Portable Executable stub has numerous ones. Each stub usually contains machine code only for a particular architecture, such as the x86. When an object file contains stubs for multiple architectures, it is called a fat object file. Examples of fat object file formats include Apple’s Universal Binary and the Linux FatELF. Sections Most stubs have at least 2 sections. The first section is the text section, sometimes called the code section, which contains machine code to be executed and is usually read-only. The second is called the data section and contains only data such as numbers and strings which may be read or written to by the program. On many machines, especially on older or embedded systems, the data section is combined, or folded, into the text section by making the text section writable. One advantage of this is that the code can modify itself to become more compact. A majority of modern object file formats also contain another section called the bss section. The term “bss” stands for “Block Started by Symbol”. It doesn’t actually contain any information, it just declares how much uninitialized data there is. This space is then allocated when the program begins, and is usually filled with null values. Each section in a stub can have multiple properties, such as being executable, relocatable, readable, or writable. All sections for code and data are relocatable until the modules are linked together into the final program or library. Symbols In some object file formats, sections have symbols that represent certain addresses for things like functions or variables. These symbols are usually stored in a particular section called the symbol table and are used to resolve relocations when the modules are linked into a program or library. Symbols can also have names by containing a relative offset to a string within another section called the string table. There are 3 types of symbols within object files. The first are normal symbols which are resolved when linking as stated above. The second are dynamic symbols. These symbols are resolved by the program loader at runtime when using shared libraries. The third type of symbols are called relocatable symbols. Like dynamic symbols, these are resolved by the program loader at runtime. However, they are typically used for position independent code. They are especially common in overlays. Overlays are sub-programs that are overlay each other in memory. They are most often used in embedded systems or older platforms like DOS to reduce the memory overhead. Each overlay can also have additional sub-overlays, forming a tree. Each branch on this tree is called a wave. The term “wave” is descriptive of how a branch of the tree of overlays is loaded, as a wave of data that overlays the previous data.