Memory Layout of a Program in UNIX

Memory layout of a Program in a UNIX-environment:



Reference : "The Environment of a Unix Process" in Advanced Programming in the UNIX Environment Richard Stevens, p.168


(High address)
+-------------------+
| | cmd line args and env vars
| |
+-------------------+
| stack |
+-------------------+
| ↓ |
| |
| ↑ |
+-------------------+
| heap |
+-------------------+
|Uninitialized data | init to zero by exec
| (bss) |
+-------------------+ _
| initialized data | |
+-------------------+ |--read from program file by exec
| text | |
+-------------------+ _|
(Low address)

No comments: