-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Medium
-
Code Generation Tools
-
CODEGEN-15086
-
C29_2.1.0.STS
-
-
default
The following commands show a source file, build it with no LTO, and with LTO, then compare the sections generated.
C:\examples>type hello.c
#include <stdio.h>
int main()
{
puts("hello, world!");
return 0;
}
C:\examples>c29clang hello.c -o no_lto.out -Wl,-c
C:\examples>c29clang -flto hello.c -o with_lto.out -Wl,-c
C:\examples>c29objdump --section-headers no_lto.out | findstr "BSS DATA"
2 .data 000001c4 000022f4 BSS
3 .bss 000000e4 000027d8 BSS
4 .cinit 00000084 000028cc DATA
5 .init_array 00000000 00000000 BSS
6 .stack 00000100 000025d8 BSS
7 .sysmem 00000100 000026d8 BSS
8 __llvm_prf_cnts 00000000 00000020 BSS
9 __llvm_prf_bits 00000000 00000020 BSS
10 .rodata 00000010 000028bc DATA
14 .cio 00000120 000024b8 BSS
C:\examples>c29objdump --section-headers with_lto.out | findstr "BSS DATA"
5 .stack 00000100 000024b0 BSS
6 .bss 0000003c 000026b0 BSS
7 .data 00000275 00002114 BSS
8 .rodata 00000010 000026ec DATA
9 .sysmem 00000100 000025b0 DATA
10 .cio 00000120 0000238c DATA
11 .cinit 00000088 000026fc DATA
When the last column is BSS, the section is uninitialized. When the last column is DATA, it is initialized. Note how .sysmem and .cio change from uninitialized to initialized.
One way this problem manifests is when creating a binary file. A binary file ignores uninitialized sections. In this case, building with LTO means the sections .sysmem and .cio are part of the binary file, instead of being ignored.