From 6296f6d7d828064d052b2d46155f074f2ece6924 Mon Sep 17 00:00:00 2001 From: Alexei Starovoitov Date: Fri, 22 May 2015 18:47:33 +0000 Subject: [PATCH] [bpf] emit jmp fixups in little endian The 'off' field of 'struct bpf_insn' is in cpu-endianness, since the rest is emitted as little endian, make sure that 'off' field is little endian as well. llvm-svn: 238038 --- llvm/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp b/llvm/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp index 8393135a2b9c..48f34e484590 100644 --- a/llvm/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp +++ b/llvm/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp @@ -68,7 +68,9 @@ void BPFAsmBackend::applyFixup(const MCFixup &Fixup, char *Data, return; } assert(Fixup.getKind() == FK_PCRel_2); - *(uint16_t *)&Data[Fixup.getOffset() + 2] = (uint16_t)((Value - 8) / 8); + Value = (uint16_t)((Value - 8) / 8); + Data[Fixup.getOffset() + 2] = Value & 0xFF; + Data[Fixup.getOffset() + 3] = Value >> 8; } MCObjectWriter *BPFAsmBackend::createObjectWriter(raw_pwrite_stream &OS) const {