Suppose I am having this code:
int main() {
int var1;
char *ptr = malloc(5 * sizeof(char));
//...........
do_something();
//...........
return 0;
}
We know that the actual memory layout will be divided into segments like: .text
, .bss
, .data
, .heap
, .stack
.
I know how to use objdump
, readelf
, etc. But, I want to get a better view of the memory stack, where I can see things like:
.heap ptr
.stack do_something()
.text main()
.bss var1
The main point is: The actual variable names are missing from the output of objdump
, readelf
etc.
I am compiling this code with -g
, thus retaining the symbol table.
Then, why am I not able to see the memory layout with local/global variable names included?
objdump -x
shows the names of the variables if type is static
otherwise not. Why?