[PATCH] D21894: [ELF] - Fixed incorrect logic of version assignments when mixing wildcards with values matching.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 1 04:41:30 PDT 2016
grimar updated this revision to Diff 62482.
grimar added a comment.
- Addressed review comments.
http://reviews.llvm.org/D21894
Files:
ELF/SymbolTable.cpp
Index: ELF/SymbolTable.cpp
===================================================================
--- ELF/SymbolTable.cpp
+++ ELF/SymbolTable.cpp
@@ -460,15 +460,6 @@
// 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.
- 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;
@@ -574,27 +565,48 @@
return;
}
+ if (Config->SymbolVersions.empty())
+ return;
+
// If we have symbols version declarations, we should
// assign version references for each symbol.
- size_t I = 2;
- for (Version &V : Config->SymbolVersions) {
- for (StringRef Name : V.Globals) {
- 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;
- }
+ // Current rules are:
+ // * If there is an exact match for the mangled name, we use it.
+ // * Otherwise, we look through the wildcard patterns. We look through the
+ // version tags in reverse order. We use the first match we find (the last
+ // matching version tag in the file).
+ for (size_t I = 0, E = Config->SymbolVersions.size(); I < E; ++I) {
+ Version &V = Config->SymbolVersions[I];
+ for (StringRef Name : V.Globals)
+ if (Name.find_first_of("?*") == StringRef::npos) {
+ SymbolBody *B = find(Name);
+
+ if (!B || B->isUndefined()) {
+ 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");
- B->symbol()->VersionId = I;
+
+ B->symbol()->VersionId = I + 2;
+ }
+ }
+
+ for (size_t I = Config->SymbolVersions.size() - 1; I != (size_t)-1; --I) {
+ Version &V = Config->SymbolVersions[I];
+ for (StringRef Name : V.Globals)
+ if (Name.find_first_of("?*") != StringRef::npos) {
+ std::vector<SymbolBody *> Syms = findAll(Name);
+ for (SymbolBody *B : Syms) {
+ if (B->symbol()->VersionId == VER_NDX_GLOBAL ||
+ B->symbol()->VersionId == VER_NDX_LOCAL)
+ B->symbol()->VersionId = I + 2;
+ }
}
- }
- ++I;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21894.62482.patch
Type: text/x-patch
Size: 2923 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160701/14aa2f4a/attachment.bin>
More information about the llvm-commits
mailing list