Index: lld/trunk/ELF/Config.h =================================================================== --- lld/trunk/ELF/Config.h +++ lld/trunk/ELF/Config.h @@ -40,7 +40,6 @@ struct Version { Version(llvm::StringRef Name) : Name(Name) {} llvm::StringRef Name; - llvm::StringRef Parent; std::vector Globals; size_t NameOff; // Offset in string table. }; Index: lld/trunk/ELF/OutputSections.cpp =================================================================== --- lld/trunk/ELF/OutputSections.cpp +++ lld/trunk/ELF/OutputSections.cpp @@ -1488,10 +1488,6 @@ 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::DynStrTab->SectionIndex; this->Header.sh_addralign = sizeof(uint32_t); @@ -1501,22 +1497,12 @@ 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 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(Verdaux) - reinterpret_cast(Verdef); Verdef->vd_next = sizeof(Elf_Verdef); @@ -1527,12 +1513,6 @@ ++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 @@ reinterpret_cast(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; } Index: lld/trunk/ELF/SymbolListFile.cpp =================================================================== --- lld/trunk/ELF/SymbolListFile.cpp +++ lld/trunk/ELF/SymbolListFile.cpp @@ -95,8 +95,13 @@ 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(";"); } Index: lld/trunk/test/ELF/verdef-defaultver.s =================================================================== --- lld/trunk/test/ELF/verdef-defaultver.s +++ lld/trunk/test/ELF/verdef-defaultver.s @@ -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: } Index: lld/trunk/test/ELF/verdef-dependency.s =================================================================== --- lld/trunk/test/ELF/verdef-dependency.s +++ lld/trunk/test/ELF/verdef-dependency.s @@ -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