80 likes | 198 Vues
This guide delves into the intricacies of the compilation process in programming languages, highlighting key steps such as pre-processing, symbol collection, instruction generation, and linking. It outlines how compilation differs between languages like C/C++ and Java, emphasizing the workflow involving loaders, linkers, assemblers, and code generators. Discover the importance of multiple passes in compilers for error checking and optimization, as well as the role of object files and libraries in producing executable programs. Ideal for students and developers seeking to understand compiler design.
E N D
Compilers != Compilation • Compilation has multiple steps • pre-processing (non-existent for java) • finalizing the actual source listing • typically used for includes in a C/C++ program • translating (half-way done for java) • from high-level or assembly language • to machine instructions • building • combine your parts and system parts
A Simple Translation Step • Most basic: two passes • first: collect and interpret symbols • second: line-by-line generation of instructions • Symbol = anything requiring interpretation • variable names • procedure/method names • your names and system names • opcodes and pseudo-instructions (in assembler)
Typical Translation • Most compilers today have 3 or 4 passes • Extra passes enable a compiler to • do extended error checking • do extra optimization of resulting code • Most projects have many pieces • each piece (e.g. .c or .cc) translated individually • files ending in .o on Unix • files ending in .obj on Windows
Linking • Once pieces translated, combine them • Each piece designed as relocatable module • External references get resolved • Complete executable built with parts • System parts often manifested as libraries • e.g. C library for unix applications • Shared libraries • Dynamically linked libraries
Total Workflow Loader Linker Assembler Compiler Preprocessor Editor or Code Generator