[lld] r274345 - [ELF] - Depricate version references.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 1 04:45:11 PDT 2016


Author: grimar
Date: Fri Jul  1 06:45:10 2016
New Revision: 274345

URL: http://llvm.org/viewvc/llvm-project?rev=274345&view=rev
Log:
[ELF] - Depricate version references.

This is PR28358

According to
https://www.akkadia.org/drepper/dsohowto.pdf

"The fourth point, the VERS 1.0 version being referred to in the VERS 2.0 definition, is not really important in symbol versioning. It marks the predecessor relationship of the two versions and it is done to maintain the similar- ities with Solaris’ internal versioning. It does not cause any problem it might in fact be useful to a human reader so predecessors should always be mentioned."

Patch partially reverts 273423 "[ELF] - Implemented version script hierarchies.",
version references are just ignored now.

Differential revision: http://reviews.llvm.org/D21888

Modified:
    lld/trunk/ELF/Config.h
    lld/trunk/ELF/OutputSections.cpp
    lld/trunk/ELF/SymbolListFile.cpp
    lld/trunk/test/ELF/verdef-defaultver.s
    lld/trunk/test/ELF/verdef-dependency.s

Modified: lld/trunk/ELF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Config.h?rev=274345&r1=274344&r2=274345&view=diff
==============================================================================
--- lld/trunk/ELF/Config.h (original)
+++ lld/trunk/ELF/Config.h Fri Jul  1 06:45:10 2016
@@ -40,7 +40,6 @@ enum class UnresolvedPolicy { NoUndef, E
 struct Version {
   Version(llvm::StringRef Name) : Name(Name) {}
   llvm::StringRef Name;
-  llvm::StringRef Parent;
   std::vector<llvm::StringRef> Globals;
   size_t NameOff; // Offset in string table.
 };

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=274345&r1=274344&r2=274345&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Fri Jul  1 06:45:10 2016
@@ -1488,10 +1488,6 @@ template <class ELFT> void VersionDefini
 
   this->Header.sh_size =
       (sizeof(Elf_Verdef) + sizeof(Elf_Verdaux)) * getVerDefNum();
-  for (Version &V : Config->SymbolVersions)
-    if (!V.Parent.empty())
-      this->Header.sh_size += sizeof(Elf_Verdaux);
-
   this->Header.sh_link = Out<ELFT>::DynStrTab->SectionIndex;
   this->Header.sh_addralign = sizeof(uint32_t);
 
@@ -1501,22 +1497,12 @@ template <class ELFT> void VersionDefini
   this->Header.sh_info = getVerDefNum();
 }
 
-static size_t getVersionNameStrTabOffset(StringRef Name) {
-  for (Version &V : Config->SymbolVersions)
-    if (V.Name == Name)
-      return V.NameOff;
-  error("unknown version name " + Name + " used as a dependency");
-  return 0;
-}
-
 template <class Elf_Verdef, class Elf_Verdaux>
 static void writeDefinition(Elf_Verdef *&Verdef, Elf_Verdaux *&Verdaux,
                             uint32_t Flags, uint32_t Index, StringRef Name,
-                            size_t StrTabOffset, StringRef ParentName) {
-  bool HasParent = !ParentName.empty();
-
+                            size_t StrTabOffset) {
   Verdef->vd_version = 1;
-  Verdef->vd_cnt = HasParent ? 2 : 1;
+  Verdef->vd_cnt = 1;
   Verdef->vd_aux =
       reinterpret_cast<char *>(Verdaux) - reinterpret_cast<char *>(Verdef);
   Verdef->vd_next = sizeof(Elf_Verdef);
@@ -1527,12 +1513,6 @@ static void writeDefinition(Elf_Verdef *
   ++Verdef;
 
   Verdaux->vda_name = StrTabOffset;
-  if (HasParent) {
-    Verdaux->vda_next = sizeof(Elf_Verdaux);
-    ++Verdaux;
-    Verdaux->vda_name = getVersionNameStrTabOffset(ParentName);
-  }
-
   Verdaux->vda_next = 0;
   ++Verdaux;
 }
@@ -1544,12 +1524,11 @@ void VersionDefinitionSection<ELFT>::wri
       reinterpret_cast<Elf_Verdaux *>(Verdef + getVerDefNum());
 
   writeDefinition(Verdef, Verdaux, VER_FLG_BASE, 1, getFileDefName(),
-                  FileDefNameOff, "" /* Parent */);
+                  FileDefNameOff);
 
   uint32_t I = 2;
   for (Version &V : Config->SymbolVersions)
