Keil™, An ARM® Company

RealView Linker and Utilities Guide

Common group or section elimination

3.3.2. Common group or section elimination

If there are inline functions or templates used in the C++ source, the ARM compiler generates complete objects for linking such that each object contains the out‑of‑line copies of inline functions and template functions that the object requires. When these functions are declared in a common header file, the functions might be defined many times in separate objects that are subsequently linked together. In order to eliminate duplicates, the compiler compiles these functions into separate instances of common code sections or groups.

It is possible that the separate instances of common code sections, or groups, are not identical. Some of the copies, for example, might be found in a library that has been built with different (but compatible) build options, different optimization, or different debug options.

If the copies are not identical, armlink retains the best available variant of each common code section, or group, based on the attributes of the input objects. armlink discards the rest.

If the copies are identical, armlink retains the first section or group located.

This optimization is controlled by linker options:

  • Use the ‑‑bestdebug option to use the largest Comdat group (likely to give the best debug view).

  • Use the ‑‑no_bestdebug option to use the smallest Comdat group (likely to give the smallest code size). This is the default. In most cases, use of ‑‑bestdebug is unlikely.

    Because ‑‑no_bestdebug is the default, the final image is the same regardless of whether you generate debug tables during compilation with ‑‑debug.

    For more information, see:

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