[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);
   auto i = b;
   for (auto j = b; ++j != e;) {
-    int p = getRankProximity(sec, *j);
-    if (p > proximity) {
+    auto p = getRankProximity(sec, *j);
----------------
smithp35 wrote:

`int` is used a few lines above. Worth being consistent?

https://github.com/llvm/llvm-project/pull/94099


More information about the llvm-commits mailing list