Keil™, An ARM® Company

RealView Compiler User's Guide

Reducing debug information in objects and libraries

4.2.3. Reducing debug information in objects and libraries

It is often useful to reduce the amount of debug information in objects and libraries. Reducing the level of debug information:

  • Reduces the size of objects and libraries, thereby reducing the amount of disk space needed to store them.

  • Speeds up link time. In the compilation cycle, most of the link time is consumed by reading in all the debug sections and eliminating the duplicates.

  • Minimizes the size of the final image. This facilitates the fast loading and processing of debug symbols by a debugger.

There are several ways in which you can reduce the amount of debug information being generated per source file. For example, you can:

  • Avoid conditional use of #define in header files. The linker is unable to remove common debug sections unless these sections are identical.

  • Modify your C or C++ source files so that header files are #included in the same order.

  • Partition header information into smaller blocks. That is, use a larger number of smaller header files rather than a smaller number of larger header files. This helps the linker to eliminate more of the common blocks.

  • Only include a header file in a C or C++ source file if it is really needed.

  • Guard against the multiple inclusion of header files. For example, if you have a header file foo.h, then add:

    #ifndef foo_h
    #define foo_h
    
    ...
    // rest of header file as before
    ...
    #endif /* foo_h */
    

    You can use the compiler option --remarks to warn about unguarded header files.

  • Compile your code with the --no_debug_macros command-line option to discard preprocessor macro definitions from debug tables.

For more information see:

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