[elf] Remove one copy of the section merging code

Summary:
Besides being superfluous, this double merging was actually wrong and
causing some sections to be added twice. The reason for that was that
the code assumes section IDs are unique in the section list, but this is
only true if all sections in the list come from the same object file.

Reviewers: fjricci, jankratochvil

Subscribers: emaste, lldb-commits, arichardson

Differential Revision: https://reviews.llvm.org/D44157

llvm-svn: 327123
This commit is contained in:
Pavel Labath
2018-03-09 12:30:09 +00:00
parent 3aa75a7f9b
commit 3ef4eebc27
2 changed files with 46 additions and 32 deletions

View File

@@ -1986,38 +1986,10 @@ void ObjectFileELF::CreateSections(SectionList &unified_section_list) {
}
}
if (m_sections_ap.get()) {
if (GetType() == eTypeDebugInfo) {
static const SectionType g_sections[] = {
eSectionTypeDWARFDebugAbbrev, eSectionTypeDWARFDebugAddr,
eSectionTypeDWARFDebugAranges, eSectionTypeDWARFDebugCuIndex,
eSectionTypeDWARFDebugFrame, eSectionTypeDWARFDebugInfo,
eSectionTypeDWARFDebugLine, eSectionTypeDWARFDebugLoc,
eSectionTypeDWARFDebugMacInfo, eSectionTypeDWARFDebugPubNames,
eSectionTypeDWARFDebugPubTypes, eSectionTypeDWARFDebugRanges,
eSectionTypeDWARFDebugStr, eSectionTypeDWARFDebugStrOffsets,
eSectionTypeELFSymbolTable,
};
SectionList *elf_section_list = m_sections_ap.get();
for (size_t idx = 0; idx < sizeof(g_sections) / sizeof(g_sections[0]);
++idx) {
SectionType section_type = g_sections[idx];
SectionSP section_sp(
elf_section_list->FindSectionByType(section_type, true));
if (section_sp) {
SectionSP module_section_sp(
unified_section_list.FindSectionByType(section_type, true));
if (module_section_sp)
unified_section_list.ReplaceSection(module_section_sp->GetID(),
section_sp);
else
unified_section_list.AddSection(section_sp);
}
}
} else {
unified_section_list = *m_sections_ap;
}
}
// For eTypeDebugInfo files, the Symbol Vendor will take care of updating the
// unified section list.
if (GetType() != eTypeDebugInfo)
unified_section_list = *m_sections_ap;
}
// Find the arm/aarch64 mapping symbol character in the given symbol name.