[lld] [ELF] Detect convergence of output section addresses (PR #93888)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu May 30 17:09:33 PDT 2024


================
@@ -1479,16 +1479,22 @@ template <class ELFT> void Writer<ELFT>::finalizeAddressDependentContent() {
         changed |= part.memtagGlobalDescriptors->updateAllocSize();
     }
 
-    const Defined *changedSym = script->assignAddresses();
+    std::pair<const OutputSection *, const Defined *> changes =
+        script->assignAddresses();
     if (!changed) {
       // Some symbols may be dependent on section addresses. When we break the
       // loop, the symbol values are finalized because a previous
       // assignAddresses() finalized section addresses.
-      if (!changedSym)
+      if (!changes.first && !changes.second)
         break;
       if (++assignPasses == 5) {
-        errorOrWarn("assignment to symbol " + toString(*changedSym) +
-                    " does not converge");
+        if (changes.first)
+          errorOrWarn("address (0x" + Twine::utohexstr(changes.first->addr) +
+                      ") of section '" + changes.first->name +
+                      "' does not converge");
+        if (changes.second)
+          errorOrWarn("assignment to symbol " + toString(*changes.second) +
----------------
MaskRay wrote:

Non-converging symbol value issues are extremely rare. In case of such an issue, I think the previous value of the non-converging symbol is useful, but probably minor. The user likely needs to read the symbol assignment to figure out the issue... I decided not to print the previous value in https://reviews.llvm.org/D66279 because it is difficult...

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


More information about the llvm-commits mailing list