Re: Where are the program variables stored in memory(text, data or stack segments)



kr wrote On 11/20/07 09:47,:
Hi All,
Suppose I consider a sample program as given below:-
[...]

This program contains several variables (global, local and dynamically
allocated variables).
How to figure out which variable is stored in which segment viz. text,
data, stack or heap? Is there any tool to get an idea about it?

Others have mentioned that the C language has no notion
of "segment," although some specific implementations might --
so your question isn't about C, but about Megahard C or
DrillAir C or LikeWater C or whatever implementations you
care about, and the answers may be different for each.

Another point I haven't seen mentioned yet: What about
variables that are stored in CPU registers, or variables
that sometimes reside in registers and sometimes in memory,
or variables that are optimized out of existence?

--
Eric.Sosman@xxxxxxx
.