C++ Compiling and Linking Flashcards
(45 cards)
What are the 5 stages of program lifetime?
Code writing, compilation, linking, loading, execution
What is a translation unit?
Source code giving rise to an object file.
What is the output of compilation?
Object file.
What is the compilation?
Process of translating the code from a higher level language to a lower level language like assembly.
What is the decompilation?
Process of translating the code from a lower level language like assembly to a higher level langauge.
What are the compilation stages?
Pre-processing, linguistic analysis, assembly, optimization, code emission.
What does pre-processing do ?
Replaces all macros with appropriate constants, conditionally includes/excludes parts of code, includes files based on include directives.
What gcc flag can be used to get only the preprocesing output?
The flag is -E:
gcc -E input.c -o output.i
What gcc flags can be used to get a more readable preprocessed output?
The flags are: -E and -P:
gcc -E -P input.c -o output.i
What do lines starting with # in preprocessed output denote?
They usually mark the lines and file to which the code that follows belong to. Example:
25 hello.c
This denotes that the code which follows belongs to file hello.c starting from line 25.
What does -E flag do to preprocessor?
It removes the suplementary information in the preprocessed output like line numbers and similar.
What is lexical analysis?
Lexical analysis is a stage in linguistic analysis which splits the source into tokens.
What is parsing/syntax analysis?
It is a stage in linguistic analysis in which the order of tokens is checked against language rules and specifications.
What is linguistic analysis?
Linguistic analysis is a stage in which source is checked against language defined rules like syntax, semantics etc.
What is semantic analysis?
It is a stage in linguistic analysis in which the source statements and are checked for validity, like two objects being concatenated via operator + or similar.
What is assembling?
Compilation stage in which the source is translated to assembly language.
What are the two known assembly instruction printing formats?
AT&T and Intel.
What is different between AT&T and Intel assembly format?
One significant difference is that AT&T format uses the (operation, source, destination) order and Intel format uses the (operation, destination, source) order.
What is the purpose of the optimization stage?
To remove unused code, inline operations where possible, remove unnecessary computations and similar.
What is the purpose of the code emission stage?
To create object files from assembly.
What flag can be used to generate the assembly output?
The -S flag,
gcc -S -masm=att input.c -o input.s
What flag can be used to generate the object files without linking?
The -c flag
What flag can be used to get the dissasembled output of objdump ?
-D
What is objdump?
Utility program to check object files.