<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/68178>68178</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
LLD puts .ARM.exidx section between .rel.dyn and .rel.plt, yielding a crash with glibc >= 2.16 < 2.23
</td>
</tr>
<tr>
<th>Labels</th>
<td>
lld
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
glandium
</td>
</tr>
</table>
<pre>
STR:
- Create a `foo.c` file with the following content:
```
#include <stdio.h>
int main() {
printf("Hello world\n");
return 0;
}
```
- Download jessie-chroot.tar.xz from https://drive.google.com/file/d/1GhGeWRsw5RB6k0JAJZRK_EXtCwuEiAHi/view?usp=sharing and unpack it.
- Build with `clang --target=armv7-unknown-linux-gnueabihf -o foo foo.c -fuse-ld=lld --sysroot=/path/to/jessie-chroot -Wl,-z,now`
- Copy the `foo` executable to somewhere in the `jessie-chroot` directory.
- On a armhf/arm64 system, or a system with qemu-user binfmt setup, run `chroot /path/to/jessie-chroot`
- Execute `foo`
Expected result:
```
Hello world
```
Actual result:
A crash.
The crash itself is due to https://sourceware.org/bugzilla/show_bug.cgi?id=14341
BFD ld places .ARM.exidx closer to .eh_frame, and places nothing between .rel.dyn and .rel.plt (except for .relr.dyn when enabled).
Section table from the binary linked with lld:
```
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .interp PROGBITS 000001b4 0001b4 000019 00 A 0 0 1
[ 2] .note.ABI-tag NOTE 000001d0 0001d0 000020 00 A 0 0 4
[ 3] .dynsym DYNSYM 000001f0 0001f0 000080 10 A 7 1 4
[ 4] .gnu.version VERSYM 00000270 000270 000010 02 A 3 0 2
[ 5] .gnu.version_r VERNEED 00000280 000280 000020 00 A 7 1 4
[ 6] .gnu.hash GNU_HASH 000002a0 0002a0 000018 00 A 3 0 4
[ 7] .dynstr STRTAB 000002b8 0002b8 000088 00 A 0 0 1
[ 8] .rel.dyn REL 00000340 000340 000050 08 A 3 0 4
[ 9] .ARM.exidx ARM_EXIDX 00000390 000390 000010 00 AL 15 0 4
[10] .rel.plt REL 000003a0 0003a0 000028 08 AI 3 25 4
[11] .rodata PROGBITS 000003c8 0003c8 000011 00 AMS 0 0 4
[12] .ARM.extab PROGBITS 000003d9 0003d9 000000 00 A 0 0 1
[13] .eh_frame_hdr PROGBITS 000003dc 0003dc 00000c 00 A 0 0 4
[14] .eh_frame PROGBITS 000003e8 0003e8 000004 00 A 0 0 4
[15] .text PROGBITS 000103ec 0003ec 000184 00 AX 0 0 4
[16] .init PROGBITS 00010570 000570 00000c 00 AX 0 0 4
[17] .fini PROGBITS 0001057c 00057c 000008 00 AX 0 0 4
[18] .plt PROGBITS 00010590 000590 000070 00 AX 0 0 16
[19] .fini_array FINI_ARRAY 00020600 000600 000004 04 WA 0 0 4
[20] .init_array INIT_ARRAY 00020604 000604 000004 04 WA 0 0 4
[21] .dynamic DYNAMIC 00020608 000608 0000d0 08 WA 7 0 4
[22] .got PROGBITS 000206d8 0006d8 00001c 00 WA 0 0 4
[23] .data PROGBITS 000306f4 0006f4 000008 00 WA 0 0 4
[24] .tm_clone_table PROGBITS 000306fc 0006fc 000000 00 WA 0 0 4
[25] .got.plt PROGBITS 000306fc 0006fc 000020 00 WA 0 0 4
[26] .bss NOBITS 0003071c 00071c 000001 00 WA 0 0 1
[27] .ARM.attributes ARM_ATTRIBUTES 00000000 00071c 000033 00 0 0 1
[28] .comment PROGBITS 00000000 00074f 00006a 01 MS 0 0 1
[29] .symtab SYMTAB 00000000 0007bc 0004c0 10 31 62 4
[30] .shstrtab STRTAB 00000000 000c7c 000129 00 0 0 1
[31] .strtab STRTAB 00000000 000da5 00028f 00 0 0 1
```
Section table from the binary linked with BFD ld:
```
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .interp PROGBITS 00000194 000194 000019 00 A 0 0 1
[ 2] .note.ABI-tag NOTE 000001b0 0001b0 000020 00 A 0 0 4
[ 3] .gnu.hash GNU_HASH 000001d0 0001d0 000018 04 A 4 0 4
[ 4] .dynsym DYNSYM 000001e8 0001e8 0000b0 10 A 5 3 4
[ 5] .dynstr STRTAB 00000298 000298 00009c 00 A 0 0 1
[ 6] .gnu.version VERSYM 00000334 000334 000016 02 A 4 0 2
[ 7] .gnu.version_r VERNEED 0000034c 00034c 000020 00 A 5 1 4
[ 8] .rel.dyn REL 0000036c 00036c 000058 08 A 4 0 4
[ 9] .rel.plt REL 000003c4 0003c4 000028 08 AI 4 21 4
[10] .init PROGBITS 00001000 001000 00000c 00 AX 0 0 4
[11] .plt PROGBITS 0000100c 00100c 000050 04 AX 0 0 4
[12] .text PROGBITS 0000105c 00105c 0001b0 00 AX 0 0 4
[13] .fini PROGBITS 0000120c 00120c 000008 00 AX 0 0 4
[14] .rodata PROGBITS 00002000 002000 000011 00 A 0 0 4
[15] .ARM.exidx ARM_EXIDX 00002014 002014 000008 00 AL 12 0 4
[16] .eh_frame PROGBITS 0000201c 00201c 000004 00 A 0 0 4
[17] .init_array INIT_ARRAY 00003ebc 002ebc 000004 04 WA 0 0 4
[18] .fini_array FINI_ARRAY 00003ec0 002ec0 000004 04 WA 0 0 4
[19] .jcr PROGBITS 00003ec4 002ec4 000004 00 WA 0 0 4
[20] .dynamic DYNAMIC 00003ec8 002ec8 0000f8 08 WA 5 0 4
[21] .got PROGBITS 00003fc0 002fc0 000040 04 WA 0 0 4
[22] .data PROGBITS 00004000 003000 000008 00 WA 0 0 4
[23] .bss NOBITS 00004008 003008 000004 00 WA 0 0 1
[24] .comment PROGBITS 00000000 003008 00007a 01 MS 0 0 1
[25] .ARM.attributes ARM_ATTRIBUTES 00000000 003082 000039 00 0 0 1
[26] .symtab SYMTAB 00000000 0030bc 0006e0 10 27 84 4
[27] .strtab STRTAB 00000000 00379c 000288 00 0 0 1
[28] .shstrtab STRTAB 00000000 003a24 0000f7 00 0 0 1
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycmVFzoso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