diff --git a/lld/MachO/InputFiles.h b/lld/MachO/InputFiles.h --- a/lld/MachO/InputFiles.h +++ b/lld/MachO/InputFiles.h @@ -151,8 +151,6 @@ std::vector callGraph; private: - Section *compactUnwindSection = nullptr; - template void parseLazy(); template void parseSections(ArrayRef); template @@ -165,7 +163,7 @@ void parseRelocations(ArrayRef sectionHeaders, const SectionHeader &, Section &); void parseDebugInfo(); - void registerCompactUnwind(); + void registerCompactUnwind(Section &compactUnwindSection); }; // command-line -sectcreate file diff --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp --- a/lld/MachO/InputFiles.cpp +++ b/lld/MachO/InputFiles.cpp @@ -344,8 +344,6 @@ section.subsections.push_back({0, isec}); } else if (auto recordSize = getRecordSize(segname, name)) { splitRecords(*recordSize); - if (name == section_names::compactUnwind) - compactUnwindSection = §ion; } else if (segname == segment_names::llvm) { if (config->callGraphProfileSort && name == section_names::cgProfile) checkError(parseCallGraph(data, callGraph)); @@ -917,8 +915,19 @@ parseRelocations(sectionHeaders, sectionHeaders[i], *sections[i]); parseDebugInfo(); + + Section *ehFrameSection = nullptr; + Section *compactUnwindSection = nullptr; + for (Section *sec : sections) { + Section **s = StringSwitch
(sec->name) + .Case(section_names::compactUnwind, &compactUnwindSection) + .Case(section_names::ehFrame, &ehFrameSection) + .Default(nullptr); + if (s) + *s = sec; + } if (compactUnwindSection) - registerCompactUnwind(); + registerCompactUnwind(*compactUnwindSection); } template void ObjFile::parseLazy() { @@ -981,8 +990,8 @@ } // Create pointers from symbols to their associated compact unwind entries. -void ObjFile::registerCompactUnwind() { - for (const Subsection &subsection : compactUnwindSection->subsections) { +void ObjFile::registerCompactUnwind(Section &compactUnwindSection) { + for (const Subsection &subsection : compactUnwindSection.subsections) { ConcatInputSection *isec = cast(subsection.isec); // Hack!! Since each CUE contains a different function address, if ICF // operated naively and compared the entire contents of each CUE, entries