Keil™, An ARM® Company

RealView Compiler User's Guide

Using linker feedback

2.6. Using linker feedback

Linker feedback enables the efficient elimination of unused functions. Unused function code might occur in the following situations:

  • Where you have legacy functions that are no longer used in your sources. Rather than manually remove the unused function code from your sources, you can use linker feedback to remove the unused object code automatically from the final image.

  • When a function is inlined. If an inlined function is not declared as static, the out‑of‑line function code is still present in the object file, but there is no longer a call to that code.

  • Where your image contains both ARM and Thumb code, functions that are called from the other state must be built for interworking. You can use linker feedback to avoid compiling for interworking those functions that are never called from the other state.

To provide linker feedback to the compiler, you must link your code as a separate step, and use the armlink option ‑‑feedback=filename to create a feedback file. You can then use this file as an input to the compiler using the compiler option ‑‑feedback=filename.

Note

To get the maximum benefit from linker feedback you have to do a full compile and link at least twice. A single compile and link using feedback from a previous build is normally sufficient to obtain some benefit.

You can specify the ‑‑feedback=filename option even when no feedback file exists. This enables you to use the same build or make file regardless of whether a feedback file exists, for example:

armcc ‑c ‑‑feedback=unused.txt test.c ‑o test.o
armlink ‑‑feedback=unused.txt test.o ‑o test.axf

The first time you build the application, it compiles normally but the compiler warns you that it cannot read the specified feedback file because it does not exist. The link command then creates the feedback file and builds the image. Each subsequent compile step uses the feedback file from the previous link step to remove any unused functions that are identified.

For more information see:

Copyright © 2007 ARM Limited. All rights reserved.ARM DUI 0375A