/// emitSectionData void ELFObjectWriter::emitSectionData(const LDSection& pSection, MemoryRegion& pRegion) const { const SectionData* sd = NULL; switch (pSection.kind()) { case LDFileFormat::Relocation: assert(pSection.hasRelocData()); return; case LDFileFormat::EhFrame: assert(pSection.hasEhFrame()); sd = pSection.getEhFrame()->getSectionData(); break; default: assert(pSection.hasSectionData()); sd = pSection.getSectionData(); break; } emitSectionData(*sd, pRegion); }
/// group - group fragments and create islands when needed /// @param pSectionData - the SectionData holds fragments need to be grouped void BranchIslandFactory::group(Module& pModule) { /* FIXME: Currently only support relaxing .text section! */ LDSection* text = pModule.getSection(".text"); if (text != NULL && text->hasSectionData()) { SectionData& sd = *text->getSectionData(); uint64_t group_end = m_MaxFwdBranchRange; for (SectionData::iterator it = sd.begin(), ie = sd.end(); it != ie; ++it) { if ((*it).getOffset() + (*it).size() > group_end) { Fragment* frag = (*it).getPrevNode(); while (frag != NULL && frag->getKind() == Fragment::Alignment) { frag = frag->getPrevNode(); } if (frag != NULL) { produce(*frag); group_end = (*it).getOffset() + m_MaxFwdBranchRange; } } } if (getIslands(sd.back()).first == NULL) produce(sd.back()); } }