Comment 3 for bug 1379254

Revision history for this message
Terry Guo (terry.guo) wrote :

It seems that LTO will discard all debug sections. Here is the section list of object built without lto:

Section Headers:
  [Nr] Name Type Addr Off Size ES Flg Lk Inf Al
  [ 0] NULL 00000000 000000 000000 00 0 0 0
  [ 1] .text PROGBITS 00000000 000034 000000 00 AX 0 0 2
  [ 2] .data PROGBITS 00000000 000034 000000 00 WA 0 0 1
  [ 3] .bss NOBITS 00000000 000034 000000 00 WA 0 0 1
  [ 4] .text.startup.mai PROGBITS 00000000 000034 000028 00 AX 0 0 4
  [ 5] .rel.text.startup REL 00000000 003a70 000018 08 26 4 4
  [ 6] .text.startup._GL PROGBITS 00000000 00005c 000024 00 AX 0 0 4
  [ 7] .rel.text.startup REL 00000000 003a88 000018 08 26 6 4
  [ 8] .init_array INIT_ARRAY 00000000 000080 000004 00 WA 0 0 4
  [ 9] .rel.init_array REL 00000000 003aa0 000008 08 26 8 4
  [10] .bss.myled NOBITS 00000000 000084 000018 00 WA 0 0 4
  [11] .debug_info PROGBITS 00000000 000084 001c7f 00 0 0 1
  [12] .rel.debug_info REL 00000000 003aa8 000da8 08 26 11 4
  [13] .debug_abbrev PROGBITS 00000000 001d03 0003c7 00 0 0 1
  [14] .debug_aranges PROGBITS 00000000 0020ca 000028 00 0 0 1
  [15] .rel.debug_arange REL 00000000 004850 000018 08 26 14 4
  [16] .debug_ranges PROGBITS 00000000 0020f2 000060 00 0 0 1
  [17] .rel.debug_ranges REL 00000000 004868 000080 08 26 16 4
  [18] .debug_line PROGBITS 00000000 002152 0003cf 00 0 0 1
  [19] .rel.debug_line REL 00000000 0048e8 000010 08 26 18 4
  [20] .debug_str PROGBITS 00000000 002521 000cba 01 MS 0 0 1
  [21] .comment PROGBITS 00000000 0031db 000074 01 MS 0 0 1
  [22] .debug_frame PROGBITS 00000000 003250 000044 00 0 0 4
  [23] .rel.debug_frame REL 00000000 0048f8 000020 08 26 22 4
  [24] .ARM.attributes ARM_ATTRIBUTES 00000000 003294 000033 00 0 0 1
  [25] .shstrtab STRTAB 00000000 0032c7 00010d 00 0 0 1
  [26] .symtab SYMTAB 00000000 003834 0001f0 10 27 26 4
  [27] .strtab STRTAB 00000000 003a24 00004a 00 0 0 1

We can find the debug sections like .debug_info/.debug_line. While if we build same file with lto, there is no such debug section:

Section Headers:
  [Nr] Name Type Addr Off Size ES Flg Lk Inf Al
  [ 0] NULL 00000000 000000 000000 00 0 0 0
  [ 1] .text PROGBITS 00000000 000034 000000 00 AX 0 0 2
  [ 2] .data PROGBITS 00000000 000034 000000 00 WA 0 0 1
  [ 3] .bss NOBITS 00000000 000034 000000 00 WA 0 0 1
  [ 4] .gnu.lto_.profile PROGBITS 00000000 000034 000013 00 E 0 0 1
  [ 5] .gnu.lto_.jmpfunc PROGBITS 00000000 000047 0000ca 00 E 0 0 1
  [ 6] .gnu.lto_.inline. PROGBITS 00000000 000111 0000cc 00 E 0 0 1
  [ 7] .gnu.lto_.purecon PROGBITS 00000000 0001dd 00001c 00 E 0 0 1
  [ 8] .gnu.lto_gpio_wri PROGBITS 00000000 0001f9 000223 00 E 0 0 1
  [ 9] .gnu.lto__ZN4mbed PROGBITS 00000000 00041c 0001d9 00 E 0 0 1
  [10] .gnu.lto__Z41__st PROGBITS 00000000 0005f5 0001d3 00 E 0 0 1
  [11] .gnu.lto_main.157 PROGBITS 00000000 0007c8 0002e6 00 E 0 0 1
  [12] .gnu.lto__GLOBAL_ PROGBITS 00000000 000aae 0000c9 00 E 0 0 1
  [13] .gnu.lto_.symbol_ PROGBITS 00000000 000b77 000098 00 E 0 0 1
  [14] .gnu.lto_.refs.15 PROGBITS 00000000 000c0f 000021 00 E 0 0 1
  [15] .gnu.lto_.decls.1 PROGBITS 00000000 000c30 002631 00 E 0 0 1
  [16] .gnu.lto_.symtab. PROGBITS 00000000 003261 0000f6 00 E 0 0 1
  [17] .gnu.lto_.opts PROGBITS 00000000 003357 0000b0 00 E 0 0 1
  [18] .comment PROGBITS 00000000 003407 000074 01 MS 0 0 1
  [19] .ARM.attributes ARM_ATTRIBUTES 00000000 00347b 000033 00 0 0 1
  [20] .shstrtab STRTAB 00000000 0034ae 000264 00 0 0 1
  [21] .symtab SYMTAB 00000000 003aac 000170 10 22 21 4
  [22] .strtab STRTAB 00000000 003c1c 000026 00 0 0 1

I need to figure out why lto abandoned those debug sections.