[PATCH] D22086: [ELF] - Add Id field to Version struct.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 7 03:20:48 PDT 2016
grimar created this revision.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: llvm-commits, grimar.
That helps to avoid expressions like I + 2 in code
that assigns version number to symbols.
Change was suggested by Rui Ueyama.
http://reviews.llvm.org/D22086
Files:
ELF/Config.h
ELF/SymbolListFile.cpp
ELF/SymbolTable.cpp
Index: ELF/SymbolTable.cpp
===================================================================
--- ELF/SymbolTable.cpp
+++ ELF/SymbolTable.cpp
@@ -180,12 +180,10 @@
if (Default)
Version = Version.drop_front();
- size_t I = 2;
- for (elf::Version &V : Config->SymbolVersions) {
+ for (elf::Version &V : Config->SymbolVersions)
if (V.Name == Version)
- return Default ? I : (I | VERSYM_HIDDEN);
- ++I;
- }
+ return Default ? V.Id : (V.Id | VERSYM_HIDDEN);
+
error("symbol " + Name + " has undefined version " + Version);
return 0;
}
@@ -596,7 +594,7 @@
if (B->symbol()->VersionId != VER_NDX_GLOBAL &&
B->symbol()->VersionId != VER_NDX_LOCAL)
warning("duplicate symbol " + Name + " in version script");
- B->symbol()->VersionId = I + 2;
+ B->symbol()->VersionId = V.Id;
}
}
@@ -609,7 +607,7 @@
for (SymbolBody *B : findAll(Name))
if (B->symbol()->VersionId == VER_NDX_GLOBAL ||
B->symbol()->VersionId == VER_NDX_LOCAL)
- B->symbol()->VersionId = I + 2;
+ B->symbol()->VersionId = V.Id;
}
}
}
Index: ELF/SymbolListFile.cpp
===================================================================
--- ELF/SymbolListFile.cpp
+++ ELF/SymbolListFile.cpp
@@ -84,7 +84,10 @@
void VersionScriptParser::parseVersion(StringRef Version) {
expect("{");
- Config->SymbolVersions.push_back(elf::Version(Version));
+ // Identifiers in start at 2 because 0 and 1 are reserved
+ // by VER_NDX_LOCAL and VER_NDX_GLOBAL constants.
+ Config->SymbolVersions.push_back(
+ elf::Version(Version, Config->SymbolVersions.size() + 2));
if (peek() == "global:") {
next();
parseVersionSymbols(Version);
Index: ELF/Config.h
===================================================================
--- ELF/Config.h
+++ ELF/Config.h
@@ -38,10 +38,11 @@
// This struct contains symbols version definition that
// can be found in version script if it is used for link.
struct Version {
- Version(llvm::StringRef Name) : Name(Name) {}
+ Version(llvm::StringRef Name, size_t Id) : Name(Name), Id(Id) {}
llvm::StringRef Name;
std::vector<llvm::StringRef> Globals;
size_t NameOff; // Offset in string table.
+ size_t Id;
};
// This struct contains the global configuration for the linker.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22086.63046.patch
Type: text/x-patch
Size: 2327 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160707/1755b61c/attachment.bin>
More information about the llvm-commits
mailing list