From 0ac129903ab033fff3103b55f2c7d2a1058b397d Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Mon, 6 Apr 2015 21:21:43 +0000 Subject: [PATCH] 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. llvm-svn: 234223 --- lld/lib/ReaderWriter/ELF/ELFFile.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lld/lib/ReaderWriter/ELF/ELFFile.h b/lld/lib/ReaderWriter/ELF/ELFFile.h index 698cf8a75bcf..7e76cdfe149d 100644 --- a/lld/lib/ReaderWriter/ELF/ELFFile.h +++ b/lld/lib/ReaderWriter/ELF/ELFFile.h @@ -671,10 +671,13 @@ template std::error_code ELFFile::createAtoms() { // Holds all the atoms that are part of the section. They are the targets of // the kindGroupChild reference. llvm::StringMap *>> atomsForSection; + // group sections have a mapping of the section header to the // signature/section. llvm::DenseMap> groupSections; + llvm::DenseMap linkOnceSections; + // Contains a list of comdat sections for a group. llvm::DenseMap> comdatSections; for (auto &i : _sectionSymbols) { @@ -722,14 +725,12 @@ template std::error_code ELFFile::createAtoms() { ErrorOr 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 std::error_code ELFFile::createAtoms() { for (auto § : 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 § : linkOnceSections) + handleGnuLinkOnceSection(sect.second, atomsForSection, sect.first); + updateReferences(); return std::error_code(); }