06.02.2013 Views

ARM Compiler toolchain Using the Linker - ARM Information Center

ARM Compiler toolchain Using the Linker - ARM Information Center

ARM Compiler toolchain Using the Linker - ARM Information Center

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

5.2 Elimination of common groups or sections<br />

5.2.1 See also<br />

The <strong>ARM</strong> compiler generates complete objects for linking. Therefore:<br />

<strong>Using</strong> linker optimizations<br />

• If <strong>the</strong>re are inline functions in C and C++ sources, each object contains <strong>the</strong> out-of-line<br />

copies of <strong>the</strong> inline functions that <strong>the</strong> object requires.<br />

• If templates are used in C++ sources, each object contains <strong>the</strong> template functions that <strong>the</strong><br />

object requires.<br />

When <strong>the</strong>se functions are declared in a common header file, <strong>the</strong> functions might be defined<br />

many times in separate objects that are subsequently linked toge<strong>the</strong>r. To eliminate duplicates,<br />

<strong>the</strong> compiler compiles <strong>the</strong>se functions into separate instances of common code sections or<br />

groups.<br />

It is possible that <strong>the</strong> separate instances of common code sections, or groups, are not identical.<br />

Some of <strong>the</strong> copies, for example, might be found in a library that has been built with different,<br />

but compatible, build options, different optimization, or debug options.<br />

If <strong>the</strong> copies are not identical, armlink retains <strong>the</strong> best available variant of each common code<br />

section, or group, based on <strong>the</strong> attributes of <strong>the</strong> input objects. armlink discards <strong>the</strong> rest.<br />

If <strong>the</strong> copies are identical, armlink retains <strong>the</strong> first section or group located.<br />

You control this optimization with <strong>the</strong> following linker options:<br />

• Use <strong>the</strong> --bestdebug option to use <strong>the</strong> largest common data (COMDAT) group (likely to<br />

give <strong>the</strong> best debug view).<br />

• Use <strong>the</strong> --no_bestdebug option to use <strong>the</strong> smallest COMDAT group (likely to give <strong>the</strong><br />

smallest code size). This is <strong>the</strong> default.<br />

Because --no_bestdebug is <strong>the</strong> default, <strong>the</strong> final image is <strong>the</strong> same regardless of whe<strong>the</strong>r<br />

you generate debug tables during compilation with --debug.<br />

Concepts<br />

• Input sections, output sections, regions, and Program Segments on page 4-5.<br />

• Elimination of common debug sections on page 5-2<br />

• Elimination of unused sections on page 5-4<br />

• Elimination of unused virtual functions on page 5-6.<br />

<strong>Using</strong> <strong>the</strong> <strong>Compiler</strong>:<br />

• Inline functions on page 6-29.<br />

Reference<br />

<strong>Linker</strong> Reference:<br />

• --bestdebug, --no_bestdebug on page 2-21.<br />

<strong>Compiler</strong> Reference:<br />

• --debug, --no_debug on page 3-55.<br />

<strong>ARM</strong> DUI 0474C Copyright © 2010-2011 <strong>ARM</strong>. All rights reserved. 5-3<br />

ID080411 Non-Confidential

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!