bounds.c
changeset 0 986b5d239ee5
child 1 3b5b7a4bf446
equal deleted inserted replaced
-1:000000000000 0:986b5d239ee5
       
     1 #include <stdio.h>
       
     2 #include <stdlib.h>
       
     3 
       
     4 extern char  etext, edata, end;
       
     5 
       
     6 int main(int argc, char **argv)
       
     7 {
       
     8     char *step = (char) NULL;
       
     9 
       
    10     char *value_string = "Hallo";
       
    11     int   value_int    = 56;
       
    12 
       
    13     printf("First address beyond:\n");
       
    14     printf("    program text segment(etext)      %10p\n", &etext);
       
    15     printf("    initialized data segment(edata)  %10p\n", &edata);
       
    16     printf("    uninitialized data segment (end) %10p\n", &end);
       
    17     printf("    size: %ld\n", &end - &etext);
       
    18     printf("-----------------------------------------------\n\n");
       
    19 
       
    20     /*
       
    21     //text bis end ausgeben
       
    22     for (step = &etext; step <= (&end); step++) {
       
    23     printf("0x%x: ", step);
       
    24     putc(*step, stdout);
       
    25     printf("\n");
       
    26     }
       
    27     */
       
    28 
       
    29     //alles nach end ausgeben:
       
    30     step = &end;
       
    31     while (1) {
       
    32     printf("0x%x: ", step);
       
    33     putc(*step, stdout);
       
    34     printf("\n");
       
    35     step++;
       
    36     }
       
    37 
       
    38     //damit der compiler das nicht weg optimiert
       
    39     printf("%s%d", value_string, value_int);
       
    40 
       
    41     return EXIT_SUCCESS;
       
    42 }