[lld] [ELF] Orphan placement: prefer the last similar section when its rank <= orphan's rank (PR #94099)
Peter Smith via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 3 08:15:36 PDT 2024
================
@@ -935,14 +935,18 @@ findOrphanPos(SmallVectorImpl<SectionCommand *>::iterator b,
return i;
}
- // Find the first element that has as close a rank as possible.
if (b == e)
return e;
+ // Select the most similar output section. In case of ties, select the first
+ // section with a rank > the orphan's rank, or the last one with a rank <= the
+ // orphan's rank.
int proximity = getRankProximity(sec, *b);
----------------
smithp35 wrote:
The implementation getRankProximity needs to be understood before this part can be understood. Perhaps worth mentioning in the comment.
```
Rank Proximity is a value in the range [-1, 32] with -1 for SectionCommands with no input sections leaving [0, 32] to
describe the proximity with 0 most different and 32 identical.
```
Perhaps worth using `highestProximity` or `maxProximity` to make the purpose a bit clearer. Could even shorten to `maxP`.
https://github.com/llvm/llvm-project/pull/94099
More information about the llvm-commits
mailing list