<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62363>62363</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
LLD ARM.exidx compression not as good as GNU ld.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
lld
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
smithp35
</td>
</tr>
</table>
<pre>
.ARM.exidx tables are designed so that identical table entries can be merged. In LLD this is done on a per-section basis and not on a per-entry basis. This means LLD can miss opportunities to merge the .ARM.exidx when there are multiple table entries per section and adjacent table entries are identical, but all the adjacent table entries are not. For example in the test case below GNU ld is able to merge the identical .cantunwind entries in the sections containing multiple table entries but because no two sections are identical LLD does not merge the entries.
This would take a more sophisticated implementation which could rewrite the contents of a .ARM.exidx input section rather than only taking the .ARM.exidx input section unaltered.
When -ffunction-sections is used there will be one function per section and only one table entry per .ARM.exidx section which will permit LLD merging to do as well as GNU ld.
```
.syntax unified
.section .text.func1, "ax",%progbits
.global func1
func1:
.fnstart
bx lr
.save {r7, lr}
.setfp r7, sp, #0
.fnend
.section .text.func2, "ax",%progbits
.global func2
func2:
.fnstart
bx lr
.cantunwind
.fnend
.section .text.func3, "ax",%progbits
.global func3
func3:
.fnstart
bx lr
.cantunwind
.fnend
.global func4
func4:
.fnstart
bx lr
.cantunwind
.fnend
.global func5
func5:
.fnstart
bx lr
.save {r7, lr}
.setfp r7, sp, #0
.fnend
.section .text.__gcc_personality_v0, "ax", %progbits
.global __gxx_personality_v0
__gxx_personality_v0:
bx lr
.section .text.__aeabi_unwind_cpp_pr0, "ax", %progbits
.global __aeabi_unwind_cpp_pr0
__aeabi_unwind_cpp_pr0:
bx lr
.text
.global _start
_start:
bl func1
bl func2
bx lr
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8lt-PozYQx_8aeBktIoZkbx942LtVqkrXPlSt-hgNeABfjY3sYZP895VNEp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