GNU Tools for Embedded Systems

 

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.

 

              

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值