-    writeDefinition(Verdef, Verdaux, 0 /* Flags */, I++, V.Name, V.NameOff,
-                    V.Parent);
+    writeDefinition(Verdef, Verdaux, 0 /* Flags */, I++, V.Name, V.NameOff);
 
   Verdef[-1].vd_next = 0;
 }

Modified: lld/trunk/ELF/SymbolListFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolListFile.cpp?rev=274345&r1=274344&r2=274345&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolListFile.cpp (original)
+++ lld/trunk/ELF/SymbolListFile.cpp Fri Jul  1 06:45:10 2016
@@ -95,8 +95,13 @@ void VersionScriptParser::parseVersion(S
     parseVersionSymbols(Version);
 
   expect("}");
+
+  // Each version may have a parent version. For example, "Ver2" defined as
+  // "Ver2 { global: foo; local: *; } Ver1;" has "Ver1" as a parent. This
+  // version hierarchy is, probably against your instinct, purely for human; the
+  // runtime doesn't care about them at all. In LLD, we simply skip the token.
   if (!Version.empty() && peek() != ";")
-    Config->SymbolVersions.back().Parent = next();
+    next();
   expect(";");
 }
 

Modified: lld/trunk/test/ELF/verdef-defaultver.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/verdef-defaultver.s?rev=274345&r1=274344&r2=274345&view=diff
==============================================================================
--- lld/trunk/test/ELF/verdef-defaultver.s (original)
+++ lld/trunk/test/ELF/verdef-defaultver.s Fri Jul  1 06:45:10 2016
@@ -106,7 +106,6 @@
 # DSO-NEXT:      Index: 3
 # DSO-NEXT:      Hash: 98456416
 # DSO-NEXT:      Name: LIBSAMPLE_2.0
-# DSO-NEXT:      Predecessor: LIBSAMPLE_1.0
 # DSO-NEXT:    }
 # DSO-NEXT:  }
 

Modified: lld/trunk/test/ELF/verdef-dependency.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/verdef-dependency.s?rev=274345&r1=274344&r2=274345&view=diff
==============================================================================
--- lld/trunk/test/ELF/verdef-dependency.s (original)
+++ lld/trunk/test/ELF/verdef-dependency.s Fri Jul  1 06:45:10 2016
@@ -33,7 +33,6 @@
 # DSO-NEXT:     Index: 3
 # DSO-NEXT:     Hash: 98456416
 # DSO-NEXT:     Name: LIBSAMPLE_2.0
-# DSO-NEXT:     Predecessor: LIBSAMPLE_1.0
 # DSO-NEXT:   }
 # DSO-NEXT:   Definition {
 # DSO-NEXT:     Version: 1
@@ -41,16 +40,5 @@
 # DSO-NEXT:     Index: 4
 # DSO-NEXT:     Hash: 98456672
 # DSO-NEXT:     Name: LIBSAMPLE_3.0
-# DSO-NEXT:     Predecessor: LIBSAMPLE_2.0
 # DSO-NEXT:   }
 # DSO-NEXT: }
-
-# RUN: echo "LIBSAMPLE_1.0{               \
-# RUN:          global: a;                \
-# RUN:          local: *; };              \
-# RUN:       LIBSAMPLE_2.0{               \
-# RUN:          global: b;                \
-# RUN:          local: *; }LIBSAMPLE_X.X; " > %t.script
-# RUN: not ld.lld --version-script %t.script -shared %t.o -o %t.so 2>&1 \
-# RUN:   | FileCheck -check-prefix=ERR %s
-# ERR: unknown version name LIBSAMPLE_X.X used as a dependency




More information about the llvm-commits mailing list