From 08b1862cafc44572f1e75f7a1e0dcd3d73e13e40 Mon Sep 17 00:00:00 2001 From: George Rimar Date: Fri, 9 Sep 2016 12:56:55 +0000 Subject: [PATCH] [ELF] - Revert r281038 to see if that unbreaks build bot. http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/19703 llvm-svn: 281041 --- lld/ELF/Config.h | 1 - lld/ELF/LinkerScript.cpp | 19 ++++++------------- lld/ELF/ScriptParser.cpp | 7 ++----- lld/ELF/SymbolTable.cpp | 5 +++-- lld/test/ELF/version-script-extern-exact.s | 22 ---------------------- 5 files changed, 11 insertions(+), 43 deletions(-) delete mode 100644 lld/test/ELF/version-script-extern-exact.s diff --git a/lld/ELF/Config.h b/lld/ELF/Config.h index 98246c3..4d7cf3e2 100644 --- a/lld/ELF/Config.h +++ b/lld/ELF/Config.h @@ -45,7 +45,6 @@ enum class UnresolvedPolicy { NoUndef, ReportError, Warn, Ignore }; struct SymbolVersion { llvm::StringRef Name; bool IsExternCpp; - bool HasWildcards; }; // This struct contains symbols version definition that diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index d5e7bc44..9d6935f 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -780,18 +780,12 @@ void ScriptParser::addFile(StringRef S) { } } -static StringRef unquote(StringRef S) { - if (!S.startswith("\"")) - return S; - return S.substr(1, S.size() - 2); -} - void ScriptParser::readAsNeeded() { expect("("); bool Orig = Config->AsNeeded; Config->AsNeeded = true; while (!Error && !skip(")")) - addFile(unquote(next())); + addFile(next()); Config->AsNeeded = Orig; } @@ -817,7 +811,7 @@ void ScriptParser::readGroup() { if (Tok == "AS_NEEDED") readAsNeeded(); else - addFile(unquote(Tok)); + addFile(Tok); } } @@ -1010,7 +1004,7 @@ Expr ScriptParser::readAssert() { expect("("); Expr E = readExpr(); expect(","); - StringRef Msg = unquote(next()); + StringRef Msg = next(); expect(")"); return [=](uint64_t Dot) { uint64_t V = E(Dot); @@ -1427,14 +1421,13 @@ void ScriptParser::readLocal() { } void ScriptParser::readExtern(std::vector *Globals) { - expect("\"C++\""); + expect("C++"); expect("{"); for (;;) { if (peek() == "}" || Error) break; - bool HasWildcard = !peek().startswith("\"") && hasWildcard(peek()); - Globals->push_back({unquote(next()), true, HasWildcard}); + Globals->push_back({next(), true}); expect(";"); } @@ -1457,7 +1450,7 @@ void ScriptParser::readGlobal(StringRef VerStr) { if (Cur == "}" || Cur == "local:" || Error) return; next(); - Globals->push_back({unquote(Cur), false, hasWildcard(Cur)}); + Globals->push_back({Cur, false}); expect(";"); } } diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp index 97d68d9..19e20b6 100644 --- a/lld/ELF/ScriptParser.cpp +++ b/lld/ELF/ScriptParser.cpp @@ -60,17 +60,14 @@ std::vector ScriptParserBase::tokenize(StringRef S) { if (S.empty()) return Ret; - // Quoted token. Note that double-quote characters are parts of a token - // because, in a glob match context, only unquoted tokens are interpreted - // as glob patterns. Double-quoted tokens are literal patterns in that - // context. + // Quoted token. if (S.startswith("\"")) { size_t E = S.find("\"", 1); if (E == StringRef::npos) { error("unclosed quote"); return {}; } - Ret.push_back(S.take_front(E + 1)); + Ret.push_back(S.substr(1, E - 1)); S = S.substr(E + 1); continue; } diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp index f758247..d80e512 100644 --- a/lld/ELF/SymbolTable.cpp +++ b/lld/ELF/SymbolTable.cpp @@ -18,6 +18,7 @@ #include "Config.h" #include "Error.h" #include "LinkerScript.h" +#include "Strings.h" #include "SymbolListFile.h" #include "Symbols.h" #include "llvm/Bitcode/ReaderWriter.h" @@ -677,7 +678,7 @@ template void SymbolTable::scanVersionScript() { // i.e. version definitions not containing any glob meta-characters. for (VersionDefinition &V : Config->VersionDefinitions) { for (SymbolVersion Sym : V.Globals) { - if (Sym.HasWildcards) + if (hasWildcard(Sym.Name)) continue; StringRef N = Sym.Name; SymbolBody *B = Sym.IsExternCpp ? findDemangled(Demangled, N) : find(N); @@ -692,7 +693,7 @@ template void SymbolTable::scanVersionScript() { for (size_t I = Config->VersionDefinitions.size() - 1; I != (size_t)-1; --I) { VersionDefinition &V = Config->VersionDefinitions[I]; for (SymbolVersion &Sym : V.Globals) { - if (!Sym.HasWildcards) + if (!hasWildcard(Sym.Name)) continue; Regex Re = compileGlobPatterns({Sym.Name}); std::vector Syms = diff --git a/lld/test/ELF/version-script-extern-exact.s b/lld/test/ELF/version-script-extern-exact.s deleted file mode 100644 index b33ea35..0000000 --- a/lld/test/ELF/version-script-extern-exact.s +++ /dev/null @@ -1,22 +0,0 @@ -# REQUIRES: x86 - -# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o -# RUN: echo "FOO { global: extern \"C++\" { \"aaa*\"; }; };" > %t.script -# RUN: ld.lld --version-script %t.script -shared %t.o -o %t.so -# RUN: llvm-readobj -V -dyn-symbols %t.so | FileCheck %s - -# CHECK: Symbol { -# CHECK: Name: _Z3aaaPf@ (1) -# CHECK: Symbol { -# CHECK: Name: _Z3aaaPi@ (10) - -.text -.globl _Z3aaaPi -.type _Z3aaaPi,@function -_Z3aaaPi: -retq - -.globl _Z3aaaPf -.type _Z3aaaPf,@function -_Z3aaaPf: -retq -- 2.7.4