Segments up to heap in /proc/self/maps output
My program, at a certain point in its execution, reads its own /proc/self/maps line by line until (and including) the heap. The program's path is "/home/t4". Here is the output:
00400000-00403000 r-xp 00000000 68:06 21629911 /home/t4
00602000-00603000 r--p 00002000 68:06 21629911 /home/t4
00603000-00604000 rw-p 00003000 68:06 21629911 /home/t4
00604000-00608000 rw-p 00000000 00:00 0
01905000-01926000 rw-p 00000000 00:00 0 [heap]
I was expecting only four segments: code, constants, static variables, heap; but here, there开发者_高级运维 are five. The first one clearly must be code, and the last is the heap. Perhaps the second one is constants--but then what are the other two? Thanks!
initialised static variables is followed by uninitialised static variables (.BSS) - which do not need storage in the binary.
The first is the executable part itself (due to the x bit), the second is likely .rodata
(absence of w bit), the third is everything else (.bss
and .data
). The fourth is the result of some mmap
call using MAP_ANONYMOUS
. Note that malloc
(3) may very well be implemented using mmap
(2) rather than sbrk
(2). The [heap]
object there is the classic sbrk-heap (and only that), and does not cover private writable regions obtained using mmap. Traditional stack would be listed as [stack]
, but stacks of subthreads can use any memory region to store their stack, usually something malloc'd, so you will not see multiple [stack]
s either...
Confusion complete? :-)
精彩评论