At the beginning of the life cycle of the hello program, it is a high-level C program, because when in this form, it can be understood by people. However, to run the hello. C program on the system, each c statement must be converted into a series of low-level machine language commands by other programs. These commands are packed in a format called executable object program and stored as binary disk files. The target program is also called an executable target file ).
Preprocessing phase: the pre-processor (CPP) modifies the original C program based on the command starting with "#" (directives. For example, the # include <stdio. h> command in the first line of Hello. c tells the Preprocessor to read the stdio. H content of the system file and insert it directly into the program text. The result shows another C program, usually with. I as the file extension.
Compilation phase: the compiler (CCL) translates the text file hello. I into the text file hello. S, which contains an assembly language program. Each statement in an assembly language program describes a low-level machine language instruction in a standard text format. Assembly language is very useful because it provides a general output language for different compilers in different advanced languages. For example, the C compiler and the Fortran compiler use the same assembly language for output files.
Assembly phase: Next, the assembler (AS) changes hello. S is translated into and its language commands. packaging these commands is called a format called relocatable, and the results are saved in the target file hello. o. The Hello. o file is a binary file whose Byte encoding is machine language instruction rather than character. If we open the hello. o file in the text editor, a pair of garbled characters will be displayed.
Link stage: Please note that the hello program calls the printf function, which is a function in the Standard C library and is provided by every C compiler. The printf function exists in a separate pre-compiled target file named printf. O, which must be incorporated into our hello. O program in some way. The linker (ID) is responsible for processing such integration, and the result is a hello file, which is an executable target file (or executable file ). After an executable file is loaded to the storage, the system is responsible for execution.