Ciro Santilli  Sponsor 中国独裁统治 China Dictatorship 新疆改造中心、六四事件、法轮功、郝海东、709大抓捕、2015巴拿马文件 邓家贵、低端人口、西藏骚乱
For each process, the virtual address space looks like this:
------------------ 2^32 - 1
Stack (grows down)
v v v v v v v v v


------------------ Maximum stack size.




brk (grows up)

------------------- 0
The kernel maintains a list of pages that belong to each process, and synchronizes that with the paging.
If the program accesses memory that does not belong to it, the kernel handles a page-fault, and decides what to do:
  • if it is above the maximum stack size, allocate those pages to the process
  • otherwise, send a SIGSEGV to the process, which usually kills it
When an ELF file is loaded by the kernel to start a program with the exec system call, the kernel automatically registers text, data, BSS and stack for the program.
The brk and mmap areas can be modified by request of the program through the brk and mmap system calls. But the kernel can also deny the program those areas if there is not enough memory.
brk and mmap can be used to implement malloc, or the so called "heap".
mmap is also used to load dynamically loaded libraries into the program's memory so that it can access and run it.
Stack allocation:
Calculating exact addresses Things are complicated by:
Why the text does not start at 0:


  1. Linux kernel usage
  2. x86 Paging Tutorial
  3. x86
  4. List of instruction set architectures
  5. Instruction set architecture
  6. Processor
  7. Computer hardware component type
  8. Computer hardware
  9. Computer
  10. Information technology
  11. Area of technology
  12. Technology
  13. Ciro Santilli's Homepage