Noeud:The Assembler, Noeud « Next »:, Noeud « Previous »:The Compiler, Noeud « Up »:GCC Commands



The Assembler

Since the output of the compilation process is a file (or possibly set of files) in assembly language for a specific machine, the penultimate stage before an executable program is produced is to take the assembler code and turn it into machine code. This is done for each source file passed to the compiler. At this stage the files are ignorant about any other files that they may be included with; possibly there will be a number of symbols that make references to other files. It is the purpose of the link/load editor to resolve these external references in the next stage, linking.

To produce the machine code file compile your program using the -c command. You can pass .c, preprocessed .i or assembled .s files to the gcc using the -c flag; the output will be a file(s) with the extension .o containing object code. Once again, like the previous stages, you don't have to rely on gcc - you can invoke the assembler as directly (see Passing Arguments to the Assembler and Linker on how to do this directly from gcc).