ARM Technical Support Knowledge Articles

How to re-implement library functions?

Applies to: DS-5


The ARM Compiler library functions are generally optimized for performance and code size, and in most cases it is not necessary to override them. However, you might need to customize some parts of the library for your target environment or to remove a dependency on semihosting.

For example, it might be more efficient for the CPU to access an external memory controller in a way that is different to what is expected by the memcpy() implementation provided by the __aeabi_memcpy() library function. In such situations, you can override the default implementation with your own __aeabi_memcpy() function that includes the optimization for memory access to the external memory controller.

To override/re-implement the library functions you will need to:

  1. Identify the lowest level implementation of the function you are targeting. This can be done by generating an image with the standard library functions and then looking at the disassembly to see which implementation is called by the library function.
  2. Make sure your implementation has the same declaration as the library function you are targeting. This can be done by referring to the header file that declares the library function you want to re-implement.
  3. If your implementation of the function will be called across various files you need to make sure it has external linkage (declared as extern).
  4. Use the --library_interface=none option during compilation. This will tell the compiler to look for local implementation of library functions. If no local definition is found the function is linked with library code. (Refer to the ARM Compiler User guide for more details on this compiler option).

The Libraries and Floating-Point Support User Guide contains an example of redefining low-level library functions to enable direct use of high-level library functions in the C library

Once the compiler finds the definition of a library function in your code it will not pull in the definition(s) from the C/C++ libraries during compile or link time.

Article last edited on: 2016-05-09 09:28:04

Rate this article

Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential