Penguin

Differences between current version and revision by previous author of MemoryMap.

Other diffs: Previous Major Revision, Previous Revision, or view the Annotated Edit History

Newer page: version 10 Last edited on Tuesday, March 20, 2007 12:56:45 pm by PerryLorier
Older page: version 9 Last edited on Tuesday, March 20, 2007 3:42:10 am by DeanDavis Revert
@@ -1,6 +1,7 @@
 The [Linux] VirtualMemory Map (as seen by a UserSpace program)<br> 
 <code> 
+<?plugin OldStyleTable  
 | __Starts at__| __Contains__<br> 
 | ffffffff |< End of the universe<br> 
 | ffffe000 |< vsyscall table (new in 2.5.x)<br> 
 | c0000000 |< Off limits, reserved for the kernel<br> 
@@ -11,50 +12,62 @@
 | yyyyyyyy |< __.bss__, uninitialised program data<br> 
 | xxxxxxxx |< __.data__ segment, initialised program data<br> 
 | 08048000 |< __.text__ segment, program code<br> 
 | 00000000 |< Unmapped to trap [NULL] pointers<br><br> 
+?>  
 </code> 
 "BSS" means __b__lock __s__tarted by __s__ymbol 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<br>  
- librt.so.1 => /lib/librt.so.1 (0x40026000)<br>  
- libc.so.6 => /lib/libc.so.6 (0x40038000)<br>  
- libpthread.so.0 => /lib/libpthread.so.0 (0x4016a000)<br>  
- /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)<br
+<verbatim>  
+ $ ldd /bin/ls  
+ librt.so.1 => /lib/librt.so.1 (0x40026000)  
+ libc.so.6 => /lib/libc.so.6 (0x40038000)  
+ libpthread.so.0 => /lib/libpthread.so.0 (0x4016a000)  
+ /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)  
+ </verbatim
  
 !Program code<br> 
- $ cat > x.c<br>  
+<verbatim>  
+ $ cat > x.c 
  
- #include <stdio.h><br >  
- int main(void) {printf("%p\n", main);return ;}<br>  
- $ gcc -o x x.c && ./x<br>  
- 0x8048344<br>  
- $<br >  
-(this is printing the address of the main function.)<br>  
+ #include <stdio.h>  
+ int main(void) {printf("%p\n", main);return ;}  
+ $ gcc -o x x.c && ./x  
+ 0x8048344  
+ $  
+ </verbatim >  
+(this is printing the address of the main function.) 
  
 !Process Heap 
- $ cat > x2.c<br>  
-<code>  
- #include <stdio.h><br >  
- int main(void) {char c;printf("%p\n", &c); return ;}<br></code>  
- $ gcc -o x2 x2.c && ./x2<br>  
- 0xbffffab7<br
+<verbatim>  
+ $ cat > x2.c  
+  
+ #include <stdio.h>  
+ int main(void) {char c;printf("%p\n", &c); return ;}  
+ $ gcc -o x2 x2.c && ./x2  
+ 0xbffffab7  
+ </verbatim
  
 !Process Data and bss segment 
  
- $ perl -e 'my $var; print \$var . "\n"'<br>  
+<verbatim>  
+ $ perl -e 'my $var; print \$var . "\n"' 
  SCALAR(0x814f38c)<br> 
-(note that this is the address in the [Perl] interpreter)<br>  
+</verbatim>  
+ (note that this is the address in the [Perl] interpreter) 
  
+<verbatim>  
  $ cat > x3.c 
  
- #include <stdio.h><br >  
- #include <stdlib.h><br >  
- int main(void) {char *p=!malloc(3);printf("%p\n", p); return ;}<br>  
- $ gcc -o x3 x3.c && ./x3<br>  
- 0x8049628<br >  
-  
+ #include <stdio.h>  
+ #include <stdlib.h>  
+ int main(void) {char *p=!malloc(3);printf("%p\n", p); return ;}  
+ $ gcc -o x3 x3.c && ./x3  
+ 0x8049628  
+ </verbatim
 Also, 
+<verbatim>  
  cat /proc/''pid''/maps 
+</verbatim>  
 gives you the memory map for a program :)