[lld] r290339 - [ELF] Linkerscript: print location of undefined symbol usage
Eugene Leviant via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 22 05:13:12 PST 2016
Author: evgeny777
Date: Thu Dec 22 07:13:12 2016
New Revision: 290339
URL: http://llvm.org/viewvc/llvm-project?rev=290339&view=rev
Log:
[ELF] Linkerscript: print location of undefined symbol usage
Differential revision: https://reviews.llvm.org/D27194
Modified:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/ELF/LinkerScript.h
lld/trunk/test/ELF/linkerscript/segment-start.s
lld/trunk/test/ELF/linkerscript/symbol-assignexpr.s
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=290339&r1=290338&r2=290339&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Thu Dec 22 07:13:12 2016
@@ -901,10 +901,11 @@ template <class ELFT> uint64_t LinkerScr
return elf::getHeaderSize<ELFT>();
}
-template <class ELFT> uint64_t LinkerScript<ELFT>::getSymbolValue(StringRef S) {
+template <class ELFT>
+uint64_t LinkerScript<ELFT>::getSymbolValue(const Twine &Loc, StringRef S) {
if (SymbolBody *B = Symtab<ELFT>::X->find(S))
return B->getVA<ELFT>();
- error("symbol not found: " + S);
+ error(Loc + ": symbol not found: " + S);
return 0;
}
@@ -1523,10 +1524,10 @@ SymbolAssignment *ScriptParser::readProv
return Cmd;
}
-static uint64_t getSymbolValue(StringRef S, uint64_t Dot) {
+static uint64_t getSymbolValue(const Twine &Loc, StringRef S, uint64_t Dot) {
if (S == ".")
return Dot;
- return ScriptBase->getSymbolValue(S);
+ return ScriptBase->getSymbolValue(Loc, S);
}
static bool isAbsolute(StringRef S) {
@@ -1547,8 +1548,12 @@ SymbolAssignment *ScriptParser::readAssi
} else {
E = readExpr();
}
- if (Op == "+=")
- E = [=](uint64_t Dot) { return getSymbolValue(Name, Dot) + E(Dot); };
+ if (Op == "+=") {
+ std::string Loc = getCurrentLocation();
+ E = [=](uint64_t Dot) {
+ return getSymbolValue(Loc, Name, Dot) + E(Dot);
+ };
+ }
return new SymbolAssignment(Name, E);
}
@@ -1800,7 +1805,7 @@ Expr ScriptParser::readPrimary() {
// Tok is a symbol name.
if (Tok != "." && !isValidCIdentifier(Tok))
setError("malformed number: " + Tok);
- return {[=](uint64_t Dot) { return getSymbolValue(Tok, Dot); },
+ return {[=](uint64_t Dot) { return getSymbolValue(Location, Tok, Dot); },
[=] { return isAbsolute(Tok); },
[=] { return ScriptBase->getSymbolSection(Tok); }};
}
Modified: lld/trunk/ELF/LinkerScript.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.h?rev=290339&r1=290338&r2=290339&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.h (original)
+++ lld/trunk/ELF/LinkerScript.h Thu Dec 22 07:13:12 2016
@@ -193,7 +193,7 @@ protected:
public:
virtual uint64_t getHeaderSize() = 0;
- virtual uint64_t getSymbolValue(StringRef S) = 0;
+ virtual uint64_t getSymbolValue(const Twine &Loc, StringRef S) = 0;
virtual bool isDefined(StringRef S) = 0;
virtual bool isAbsolute(StringRef S) = 0;
virtual const OutputSectionBase *getSymbolSection(StringRef S) = 0;
@@ -245,7 +245,7 @@ public:
void assignAddresses(std::vector<PhdrEntry> &Phdrs);
bool hasPhdrsCommands();
uint64_t getHeaderSize() override;
- uint64_t getSymbolValue(StringRef S) override;
+ uint64_t getSymbolValue(const Twine &Loc, StringRef S) override;
bool isDefined(StringRef S) override;
bool isAbsolute(StringRef S) override;
const OutputSectionBase *getSymbolSection(StringRef S) override;
Modified: lld/trunk/test/ELF/linkerscript/segment-start.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/segment-start.s?rev=290339&r1=290338&r2=290339&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/segment-start.s (original)
+++ lld/trunk/test/ELF/linkerscript/segment-start.s Thu Dec 22 07:13:12 2016
@@ -24,4 +24,4 @@
// RUN: echo "SECTIONS { . = SEGMENT_START(\"foobar\", foo); }" > %t.script
// RUN: not ld.lld %t.o %t.script -shared -o %t2.so 2>&1 \
// RUN: | FileCheck --check-prefix=ERR %s
-// ERR: symbol not found: foo
+// ERR: {{.*}}.script:1: symbol not found: foo
Modified: lld/trunk/test/ELF/linkerscript/symbol-assignexpr.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/symbol-assignexpr.s?rev=290339&r1=290338&r2=290339&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/symbol-assignexpr.s (original)
+++ lld/trunk/test/ELF/linkerscript/symbol-assignexpr.s Thu Dec 22 07:13:12 2016
@@ -38,7 +38,7 @@
# RUN: }" > %t2.script
# RUN: not ld.lld -o %t2 --script %t2.script %t 2>&1 \
# RUN: | FileCheck -check-prefix=ERR %s
-# ERR: symbol not found: symbol
+# ERR: {{.*}}.script:1: symbol not found: symbol
.global _start
_start:
More information about the llvm-commits
mailing list