From 4eb2eccb247dd88381e58ac8172aef658118bfc1 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Wed, 5 Apr 2017 18:02:30 +0000 Subject: [PATCH] Rename ScriptConfig::UndefinedSymbols ReferencedSymbols. Symbols referenced by linker scripts are not necessarily be undefined, so the previous name didn't convey the meaining of the variable. llvm-svn: 299573 --- lld/ELF/Driver.cpp | 2 +- lld/ELF/LinkerScript.h | 2 +- lld/ELF/ScriptParser.cpp | 12 +++++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 932aee3d5768..9f66360e6e22 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -906,7 +906,7 @@ template void LinkerDriver::link(opt::InputArgList &Args) { // Some symbols (such as __ehdr_start) are defined lazily only when there // are undefined symbols for them, so we add these to trigger that logic. - for (StringRef Sym : Script->Opt.UndefinedSymbols) + for (StringRef Sym : Script->Opt.ReferencedSymbols) Symtab.addUndefined(Sym); for (auto *Arg : Args.filtered(OPT_wrap)) diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h index f96607271efd..2c8be8df3eb5 100644 --- a/lld/ELF/LinkerScript.h +++ b/lld/ELF/LinkerScript.h @@ -209,7 +209,7 @@ struct ScriptConfiguration { llvm::DenseMap MemoryRegions; // A list of undefined symbols referenced by the script. - std::vector UndefinedSymbols; + std::vector ReferencedSymbols; }; class LinkerScript { diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp index a7aab1416a18..fe0ecfb1d6ef 100644 --- a/lld/ELF/ScriptParser.cpp +++ b/lld/ELF/ScriptParser.cpp @@ -913,17 +913,19 @@ Expr ScriptParser::readPrimary() { if (Tok == "SIZEOF_HEADERS") return [=] { return elf::getHeaderSize(); }; + // Tok is the dot. + if (Tok == ".") + return [=] { return Script->getSymbolValue(Location, Tok); }; + // Tok is a literal number. uint64_t V; if (readInteger(Tok, V)) return [=] { return V; }; // Tok is a symbol name. - if (Tok != ".") { - if (!isValidCIdentifier(Tok)) - setError("malformed number: " + Tok); - Script->Opt.UndefinedSymbols.push_back(Tok); - } + if (!isValidCIdentifier(Tok)) + setError("malformed number: " + Tok); + Script->Opt.ReferencedSymbols.push_back(Tok); return [=] { return Script->getSymbolValue(Location, Tok); }; } -- 2.34.1