Nepedia
Back to Discover
Advanced Reader
💻

Object code

technology Maturity 11-13 Next article →

In the world of computing, object code is a vital intermediate product. It is the result of a process called compilation or assembly. You can think of it as a bridge between human ideas and machine actions. Object code consists of a sequence of instructions in a computer language. Most often, this is machine code, which is a binary language. It can also be an intermediate language like register transfer language (RTL). This code represents the goal or result of the compiling process.

To understand how this works, we must look at the conversion process. A programmer starts with source code to write instructions. Then, a tool called an assembler or a compiler takes that code. An assembler converts assembly code into machine code, which becomes the object code. This object code is a portion of machine code. However, it is not yet a complete, runnable program. It is the machine code for one specific module or library.

Object code has unique features that distinguish it from final machine code. While machine code can be executed directly by a CPU, object code cannot. This is because object code contains placeholders or offsets. These are specific spots that are not found in a completed program. These placeholders allow for future connections. The code has jumps and inter-module references that are partially parametrized. This means they are not yet fully defined. A tool called a linker must fill these parameters in later.

There are different ways these files are organized and used. An object file is typically one part of a larger system. It might represent one particular library or one specific module. To be useful, object code must be placed into a specific type of file. It can be placed in an executable file or a library file. It can also remain as an object file itself. These files are eventually combined to make the final product.

The linker plays a crucial role in managing these files. A linker takes several object files and library files and joins them. This process generates either an executable file or a library file. An executable file is a complete program that a computer can run. During this process, the linker handles memory and connections. An object file is assumed to begin at a specific location in memory. This starting location is often zero.

Linking also involves a process called relocation. Object files contain information regarding instructions that reference memory. The linker uses this information to move the code around. This allows the linker to relocate the code when combining multiple files. This step is necessary to fit all the pieces into a single, working program. Without relocation, the different modules might conflict with each other in the computer's memory.

Historically, the way we describe these processes has changed. In early computing sources, the original source code was called a "subject program." This terminology shows that the object code was seen as the ultimate goal. Today, we use more specific terms like compiler and assembler. We also know that some tools can skip steps. Some assemblers and compilers can assemble directly to machine code. This allows them to produce executable files without using an object intermediary step.

534 words

Where will your curiosity go next?

Keep exploring at your chosen reading level.

More to explore

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.