1 / 13

Building a target library

Building a target library. An example of Newlib. 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

kamal
Download Presentation

Building a target library

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 + + - -

  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

More Related