I’m trying to understand the C memory layout and would appreciate your feedback on my general interpretation.
Assuming a memory range from 0x00 to 0xFF, memory is typically divided into the following segments:
To inspect where static and global variables are stored, I understand we can check both the object file and the map file generated during compilation. However, stack and heap information can only be observed during runtime.
Could you please confirm if this understanding is correct or suggest any adjustments?
Note : This is a general question, and I’m looking for a general answer. Once I’m on the right track, I plan to ask more specific questions regarding memory inspection with the GCC compiler on Ubuntu.
Assuming a memory range from 0x00 to 0xFF, memory is typically divided into the following segments:
- Text Segment (0x00 - 0x3F): Contains the program’s compiled instructions.
- Data Segment:
- Initialized Data (0x40 - 0x6F): For global/static variables with initial values.
- BSS (0x70 - 0x7F): For uninitialized global/static variables.
- Stack (0x80 - 0xBF): Manages function calls, local variables, and return addresses.
- Heap (0xC0 - 0xFF): Used for dynamic memory allocation.
To inspect where static and global variables are stored, I understand we can check both the object file and the map file generated during compilation. However, stack and heap information can only be observed during runtime.
Could you please confirm if this understanding is correct or suggest any adjustments?
Note : This is a general question, and I’m looking for a general answer. Once I’m on the right track, I plan to ask more specific questions regarding memory inspection with the GCC compiler on Ubuntu.