[PATCH] D21828: Make SymbolTable::findAll to return only defined symbols.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 28 21:54:52 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL274099: Make SymbolTable::findAll to return only defined symbols. (authored by ruiu).
Changed prior to commit:
http://reviews.llvm.org/D21828?vs=62172&id=62177#toc
Repository:
rL LLVM
http://reviews.llvm.org/D21828
Files:
lld/trunk/ELF/SymbolTable.cpp
Index: lld/trunk/ELF/SymbolTable.cpp
===================================================================
--- lld/trunk/ELF/SymbolTable.cpp
+++ lld/trunk/ELF/SymbolTable.cpp
@@ -457,19 +457,26 @@
return SymVector[It->second]->body();
}
+// Returns a list of defined symbols that match with a given glob pattern.
template <class ELFT>
std::vector<SymbolBody *> SymbolTable<ELFT>::findAll(StringRef Pattern) {
// Fast-path. Fallback to find() if Pattern doesn't contain any wildcard
// characters.
- bool HasWildcards = (Pattern.find_first_of("?*") != StringRef::npos);
- if (!HasWildcards)
- return {find(Pattern)};
-
- std::vector<SymbolBody *> Result;
- for (auto &It : Symtab)
- if (matchStr(Pattern, It.first.Val))
- Result.push_back(SymVector[It.second]->body());
- return Result;
+ if (Pattern.find_first_of("?*") == StringRef::npos) {
+ if (SymbolBody *B = find(Pattern))
+ if (!B->isUndefined())
+ return {B};
+ return {};
+ }
+
+ std::vector<SymbolBody *> Res;
+ for (auto &It : Symtab) {
+ StringRef Name = It.first.Val;
+ SymbolBody *B = SymVector[It.second]->body();
+ if (!B->isUndefined() && matchStr(Pattern, Name))
+ Res.push_back(B);
+ }
+ return Res;
}
template <class ELFT>
@@ -572,14 +579,15 @@
size_t I = 2;
for (Version &V : Config->SymbolVersions) {
for (StringRef Name : V.Globals) {
- for (SymbolBody *B : findAll(Name)) {
- if (!B || B->isUndefined()) {
- if (Config->NoUndefinedVersion)
- error("version script assignment of " + V.Name + " to symbol " +
- Name + " failed: symbol not defined");
- continue;
- }
+ std::vector<SymbolBody *> Syms = findAll(Name);
+ if (Syms.empty()) {
+ if (Config->NoUndefinedVersion)
+ error("version script assignment of " + V.Name + " to symbol " +
+ Name + " failed: symbol not defined");
+ continue;
+ }
+ for (SymbolBody *B : Syms) {
if (B->symbol()->VersionId != VER_NDX_GLOBAL &&
B->symbol()->VersionId != VER_NDX_LOCAL)
warning("duplicate symbol " + Name + " in version script");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21828.62177.patch
Type: text/x-patch
Size: 2187 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160629/8ec53270/attachment.bin>
More information about the llvm-commits
mailing list