`findOrphanPos` finds the most similar output section (that has input sections). In the event of proximity ties, we select the first section. However, when an orphan section's rank is equal to or larger than the most similar sections's, it makes sense to prioritize the last similar section. This new behavior matches GNU ld better. ``` // orphan placement for .bss (SHF_ALLOC|SHF_WRITE, SHT_NOBITS) WA SHT_PROGBITS (old behavior) <= here A WA SHT_PROGBITS AX WA (.data) (new behavior) <= here ``` When the orphan section's rank is less, the current behavior prioritizing the first section still makes sense. ``` // orphan with a smaller rank, e.g. .rodata <= here WA AX WA ``` Close #92987 Pull Request: https://github.com/llvm/llvm-project/pull/94099
110 KiB
110 KiB