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
This commit is contained in:
Rui Ueyama 2015-04-06 21:21:43 +00:00
parent f2daddbba4
commit 0ac129903a
1 changed files with 10 additions and 9 deletions

View File

@ -671,10 +671,13 @@ template <class ELFT> std::error_code ELFFile<ELFT>::createAtoms() {
// 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 ELFFile<ELFT>::createAtoms() {
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 ELFFile<ELFT>::createAtoms() {
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();
}