c language memory, executable file

 

C language mapping between the code and executable files

Function code stored in the .text section 
initialized global variables stored in the .data segment 
global variables stored in the uninitialized section .bss 
program types are mapped to the file header

 

Interview questions:
script code file is not an executable program?

Yes and no! Here is the process!
Executable program -> operating system loads -> Generate Process
script -> Script interpreter -> Generate Process -> operating system reads the script file interpreted

-------------------------------------------------- ----------------------------------------------
executable program and memory mapping between the
stack segment is running after the formal existence, it is the basis for the program to run.


# Static memory
.bss storage uninitialized global and static variables
.data stored initialized global and static variables
.text function program stored in the body of executable code


# Read only memory area
constant values .rodata stored program, such as string constants


Local variables in a stack space
dynamic heap space for
executable code stored in the .text section

------------------------------------------------------------------------------------------------

Interview questions:
global variables and static variables, why initialized and uninitialized stored in the different sections?

Free to play

 

In an array of contiguous memory space store element
number of array elements may be displayed or implicitly specified
example:

int a[5]={1,2}
int b[]={1,2}

 

Guess you like

Origin www.cnblogs.com/sea-stream/p/10995005.html