One of the most useful files for understanding what a process really looks like:
$ head -8 /proc/self/maps
5593a1c2e000-5593a1c30000 r--p 00000000 fd:01 1310722 /usr/bin/cat
5593a1c30000-5593a1c35000 r-xp 00002000 fd:01 1310722 /usr/bin/cat
5593a1c35000-5593a1c38000 r--p 00007000 fd:01 1310722 /usr/bin/cat
5593a1c38000-5593a1c3a000 rw-p 00009000 fd:01 1310722 /usr/bin/cat
5593a2d16000-5593a2d37000 rw-p 00000000 00:00 0 [heap]
7f2b5c000000-7f2b5c1a0000 r-xp 00000000 fd:01 1315008 /usr/lib/x86_64-linux-gnu/libc.so.6
7ffd1d5a2000-7ffd1d5c3000 rw-p 00000000 00:00 0 [stack]
7ffd1d5f7000-7ffd1d5fb000 r--p 00000000 00:00 0 [vvar]
Columns: address range, permissions (r, w, x, and p private or s shared), file offset, device, inode, path.
What to look for:
- The binary appears several times, one mapping per segment, each with different permissions. Code is
r-x, constantsr--, datarw-. - No mapping is both
wandx. That is W^X, and when you do seerwxit deserves a question. - No path and inode 0 means anonymous memory: heap, stack, or whatever
mmaphanded out. - Run it twice. The addresses change every time. That is ASLR.
/proc/PID/smaps adds resident size, dirty pages and more per mapping. Great for "where did my RAM go?".