Fundamentals 5 min read

Step‑by‑Step: How a Program Is Loaded and Executed by the OS

The article explains how an executable file is located, parsed (e.g., ELF), loaded into memory, divided into code, data, heap and stack regions, how dynamic libraries are placed, and how the OS uses the entry‑point address to start the CPU executing the program.

IT Services Circle
IT Services Circle
IT Services Circle
Step‑by‑Step: How a Program Is Loaded and Executed by the OS

A program is simply a file that stores a sequence of machine instructions; for example, chrome.exe is a regular file containing millions of instructions that the CPU can execute.

Running the program—by double‑clicking its icon or invoking it from a command line—first requires the operating system to locate the file on disk using the file system.

Once found, the OS parses the executable format (Linux typically uses the ELF format) to identify the locations of code, data, and other sections.

The OS then loads the program by copying its instructions and global variables from the file into RAM, allocating a contiguous free memory region for the new process.

Within that region the OS creates the familiar memory areas: the code (text) segment and data segment come directly from the executable, while the heap and stack are runtime‑allocated abstractions that grow in opposite directions.

If the program depends on shared libraries, the OS loads those libraries into the free space between the heap and stack.

The compiler records the address of the first instruction (the entry point) in the ELF header. Tools like readelf show this as the "Entry point address" field.

When the OS schedules the new process, it initializes the CPU’s instruction pointer with this entry‑point address, allowing the CPU to begin execution at the correct location.

Thus, the seemingly simple action of double‑clicking an icon triggers a chain of OS operations that locate, load, and start the program in memory.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ELFoperating systemmemory layoutexecutableentry pointprogram loading
IT Services Circle
Written by

IT Services Circle

Delivering cutting-edge internet insights and practical learning resources. We're a passionate and principled IT media platform.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.