本文整理汇总了C++中LDSection::getRelocData方法的典型用法代码示例。如果您正苦于以下问题:C++ LDSection::getRelocData方法的具体用法?C++ LDSection::getRelocData怎么用?C++ LDSection::getRelocData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LDSection
的用法示例。
在下文中一共展示了LDSection::getRelocData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: emitRelocation
/// emitRelocation
void ELFObjectWriter::emitRelocation(const LinkerConfig& pConfig,
const LDSection& pSection,
MemoryRegion& pRegion) const
{
const RelocData* sect_data = pSection.getRelocData();
assert(NULL != sect_data && "SectionData is NULL in emitRelocation!");
if (pSection.type() == SHT_REL) {
if (pConfig.targets().is32Bits())
emitRel<32>(pConfig, *sect_data, pRegion);
else if (pConfig.targets().is64Bits())
emitRel<64>(pConfig, *sect_data, pRegion);
else {
fatal(diag::unsupported_bitclass) << pConfig.targets().triple().str()
<< pConfig.targets().bitclass();
}
} else if (pSection.type() == SHT_RELA) {
if (pConfig.targets().is32Bits())
emitRela<32>(pConfig, *sect_data, pRegion);
else if (pConfig.targets().is64Bits())
emitRela<64>(pConfig, *sect_data, pRegion);
else {
fatal(diag::unsupported_bitclass) << pConfig.targets().triple().str()
<< pConfig.targets().bitclass();
}
} else
llvm::report_fatal_error("unsupported relocation section type!");
}
示例2: doRelax
bool MipsGNULDBackend::doRelax(Module& pModule,
IRBuilder& pBuilder,
bool& pFinished) {
assert(getStubFactory() != NULL && getBRIslandFactory() != NULL);
bool isRelaxed = false;
for (Module::obj_iterator input = pModule.obj_begin();
input != pModule.obj_end();
++input) {
LDContext* context = (*input)->context();
for (LDContext::sect_iterator rs = context->relocSectBegin();
rs != context->relocSectEnd();
++rs) {
LDSection* sec = *rs;
if (LDFileFormat::Ignore == sec->kind() || !sec->hasRelocData())
continue;
for (RelocData::iterator reloc = sec->getRelocData()->begin();
reloc != sec->getRelocData()->end();
++reloc) {
if (llvm::ELF::R_MIPS_26 != reloc->type())
continue;
if (relaxRelocation(pBuilder, *llvm::cast<Relocation>(reloc)))
isRelaxed = true;
}
}
}
SectionData* textData = getOutputFormat()->getText().getSectionData();
// find the first fragment w/ invalid offset due to stub insertion
Fragment* invalid = NULL;
pFinished = true;
for (BranchIslandFactory::iterator ii = getBRIslandFactory()->begin(),
ie = getBRIslandFactory()->end();
ii != ie;
++ii) {
BranchIsland& island = *ii;
if (island.end() == textData->end())
break;
Fragment* exit = island.end();
if ((island.offset() + island.size()) > exit->getOffset()) {
invalid = exit;
pFinished = false;
break;
}
}
// reset the offset of invalid fragments
while (invalid != NULL) {
invalid->setOffset(invalid->getPrevNode()->getOffset() +
invalid->getPrevNode()->size());
invalid = invalid->getNextNode();
}
// reset the size of .text
if (isRelaxed)
getOutputFormat()->getText().setSize(textData->back().getOffset() +
textData->back().size());
return isRelaxed;
}