initial version
authorHeiko Schlittermann <hs@schlittermann.de>
Wed, 12 Jan 2011 21:54:36 +0100
changeset 0 986b5d239ee5
child 1 3b5b7a4bf446
initial version
Makefile
bounds.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile	Wed Jan 12 21:54:36 2011 +0100
@@ -0,0 +1,6 @@
+CFLAGS=-Wall
+
+.PHONY:	all clean
+
+all:	bounds
+clean:	; -rm -f bounds
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bounds.c	Wed Jan 12 21:54:36 2011 +0100
@@ -0,0 +1,42 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+extern char  etext, edata, end;
+
+int main(int argc, char **argv)
+{
+    char *step = (char) NULL;
+
+    char *value_string = "Hallo";
+    int   value_int    = 56;
+
+    printf("First address beyond:\n");
+    printf("    program text segment(etext)      %10p\n", &etext);
+    printf("    initialized data segment(edata)  %10p\n", &edata);
+    printf("    uninitialized data segment (end) %10p\n", &end);
+    printf("    size: %ld\n", &end - &etext);
+    printf("-----------------------------------------------\n\n");
+
+    /*
+    //text bis end ausgeben
+    for (step = &etext; step <= (&end); step++) {
+    printf("0x%x: ", step);
+    putc(*step, stdout);
+    printf("\n");
+    }
+    */
+
+    //alles nach end ausgeben:
+    step = &end;
+    while (1) {
+    printf("0x%x: ", step);
+    putc(*step, stdout);
+    printf("\n");
+    step++;
+    }
+
+    //damit der compiler das nicht weg optimiert
+    printf("%s%d", value_string, value_int);
+
+    return EXIT_SUCCESS;
+}