[lld] [ELF] Postpone "unable to move location counter backward" error (PR #66854)

Alexander Richardson via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 19 22:18:32 PDT 2023


================
@@ -169,9 +169,16 @@ void LinkerScript::expandOutputSection(uint64_t size) {
 
 void LinkerScript::setDot(Expr e, const Twine &loc, bool inSec) {
   uint64_t val = e().getValue();
-  if (val < dot && inSec)
-    error(loc + ": unable to move location counter backward for: " +
-          state->outSec->name);
+  // If val is smaller and we are in an output section, record the error and
+  // report it if this is the last assignAddresses iteration. dot may be smaller
+  // if there is another assignAddresses iteration.
+  if (val < dot && inSec) {
+    backwardDotErr =
+        (loc + ": unable to move location counter (0x" + Twine::utohexstr(dot) +
+         ") backward (0x" + Twine::utohexstr(val) + ") for section '" +
----------------
arichardson wrote:

Much prefer the new error message but I noticed that it's ambiguous if this means we are moving it backwards by a number of bytes or to given address. How about the following:

```suggestion
         ") backward to (0x" + Twine::utohexstr(val) + ") for section '" +
```

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


More information about the llvm-commits mailing list