diff options
author | George Rimar <grimar@accesssoftek.com> | 2017-06-07 08:54:43 +0000 |
---|---|---|
committer | George Rimar <grimar@accesssoftek.com> | 2017-06-07 08:54:43 +0000 |
commit | 41c7ab4a3d30a235956cd752808c1e0325fd47d5 (patch) | |
tree | 3d8ed5f56a623bcb4d599649c2181656800cb860 /lld/ELF/ScriptParser.cpp | |
parent | 154a4fd5dc47591a662b193880ca010ffc880a87 (diff) | |
download | llvm-41c7ab4a3d30a235956cd752808c1e0325fd47d5.zip llvm-41c7ab4a3d30a235956cd752808c1e0325fd47d5.tar.gz llvm-41c7ab4a3d30a235956cd752808c1e0325fd47d5.tar.bz2 |
[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
Diffstat (limited to 'lld/ELF/ScriptParser.cpp')
-rw-r--r-- | lld/ELF/ScriptParser.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp index 6bd4b86..fc6b8e3 100644 --- a/lld/ELF/ScriptParser.cpp +++ b/lld/ELF/ScriptParser.cpp @@ -127,16 +127,16 @@ static void moveAbsRight(ExprValue &A, ExprValue &B) { if (A.isAbsolute()) std::swap(A, B); if (!B.isAbsolute()) - error("At least one side of the expression must be absolute"); + error(A.Loc + ": at least one side of the expression must be absolute"); } static ExprValue add(ExprValue A, ExprValue B) { moveAbsRight(A, B); - return {A.Sec, A.ForceAbsolute, A.Val + B.getValue()}; + return {A.Sec, A.ForceAbsolute, A.Val + B.getValue(), A.Loc}; } static ExprValue sub(ExprValue A, ExprValue B) { - return {A.Sec, A.Val - B.getValue()}; + return {A.Sec, A.Val - B.getValue(), A.Loc}; } static ExprValue mul(ExprValue A, ExprValue B) { @@ -153,13 +153,13 @@ static ExprValue div(ExprValue A, ExprValue B) { static ExprValue bitAnd(ExprValue A, ExprValue B) { moveAbsRight(A, B); return {A.Sec, A.ForceAbsolute, - (A.getValue() & B.getValue()) - A.getSecAddr()}; + (A.getValue() & B.getValue()) - A.getSecAddr(), A.Loc}; } static ExprValue bitOr(ExprValue A, ExprValue B) { moveAbsRight(A, B); return {A.Sec, A.ForceAbsolute, - (A.getValue() | B.getValue()) - A.getSecAddr()}; + (A.getValue() | B.getValue()) - A.getSecAddr(), A.Loc}; } void ScriptParser::readDynamicList() { @@ -859,7 +859,9 @@ Expr ScriptParser::readPrimary() { if (Tok == "ADDR") { StringRef Name = readParenLiteral(); OutputSectionCommand *Cmd = Script->getOrCreateOutputSectionCommand(Name); - return [=]() -> ExprValue { return {checkSection(Cmd, Location), 0}; }; + return [=]() -> ExprValue { + return {checkSection(Cmd, Location), 0, Location}; + }; } if (Tok == "ALIGN") { expect("("); |