diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index da765689df52..25774b6d04aa 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -852,18 +852,18 @@ bool LinkerScript::needsInterpSection() { return false; } -ExprValue LinkerScript::getSymbolValue(const Twine &Loc, StringRef S) { - if (S == ".") { +ExprValue LinkerScript::getSymbolValue(StringRef Name, const Twine &Loc) { + if (Name == ".") { if (Ctx) return {Ctx->OutSec, false, Dot - Ctx->OutSec->Addr, Loc}; error(Loc + ": unable to get location counter value"); return 0; } - if (auto *Sym = dyn_cast_or_null(Symtab->find(S))) + if (auto *Sym = dyn_cast_or_null(Symtab->find(Name))) return {Sym->Section, false, Sym->Value, Loc}; - error(Loc + ": symbol not found: " + S); + error(Loc + ": symbol not found: " + Name); return 0; } diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h index 291981bd06e9..4362edf4ec9e 100644 --- a/lld/ELF/LinkerScript.h +++ b/lld/ELF/LinkerScript.h @@ -231,7 +231,7 @@ public: uint64_t getDot() { return Dot; } void discard(ArrayRef V); - ExprValue getSymbolValue(const Twine &Loc, StringRef S); + ExprValue getSymbolValue(StringRef Name, const Twine &Loc); void fabricateDefaultCommands(); void addOrphanSections(OutputSectionFactory &Factory); diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp index acbe0a985e02..7c8e260c576c 100644 --- a/lld/ELF/ScriptParser.cpp +++ b/lld/ELF/ScriptParser.cpp @@ -756,7 +756,7 @@ SymbolAssignment *ScriptParser::readAssignment(StringRef Name) { Expr E = readExpr(); if (Op == "+=") { std::string Loc = getCurrentLocation(); - E = [=] { return add(Script->getSymbolValue(Loc, Name), E()); }; + E = [=] { return add(Script->getSymbolValue(Name, Loc), E()); }; } return make(Name, E, getCurrentLocation()); } @@ -1051,7 +1051,7 @@ Expr ScriptParser::readPrimary() { // Tok is the dot. if (Tok == ".") - return [=] { return Script->getSymbolValue(Location, Tok); }; + return [=] { return Script->getSymbolValue(Tok, Location); }; // Tok is a literal number. if (Optional Val = parseInt(Tok)) @@ -1061,7 +1061,7 @@ Expr ScriptParser::readPrimary() { if (!isValidCIdentifier(Tok)) setError("malformed number: " + Tok); Script->ReferencedSymbols.push_back(Tok); - return [=] { return Script->getSymbolValue(Location, Tok); }; + return [=] { return Script->getSymbolValue(Tok, Location); }; } Expr ScriptParser::readTernary(Expr Cond) {