您的位置:首页 > 其它

GNU Tools for Embedded Systems

2006-09-16 09:22 302 查看
1. Using GNU tools on embedded systems
The following GNUPro tools can be run on embedded targets.
n gcc, the GUNPro Toolkit compiler
n cpp, the GUNPro C preprocessor
n gas, theGNUPro Toolkitassembler
n ld, the GNUPro Toolkit linker
n binutils, theGUNPro Toolkit directory of utilities
n libgloss, the support library for embedded targets and newlib, the C library developed by Cygnus

Invoking the GNU tools
gcc invokes all the required GNU passes for you with the following utilities.
n cpp The preprocessor which processes all the header files and macros that your target requires.
n gcc The compiler which produces assembly language code from the processed C files.
n gas The assembler which produces binary code from the assembly language code and puts it in an object file.
n ld The linker which binds the code to address, links the startupfile and libraries to the object file, and produces the executable binary image.
There are several machine-independent compiler switches, among which are, notably –fno-execeptions(for C++), -fritt1(for C++) and –T(for linking)

gcc, the GNU compiler
When you compile C or C++ programs with gnu C, the complier quietly inserts a call at the begginning of main to a gcc support subroutine called _main.
_main is the initializatin routine for C++ constructors. Because GNU C is designed to interoperate with GNU C++, even C programs must have this call: otherwise C++ object files linked with a C main might fail.

cpp, the GNU preprocessor
cpp merges in the #include files, expands all macros definitions, and processes the #ifdef sections.To see the output of cpp, invoke gcc with the –E option

gas, the GNU assembler
gas can be used as either a compiler pass or a source-level assembler.

ld, the GNU linker
ld resolves the code addresses and debug symbols, links the startup code and additional libraries to the binary code, and produces an executable binary image.

.coff for object file formats
.coff is the main object file format when using the tools on embedded target system.

binutils, the GNU binary utilities
The following are the binary utilities, although they are not included on all hosts: ar, nm, objcopy, objdump, ranlib, size, strings and strip.
objcopy
A few ROM monitors, such as a.out, load executable binary images, and, consequently, most load an S-record. An S-record is a printable ASCII representation of executable binary image.
S-records are suitable both for building ROM images for standalone boards and for downloading images to embedded systems. Usethe following examples’s input for this process.
objcopy –O srec infile outfile

objdump
objdump displays information about one or more object files. This information is mostly useful to programmers who are working on the compilation tools, as opposed to programmers who just want their program to compile and work. A few of the more useful options for commands are: -d, -disassemble and –prefix-addresses.
-d
--disassemble
Displays the assembler mnemonics for the machine instructions from objfile.
This option only disassembles those sections that are expected to contain instructins.
--prefix-addresses
For disassembling, prints the complete address on each line.

gdb, the debugging tool

crt0, the main startup file
The crt0(C RunTime 0) file contains the initial startup code.
Cygnus provides a crt0 file, although you may want to write your own crt0 file for each target. The crt0 file is usually written in assembler as ‘crt0.s’, and its object gets linked in first and bootstraps the rest of your application. The crt0 file defines a special symbol like _start, which is both the default base address for the application and the first symbol in the executable binary image.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: