An Introduction to the Run-Time Libraries 
------------------------------------------

There are two run-time libraries provided to support cross-compiled C:

 *  the minimal stand alone run time library;

 *  the ANSI C library.

Both libraries are supplied in source form and will need to be re-targeted to 
your ARM-based hardware. However, both have been designed to make re-targeting 
straightforward. Both libraries are also provided in binary form targeted at 
the <ARMulator>, ARM's user-extensible, CPU emulator, so you can run and debug 
programs running on an emulated ARM immediately. For details see chapter "<armsd 
Command Language>", in this book, and examples in the 
Cookbook.

The minimal standalone run time library provides only those functions required 
by code compiled by the ARM C compiler:

 *  division and remainder functions;

 *  stack-limit checking functions;

 *  lowest-level memory management (stack + heap);

 *  program startup (calling <main()>); 

 *  program termination (<_exit()>);

This library is a single module written in ARM assembly language. It is a few 
pages of code, a high proportion of which is comment. Little needs to be 
re-written for each new environment: only a few small functions. Thus 
re-targeting typically takes an hour or two, and is right first time.

Once the stand alone library is operational, code compiled from C may be run, 
beginning with the supplied test programs.  Refer to the Cookbook for details.

The full ANSI C library contains the following:

 *  target-independent modules written in ANSI C (e.g. <printf()>); 

 *  target-independent modules written in ARM assembly language (e.g. <divide()>
    , <memcpy()>, etc.); 

 *  target-dependent modules written in ANSI C (e.g. default signal handlers, 
    <clock()>, etc.);

 *  target-dependent modules written in ARM assembly language.

The target-independent portions of the library can be built immediately. The 
target dependent parts require some effort to implement. An example 
implementation for a commercially available ARM-based personal computer is 
provided in the tools release, and this can be modified as required.

Re-targeting the ANSI C library will require some knowledge of ARM assembly 
language, and some understanding of the ARM processor and hardware being used. 
It will be necessary to refer to the relevant ARM data sheet and to "<ARM 
Assembly Language>".

Because of its modular structure, not all of the library needs to be 
re-targeted at once: re-target only what will be used.

Re-targeting the C library is described in chapter  "<ARM C Library Porting 
Guide>" of the Reference Manual.

