[ELF] - Make ASSERT() return Dot instead of evaluated value.
Previously ASSERT we implemented returned expression value.
Ex:
. = ASSERT(0x100);
would set Dot value to 0x100
Form of assert when it is assigned to Dot was implemented for
compatibility with very old GNU ld which required it.
Some scripts in the wild, including linux kernel scripts
use such ASSERTs at the end for doing different checks.
Currently we fail with "unable to move location counter backward"
for such scripts. Patch changes ASSERT to return location counter
value to fix that.
Differential revision: https://reviews.llvm.org/D30171
llvm-svn: 295703
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index a323d3a..53b39f2 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -1468,10 +1468,9 @@
StringRef Msg = unquote(next());
expect(")");
return [=](uint64_t Dot) {
- uint64_t V = E(Dot);
- if (!V)
+ if (!E(Dot))
error(Msg);
- return V;
+ return Dot;
};
}