Previous: The GCC Runtime, Up: Libraries


6.2 The C Library

A port of newlib, an implementation of the Standard C Library, is available for separate download. Like the GCC runtime, some of the functions are system-dependent. Target types are used to build the library, and the default target type produces programs which works under the simulator.

When linking with gcc, the -lc option is automatically added so that C library function calls will be resolved, unless you link with the -nostdlib option. If you don't have the C library, you probably also want to compile with -ffreestanding, which prevents GCC from emitting calls to some C functions like memcpy.

6.2.1 Machine Subroutines

The directory machine/m6809 contains processor-specific functions. The 6809 port only adds two functions here, an implementation of setjmp and longjmp.

6.2.2 System Functions

The directory sys/m6809sim contains the UNIX system call functions, such as write and kill. For the simulator, most of these are stubs. The file-related functions do support standard input and standard output, and read/write special I/O addresses which the simulator understands. The process-related functions do nothing and assume a single-tasking environment.

There is a sys/coco implementation as well that is used when building the ‘m6809-coco-*’ target type.