[llvm-bugs] [Bug 41653] New: lld produces invalid binary
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Apr 29 12:29:19 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=41653
Bug ID: 41653
Summary: lld produces invalid binary
Product: lld
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: ELF
Assignee: unassignedbugs at nondot.org
Reporter: phosek at chromium.org
CC: llvm-bugs at lists.llvm.org, peter.smith at linaro.org
The change r358981/D60131 broke our kernel build.
https://storage.googleapis.com/fuchsia-build/lld-repro.tar.gz is the
reproducer.
Looking at the differences in output layout, after this change lld places the
orphan section `code_patch_table` first, which breaks everything:
Section Headers:
[Nr] Name Type Address Off Size ES Flg
Lk Inf Al
[ 0] NULL 0000000000000000 000000 000000 00
0 0 0
[ 1] code_patch_table PROGBITS ffffffff80100000 001000 000060 00 A
0 0 8
[ 2] .text.boot0 PROGBITS ffffffff80100060 001060 000050 00 A
0 0 1
[ 3] .buildsig PROGBITS ffffffff801000b0 0010b0 000028 00 A
0 0 1
[ 4] .text.boot PROGBITS ffffffff801000d8 0010d8 000158 00 AX
0 0 8
[ 5] .text.bootstrap16 PROGBITS ffffffff80101000 002000 000166 00 AX
0 0 4096
[ 6] .text PROGBITS ffffffff80101170 002170 137298 00 AX
0 0 16
[ 7] .rodata.rodso_image PROGBITS ffffffff80239000 13a000 00d000 00
A 0 0 4096
[ 8] .kcounter.desc PROGBITS ffffffff80246000 147000 002000 00 A
0 0 4096
[ 9] .note.gnu.build-id NOTE ffffffff80248000 149000 000018 00 A
0 0 4
[10] .rodata PROGBITS ffffffff80248020 149020 030dd1 00 AMS
0 0 16
[11] .data.rel.ro PROGBITS ffffffff80278e00 179e00 006fa0 00 WA
0 0 16
[12] .init_array INIT_ARRAY ffffffff8027fda0 180da0 0000e0 00 WA
0 0 8
[13] .data PROGBITS ffffffff80280000 181000 006310 00 WA
0 0 4096
[14] .bss NOBITS ffffffff80287000 187310 08b423 00 WA
0 0 4096
[15] .rela.text RELA 0000000000000000 187310 132810 18 I
33 6 8
[16] .debug_str PROGBITS 0000000000000000 2b9b20 1555c9 01 MS
0 0 1
[17] .debug_loc PROGBITS 0000000000000000 40f0e9 33ad16 00
0 0 1
[18] .debug_abbrev PROGBITS 0000000000000000 749dff 05c080 00
0 0 1
[19] .debug_info PROGBITS 0000000000000000 7a5e7f 66590a 00
0 0 1
[20] .debug_ranges PROGBITS 0000000000000000 e0b789 093910 00
0 0 1
[21] .debug_macinfo PROGBITS 0000000000000000 e9f099 000140 00
0 0 1
[22] .comment PROGBITS 0000000000000000 e9f1d9 00010a 01 MS
0 0 1
[23] .debug_frame PROGBITS 0000000000000000 e9f2e8 0397c0 00
0 0 8
[24] .debug_line PROGBITS 0000000000000000 ed8aa8 119414 00
0 0 1
[25] .rela.data.rel.ro RELA 0000000000000000 ff1ec0 0102a8 18 I
33 11 8
[26] .rela.rodata RELA 0000000000000000 1002168 012660 18 I
33 10 8
[27] .rela.data RELA 0000000000000000 10147c8 000330 18 I
33 13 8
[28] .rela.init_array RELA 0000000000000000 1014af8 0002a0 18 I
33 12 8
[29] .debug_aranges PROGBITS 0000000000000000 1014d98 000290 00
0 0 1
[30] .rela.text.boot RELA 0000000000000000 1015028 000288 18 I
33 4 8
[31] .rela.text.bootstrap16 RELA 0000000000000000 10152b0 0000c0
18 I 33 5 8
[32] .relacode_patch_table RELA 0000000000000000 1015370 0000c0 18
I 33 1 8
[33] .symtab SYMTAB 0000000000000000 1015430 044820 18
35 11684 8
[34] .shstrtab STRTAB 0000000000000000 1059c50 0001c8 00
0 0 1
[35] .strtab STRTAB 0000000000000000 1059e18 03a0b7 00
0 0 1
Prior to this change, lld would place it between `.kcounter.desc` and
`.note.gnu.build-id`:
Section Headers:
[Nr] Name Type Address Off Size ES Flg
Lk Inf Al
[ 0] NULL 0000000000000000 000000 000000 00
0 0 0
[ 1] .text.boot0 PROGBITS ffffffff80100000 001000 000050 00 A
0 0 1
[ 2] .buildsig PROGBITS ffffffff80100050 001050 000028 00 A
0 0 1
[ 3] .text.boot PROGBITS ffffffff80100078 001078 000158 00 AX
0 0 8
[ 4] .text.bootstrap16 PROGBITS ffffffff80101000 002000 000166 00 AX
0 0 4096
[ 5] .text PROGBITS ffffffff80101170 002170 137298 00 AX
0 0 16
[ 6] .rodata.rodso_image PROGBITS ffffffff80239000 13a000 00d000 00
A 0 0 4096
[ 7] .kcounter.desc PROGBITS ffffffff80246000 147000 002000 00 A
0 0 4096
[ 8] code_patch_table PROGBITS ffffffff80248000 149000 000060 00 A
0 0 8
[ 9] .note.gnu.build-id NOTE ffffffff80248060 149060 000018 00 A
0 0 4
[10] .rodata PROGBITS ffffffff80248080 149080 030ce1 00 AMS
0 0 16
[11] .data.rel.ro PROGBITS ffffffff80278d70 179d70 006f70 00 WA
0 0 16
[12] .init_array INIT_ARRAY ffffffff8027fce0 180ce0 0000e0 00 WA
0 0 8
[13] .data PROGBITS ffffffff80280000 181000 006310 00 WA
0 0 4096
[14] .bss NOBITS ffffffff80287000 187310 08b423 00 WA
0 0 4096
[15] .rela.text RELA 0000000000000000 187310 132738 18 I
33 5 8
[16] .debug_str PROGBITS 0000000000000000 2b9a48 15825c 01 MS
0 0 1
[17] .debug_loc PROGBITS 0000000000000000 411ca4 2990b2 00
0 0 1
[18] .debug_abbrev PROGBITS 0000000000000000 6aad56 05e57e 00
0 0 1
[19] .debug_info PROGBITS 0000000000000000 7092d4 66c13c 00
0 0 1
[20] .debug_ranges PROGBITS 0000000000000000 d75410 092220 00
0 0 1
[21] .debug_macinfo PROGBITS 0000000000000000 e07630 00015b 00
0 0 1
[22] .comment PROGBITS 0000000000000000 e0778b 000116 01 MS
0 0 1
[23] .debug_frame PROGBITS 0000000000000000 e078a8 03a430 00
0 0 8
[24] .debug_line PROGBITS 0000000000000000 e41cd8 118d8d 00
0 0 1
[25] .rela.data.rel.ro RELA 0000000000000000 f5aa68 010230 18 I
33 11 8
[26] .rela.rodata RELA 0000000000000000 f6ac98 012660 18 I
33 10 8
[27] .rela.data RELA 0000000000000000 f7d2f8 000330 18 I
33 13 8
[28] .rela.init_array RELA 0000000000000000 f7d628 0002a0 18 I
33 12 8
[29] .debug_aranges PROGBITS 0000000000000000 f7d8c8 000290 00
0 0 1
[30] .rela.text.boot RELA 0000000000000000 f7db58 000288 18 I
33 3 8
[31] .rela.text.bootstrap16 RELA 0000000000000000 f7dde0 0000c0 18
I 33 4 8
[32] .relacode_patch_table RELA 0000000000000000 f7dea0 0000c0 18
I 33 8 8
[33] .symtab SYMTAB 0000000000000000 f7df60 01e978 18
35 5213 8
[34] .shstrtab STRTAB 0000000000000000 f9c8d8 0001c8 00
0 0 1
[35] .strtab STRTAB 0000000000000000 f9caa0 0347d1 00
0 0 1
The BFD linker places it between `.rodata` and `.data.rel.ro`. The BFD
placement is the one that makes the most sense: it's after all the read-only
sections, near the end of the rodata segment. This is a read-only,
non-executable section so the orphans placement logic puts it after all the
read-only, non-executable sections explicit in the linker script.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190429/f3ed326a/attachment.html>
More information about the llvm-bugs
mailing list