AFAIK, there are 2 types of global variables, initialized and unintellized. How are they stored? Are they saved in an executable file? I can think of initialized global variables having their initial values ββstored in an executable. But what needs to be stored for uninitialized ones?
My current understanding is this:
The executable file is organized into several sections, such as .text, .data and .bss. Code is stored in the .text section, initialized global or static data is stored in the .data section, and uninitialized global or static data is stored in the .bss section.
Thanks for watching my questions.
Update 1 - 9:56 AM 03/11/2010
I found a good link here:
Segments in the source of the assembly language - Build segments of text and data using the directives .text, .data and .bss
Update 2 - 10:09 AM 03/11/2010
@Michael
I define 100 bytes of an uninitialized data area in my assembler code, this 100-byte is not stored in my executable file because it is NOT initialized.
Who will allocate 100-byte uninitialized memory space in RAM? Program loader?
Suppose I got the following code:
int global[100]; void main(void) {
Global [100] is not initialized. How will global [100] be transcoded in my executable? And who will single it out at what time? What if it is initialized?
c ++ c assembly
smwikipedia
source share