return processSECTDIFFRelocation(SectionID, RelI, Obj,
ObjSectionToID);
else if (RelType == MachO::GENERIC_RELOC_VANILLA)
- return processI386ScatteredVANILLA(SectionID, RelI, Obj,
- ObjSectionToID);
+ return processScatteredVANILLA(SectionID, RelI, Obj, ObjSectionToID);
llvm_unreachable("Unhandled scattered relocation.");
}
// Value.Addend += RelocAddr + 4;
// }
if (RE.IsPCRel)
- makeValueAddendPCRel(Value, Obj, RelI, 1 << RE.Size);
+ makeValueAddendPCRel(Value, RelI, 1 << RE.Size);
RE.Addend = Value.Offset;
uint32_t RelocType = Obj.getAnyRelocationType(RE);
bool IsPCRel = Obj.getAnyRelocationPCRel(RE);
unsigned Size = Obj.getAnyRelocationLength(RE);
- uint64_t Offset;
- RelI->getOffset(Offset);
+ uint64_t Offset = RelI->getOffset();
uint8_t *LocalAddress = Section.Address + Offset;
unsigned NumBytes = 1 << Size;
uint64_t Addend = readBytesUnaligned(LocalAddress, NumBytes);
return ++RelI;
}
- relocation_iterator processI386ScatteredVANILLA(
- unsigned SectionID, relocation_iterator RelI,
- const ObjectFile &BaseObjT,
- RuntimeDyldMachO::ObjSectionToIDMap &ObjSectionToID) {
- const MachOObjectFile &Obj =
- static_cast<const MachOObjectFile&>(BaseObjT);
- MachO::any_relocation_info RE =
- Obj.getRelocation(RelI->getRawDataRefImpl());
-
- SectionEntry &Section = Sections[SectionID];
- uint32_t RelocType = Obj.getAnyRelocationType(RE);
- bool IsPCRel = Obj.getAnyRelocationPCRel(RE);
- unsigned Size = Obj.getAnyRelocationLength(RE);
- uint64_t Offset;
- RelI->getOffset(Offset);
- uint8_t *LocalAddress = Section.Address + Offset;
- unsigned NumBytes = 1 << Size;
- int64_t Addend = readBytesUnaligned(LocalAddress, NumBytes);
-
- unsigned SymbolBaseAddr = Obj.getScatteredRelocationValue(RE);
- section_iterator TargetSI = getSectionByAddress(Obj, SymbolBaseAddr);
- assert(TargetSI != Obj.section_end() && "Can't find section for symbol");
- uint64_t SectionBaseAddr = TargetSI->getAddress();
- SectionRef TargetSection = *TargetSI;
- bool IsCode = TargetSection.isText();
- uint32_t TargetSectionID =
- findOrEmitSection(Obj, TargetSection, IsCode, ObjSectionToID);
-
- Addend -= SectionBaseAddr;
- RelocationEntry R(SectionID, Offset, RelocType, Addend, IsPCRel, Size);
-
- addRelocationForSection(R, TargetSectionID);
-
- return ++RelI;
- }
-
// Populate stubs in __jump_table section.
void populateJumpTable(const MachOObjectFile &Obj, const SectionRef &JTSection,
unsigned JTSectionID) {
unsigned SymbolIndex =
Obj.getIndirectSymbolTableEntry(DySymTabCmd, FirstIndirectSymbol + i);
symbol_iterator SI = Obj.getSymbolByIndex(SymbolIndex);
- StringRef IndirectSymbolName;
- SI->getName(IndirectSymbolName);
+ ErrorOr<StringRef> IndirectSymbolName = SI->getName();
+ if (std::error_code EC = IndirectSymbolName.getError())
+ report_fatal_error(EC.message());
uint8_t *JTEntryAddr = JTSectionAddr + JTEntryOffset;
createStubFunction(JTEntryAddr);
RelocationEntry RE(JTSectionID, JTEntryOffset + 1,
MachO::GENERIC_RELOC_VANILLA, 0, true, 2);
- addRelocationForSymbol(RE, IndirectSymbolName);
+ addRelocationForSymbol(RE, *IndirectSymbolName);
JTEntryOffset += JTEntrySize;
}
}
};
-} // namespace llvm
+}
#undef DEBUG_TYPE