Building a target library - PowerPoint PPT Presentation

About This Presentation
Title:

Building a target library

Description:

After the creation of the cross compiler the creation of a library is ... It provides ANSI and K & R standard C libraries. It has a good range of functionality ... – PowerPoint PPT presentation

Number of Views:25
Avg rating:3.0/5.0
Slides: 14
Provided by: craig60
Category:

less

Transcript and Presenter's Notes

Title: Building a target library


1
Building a target library
  • An example of Newlib

2
Role of a library
  • After the creation of the cross compiler the
    creation of a library is the next major task
  • There are a number of choices
  • If the system has pre-compiled or source
    libraries that can be used
  • May not be possible will all compilers or
    languages
  • Use the standard GNU libc
  • Port another library

3
Where does the library fit in the system?
  • There is a 3 level hierarchy of compiler
    library and operating system
  • The link between C and the library should be
    straight forward
  • The OS library link can be more problematic
  • It is possible to do without a library

Compiler
Operating System
Library
Implements calls Adds functionality
Does the calls
Calls functions getchar,
4
Which library?
  • Selection of the library is important
  • The features and functions of the board may
    dictate the library
  • i.e. if the board has lots of special,
    non-standard functions your library will have to
    implement these
  • Should use conformant library
  • i.e. ANSI, IEEE
  • Beware of over conformance

5
GNUlibc vs Newlib vs Minos
  • There are often a number of options
  • The original libraries with the board
  • In our case the Minos libraries
  • GNU has its own library GNU libc
  • There are a number of other libraries around
  • For example Newlib developed by Cygnus for cross
    development
  • Another library, slib, has been developed for the
    uCLinux, embedded linux system

6
Which library?
GNU libc
Newlib
Minos lib
Works well with gcc Works well with gcc Small
Easy to install intended for ebd targets Works with board
Very large Needs porting Non-standard
Limited functionality


-
-
7
Using Newlib
  • Newlib is a good choice for embedded systems work
  • It provides ANSI and K R standard C libraries
  • It has a good range of functionality
  • It is reasonably small
  • It is intended for porting lots of ports
    available
  • Integrated with GNU

8
Issues around porting a library
  • Does the code need to be reentrant?
  • This is only really important in a
    multiprocessing environment
  • In general it is better to build a reentrant
    library
  • The library may have to assume that there is
    no/limited OS support for reentrancy
  • Newlib provides library support for reentrancy

9
Reentrancy
  • If the Operating System does not provide support
    for process state variables, i.e. error numbers,
    file descriptors, then either the library code
    will be non-reentrant or the library will have to
    support such variables

Process 1
Process 2
Read, write, etc
Volatile State data
Volatile State data
Library Code
10
System Call Interface
  • _open_r
  • _close_r
  • _lseek_r
  • _read_r
  • _write_r
  • _fork_r
  • _wait_r
  • _stat_r
  • _fstat_r
  • _link_r
  • _unlink_r
  • _sbrk_r

11
A system call stub
12
A system call implementation
13
A system call implementation
Write a Comment
User Comments (0)
About PowerShow.com