The Linux VirtualMemory Map (as seen by a UserSpace program)

 Starts at   Contains
 ffffffff   End of the universe
 ffffe000   vsyscall table (new in 2.5.x)
 c0000000   Off limits, reserved for the kernel
 bfffffff   Process stack (grows down)
 bffff000   Process heap (grows up)
 40000000   Libraries
 zzzzzzzz   Unused
 yyyyyyyy   .bss, uninitialised program data
 xxxxxxxx   .data segment, initialised program data
 08048000   .text segment, program code
 00000000   Unmapped to trap NULL pointers


</code> "BSS" means block started by symbol and is a segment of uninitialised that is only stored in the BinaryExecutable image as a length and offset, since it would otherwise waste space. The "text" segment on the other hand contains initialized global variables and is stored in the BinaryExecutable.

Practical examples

Library-mapped memory (using ldd(1))

 $ ldd /bin/ls => /lib/ (0x40026000) => /lib/ (0x40038000) => /lib/ (0x4016a000)
        /lib/ => /lib/ (0x40000000)

Program code

  $ cat > x.c

  #include <stdio.h>
  int main(void) {printf("%p\n", main);return 0;}
  $ gcc -o x x.c && ./x

(this is printing the address of the main function.)

Process Heap

  $ cat > x2.c

  #include <stdio.h>
  int main(void) {char c;printf("%p\n", &c); return 0;}
  $ gcc -o x2 x2.c && ./x2

Process Data and bss segment

 $ perl -e 'my $var; print \$var . "\n"'

(note that this is the address in the Perl interpreter)

  $ cat > x3.c

  #include <stdio.h>
  #include <stdlib.h>
  int main(void) {char *p=!malloc(3);printf("%p\n", p); return 0;}
  $ gcc -o x3 x3.c && ./x3


 cat /proc/''pid''/maps

gives you the memory map for a program :)