Embedded 3.10 and expand operations

GCC is GPL licenses issued free software, is a key part of the GNU project. GCC intention is for the GNU operating system specifically written a compiler, has been most Unix-like operating systems (such as Linux, BSD, Mac OS X, etc.) adopted as the standard compiler, or even be on Microsoft's Windows use GCC. GCC chip supports many computer architectures, such as x86, ARM, MIPS, etc., and has been ported to a variety of other hardware platforms [1].
GCC formerly known as GNU C compiler (GNU C Compiler), can only handle C language. But it soon expanded, it becomes possible to deal with C ++, and later extended to support more programming languages such as Fortran, Pascal, Objective -C, Java , Ada, Go and assembly language on types of processor architecture, so renamed GNU compiler kit (GNU compiler Collection) [1] .
Structure Editor
GCC's external interface looks like a standard Unix compiler. A user typing in the command line gcc program name, and a number of command parameters in order to decide for each individual language compiler to use the input file and the output of this program code using an appropriate combination of hardware platform language compiler, and selectively connector performed to produce an executable program.
Each language compiler is a separate program, the program source code can handle inputs and outputs assembly code. All language compilers have a common architecture intermediary: a front-end analytical meet the source of this language, and generate a abstract syntax tree, and a translation of the syntax tree to become the back-end of GCC register Switch language <RTL> of. Compiler optimization program code and static analytical techniques (e.g. FORTIFY_SOURCE, trying to find a buffer overflow <buffer overflow> compiler) applied at this stage the program code. Finally, for this hardware architecture assembly language programming code to Jack Davidson and Chris Fraser invention algorithm outputs.
Almost all of the GCC by the C languages, in addition to most of the Ada front end written in Ada.
Front-end interface
Front-end function is to generate a syntax tree can make the back-end processing. This is the handwriting of a recursive parser parser.
Until 2004, the syntax tree structure of the program could not be decoupled from the processor architecture to be output. The rule syntax tree is sometimes not the same in a different language front-end, front-end will provide them some special rules of syntax tree.
In 2005, two new types of decoupling language syntax tree included in the GCC. They are called GENERIC and GIMPLE. Parsing become temporarily generated syntax tree associated with the language, and then they turn into GENERIC. After the re-use "gimplifier" technology to reduce complex structure GENERIC become a relatively simple static only form (Static Single Assignment form, SSA) GIMPLE form the basis of. This is a form of decoupling language and processor architecture optimized global common language, suitable for most modern programming languages.
Intermediary interfaces
optimized compiler writers will be placed in the general syntax tree of the front, but in fact this step does not see the kind of language and there are different and do not need the parser. Therefore GCC authors included in this step is known as part of the intermediary stages in. Such optimization of dead code digestion comprises digestion with global numerical calculation is repeated re-encoding and the like. Many optimization techniques are also being implemented in.
End interface
behavior varies rear GCC preprocessor macros and functions specific and different architectures, such as different character sizes, and the size of the call-endian mode and the like. The rear end of the front half interface generated using these messages to determine their form of RTL, so though the RTL GCC theoretically not impact processor, but at this stage it has been abstracted command into a format of the target architecture.
GCC optimization techniques according to their release version is very different, but they all contain the optimized algorithm standard, such as cycle optimization, jump threading, common clause abatement program, instruction scheduling and so on. The optimized RTL situation due to less available, and the lack of higher-order information, and therefore the phase comparison, the increase of GIMPLE syntax tree form, it seemed more important.
After the rear end by a re-reading step, using the information describing the instruction set of the target processor made to replace the abstract register to register the real processors. This stage is very complex, because it must pay attention to specifications and technical details of the processor instruction set of all GCC portable platform.
The last step of the rear end of the formulation rather, only the assembly language code obtained by the preceding stage of the subroutine simply converted into scratchpad memory location corresponding to the machine code.
Basic Usage editing
when using the GCC compiler, we must be given the necessary set of call parameters and file names. Call parameters GCC compiler there are about 100, here only the most basic, the most commonly used parameters. Specific reference GCC Manual.
GCC is the most basic usage :gcc [options] [filenames]
where is the compiler options required parameters, filenames given the relevant file name.
-c, compile only, not linked into an executable file generated by the compiler just like .c .o input source code file suffix object file, typically used to compile the file does not contain a main subroutine.
-o output_filename, to determine the name of the output file is output_filename, while the name of the source file of the same name and can not. If this option is not given, gcc will be given preset executable file a.out.
-g, generates symbolic debugging tools (GNU's gdb) symbol information necessary, in order to debug the source code, we must add this option.
-O, a program optimizing compiler, linker, using this option, the entire source code to optimize the compilation, linking process, the efficiency of the executable file thus produced can be increased, however, compile, link speed accordingly to be slower.
-O2, -O and better than optimizing compiler, linker, and of course the entire compilation, linking process will be slower.
-Idirname, pointed out the dirname directory to the directory list program header files, are the parameters used in the pre-compilation. C header file contains two programs where:
A) #include <myinc.h>
B) #include "myinc.h"
wherein, A Class angle brackets (<>), type B double quotation marks ( "") . For category A, preprocessor cpp preset file directory containing the file (such as / usr / include) search for the corresponding file, and Classes B, preprocessor search target file in the file folder in the system.
detailed process executed when the execution -v gcc, gcc version number and related procedures
original gcc manual This option English interpretation
Print (on standard error output) the commands executed to run the stages of compilation. Also print the version number of the compiler driver program and of the preprocessor and proper . the compiler
search path to use when adding this option to see search header files gcc / library file when compiling the program!
The basic rule editor
section gcc rules of engagement followed by:
.c file with the extension, C language source code files;
.a suffix of the file, the archive file is composed of object files;
.C, .cc, or as .cxx suffix files, are C ++ source code files and must be pretreated;
.h file with the extension, file header is included in the program;
.i file with the extension, the C source code file and should not be pre its implementation deal with;
.ii file with the extension, is the C ++ source code files and should not be performed Preconditioning;
.m file with the extension, Objective-C is a source code file;
.mm file with the extension, is Objective-C ++ source code files ;
.o suffix file, the target file is compiled;
.s suffix files, assembly language source code files;
.S suffix file is the result of the assembly language source code files precompiled.

Released four original articles · won praise 0 · Views 135

Guess you like

Origin blog.csdn.net/weixin_46412477/article/details/104885992