Memory Layout of a Process
- Once loaded, the process (currently on linux, x86) has the following layout in memory.
-
- The text segment contains the executable machine code.
- He claims that this is read-only so no self modifying code.
- :)
- This may be sharable, since many processes may be running the same code
- Think bash, or cstdlib
- The initialized data segment
- The home of static and global variables that are initialized at compile time.
- The uninitialized data segment
- Global and static variables that are not initialized at compile time.
- All values are initialized to 0
- This section exists to save disk space in executables.
- The heap
- the source of memory from brk, malloc and new.
- Grows up.
- The stack
- function activation records and local variables for functions.
- Grows down towards the heap.