当前位置:网站首页>From source code to executable file

From source code to executable file

2022-04-23 18:03:00 OceanKeeper1215

 

1、 Preprocessing gcc -c

  1. Will all ”#define“ Delete , And expand all the macro definitions
  2. Handle all conditional compilation instructions , Enter into “#if”,“ifdef” etc. .
  3. Handle #“include” Precompiling instructions , Insert the included file into the location of the precompiled directive
  4. Delete all comments

2、 compile

Carry out a series of syntax analysis and optimization of the preprocessed files , Generate the corresponding assembly code file

3、 assembly

Translate the mutated assembly code file into machine instructions , And generate relocatable .o file , The file is binary , Byte encoding is a machine instruction

4、 link gcc -o

Link the target files and library files together through the linker to generate a completed executable program

The main job of the linker is to connect the target files to each other , That is to connect the symbol referenced in one file with the definition of the symbol in another file , Make all these target files into a unified whole that can be loaded and executed by the operating system .

版权声明
本文为[OceanKeeper1215]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230545105090.html