Integrated several big man blogs , And what you already know , Some doubts have been answered satisfactorily at this stage .

However, a lot of questions have arisen :

* Relationship between memory and disk
* CPU How do I run machine instructions ( Although I probably thought it would be a combination of digital logic circuits in the past )
* ......


The last tweet I wrote was :Vscode Multi file compilation in , Originally, this plan was a multi language mixture , But I don't understand yet , Let's add the running process of the program , It is also a supplement to the previous article .

When we want a program to run , Such as the following code :
1 #include <stdio.h> 2 int main() 3 { 4 printf("Hello World\n"); 5 return 0; 6
The following process is required :

1. Pretreatment
 gcc -E hello.c -o hello.i 
This process mainly deals with the data in the source code file :

with ”#” Start precompiled instruction

as ”#include”,”#define” etc.

take include Insert your file , Will all define Macro definition expansion for .

Delete Note

Add line number and file name identification .

So that the compiler can generate the line number information for debugging at compile time and display the line number when compiling errors or warnings at compile time

2. compile
 gcc -S hello.i -o hello.s 
Compiler (Compiler) Carry out a series of lexical analysis on the preprocessed files , Syntax analysis , After semantic analysis and optimization, the corresponding assembly code files are produced .

of course , Preprocessing and compilation can be combined , Directly in one step :
 1 gcc -S hello.c -o hello.s 
Mention this here gcc, This is just a background compiler (compiler) Console for , Different preprocessing will be called according to different parameters , Compiler , To deal with different languages .

3. assembly
 1 gcc -c hello.c -o hello.o 
.o File is “ Target file ”(Object File), Convert assembly statements to machine language , Machine language is CPU Executable commands .

4. link

In the process above , The original file will generate several target modules , These modules are fragmented .

By linker (Linker) These target modules ( Program segment ), And the library functions they need , Form a complete loading module (Load Module)
; This is the complete executable for executing commands exe( This is already a binary file ).

Links are divided into static links and dynamic links . No, it doesn't .

DLL File is Dynamic Link Library file .

5. load

Executable files cannot be deleted until they are loaded into memory CPU implement .

The loading process is performed by the loader (Loader) Load module into physical memory . Physical memory is a real memory module .

Physical memory is composed of several storage units , Each storage unit has a number , This number uniquely identifies a storage unit , Called memory address ( Or physical address ).

It can be simply understood as a structure of class array .

This process performs address relocation , It mainly converts the logical address into the absolute address of physical memory ( It's equivalent to taking the test number to find a seat ). This process occurs only when the program is about to be run .

6. implement

Execution is not a strict concept , It's just what I use to describe loading to output “Hello World” A noun of this process .

When the computer wants to run the program , The relevant instructions in the binary file are sent to CPU, after CPU Operation of , Displayed on the display .

7. GCC

supplement GCC Tool chain

8 review

* Program from press “ compile ” What processes are required to load memory ?
* GCC What are the tool chains ?

©2019-2020 Toolsou All rights reserved,
Redis Underlying data structure A person who dissuades others from learning computer , Are not good people win10 System computer C Where's the disc ,c disc users where? (win10c Disk not found users) Freshman c Language student management system ( lower ) hospital WIFI Which family is strong ? utilize Python Script unlimited spoof girlfriend computer C language program design —— Student management system Byte runout - Test development practice - One side cool meridian python Run code at specified time 5 Best style Linux Server system recommendation Anti anxiety life after naked resignation , I believe everything will have the best arrangement