diff options
| author | Petr Hosek <phosek@chromium.org> | 2017-03-23 03:52:34 +0000 |
|---|---|---|
| committer | Petr Hosek <phosek@chromium.org> | 2017-03-23 03:52:34 +0000 |
| commit | 30f16b23398f44926656d221131f1b015f424b8f (patch) | |
| tree | 200bf80bdd3ce5aec9a93450292d5689c6721607 /lld/ELF/LinkerScript.cpp | |
| parent | 968381ef22f9d782a8097b05a3eb5781e58eebb7 (diff) | |
| download | bcm5719-llvm-30f16b23398f44926656d221131f1b015f424b8f.tar.gz bcm5719-llvm-30f16b23398f44926656d221131f1b015f424b8f.zip | |
[ELF] Allow references to reserved symbols in linker scripts
This requires collectign all symbols referenced in the linker script
and adding them to symbol table as undefined symbol.
Differential Revision: https://reviews.llvm.org/D31147
llvm-svn: 298577
Diffstat (limited to 'lld/ELF/LinkerScript.cpp')
| -rw-r--r-- | lld/ELF/LinkerScript.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index f98e689f0b9..adb7ce862bb 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -999,8 +999,8 @@ ExprValue LinkerScript::getSymbolValue(const Twine &Loc, StringRef S) { if (SymbolBody *B = findSymbol(S)) { if (auto *D = dyn_cast<DefinedRegular>(B)) return {D->Section, D->Value}; - auto *C = cast<DefinedCommon>(B); - return {InX::Common, C->Offset}; + if (auto *C = dyn_cast<DefinedCommon>(B)) + return {InX::Common, C->Offset}; } error(Loc + ": symbol not found: " + S); return 0; @@ -1867,8 +1867,11 @@ Expr ScriptParser::readPrimary() { return [=] { return V; }; // Tok is a symbol name. - if (Tok != "." && !isValidCIdentifier(Tok)) - setError("malformed number: " + Tok); + if (Tok != ".") { + if (!isValidCIdentifier(Tok)) + setError("malformed number: " + Tok); + Script->Opt.UndefinedSymbols.push_back(Tok); + } return [=] { return Script->getSymbolValue(Location, Tok); }; } |

