tags:

views:

118

answers:

2

This is a code from linux man page....

   #include <stdio.h>
   #include <stdlib.h>

   extern char etext, edata, end; 
   int main(int argc, char *argv[])
   {
       printf("First address past:\n");
       printf("    program text (etext)      %10p\n", &etext);
       printf("    initialized data (edata)  %10p\n", &edata);
       printf("    uninitialized data (end)  %10p\n", &end);

       exit(EXIT_SUCCESS);

   }

when run, the program below produces output such as the following:

       $ ./a.out
       First address past:
           program text (etext)       0x8048568
           initialized data (edata)   0x804a01c
           uninitialized data (end)   0x804a024

Where are those symbols (etext edata end ) defined ? How those symbols are assigned values ? Is it by linker or something else ?

+3  A: 

Those symbols correspond to the beginnings of various program segments. They are set by the linker.

Steve Emmerson
+2  A: 

These symbols are defined in a linker script file.

kgiannakakis