8.4.8. Link-Time Compression and Specialization Options¶
The options listed in the subsections below control how the linker handles optimization. On the c29clang command line they should be passed to the linker using the -Wl or -Xlinker option as described in Passing Options to the Linker.
8.4.8.1. Option Summary¶
- --cinit_compression [=compression_kind]¶
Specifies the type of compression to apply to the C auto initialization data. The default if this option is used with no kind specified is lzss for Lempel-Ziv-Storer-Szymanski compression. Alternately, specify --cinit_compression=rle to use Run Length Encoded compression, which generally provides less efficient compression. See Compression (--cinit_compression and --copy_compression Option).
- --compress_dwarf¶
Aggressively reduces the size of DWARF information from input object files. See Compress DWARF Information (--compress_dwarf Option).
- --copy_compression [=compression_kind]¶
Compresses data copied by linker copy tables. See Compression (--cinit_compression and --copy_compression Option).
- --use_memcpy [=small | fast]¶
Select the optimization goal for the RTS memcpy() function. See RTS Optimization (--use_memcpy and --use_memset Options).
- --use_memset [=small | fast]¶
Select the optimization goal for the RTS memset() function. See RTS Optimization (--use_memcpy and --use_memset Options).
- --unused_section_elimination¶
Eliminates sections that are not needed in the executable module; on by default. See Do Not Remove Unused Sections (--unused_section_elimination Option).
In addition, the version of the C RTS printf function used is optimized at link-time based on the format strings used in the application. See Printf Support Optimization (no option).
8.4.8.2. Compression (--cinit_compression and --copy_compression Option)¶
By default, the linker does not compress copy table (About Linker-Generated Copy Tables and Using Linker-Generated Copy Tables) source data sections. The --cinit_compression and --copy_compression options specify compression through the linker.
The --cinit_compression option specifies the compression type the linker applies to the C autoinitialization copy table source data sections. The default is lzss.
Overlays can be managed by using linker-generated copy tables. To save ROM space the linker can compress the data copied by the copy tables. The compressed data is decompressed during copy. The --copy_compression option controls the compression of the copy data tables.
The syntax for the options are:
--cinit_compression[=compression_kind]
--copy_compression[=compression_kind]
The compression_kind can be one of the following types:
off. Don’t compress the data.
rle. Compress data using Run Length Encoding.
lzss. Compress data using Lempel-Ziv-Storer-Szymanski compression(the default if no compression_kind is specified).
Compressed sections within initialization tables are byte aligned in order to reduce the occurrence of holes in the .cinit table.
See Compression for more information about compression.
8.4.8.3. Compress DWARF Information (--compress_dwarf Option)¶
The --compress_dwarf option aggressively reduces the size of DWARF information by eliminating duplicate information from input object files.
For ELF object files, which are used with EABI, the --compress_dwarf option eliminates duplicate information that could not be removed through the use of ELF COMDAT groups. (See the ELF specification for information on COMDAT groups.)
8.4.8.4. RTS Optimization (--use_memcpy and --use_memset Options)¶
There are two versions of the memcpy and memset functions available in the C RTS library. One version is designed for efficient performance in terms of speed. The other version is much smaller than the first, but slower in comparison, especially if large blocks of data are to be handled by the memcpy or memset functions. The linker chooses one of these two versions of the C RTS memcpy and memset functions according to the optimization goals of the application.
The c29clang command line influences the selection of the memcpy and memset function implementations used. If the specified optimization option favors generating smaller code (as with the -Oz option), the linker chooses the smaller implementation of memcpy and memset. If the specified optimization option favors generating faster code (as with the -O3 option), the linker chooses the faster implementations.
The selection of the memcpy and memset function implementations can also be set explicitly using the following linker options:
-–use_memcpy={small|fast}
-–use_memset={small|fast}
These options override any influence that the optimization option has on link-time selection of the memcpy or memset implementation. If neither the -–use_memcpy/-–use_memset options nor an optimization option is specified, then the linker selects the smaller implementation of the memcpy and memset functions by default.
8.4.8.5. Printf Support Optimization (no option)¶
There are three different versions of the __TI_printfi function in the C RTS library. This function supports processing of format strings and format specifiers for the C RTS family of printf-like functions (printf, sprintf, fprintf, etc.).
Each version of __TI_printfi provides a different level of support for processing format strings. The linker chooses the smallest version of the underlying printf support function to that meets the needs of the application. This choice is based on what format specifiers are used in format strings in the application.
The three version of the function can then be characterized in terms of the format specifiers they support:
minimal. The smallest version of __TI_printfi is chosen if there are no calls to any variation of printf with format strings that contain any of the following format specifiers: l, u, p, x, field width with precision, h, i, a, A, g, G, e, E, f, F, and L.
nofloat. This version of __TI_printfi is larger than the minimal version, but still quite a bit smaller than the full version of __TI_printfi. It is chosen if there are no calls to any variation of printf with format strings that contain any of the floating-point related format specifiers: a, A, g, G, e, E, f, F, and L.
full. This version of __TI_printfi is chosen if any calls are made to any variation of printf with format strings that contain any of the floating-point format specifier: a, A, g, G, e, E, f, F, or L. Additionally, if the linker is unable to determine whether a smaller version of __TI_printfi can be safely used, the full version of __TI_printfi is included in the link by default.
If your application uses printf-style functions from the C RTS library, but it does not use format specifiers that require more involved code to support, then you may realize a code size savings if the linker can determine it is safe to use a smaller version of __TI_printfi.
8.4.8.6. Do Not Remove Unused Sections (--unused_section_elimination Option)¶
To minimize the footprint, the ELF linker does not include sections that are not needed to resolve any references in the final executable. Use --unused_section_elimination=off to disable this optimization. The linker default behavior is equivalent to --unused_section_elimination=on.