[lld] [lld:MachO] Allow independent override of weak symbols aliased via .set (PR #167825)

Jez Ng via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 20 19:06:06 PST 2025


================
@@ -78,22 +78,23 @@ static void transplantSymbolsAtOffset(InputSection *fromIsec,
   auto insertIt = llvm::upper_bound(toIsec->symbols, toOff, symSucceedsOff);
   llvm::erase_if(fromIsec->symbols, [&](Symbol *s) {
     auto *d = cast<Defined>(s);
-    if (d->value != fromOff)
+    if (d == skip)
+      return true;
+    if (d->value != fromOff || d->isExternal())
       return false;
-    if (d != skip) {
-      // This repeated insertion will be quadratic unless insertIt is the end
-      // iterator. However, that is typically the case for files that have
-      // .subsections_via_symbols set.
-      insertIt = toIsec->symbols.insert(insertIt, d);
-      d->originalIsec = toIsec;
-      d->value = toOff;
-      // We don't want to have more than one unwindEntry at a given address, so
-      // drop the redundant ones. We We can safely drop the unwindEntries of
-      // the symbols in fromIsec since we will be adding another unwindEntry as
-      // we finish parsing toIsec's file. (We can assume that toIsec has its
-      // own unwindEntry because of the ODR.)
-      d->originalUnwindEntry = nullptr;
-    }
+
+    // This repeated insertion will be quadratic unless insertIt is the end
+    // iterator. However, that is typically the case for files that have
+    // .subsections_via_symbols set.
+    insertIt = toIsec->symbols.insert(insertIt, d);
+    d->originalIsec = toIsec;
+    d->value = toOff;
+    // We don't want to have more than one unwindEntry at a given address, so
+    // drop the redundant ones. We We can safely drop the unwindEntries of
----------------
int3 wrote:

```suggestion
    // drop the redundant ones. We can safely drop the unwindEntries of
```

let's fix the typo while we're here

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


More information about the llvm-commits mailing list