[all-commits] [llvm/llvm-project] 7b3463: [ELF] Orphan placement: prefer the last similar se...
Fangrui Song via All-commits
all-commits at lists.llvm.org
Tue Jun 4 09:15:15 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 7b346357db30d531245104c1c0aa8940a1f41b9a
https://github.com/llvm/llvm-project/commit/7b346357db30d531245104c1c0aa8940a1f41b9a
Author: Fangrui Song <i at maskray.me>
Date: 2024-06-04 (Tue, 04 Jun 2024)
Changed paths:
M lld/ELF/Writer.cpp
M lld/test/ELF/linkerscript/orphan.s
M lld/test/ELF/linkerscript/sections-nonalloc.s
M lld/test/ELF/linkerscript/sections.s
Log Message:
-----------
[ELF] Orphan placement: prefer the last similar section when its rank <= orphan's rank
`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
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list