from apue 7.6. Memory Layout of a C Program
A typical memory representation of C program consists of following
sections.
1. Text segment
2. Initialized data segment
2.1
initialized read-only area
2.2 initialized read-write
area
3. Uninitialized data segment
4. Heap
5. Stack
Read Memory
Layout of C Programs for more details. It‘s compiled from apue 7.6 with
more details and examples.
做個實驗吧
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
|
address of a1 is 0x7fff4e62c554
address of a2 is
0x7fff4e62c550
address of a3 is
0x7fff4e62c54c
address of a4 is
0x7fff4e62c548
address of a5 is
0x7fff4e62c544
address of b1 is
0x7fff4e62c538
value of b1 is 0x417a010
address
of b2 is 0x7fff4e62c530
value of b2 is
0x417a030
address of b3 is 0x7fff4e62c528
value
of b3 is 0x417a050
address of b4 is
0x7fff4e62c520
value of b4 is
0x417a070
可以發現,a1到a5的記憶體位址是由大而小,也就是由高而低。而b1到b4的所指的位址(在heap)是由小而大,也就是由低而高,b1到b4本身的位址(在stack)則是由高而低。
Other references:
<<Advanced Programming in the UNIX Environment>> 7.6. Memory
Layout of a C Program
Memory
layout of C process (pdf), download
[0x03]. Notes on Assembly - Memory from a process‘ point of
view
Structure of a C-Program in Memory | How Heap,Stack,Data and
Code segments are stored in memory?
Memory Layout of C Programs,布布扣,bubuko.com