Relocations refering zero sized .eh_frame sections can happen when linking against crtbeginT.o.
Section Headers:
[Nr] Name Type Address Offset Size EntSize Flags Link Info Align
...
[ 4] .bss NOBITS 0000000000000000 00000140 0000000000000050 0000000000000000 WA 0 0 32 [ 5] .eh_frame PROGBITS 0000000000000000 00000140 0000000000000000 0000000000000000 A 0 0 4 [ 6] .jcr PROGBITS 0000000000000000 00000140 0000000000000000 0000000000000000 WA 0 0 8
...
0000000000000080 <__do_global_dtors_aux>:
80: 80 3d 00 00 00 00 00 cmpb $0x0,0x0(%rip) # 87 <__do_global_dtors_aux+0x7> 87: 75 22 jne ab <__do_global_dtors_aux+0x2b> 89: 55 push %rbp 8a: 48 89 e5 mov %rsp,%rbp 8d: e8 6e ff ff ff callq 0 <deregister_tm_clones> 92: b8 00 00 00 00 mov $0x0,%eax 97: 48 85 c0 test %rax,%rax 9a: 74 07 je a3 <__do_global_dtors_aux+0x23> 9c: bf 00 00 00 00 mov $0x0,%edi a1: ff d0 callq *%rax a3: 5d pop %rbp a4: c6 05 00 00 00 00 01 movb $0x1,0x0(%rip) # ab <__do_global_dtors_aux+0x2b> ab: f3 c3 repz retq ad: 0f 1f 00 nopl (%rax)
...
00000000009d 00050000000a R_X86_64_32 0000000000000000 .eh_frame + 0
...
0000000000c4 00050000000a R_X86_64_32 0000000000000000 .eh_frame + 0
The result of linking without this patch is assertion fail, details can be found in https://llvm.org/bugs/show_bug.cgi?id=25762&list_id=89776.
With this patch behavior seems to be consistent with gold.