Skip to content

32bit

32 bit

Program Memory

When process switches in the CPU the memory gets unmapped and the new process gets remapped.

Linux Memory Map:

Kernel Space 0xffffffff
(1 GB) - 0xc0000000
______________ ________________
0xbfffffff
User Mode
Space (3 GB)
- 0x00000000
______________ ________________

  • Stack
    • Local Variables
    • Function Parameters
  • Memory Mapping Segment
    • File mapping including dynamic libraries
  • Heap
    • Runtime Memory allocation through malloc
  • BSS Segment
    • Uninitialized static variables
  • Data Segment
    • Variables Initialized by the programmer
  • Text Segment
    • Elf file of the process

Windows Memory Map:

Kernel Space 0xffffffff
(2 GB) - 0x80000000
______________ ________________
User Mode 0x7fffffff
Space (2 GB) - 0x00000000
______________ ________________

Stack

Sample Program:

int foobar(int a, int b, int c)
{
    int xx = a + 2;
    int yy = b + 3;
    int zz = c + 4;
    int sum = xx + yy + zz;

    return xx * yy * zz + sum;
}

int main()
{
    return foobar(77, 88, 99);
}