<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/92987>92987</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
lld: Questionable heuristics for placing orphaned input sections
</td>
</tr>
<tr>
<th>Labels</th>
<td>
lld
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mintsuki
</td>
</tr>
</table>
<pre>
Hello,
The following was tested with LLVM/Clang version 17.0.6 and main branch.
This issue is similar, albeit not the same, as issue #92864 .
LLD seems to choose the first PHDR, in ascending order, with matching enough permissions to place orphaned input sections. This behaviour differs compared to ld.bfd, which prefers placing orphaned input sections with, e.g., `RW` permissions, into the PHDR which contains the `.data` output section, rather than the first PHDR that matches permissions in ascending order.
This is true whether the `.data` output sections will be emitted or not, which also ties in with #92864 .
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEU81unDAQfhpzGQWBgSUcOKRZrXLYSm1UtWcDA3ZrbOQZsurbV_YmStJW7QUka76_8WdFZBaH2Ivmg2iOmdpZ-9CvxjHtP0w2-Oln_4DWeiHvRXEUxd31-0UjzN5afzFugYsiYCTGCS6GNZzPXz8Kebq3yi3whIGMd1C2eZEfQLkJVmUcDEG5UecvfIbAEO0IhoDMaqwKQt6DsgMaBucZWCOQWjEdv0wLWXXy9lBD_tbe-XwEQlwJ2MOovSdM8NkEYvj0cHyMJMaBohHdFDP4MGFSTAlWxaOOx-j8vmjYMKyGYo5EuVk1IviwaeVwAuO2nYFw5DiQQ0ozoFZPxu8BJjPPGAhGv24q4BQZ7JQP85T0tBk1bAHTTGS-2vkrd3IXUZgvefyLQ_H4TRyKtw6v2dinyDHss8boHSsTE2iMwHxSrCLW7_xGJMKDYo0BWCv32-LiGV_3g_RuL3-uM39fmXTFwGFHuGh8FviXkxjXWhgQcDUc6-VDrMLr2pQlD2wwqaebey1ENvXV1FWdyrAv2_JQ1V3ZtZnup2Ye6rKrq65rx1o1iHV7aG9nVReHuSyGzPSykHXRSFlUVde0uVSDKhpVl01Zz8Nci7rAVRmbW_u05j4sWWpj38nuts2sGtBSelNSWjsJKePjCn2cvhn2hURdWENMr3g2bLGPw9UdfN6RYn41WASNezDEZiSYffhfQbI92F4zbySqOyFPQp4Ww3of8tGvQp6i4PPvZgv-O44s5Cm5JyFPKcCvAAAA__9aQ14U">