<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64824>64824</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[LLD] LTO -r hidden symbol could not merge
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
joyhou-hw
</td>
</tr>
</table>
<pre>
The attach file is a parts of my projects some enable lto, include two aarch64 big endian objs.
a_obj.o is a real objects binary file.
b.bc is a LLVM IR bitcode file
a_obj.o and b.bc both content a hidden symbol, named `_ZN3rtl7rb_treeINS_12rb_node_baseEE20rebalance_for_removeEPS1_S3_`
, this come from a header file template.
When use` lld -r `for linking , if the b.bc file is passed at front, the merged obj merge_out.o only keep a WEAK HIDDEN symbol.
```
ld.lld -EB -o merge_out.o -r b.bc a_obj.o
readelf -sW merge_out.o | grep _ZN3rtl7rb_treeINS_12rb_node_baseEE20rebalance_for_removeEPS1_S3
1683: 00000000 0 SECTION LOCAL DEFAULT 1523 .text.unlikely._ZN3rtl7rb_treeINS_12rb_node_baseEE20rebalance_for_removeEPS1_S3_
1798: 00000000 136 FUNC WEAK HIDDEN 1523 _ZN3rtl7rb_treeINS_12rb_node_baseEE20rebalance_for_removeEPS1_S3_
```
If b.bc at end , the link result will keep a LOCAL DEFAULT more. My real project many of cpp file include the header file, so there are a lot of same LOCAL DEFAULT symbol in the out obj file.
```
ld.lld -EB -o merge_out.o -r a_obj.o b.bc
readelf -sW merge_out.o | grep _ZN3rtl7rb_treeINS_12rb_node_baseEE20rebalance_for_removeEPS1_S3
638: 00000000 0 SECTION LOCAL DEFAULT 143 .text._ZN3rtl7rb_treeINS_12rb_node_baseEE20rebalance_for_removeEPS1_S3_
1632: 00000000 136 FUNC LOCAL DEFAULT 1551 _ZN3rtl7rb_treeINS_12rb_node_baseEE20rebalance_for_removeEPS1_S3_
1735: 00000000 0 SECTION LOCAL DEFAULT 1551 .text.unlikely._ZN3rtl7rb_treeINS_12rb_node_baseEE20rebalance_for_removeEPS1_S3_
1948: 00000000 140 FUNC WEAK HIDDEN 143 _ZN3rtl7rb_treeINS_12rb_node_baseEE20rebalance_for_removeEPS1_S3_
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEVt1u4zYTfRr55sCC_m1f6MIb2_iCz5sUTbYBeiOQ0shiQpEGSW3qty8o2e3Giy5QJIsatvyj4czhnHPGZNaKgyIqg_xTkG9mbHCdNuWzPnV6mHevM66bU_nYEZhzrO7QCkkQFgxHZpyFbtGfcDT6mWpnYXVPIMW4JEing-QGEKqWQ0NwrxqMmborMnBxAKlGMAXNn22IINoE0ZpVmj-HGlMFGGLS3x9Tc6GYOY0Awimah7yeIvf73z7j9ldw4Wrd0Bg0xbzNy1SDcRXXrkOtlSPlwNCJpiEFe-q5lh60Yj01CIqo-v0uNU4uDK-cIbq9e6jixPBK6YYqzixtt0lkiDPJVE1Vq01lqNdfafvLQ1w9pFVQRGckyQ1cJyxq36PW6N4XJtaQmbrqqD9K5ujSjOn61JHCYCkoIkjZYG48rFYbQAr1ItQBPrNo4TqaNnfh6MispQbM-WrKjWSMUT2ZAzW-s9PHSg8u1NBKnvBCdATD03b9fwD_u91stnfnxoTf4vL7mp7jV9mEHh3m20_AXL_J6zFPyM48TEuM37tsMbdPeBsPIFjc4GDoiPcSMNUC4mKZBuka0fkxVonwsL15vL2_w_7-Zr0HNtvd-sv-EXGepAgd_eHCQUnxQvIUvl8KE5R4sVpeIYnTArsvd56fq85PSD6o9BVn0_W2PXPjvCMxyZRGccGQHaTDq5DyIozrTvXaUAjg82my63kUoGfq5KdDfTyeBXkZAx19K3tfz2r_qyEw_4LUzq-0rKfrapMQIdSYRg8Oo4rHoQC8Q59_TR7fi_9CnyjSa1X8QJ-Is4s-P0yWRZr8QJbfGSSPP0qWQLxI839jzjz-aeZcZd-ZM4v-yZwjDT_HnLOmTJtVumIzKuNilWRJmi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