Tooling Part 2
Tooling Part 2
Tools part 2
•It contains the max RAM & ROM size and all the prepherals
and registers the could exist in a microcontroller in this
family.
Type information :
For every function or variable, debug information can store
additional information about its type. For a variable or a function
parameter, this information will tell the debugger whether it is an
integer, or a string, or a user defined type, and so on. For a
function, it will tell the number of parameters, calling convention,
and the type of the function’s return value.
Eclipse
NetBeans
MonoDevelop
CodeWarrior
Linker File
Preprocessor
The input to this phase is the .c File, .h Files
The preprocess process the preprocessor keywords like
#define, #ifdef.... and generate a new .c File after the text
replacement process.
The output of this phase is a .c File without any
preprocessor keyword.
• Compiler
The input to this phase .c File
The compiler parse the code, and check the syntax
correctness of the file.
Convert the .c Code into optimized machine language
code.
The output of this phase is object file (.o File) and list file
(.lss file).
• List File:
Contain the corresponding assembly code for each line.
GCC Compiler:
GNU C Compiler, Started at 1987 as a part of
the GNU project
Renamed to GNU Compiler Collection
GCC is not only a Native Compiler but also it’s
a Cross Compiler
GCC is ported to a wide variety of processor
architectures and is also available for most
embedded platforms
Compilation Options:
gcc –E h2d.c
Produce preprocessed file(.i file) of h2d.c
gcc –S h2d.c
produce assembly code in h2d.s
gcc –c h2d.s
produce object code in h2d.o
gcc –o final.exe main.c aux1.s aux2.o
compile, assemble and link three files into one executable
gcc h2d.c –O2 –o h2d.exe
-O0, -O1, -O2, -O3 are optimization levels
Assembler
The input to this phase .asm File
The Assembler coverts the assembly code to the
corresponding machine language code.
The output of this phase is object file (.o File).
•Linker
The input to this phase multiple .O File
The Linker merges different object files and library files.
The linker allocate target memory (RAM, ROM, Stack)
The linker produce the debug info
The output of this phase is the executable file and the
map file.
LD :
Is a GNU linker
Is a part of GCC “GNU Compiler Collection”
Is responsible of doing the linking
operation.
Is called automatically within the
compilation process.
Why makefiles ?
Let’s say that we have the following files “main.c”, “file1.c”
and “file2.c” to compile these files we should type the
following line in the the shell :
gcc -std=c99 -wall -o final.exe main.c file1.c file2.c
GNU Automake
GNU Automake is a programming tool that produces portable
makefiles for use by the make program, used in compiling
software.
It is made by the Free Software Foundation as one of GNU
programs, and is part of the GNU build system.
a script file called makefile is responsible of guiding make.
The script file should be named “makefile”, “Makefile” or
“GNUmakefile”.
The C file is recompiled if it has been changed or any of it’s
dependencies is changed
Project Compilation
Done by the Makefile mechanism
A makefile is a file (script) containing:
• Project structure (files, dependencies)
• Instructions for files creation
• The make command reads a makefile, understands the project
structure and makes up the executable
Note that the Makefile mechanism is not limited to C
programs
Project structure
Program contains 3 files
main.c., sum.c, sum.h
sum.h included in both .c files
Executable should be the file sum
Group of lines
Target: the file you want to create
Dependencies: the files on which this file depends
Command: what to execute to create the file (after a
TAB)
Testmath :: testmath.o mymath.o
gcc –o testmath testmath.o mymath.o
MakeFile
sum: main.o sum.o
gcc –o sum main.o sum.o
MakeFile
.o depends (by default) on corresponding .c file. Therefore,
equivalent makefile is:
Make Operation
Project dependencies tree is constructed
Target of first rule should be created
We go down the tree to see if there is a target that should
be recreated. This is the case when the target file is older than
one of its dependencies
In this case we recreate the target file according to the action
specified, on our way up the tree. Consequently, more files
may need to be recreated
If something is changed, linking is usually necessary
Make Operation
make operation ensures minimum compilation, when the
project structure is written properly.
Using Makefile
Example
Targets
We can define multiple targets in a makefile
Target clean – has an empty set of
dependencies. Used to clean intermediate
files.
make
• Will execute the first target in make file
make TARGET_NAME
• Will execute the action of this target
make clean
• AMITWill
Prepared by: remove
Learning intermediate files(like .o Files)
Eclipse IDE Integration