void RuntimeDyldMachOCRTPBase<Impl>::finalizeLoad(const ObjectFile &Obj, ObjSectionToIDMap &SectionMap) { unsigned EHFrameSID = RTDYLD_INVALID_SECTION_ID; unsigned TextSID = RTDYLD_INVALID_SECTION_ID; unsigned ExceptTabSID = RTDYLD_INVALID_SECTION_ID; for (const auto &Section : Obj.sections()) { StringRef Name; Section.getName(Name); // Force emission of the __text, __eh_frame, and __gcc_except_tab sections // if they're present. Otherwise call down to the impl to handle other // sections that have already been emitted. if (Name == "__text") TextSID = findOrEmitSection(Obj, Section, true, SectionMap); else if (Name == "__eh_frame") EHFrameSID = findOrEmitSection(Obj, Section, false, SectionMap); else if (Name == "__gcc_except_tab") ExceptTabSID = findOrEmitSection(Obj, Section, true, SectionMap); else { auto I = SectionMap.find(Section); if (I != SectionMap.end()) impl().finalizeSection(Obj, I->second, Section); } } UnregisteredEHFrameSections.push_back( EHFrameRelatedSections(EHFrameSID, TextSID, ExceptTabSID)); }
void RuntimeDyldMachO::finalizeLoad(ObjectImage &ObjImg, ObjSectionToIDMap &SectionMap) { unsigned EHFrameSID = RTDYLD_INVALID_SECTION_ID; unsigned TextSID = RTDYLD_INVALID_SECTION_ID; unsigned ExceptTabSID = RTDYLD_INVALID_SECTION_ID; ObjSectionToIDMap::iterator i, e; for (i = SectionMap.begin(), e = SectionMap.end(); i != e; ++i) { const SectionRef &Section = i->first; StringRef Name; Section.getName(Name); if (Name == "__eh_frame") EHFrameSID = i->second; else if (Name == "__text") TextSID = i->second; else if (Name == "__gcc_except_tab") ExceptTabSID = i->second; else if (Name == "__jump_table") populateJumpTable(cast<MachOObjectFile>(*ObjImg.getObjectFile()), Section, i->second); else if (Name == "__pointers") populatePointersSection(cast<MachOObjectFile>(*ObjImg.getObjectFile()), Section, i->second); } UnregisteredEHFrameSections.push_back( EHFrameRelatedSections(EHFrameSID, TextSID, ExceptTabSID)); }
unsigned RuntimeDyldImpl::findOrEmitSection(const SectionRef &Section, bool IsCode, ObjSectionToIDMap &LocalSections) { unsigned SectionID = 0; ObjSectionToIDMap::iterator i = LocalSections.find(Section); if (i != LocalSections.end()) SectionID = i->second; else { SectionID = emitSection(Section, IsCode); LocalSections[Section] = SectionID; } return SectionID; }
void RuntimeDyldMachO::finalizeLoad(ObjSectionToIDMap &SectionMap) { unsigned EHFrameSID = RTDYLD_INVALID_SECTION_ID; unsigned TextSID = RTDYLD_INVALID_SECTION_ID; unsigned ExceptTabSID = RTDYLD_INVALID_SECTION_ID; ObjSectionToIDMap::iterator i, e; for (i = SectionMap.begin(), e = SectionMap.end(); i != e; ++i) { const SectionRef &Section = i->first; StringRef Name; Section.getName(Name); if (Name == "__eh_frame") EHFrameSID = i->second; else if (Name == "__text") TextSID = i->second; else if (Name == "__gcc_except_tab") ExceptTabSID = i->second; } UnregisteredEHFrameSections.push_back( EHFrameRelatedSections(EHFrameSID, TextSID, ExceptTabSID)); }