Home | Download | Documentation | Programming | FAQ | About Me
Executable File Format

Program:

const int b=1;
int c=2;
int main(){
int a;
char *sptr;
a=b+c;
}

When It complied using gcc compiler. It produces an executable file.When it runs in RAM (it is called as process),executable file will have
text or code part,data part,stack and heap. Sample executable format will be of form :

  
Text or Code Section
	/*.text section (Contains executable code part ie. Machine language .Most OS 
	treats this code part  as read-only section ) */

a=b+c;
Data part  (global variables)
/*.data section Contains either all initialized  Read-only data variables */
                          const int b=1;
/* or Contains all initialized  Read-Write data variables)*/

int c=2; /*.bss section(block started symbol- Contains all un- initialized data variables-It doesn’t
occupy any space. It’s is not available in binary image but exists in primary memory (RAM)
when the binary is loaded)*/

char * sptr;
Stack
/* Contains all Local variables */
      int a;
Heap
/* Dynamically allocated memory created during malloc()*/
Powered by
Open Source Programmers