bool SectionSymbolSet::finalize(LDSection& pOutSect, SymbolTable& pSymTab, bool relocatable) { if (!relocatable && pOutSect.size() == 0) return true; LDSymbol* sym = get(pOutSect); assert(NULL != sym); SectionData* data = NULL; switch (pOutSect.kind()) { case LDFileFormat::Relocation: // Relocation section should not have section symbol. return true; case LDFileFormat::EhFrame: if (EhFrame *ehframe = pOutSect.getEhFrame()) data = ehframe->getSectionData(); break; default: data = pOutSect.getSectionData(); break; } FragmentRef* frag_ref; if (data && !data->empty()) frag_ref = FragmentRef::Create(data->front(), 0x0); else frag_ref = FragmentRef::Null(); sym->setFragmentRef(frag_ref); // push symbol into output symbol table pSymTab.add(*sym); return true; }
/// 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); }