Rename ScriptConfig::UndefinedSymbols ReferencedSymbols.
authorRui Ueyama <ruiu@google.com>
Wed, 5 Apr 2017 18:02:30 +0000 (18:02 +0000)
committerRui Ueyama <ruiu@google.com>
Wed, 5 Apr 2017 18:02:30 +0000 (18:02 +0000)
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
lld/ELF/LinkerScript.h
lld/ELF/ScriptParser.cpp

index 932aee3d576882e23b694fdef151c92c8f41f497..9f66360e6e2287bf1bb52716e969e22042bfc135 100644 (file)
@@ -906,7 +906,7 @@ template <class ELFT> 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))
index f96607271efd947faf0f199657b034f5d5f5e98f..2c8be8df3eb542be7e404898dd8900485a498721 100644 (file)
@@ -209,7 +209,7 @@ struct ScriptConfiguration {
   llvm::DenseMap<llvm::StringRef, MemoryRegion> MemoryRegions;
 
   // A list of undefined symbols referenced by the script.
-  std::vector<llvm::StringRef> UndefinedSymbols;
+  std::vector<llvm::StringRef> ReferencedSymbols;
 };
 
 class LinkerScript {
index a7aab1416a18a31aba2819e09aa9e5915c0e5cd1..fe0ecfb1d6ef25b17b5af2bf544e68583744a56c 100644 (file)
@@ -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); };
 }