In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what the gcc-c command does in the process of linux compilation". In the daily operation, I believe that many people have doubts about what the gcc-c command did in the process of linux compilation. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "what the gcc-c command does in the process of linux compilation". Next, please follow the editor to study!
Behind gcc-c hello.c # includeint main () {printf ("Hello World\ n"); return 0;} gcc hello.c-o hello.o./hello.oHello World
The above process can be divided into four parts: preprocessing, compilation, assembly and linking.
Precompile and compile handler: cc1
Assembler handler: as
Linker handler: ld
Precompile (cc1)
Delete
Deployment
Add
Keep
Gcc-E hello.c-o hello.i
Compile (cc1) gcc-S hello.c-o hello.s
Assembly (as) gcc-c hello.s-o hello.o or as hello.s-o hello.o
Link (ld)
The way of communication between modules in the static language cUniverse +
Function calls between modules and variable visits between modules, function access must know the address of the target function, and variable access must also know the address of the target variable, so both methods can be summed up in the same way. that is the reference of symbols between modules. The splicing of the module leads to the link. Link
Objective: to deal with the referenced parts of each module, so that the modules can be connected correctly.
Process: the linking process is divided into two steps, the first step is to merge the segments of all target files, and adjust the segment offset and segment length, merge the symbol table, and assign the memory address; the second step is the core of the link to relocate the symbols.
data
There are three areas where data is stored: .data segment, .bss segment, and .text segment. Generally, the compiled execution statements of the C language are compiled into machine code and saved in the .text section; the global and static variables that are not initialized are stored in the .data section; for the segments that are not initialized or the initialization value is 0, they are stored in the .bss section and do not take up the space of the target file.
Text segments: machine instructions that are read-only, shareable, compiled from program source code, stored on the heap or below the stack to prevent stack overflow
Initialization segment: not read-only, the value of the variable can be modified at run time
Uninitialized data segment
The benefits of separating data from instructions
Prevent instructions from being modified, data segments read-write, instruction segments read-only, and mapped to different virtual storage areas
The cache of CPU is designed as data cache and instruction cache.
Text segments are shareable, that is, executable instructions are shared, and for frequently executed programs, only one copy is needed in memory, while data segments are private to each process; doing so can save a lot of memory.
At this point, the study of "what did the gcc-c command do in the process of linux compilation" is over. I hope to be able to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.