Object code is the result of a program taking source code and running it through a compiler or assembler. This creates the object code which can then be linked together in such a way that the computer can understand it. Executables are created in such a way. Both are platform/processor dependend. A Mac could not understand the object code created for Linux, just as DOS could not understand the object code created for an Amiga, unless an emulator was used.

Object code is the machine-readable representation of a computer program, and is the final target of the source-code compilation process. Object code is not simply a binary memory image of the program when loaded, but contains metadata necessary for modern operational necessities, such as relocation.

Object Files: Object code is stored in object files, which are repositories of the individual objects and symbols a program requires for operation — if it is executable — or that can be included in complete programs. Operating systems generally define object file formats, since the operating system is responsible for reading the object file and communicating its contents to the processor.

Symbols: One of the major forms of metadata stored in object files is the symbol table. Each unit of machine-executable instructions — whether it be a subroutine/function, or address for a variable — has a name by which it is referenced by other parts of a program when they wish to make use of it. The symbol table provides a means of organizing individual objects with the object file into a usable collection of object code.

Linking: Linking is one of the processes which depend on symbol table metadata. In producing an executable file (a special object file which is capable of being read into memory and executed as a unified whole), symbols to which individual segments of the program refer are added to the executable object file, along with the blocks of object code to which they refer (in static linking, that is: dynamic linking is more complex) so that when the program is executed, it can easily find and load objects it requires.

Relocation: <gross_simplification>In the past, object code was created with absolute addresses pointing to fixed locations in memory. Programs could operate only using memory at these hardcoded locations, and could not run if another program was loaded into their desired space. Modern object code is created with reference to offsets from a runtime-determined location in memory, and is relocated by setting the start point at runtime and loading code into memory locations relative this start point.</gross_simplification>

Log in or registerto write something here or to contact authors.