本文整理汇总了C++中SectionRef::getRawDataRefImpl方法的典型用法代码示例。如果您正苦于以下问题:C++ SectionRef::getRawDataRefImpl方法的具体用法?C++ SectionRef::getRawDataRefImpl怎么用?C++ SectionRef::getRawDataRefImpl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SectionRef
的用法示例。
在下文中一共展示了SectionRef::getRawDataRefImpl方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MCObjectSymbolizer
MCMachObjectSymbolizer::MCMachObjectSymbolizer(
MCContext &Ctx, std::unique_ptr<MCRelocationInfo> &RelInfo,
const MachOObjectFile *MOOF)
: MCObjectSymbolizer(Ctx, RelInfo, MOOF), MOOF(MOOF), StubsStart(0),
StubsCount(0), StubSize(0), StubsIndSymIndex(0) {
for (const SectionRef &Section : MOOF->sections()) {
StringRef Name;
Section.getName(Name);
if (Name == "__stubs") {
SectionRef StubsSec = Section;
if (MOOF->is64Bit()) {
MachO::section_64 S = MOOF->getSection64(StubsSec.getRawDataRefImpl());
StubsIndSymIndex = S.reserved1;
StubSize = S.reserved2;
} else {
MachO::section S = MOOF->getSection(StubsSec.getRawDataRefImpl());
StubsIndSymIndex = S.reserved1;
StubSize = S.reserved2;
}
assert(StubSize && "Mach-O stub entry size can't be zero!");
StubsSec.getAddress(StubsStart);
StubsSec.getSize(StubsCount);
StubsCount /= StubSize;
}
}
}
示例2:
void DyldELFObject<target_endianness, is64Bits>::updateSectionAddress(
const SectionRef &Sec,
uint64_t Addr) {
DataRefImpl ShdrRef = Sec.getRawDataRefImpl();
Elf_Shdr *shdr = const_cast<Elf_Shdr*>(
reinterpret_cast<const Elf_Shdr *>(ShdrRef.p));
// This assumes the address passed in matches the target address bitness
// The template-based type cast handles everything else.
shdr->sh_addr = static_cast<addr_type>(Addr);
}
示例3: checked
bool checked(const ELFObjectFile<T> &obj, SectionRef sec_ref) {
typedef typename ELFObjectFile<T>::Elf_Shdr Elf_Shdr;
auto &elf = *obj.getELFFile();
const Elf_Shdr *RelSec = obj.getSection(sec_ref.getRawDataRefImpl());
auto symsec = elf.getSection(RelSec->sh_link);
if (!symsec) return false;
uint32_t sec_typ = (*symsec)->sh_type;
return
(sec_typ == ELF::SHT_SYMTAB || sec_typ == ELF::SHT_DYNSYM);
}
示例4: populateIndirectSymbolPointersSection
// Populate __pointers section.
void RuntimeDyldMachO::populateIndirectSymbolPointersSection(
const MachOObjectFile &Obj,
const SectionRef &PTSection,
unsigned PTSectionID) {
assert(!Obj.is64Bit() &&
"Pointer table section not supported in 64-bit MachO.");
MachO::dysymtab_command DySymTabCmd = Obj.getDysymtabLoadCommand();
MachO::section Sec32 = Obj.getSection(PTSection.getRawDataRefImpl());
uint32_t PTSectionSize = Sec32.size;
unsigned FirstIndirectSymbol = Sec32.reserved1;
const unsigned PTEntrySize = 4;
unsigned NumPTEntries = PTSectionSize / PTEntrySize;
unsigned PTEntryOffset = 0;
assert((PTSectionSize % PTEntrySize) == 0 &&
"Pointers section does not contain a whole number of stubs?");
DEBUG(dbgs() << "Populating pointer table section "
<< Sections[PTSectionID].getName() << ", Section ID "
<< PTSectionID << ", " << NumPTEntries << " entries, "
<< PTEntrySize << " bytes each:\n");
for (unsigned i = 0; i < NumPTEntries; ++i) {
unsigned SymbolIndex =
Obj.getIndirectSymbolTableEntry(DySymTabCmd, FirstIndirectSymbol + i);
symbol_iterator SI = Obj.getSymbolByIndex(SymbolIndex);
ErrorOr<StringRef> IndirectSymbolNameOrErr = SI->getName();
if (std::error_code EC = IndirectSymbolNameOrErr.getError())
report_fatal_error(EC.message());
StringRef IndirectSymbolName = *IndirectSymbolNameOrErr;
DEBUG(dbgs() << " " << IndirectSymbolName << ": index " << SymbolIndex
<< ", PT offset: " << PTEntryOffset << "\n");
RelocationEntry RE(PTSectionID, PTEntryOffset,
MachO::GENERIC_RELOC_VANILLA, 0, false, 2);
addRelocationForSymbol(RE, IndirectSymbolName);
PTEntryOffset += PTEntrySize;
}
}
示例5: getSectionID
unsigned COFFObjectFile::getSectionID(SectionRef Sec) const {
uintptr_t Offset =
uintptr_t(Sec.getRawDataRefImpl().p) - uintptr_t(SectionTable);
assert((Offset % sizeof(coff_section)) == 0);
return (Offset / sizeof(coff_section)) + 1;
}