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; }
FragmentRef* FragmentRef::Create(LDSection& pSection, uint64_t pOffset) { SectionData* data = NULL; switch (pSection.kind()) { case LDFileFormat::Relocation: // No fragment reference refers to a relocation section break; case LDFileFormat::EhFrame: if (pSection.hasEhFrame()) data = pSection.getEhFrame()->getSectionData(); break; default: data = pSection.getSectionData(); break; } if (data == NULL || data->empty()) { return Null(); } return Create(data->front(), pOffset); }