C language compilation principle
1. Pre-processing command: gcc-E file. c-o hello. I <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + IyDJvrP9y/examples + examples/templates + IyC0psDtzPW8/examples + ciagicajicagicagicagicagicc/examples + examples/examples + example + CiAgICAjdW5kZWYg ICAgICDIoc/queues + LaozPW8/s6q1eajrNTyseDS68/Cw + a0 + records + 7rq0tG + records/Cw + a0 + records + outputs/Cw + a0 + 8eww + records/queues/ cw + a0 + sLro6zG5Mq1vs3Kx2Vsc2UgaWa1xLzy0LQ8YnI + CiAgICAjZW5kaWYgICAgICC94cr4 Authorization + k8YnI + signature + iPGJyPgo8L3A + signature/qrG7sPy6rLXEzsS8/export vcd4kpha + signature + CjxwPg = "# pragma 'It is used to set the compiler status or instruct the compiler to complete certain actions.
2. Compilation command: gcc-S file. c-o hello. S
# Perform a series of lexical analysis, syntax analysis, and Semantic Analysis on pre-processed files
Lexical analysis mainly analyzes the validity of keywords, identifiers, and immediate numbers
Syntax analysis mainly analyzes whether expressions follow the syntax rules.
Semantic Analysis further analyzes the validity of expressions based on syntax analysis
# Code optimization after analysis to generate the corresponding assembly code file
3. Assembly command: gcc-c file. S-o hello. o
# The assembler converts the assembly code into commands that can be executed by machines.
Almost every Assembly statement corresponds to a machine command.
4. Significance of the linker
The main function of the linker is to process the reference parts of each module so that the modules can be correctly connected.
Links are divided into static links and Dynamic Links: static links refer to. o files and the. a file of the Link Library are spliced together to form executable files. In this way, the compiled executable file is large and occupies a large amount of memory space. If the executable program is run multiple times concurrently, it will be called repeatedly. the a-Link Library File enters the memory. This results in a great waste. Static links exchange space for time.
Dynamic Link means that the Linked Library file is not spliced together with the. o file, but dynamically called by the library file in the memory when the execution file is running. If not, it is dynamically loaded. Dynamic Links exchange time for space.
# The compiler mainly divides compilation into three parts: preprocessing, compilation, and assembly.
# The function of the linker is to link independent modules to executable programs.
# Static links are completed during the compilation period, and dynamic links are completed during the runtime.