110 likes | 239 Views
UQC122S3 Real-Time and Embedded Systems. GCC as a cross compiler. GCC. Long standing compiler development Developed an editor emacs , compiler suite gcc and UNIX-like OS Hurd . Plus many other tools and utilities.
E N D
UQC122S3 Real-Time and Embedded Systems GCC as a cross compiler
GCC • Long standing compiler development • Developed an editor emacs, compiler suite gcc and UNIX-like OS Hurd. Plus many other tools and utilities. • emacs and gcc have been the most successful and central to many developments – BSD, Linux • Developed by Richard Stallman and the Free Software Foundation
The GCC suite • The development tools are made up of • gcc , a set of compilers for C, C++, Ada, Java • The gnu linker, ld and assembler, as • Binutils, a collection of useful code development tools • ar, nm, objcopy, objdump, ranlib, size, strings, strip, addr2line
GCC • The gcc compiler has front ends to provide different language capabilities • It also has a gcc core which allows it to generate the actual code • The code generation is done through an intermediate language called RTL • Register Transfer Language – a LISP variant
RTL • The front end generates a parse tree which checks the syntax for the target language and any supporting data structures • This tree is then used to generate RTL which expresses the structure of the code • The RTL code is then used to do optimisation • Finally assembler code is generated from the RTL
gcc passes gcc Language Specific Front end RTL code Assembler Code
gcc output formats • Although the gcc compiler can be installed on one host it can create outputs for many targets and formats • The normal situation is that the host and the target are the same. • A Intel 686 running Linux with ELF output would generate ELF 686 binaries that would run under Linux
BFD • In order to allow the compiler to create a number of different formats gcc use Binary File Definitions – BFD • BFD allows the compiler and linker to have descriptions of different file and machine formats • This then means that object files can be converted from one format to another
BFD • When gcc is created it will, by default, use the host machine as the basis for its target code generation. • The format is CPU-MACHINE-SYSTEM • i386-sun-sunos4 • So host and target might be m68k-hp-netbsdelf • Conversion between formats may lose information or not be possible
Using gcc as a cross compiler • gcc is popular as a cross compiler • This requires the installation to distinguish between the system the compiler run upon and the code it generates for another system • More care is required when configuring and installing
A gcc cross compiler Library files ccc compiler Generated code Binary output Startup code Host binary Target binary