Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp
Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | bool BPFAsmBackend::writeNopData(raw_ostream &OS, uint64_t Count) const { | ||||
return true; | return true; | ||||
} | } | ||||
void BPFAsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, | void BPFAsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, | ||||
const MCValue &Target, | const MCValue &Target, | ||||
MutableArrayRef<char> Data, uint64_t Value, | MutableArrayRef<char> Data, uint64_t Value, | ||||
bool IsResolved, | bool IsResolved, | ||||
const MCSubtargetInfo *STI) const { | const MCSubtargetInfo *STI) const { | ||||
if (Fixup.getKind() == FK_SecRel_4 || Fixup.getKind() == FK_SecRel_8) { | if (Fixup.getKind() == FK_SecRel_4) { | ||||
// The Value is 0 for global variables, and the in-section offset | // The Value is 0 for global variables, and the in-section offset | ||||
// for static variables. Write to the immediate field of the inst. | // for static variables. Write to the immediate field of the inst. | ||||
assert(Value <= UINT32_MAX); | support::endian::write<uint32_t>(&Data[Fixup.getOffset() + 4], Value, | ||||
support::endian::write<uint32_t>(&Data[Fixup.getOffset() + 4], | |||||
static_cast<uint32_t>(Value), | |||||
Endian); | Endian); | ||||
} else if (Fixup.getKind() == FK_Data_4) { | } else if (Fixup.getKind() == FK_Data_4) { | ||||
support::endian::write<uint32_t>(&Data[Fixup.getOffset()], Value, Endian); | support::endian::write<uint32_t>(&Data[Fixup.getOffset()], Value, Endian); | ||||
} else if (Fixup.getKind() == FK_Data_8) { | } else if (Fixup.getKind() == FK_Data_8) { | ||||
support::endian::write<uint64_t>(&Data[Fixup.getOffset()], Value, Endian); | support::endian::write<uint64_t>(&Data[Fixup.getOffset()], Value, Endian); | ||||
} else if (Fixup.getKind() == FK_PCRel_4) { | } else if (Fixup.getKind() == FK_PCRel_4) { | ||||
Value = (uint32_t)((Value - 8) / 8); | Value = (uint32_t)((Value - 8) / 8); | ||||
if (Endian == support::little) { | if (Endian == support::little) { | ||||
Show All 32 Lines |