[ILUG-BOM] help wanted regarding memory model in C program

Vihan Pandey vihanpandey@[EMAIL-PROTECTED]
Thu Feb 1 13:54:27 IST 2007


> first of all my apologies to all,for asking a question that may be very
> silly,but i am not ashamed to tell that i duuno the concept about this...
> :-(,so i am ready to show my ignorance and not become ignorant my whole
> life...anyway following is the question,and please can some one define it
> or
> give some good link about it.It will be really helpful for me.


Melodrama does not really help. Why is it that Indians on any mailing list
use such words? Its a mailing list not an amateur dramatics forum.

1) Where in memory exactly auto,static and extern(global) variables are
> stored..?

2) Detail explanation of the memory model of a C program.


Have you heard of GDB?

To answer question 1 and 2 please refer here(there is not a more eloquent
answer ANYWHERE else) :

http://www.dirac.org/linux/gdb/02a-Memory_Layout_And_The_Stack.php#memorylayout

If you want a GDB tutorial :

http://www.dirac.org/linux/gdb/

I am confused where in memory these variables are stored and also what are
> the stages in memory during compilation..
> It will be very helpful for me,if someone guide me.


What surprises me is that you have not explored GDB earlier. i remember you
talking about memory programming in an earlier mail curious how you manage
debug those programs.

i remember my first encounter happened when i saw the ``immortal words" :

Segmentation Fault: core dumped

Regards,

- vihan


More information about the Linuxers mailing list