4.2 Elimination of common groups or sections

The linker can detect multiple copies of groups and sections, and discard the additional copies.

The ARM® compiler generates complete objects for linking. Therefore:
  • If there are inline functions in C and C++ sources, each object contains the out-of-line copies of the inline functions that the object requires.
  • If templates are used in C++ sources, each object contains the 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. 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 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.
You control this optimization with the following linker options:
  • Use the --bestdebug option to use the largest common data (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.
    Because --no_bestdebug is the default, the final image is the same regardless of whether you generate debug tables during compilation with --debug.
Related concepts
4.1 Elimination of common debug sections
4.3 Elimination of unused sections
4.4 Elimination of unused virtual functions
3.1.2 Input sections, output sections, regions, and program segments
Related reference
9.9 --bestdebug, --no_bestdebug
Related information
Inline functions
--debug, --no_debug compiler option
Non-ConfidentialPDF file icon PDF versionARM DUI0377G
Copyright © 2007, 2008, 2011, 2012, 2014, 2015 ARM. All rights reserved.