Analyzing the memory layout for my sample program in Linux Environment.


int test_g = 1; // Data or BSS ? Data section Right ?
int test_h; // Data or BSS ? BSS section Right ?

static int test_s = 1;
static int test_q;

int func1(bool a ,bool b)
short temp;
static int var_temp; // Stack or BSS ?
return 0;


int main(void)
int m_var = 0; // Will be assigned in Stack section Right ?
static int main_temp = 0 ; Which section Data or BSS ?
m_var = func(true,true);// Will be assigned in Stack section Right ?

return m_var;

help me for the queries added as comments in 'C' Program.

My Qs Is :

What are all the sections shared during ,when the function call func1 made from the main?

Generally every function call has its own stack.Other sections bss , data . text are shared between the multiple process or threads ?.
will the heap shared ?

Will the compiler assign the sections during the program compilation itself?

Last edited by shabbir; 6Nov2008 at 09:33.. Reason: Code block