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