[ELF] - Linkerscript: improved error reporting.
When linking linux kernel LLD currently reports next errors:
ld: error: unable to evaluate expression: input section .head.text has no output section assigned
ld: error: At least one side of the expression must be absolute
ld: error: At least one side of the expression must be absolute
That does not provide file/line information and overall looks unclear.
Patch adds location information to ExprValue and that allows
to provide more clear error messages.
Differential revision: https://reviews.llvm.org/D33943
llvm-svn: 304881
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index ef7ce75..772af14 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -54,7 +54,7 @@
if (Sec) {
if (OutputSection *OS = Sec->getOutputSection())
return alignTo(Sec->getOffset(Val) + OS->Addr, Alignment);
- error("unable to evaluate expression: input section " + Sec->Name +
+ error(Loc + ": unable to evaluate expression: input section " + Sec->Name +
" has no output section assigned");
}
return alignTo(Val, Alignment);
@@ -1231,12 +1231,12 @@
ExprValue LinkerScript::getSymbolValue(const Twine &Loc, StringRef S) {
if (S == ".")
- return {CurOutSec, Dot - CurOutSec->Addr};
+ return {CurOutSec, Dot - CurOutSec->Addr, Loc};
if (SymbolBody *B = findSymbol(S)) {
if (auto *D = dyn_cast<DefinedRegular>(B))
- return {D->Section, D->Value};
+ return {D->Section, D->Value, Loc};
if (auto *C = dyn_cast<DefinedCommon>(B))
- return {InX::Common, C->Offset};
+ return {InX::Common, C->Offset, Loc};
}
error(Loc + ": symbol not found: " + S);
return 0;