diff options
Diffstat (limited to 'lld/ELF')
| -rw-r--r-- | lld/ELF/Config.h | 2 | ||||
| -rw-r--r-- | lld/ELF/Driver.cpp | 1 | ||||
| -rw-r--r-- | lld/ELF/SymbolListFile.cpp | 33 | ||||
| -rw-r--r-- | lld/ELF/SymbolTable.cpp | 2 |
4 files changed, 27 insertions, 11 deletions
diff --git a/lld/ELF/Config.h b/lld/ELF/Config.h index 2dbbdbe40d6..be8059b46a9 100644 --- a/lld/ELF/Config.h +++ b/lld/ELF/Config.h @@ -88,7 +88,7 @@ struct Configuration { bool Threads; bool Trace; bool Verbose; - bool VersionScript = false; + bool VersionScriptGlobalByDefault = true; bool WarnCommon; bool ZCombreloc; bool ZDefs; diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index b816e7dfe7d..c99b22988ac 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -414,7 +414,6 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) { Config->DynamicList.push_back(Arg->getValue()); if (auto *Arg = Args.getLastArg(OPT_version_script)) { - Config->VersionScript = true; if (Optional<MemoryBufferRef> Buffer = readFile(Arg->getValue())) parseVersionScript(*Buffer); } diff --git a/lld/ELF/SymbolListFile.cpp b/lld/ELF/SymbolListFile.cpp index b8cfdc88f33..3d1377be438 100644 --- a/lld/ELF/SymbolListFile.cpp +++ b/lld/ELF/SymbolListFile.cpp @@ -78,24 +78,41 @@ public: private: void parseVersion(); + void parseLocal(); + void parseVersionSymbols(); }; void VersionScriptParser::parseVersion() { expect("{"); if (peek() == "global:") { next(); - while (!Error) { - Config->VersionScriptGlobals.push_back(next()); - expect(";"); - if (peek() == "local:") - break; - } + parseVersionSymbols(); } + if (peek() == "local:") + parseLocal(); + else + parseVersionSymbols(); + + expect("}"); + expect(";"); +} + +void VersionScriptParser::parseLocal() { expect("local:"); expect("*"); expect(";"); - expect("}"); - expect(";"); + Config->VersionScriptGlobalByDefault = false; +} + +void VersionScriptParser::parseVersionSymbols() { + for (;;) { + StringRef Cur = peek(); + if (Cur == "}" || Cur == "local:") + return; + next(); + Config->VersionScriptGlobals.push_back(Cur); + expect(";"); + } } void VersionScriptParser::run() { diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp index e5477140a95..e9cee22c1bf 100644 --- a/lld/ELF/SymbolTable.cpp +++ b/lld/ELF/SymbolTable.cpp @@ -175,7 +175,7 @@ std::pair<Symbol *, bool> SymbolTable<ELFT>::insert(StringRef Name) { Sym->Visibility = STV_DEFAULT; Sym->IsUsedInRegularObj = false; Sym->ExportDynamic = false; - Sym->VersionScriptGlobal = !Config->VersionScript; + Sym->VersionScriptGlobal = Config->VersionScriptGlobalByDefault; SymVector.push_back(Sym); } else { Sym = SymVector[P.first->second]; |

