Describe in as much detail as you can the layout of the
virtual address space as it is used by the versions of Linux
and gcc/g++ in our labs. You can print out addresses:
#include
...
cout << "0x" << hex << (unsigned int)(ptrofsomekind) << endl;
or
#include
...
printf( "0x%x\n", (unsigned int)(&i) );
You can also use the gnu debugger gdb to get a better
look at where the stack pointer points, where global variables
are located, etc.
I'm particularly interested in knowing
- Where (i.e. in what range of virtual addresses) are global
variables located? Does there seem to be a limit to the
size of global variables allowed?
- Where are literal strings stored?
- Where is the program text stored? Try modifying program
instructions at run-time (you can get a function's address
by "char *p = (char *)(FunctionName)"). What happens?
- Where is the stack? Is there a limit to the stack size?
Is that limit configurable?
- Where is the heap (a.k.a. "free store" or "place where
memory allocated by malloc or new comes from")? Which way does
it grow?
But please tell me about anything else you learn.