When a native program is built, the linker generates a binary file called an executable.

Executables have a specific format that is known by the target operating system.

The executable data is known as a binary image.

When a program is started, the operating system copies the image in system memory and allocates additional memory for the program.


An image is divided into sections (or segments).

The layout of the sections is platform-dependent.

The most common formats are defined in Windows and Unix.

Text Segment

The text segment (or code segment) contains the machine code for the program.

Data Segment

The data segment contains the initialized global and static variables.

The layout of the data in the image is identical to the layout of the data in system memory.

BSS Segment

BSS stands for Block Started by Symbol.

The BSS segment contains the uninitialized global and static variables.

In C and C++, uninitialized variables are set to 0.

In the image, the BSS segment just contains the size of the data.

When the operating systems loads an image, it allocates a block of memory filled with 0 that is large enough for all the uninitialized variables.

Read-Only Data Segment

The read-only data segment ( or rodata segment) contains the data for the constant variables.

Static variables defined in a function are only visible in that function but they are stored in the Data or BSS segment.


The Windows operating system uses the Portable Executable (PE) format.

Executable files have the .exe extension.



The Unix operating system uses the Executable and Linking Format (ELF).

Executable files have the .elf extension.