5.7.10.1 Dinit-compression Option

The -Wl,--dinit-compression=level option enables optimization to the specified level of the data initialization template, which initializes objects and ramfunc-attributed functions in RAM. See 18.2.5 Initialize Objects and RAM Functions for more information on the operation of the data initialization template and record formats.

When the argument level is set to 0, the compiler uses the unoptimized legacy .dinit format used by v4.10 and prior compilers.

Level 1 merges those initialized objects in contiguous memory under the same .dinit record.

Level 2 performs level 1 optimizations but additionally groups the same (non-zero) initial value in a record of format #2 or #3 (as described in 18.2.5 Initialize Objects and RAM Functions), specifying respectively a single 16- or 32-bit initial value that will be copied multiple times. A format #2 record is chosen when there is a 16-bit repeated value in the initial value sequence (e.g. 0x13571357...); a format #3 record is chosen when there is a 32-bit repeated value in the initial value sequence (e.g. 0x6701238067012380...). This option adds size to runtime startup code.

Level 3 can perform any of the optimizations available in the lower levels and can additionally perform a PackBits-based run-length encoding compression to objects and ramfunc functions, storing this in record format #4. The pack-bits decompression algorithm will only be used if it saves an amount of space equal to or larger than the size of the decompression algorithm that needs to be additionally linked in; however, any repeated values initialized (as described above) might add to the size of the runtime startup routine. This is the default level if no option is specified.