Compiler

Compilation process of a C program

Executable creation
PREPROCESSING
Removal of comments
Interpretation of preprocessor directives (
#
)
COMPILING
Translation of source code into assembly language
ASSEMBLING
Creation of object code
LINKING
Combining with system libraries and/or libraries from other files
Extensions recognized
Header file
.h
Source file
.c
Preprocessed source file
.i
Assembly file
.s
Object module
.o
Dynamic libraries
.so
Static libraries
.a
GCC (GNU Compiler Collection)
A project by the Free Software Foundation, an organization founded by Richard M. Stallman as a protest against proprietary software licenses.
Multi-target compiler for:
C (originally created for this language)
Java, C++, Objective-C, Fortran, and Ada (front-end support)
Various machine languages (back-end support)
gcc [OPTIONS] source_file
-Wall
Sets the highest warning level
-w
Suppresses all warning messages
-g
Generates information useful for DEBUGGING
-o
fileOutput
Specifies the output file of the compilation
-E
Stops the process after the preprocessing phase (Does NOT perform COMPILATION)
-S
Stops the process after the compilation phase (Does NOT perform ASSEMBLY)
-c
Compiles and/or assembles the source after preprocessing (Does NOT perform linking with libraries)
-pedantic
Informs the programmer when deviating from the ISO standard
-O
Enables optimization of the executable file
-std=cXX
Specifies the C standard to use (by number XX
)
-std=c++XX
Specifies the C++ standard to use (by number XX
)
-Ldirectory -lname_library
-L
specifies the directory to search for library files (static or dynamic)
-l
indicates the library name to use
Analysis of a binary file
objdump [OPTIONS] binary_file
--disassemble
-Dslx
-d
Disassemble the binary file
-h
View ELF headers
-full-contents
View an ELF section
Last updated