[lld] r234223 - ELF: Do not mix link-once and group sections.

Rui Ueyama ruiu at google.com
Mon Apr 6 14:21:43 PDT 2015


Author: ruiu
Date: Mon Apr  6 16:21:43 2015
New Revision: 234223

URL: http://llvm.org/viewvc/llvm-project?rev=234223&view=rev
Log:
ELF: Do not mix link-once and group sections.

Previously, we put both link-once and group sections into the same map
and seaparated them out when we use them. Apparently we should put them
into seaprate maps in the first place.

This piece of code is added recently, and I still don't understand all
of them. Looks like we need to clean this up even more.

Modified:
    lld/trunk/lib/ReaderWriter/ELF/ELFFile.h

Modified: lld/trunk/lib/ReaderWriter/ELF/ELFFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFFile.h?rev=234223&r1=234222&r2=234223&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFFile.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFFile.h Mon Apr  6 16:21:43 2015
@@ -671,10 +671,13 @@ template <class ELFT> std::error_code EL
   // Holds all the atoms that are part of the section. They are the targets of
   // the kindGroupChild reference.
   llvm::StringMap<std::vector<ELFDefinedAtom<ELFT> *>> atomsForSection;
+
   // group sections have a mapping of the section header to the
   // signature/section.
   llvm::DenseMap<const Elf_Shdr *, std::pair<StringRef, StringRef>>
       groupSections;
+  llvm::DenseMap<const Elf_Shdr *, StringRef> linkOnceSections;
+
   // Contains a list of comdat sections for a group.
   llvm::DenseMap<const Elf_Shdr *, std::vector<StringRef>> comdatSections;
   for (auto &i : _sectionSymbols) {
@@ -722,14 +725,12 @@ template <class ELFT> std::error_code EL
       ErrorOr<StringRef> symbolName = _objFile->getSymbolName(symtab, symbol);
       if (std::error_code ec = symbolName.getError())
         return ec;
-      groupSections.insert(
-          std::make_pair(section, std::make_pair(*symbolName, *sectionName)));
+      groupSections.insert({section, {*symbolName, *sectionName}});
       continue;
     }
 
     if (isGnuLinkOnceSection(*sectionName)) {
-      groupSections.insert(
-          std::make_pair(section, std::make_pair(*sectionName, *sectionName)));
+      linkOnceSections.insert({section, *sectionName});
       addAtoms = false;
     }
 
@@ -862,13 +863,13 @@ template <class ELFT> std::error_code EL
   for (auto &sect : groupSections) {
     StringRef signature = sect.second.first;
     StringRef groupSectionName = sect.second.second;
-    if (isGnuLinkOnceSection(signature))
-      handleGnuLinkOnceSection(signature, atomsForSection, sect.first);
-    else if (isGroupSection(sect.first))
-      handleSectionGroup(signature, groupSectionName, atomsForSection,
-                         comdatSections, sect.first);
+    handleSectionGroup(signature, groupSectionName, atomsForSection,
+                       comdatSections, sect.first);
   }
 
+  for (auto &sect : linkOnceSections)
+    handleGnuLinkOnceSection(sect.second, atomsForSection, sect.first);
+
   updateReferences();
   return std::error_code();
 }





More information about the llvm-commits mailing list