Hello All!
I am a little confused about the memory allocated for an executable. Now, say for example, this is my code:
int foo = 1;
int main()
{
const char* bar = "hello world";
int num;
return 0;
}
Now, the "hello world" part would be stored in the read-only code segment part, this would need 11 bytes, thus contributing to the size of the executable.
Now, foo would be in the data segment and num would be in the stack segment once the executable is loaded into memory. However, my question is, how is information about these variables stored in the binary, such that memory is allocated on the stack and the data segment for these variables?
Any inputs would be helpful.
Thanks!