Fundamentals 6 min read

What Really Happens When You Double‑Click an App? Inside the OS Loading Process

From double‑clicking an icon to the CPU executing the first instruction, this article walks through how an executable file is identified, loaded into memory, partitioned into code, data, heap and stack sections, and finally launched via the entry‑point address defined in the ELF format.

ITPUB
ITPUB
ITPUB
What Really Happens When You Double‑Click an App? Inside the OS Loading Process

When you double‑click an application icon or run a command in a terminal, the operating system first locates the executable file on disk. An executable is simply a file that contains a sequence of machine instructions, just like a text file contains readable characters, but its contents are meant for the CPU.

After finding the file, the OS parses its format to discover where the machine code and other required data reside. On Linux, most executables follow the ELF (Executable and Linkable Format) specification.

The OS then loads the program by copying its code and global variables from disk into RAM. It must first allocate a suitable region of free memory for the process.

Within the allocated memory the OS creates several logical regions: the code (text) segment, the data segment, the heap, and the stack. The code and data segments come directly from the executable’s sections, while the heap and stack are used dynamically at runtime.

The heap grows upward in memory, the stack grows downward, and the space between them can be used to load shared libraries if the program depends on them.

Once loading is complete, the OS needs to know where execution should start. The compiler records the entry‑point address in the ELF header. Tools like readelf can display this value.

The OS initializes the CPU’s instruction pointer with the entry‑point address, and the processor begins fetching and executing the first instruction, effectively starting the program.

This sequence—locating the file, loading its contents into memory, setting up logical regions, and jumping to the entry point—explains what actually happens behind the scenes when you double‑click an application icon.

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.

memory layoutprogram executionELF formatexecutable filesprocess loading
ITPUB
Written by

ITPUB

Official ITPUB account sharing technical insights, community news, and exciting events.

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.