Services and Modeling for Embedded Software Development
Embecosm divider strip

Howto: Porting newlib

A Simple Guide

Jeremy Bennett


Application Note 9. Issue 1

July 2010

Table of Contents

1. Introduction
1.1. Target Audience
1.2. Examples
1.3. Further information
1.4. About Embecosm Application Notes
2. newlib within the GNU Tool Chain
2.1. The Unified Source Tree
2.1.1. Incorporating Newlib within the Tool Chain Build
3. Overview of newlib
3.1. The relationship between libgloss and newlib
3.2. The C Namespace and Reentrant Functions
3.3. Adding a new Target to Newlib
3.3.1. Extending for a New Target
4. Modifying newlib
4.1. The Machine Directory
4.1.1. Updating the Main Machine Directory Configuration files
4.1.2. Implementing the setjmp and longjmp functions.
4.1.3. Updating the Target Specific Machine Directory Configuration files
4.2. Changing Headers
4.2.1. IEEE Floating Point
4.2.2. setjmp Buffer Size
4.2.3. Miscellaneous System Definitions
4.2.4. Overriding Other Header Files
5. Modifying libgloss
5.1. The Platform Directory
5.1.1. Ensuring the Platform Directory is Configured
5.2. The C Runtime Initialization, crt0.o
5.2.1. Exception vector setup
5.2.2. The _start Function and Stack Initialization
5.2.3. Cache Initialization
5.2.4. Clearing BSS
5.2.5. Constructor and Destructor Handling
5.2.6. C Initialization Functions
5.2.7. Invoking the main program
5.3. Standard System Call Implementations
5.3.1. Error Handling
5.3.2. The Global Environment, environ
5.3.3. Exit a program, _exit
5.3.4. Closing a file, close
5.3.5. Transfer Control to a New Process, execve
5.3.6. Create a new process, fork
5.3.7. Provide the Status of an Open File, fstat
5.3.8. Get the Current Process ID, getpid
5.3.9. Determine the Nature of a Stream, isatty
5.3.10. Send a Signal, kill
5.3.11. Rename an existing file, link
5.3.12. Set Position in a File, lseek
5.3.13. Open a file, open
5.3.14. Read from a File, read
5.3.15. Allocate more Heap, sbrk
5.3.16. Status of a File (by Name), stat
5.3.17. Provide Process Timing Information, times
5.3.18. Remove a File's Directory Entry, unlink
5.3.19. Wait for a Child Process, wait
5.3.20. Write to a File, write
5.4. Reentrant System Call Implementations
5.5. BSP Configuration and Make file;
5.5.1. for the BSP
5.5.2. for the BSP
5.6. The Default BSP, libnosys
6. Configuring, Building and Installing Newlib and Libgloss
6.1. Configuring Newlib and Libgloss
6.2. Building Newlib and Libgloss
6.3. Testing Newlib and Libgloss
6.4. Installing Newlib and Libgloss
7. Modifying the GNU Tool Chain
7.1. Putting Newlib in a Custom Location
7.2. Changes to GCC
7.2.1. Adding Machine Specific Options for Newlib
7.2.2. Updating Spec Definitions
7.3. Changes to the GNU Linker
8. Testing Newlib and Libgloss
8.1. Testing Newlib
8.1.1. Checking Physical Hardware
8.2. Testing Libgloss
9. Summary Checklist
Embecosm divider strip