[PATCH] D21930: [ELF] - Implement extern "c++" version script tag

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 8 02:05:43 PDT 2016


grimar added inline comments.

================
Comment at: ELF/SymbolTable.cpp:601-607
@@ -586,2 +600,9 @@
+
+      if (Sym.IsExternCpp) {
+        size_t &Ver = DemangledExterns[Sym.Name];
+        if (Ver != 0)
+          warning("duplicate symbol " + Sym.Name + " in version script");
+        Ver = I + 2;
         continue;
+      }
 
----------------
ruiu wrote:
> I do not understand the exact logic. Can this handle C++ mangled name patterns that contain glob meta characters?
This patch handles only exact matches.
According to rules of processing version script files described in Ian Lance Taylor article,
handling of wildcards is the last step and the same should be applied for wildcarded
externs. So handling wildcards in externs is a job for following patches I think.

Speaking about exactly this piece of code - it just builds association map to map [extern name -> its version].
That is done to simplify and accelerate the pass to handle externs (lines 621-628). Without that map I would
need to iterate over all versions and all externs after demangle() call to find which version to use. 
It would be something like next without this map (pseudocode):


```
for (auto I = Symtab.begin(); I != Symtab.end(); ++I) {
  StringRef Demangled = demangle(I->first.Val);

  for (size_t J = 0, E = Config->SymbolVersions.size(); J < E; ++J) {
    Version &V = Config->SymbolVersions[I];
    for (SymbolVersion Sym : V.Globals) {
        if (!Sym.IsExternCpp)
          continue;
      
        if (Sym.Name == Demangled) {
          overrideSymbolVersion(SymVector[I->second], Sym.Name, J + 2);
          return;
        }
      }
    }
}
```


http://reviews.llvm.org/D21930





More information about the llvm-commits mailing list