Penguin

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

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

Newer page: version 3 Last edited on Friday, November 28, 2003 6:02:02 pm by JohnMcPherson Revert
Older page: version 2 Last edited on Friday, November 28, 2003 3:16:58 pm by AristotlePagaltzis Revert
@@ -6,8 +6,45 @@
 | xxxxxxxx |< Process stack (grows down) 
 | bffff000 |< Process heap (grows up) 
 | 40000000 |< Libraries 
 | zzzzzzzz |< Unused 
-| yyyyyyyy |< __.bss__ segment, uninitialised proram data 
+| yyyyyyyy |< __.bss__ segment, uninitialised program data 
 | xxxxxxxx |< __.data__ segment, initialised program data 
 | 08048000 |< __.text__ segment, program code 
 | 00000000 |< Unmapped to trap NULL pointers 
+  
+  
+!!Practical examples  
+!Library-mapped memory (using ldd(1))  
+ $ 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)  
+  
+!Program code  
+ $ cat > x.c  
+ #include <stdio.h>  
+ int main(void) {printf("%p\n", main);return 0;}  
+ $ gcc -o x x.c && ./x  
+ 0x8048344  
+ $  
+(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  
+ 0xbffffab7  
+  
+!Process Data and bss segment  
+ $ perl -e 'my $var; print \$var . "\n"'  
+ SCALAR(0x814f38c)  
+(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  
+ 0x8049628