By default, the C library uses semihosting to provide device driver level functionality, enabling a host computer to act as an input and an output device. This is useful because development hardware often does not have all the input and output facilities of the final system.
You can provide your own implementation of C library functions that make use of target hardware, and that are automatically linked in to your image in favor of the C library implementations. This process, known as retargeting the C library, is shown in Figure 5.
For example, you might have a peripheral I/O device such as
an LCD screen, and you might want to override the library implementation
fputc(), that writes to the debugger console,
with one that outputs to the LCD. Because this implementation of
linked in to the final image, the entire
of functions prints out to the LCD.
In this example implementation of
the function redirects the input character parameter of
a serial output function
sendchar() that is
assumed to be implemented in a separate source file. In this way,
as an abstraction layer between target dependent output and the
C library standard output functions.
In a standalone application, you are unlikely to support semihosting operations. Therefore, you must remove all calls to semihosting functions or re-implement them with non semihosting functions.