This program is used:
const size_t arraySize=0x1000000; //16M
char global[arraySize*2];
int main(int argc, char** argv)
{
int i=0;
char local[arraySize];
char* heap=(char*)malloc(arraySize*3);
for (i=0; i
}
(1) In linux 32 bit, the output is:
local bee40ef0, global 08049800, heap 4000a008
The memory map is:
00734000-00749000 r-xp 00000000 03:03 32066 /lib/ld-2.3.4.so
00749000-0074a000 r--p 00015000 03:03 32066 /lib/ld-2.3.4.so
0074a000-0074b000 rw-p 00016000 03:03 32066 /lib/ld-2.3.4.so
00753000-0075c000 r-xp 00000000 03:03 38761 /lib/libgcc_s-3.4.6-20060404.so.1
0075c000-0075d000 rw-p 00009000 03:03 38761 /lib/libgcc_s-3.4.6-20060404.so.1
00774000-00898000 r-xp 00000000 03:03 32151 /lib/tls/libc-2.3.4.so
00898000-00899000 r--p 00124000 03:03 32151 /lib/tls/libc-2.3.4.so
00899000-0089c000 rw-p 00125000 03:03 32151 /lib/tls/libc-2.3.4.so
0089c000-0089e000 rw-p 0089c000 00:00 0
008a0000-008c1000 r-xp 00000000 03:03 38754 /lib/tls/libm-2.3.4.so
008c1000-008c3000 rw-p 00020000 03:03 38754 /lib/tls/libm-2.3.4.so
00af9000-00bb9000 r-xp 00000000 03:03 195327 /usr/lib/libstdc++.so.6.0.3
00bb9000-00bbe000 rw-p 000bf000 03:03 195327 /usr/lib/libstdc++.so.6.0.3
00bbe000-00bc4000 rw-p 00bbe000 00:00 0
08048000-08049000 r-xp 00000000 00:14 34996225 /mnt/centos/ut/a.out
08049000-0804a000 rw-p 00000000 00:14 34996225 /mnt/centos/ut/a.out
0804a000-0a04a000 rw-p 0804a000 00:00 0
40008000-4300d000 rw-p 40008000 00:00 0
bee40000-c0000000 rw-p bee40000 00:00 0
ffffe000-fffff000 ---p 00000000 00:00 0
The exeutable is start from 0x08048000, and then the data and bss section for global variable (32M):
0804a000-0a04a000 rw-p 0804a000 00:00 0
And then the heap starts from 1/3 of the user space (0x4000000), which is 48M:
40008000-4300d000 rw-p 40008000 00:00 0
The stack begins at 0xc0000000 and grows to low address, which is 18M:
bee40000-c0000000 rw-p bee40000 00:00 0
(2) in Linux 64 bit:
The output is:
local 7fffa88b2e40, global 00600b20, heap 2ab801210010
The memory map is:
00400000-00401000 r-xp 00000000 fd:00 34996225 /home/bliu/ut/a.out
00600000-00601000 rw-p 00000000 fd:00 34996225 /home/bliu/ut/a.out
00601000-02601000 rw-p 00601000 00:00 0
314ec00000-314ec1c000 r-xp 00000000 fd:00 11796527 /lib64/ld-2.5.so
314ee1b000-314ee1c000 r--p 0001b000 fd:00 11796527 /lib64/ld-2.5.so
314ee1c000-314ee1d000 rw-p 0001c000 fd:00 11796527 /lib64/ld-2.5.so
314f000000-314f14d000 r-xp 00000000 fd:00 11796545 /lib64/libc-2.5.so
314f14d000-314f34d000 ---p 0014d000 fd:00 11796545 /lib64/libc-2.5.so
314f34d000-314f351000 r--p 0014d000 fd:00 11796545 /lib64/libc-2.5.so
314f351000-314f352000 rw-p 00151000 fd:00 11796545 /lib64/libc-2.5.so
314f352000-314f357000 rw-p 314f352000 00:00 0
315ae00000-315ae0d000 r-xp 00000000 fd:00 11796784 /lib64/libgcc_s-4.1.2-20080825.so.1
315ae0d000-315b00d000 ---p 0000d000 fd:00 11796784 /lib64/libgcc_s-4.1.2-20080825.so.1
315b00d000-315b00e000 rw-p 0000d000 fd:00 11796784 /lib64/libgcc_s-4.1.2-20080825.so.1
3cb2600000-3cb26e6000 r-xp 00000000 fd:00 18000239 /usr/lib64/libstdc++.so.6.0.8
3cb26e6000-3cb28e5000 ---p 000e6000 fd:00 18000239 /usr/lib64/libstdc++.so.6.0.8
3cb28e5000-3cb28eb000 r--p 000e5000 fd:00 18000239 /usr/lib64/libstdc++.so.6.0.8
3cb28eb000-3cb28ee000 rw-p 000eb000 fd:00 18000239 /usr/lib64/libstdc++.so.6.0.8
3cb28ee000-3cb2900000 rw-p 3cb28ee000 00:00 0
3ecfe00000-3ecfe82000 r-xp 00000000 fd:00 35454980 /lib64/libm-2.5.so
3ecfe82000-3ed0081000 ---p 00082000 fd:00 35454980 /lib64/libm-2.5.so
3ed0081000-3ed0082000 r--p 00081000 fd:00 35454980 /lib64/libm-2.5.so
3ed0082000-3ed0083000 rw-p 00082000 fd:00 35454980 /lib64/libm-2.5.so
2ab8011f6000-2ab8011f7000 rw-p 2ab8011f6000 00:00 0
2ab80120d000-2ab804213000 rw-p 2ab80120d000 00:00 0
7fffa88b2000-7fffa98b4000 rw-p 7ffffeffd000 00:00 0 [stack]
ffffffffff600000-ffffffffffe00000 ---p 00000000 00:00 0 [vdso]
Here the executable is start from 0x00400000, then 32M is allocated for the global bss section:
00601000-02601000 rw-p 00601000 00:00 0
After load the library at low address, the heap is started at 0x2ab80120d000, which is 48M:
2ab80120d000-2ab804213000
The stack is started at 7fffa98b4000, which is 16M:
7fffa88b2000-7fffa98b4000
Then VDSO(Virtual dynamic shared object):
ffffffffff600000-ffffffffffe00000 ---p 00000000 00:00 0 [vdso]
the vdso mapped to linux-gate.so.1, which is a virtual shared object exposed by kernel. It is used to make virtual system call using sysenter/sysexit, and this is faster than regular interruption.
No comments:
Post a Comment