In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Brief introduction
Please talk about how the linux source file is gradually compiled into an executable file.
Solution
First of all, the above figure has a perceptual understanding of the whole process of compilation, and then analyze each process step by step.
Take hello.c program as an example
# include main {printf ("hello\ n");}
A .c source program needs to generate a .i file through a preprocessor, a .s file through the compiler, a relocatable object file .o file through the assembler, and a linker with other .o files to generate the final executable object program.
Pretreatment stage. It mainly deals with the precompiled instructions in the source file that begin with "#".
Delete # define and expand the macro
Handle all conditional precompiled instructions, such as # if, # ifdef, # endif
Insert header file into "# include"
Delete all comments
Add line number and file name identification so that the compiler generates line number information for debugging at compile time
Retain all # pragma compilation instructions.
The compilation phase. The preprocessed files are analyzed by syntax analysis, lexical analysis, semantic analysis and optimization, and the assembly code file (assembly language source program) is generated.
The assembly stage. Assembler (assembler) is used to convert assembly language source programs into machine instruction sequences (machine language programs).
Link phase. Merge multiple relocatable object files .o to produce an executable file, which can be loaded into memory and executed by the system.
Summary
The above is all about the parsing of the process of compiling the source file into the target file under Linux. I hope it will be helpful to you. Interested friends can continue to refer to other related topics on this site, if there are any deficiencies, please leave a message to point out. Thank you for your support to this site!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.