[llvm] r238038 - [bpf] emit jmp fixups in little endian
Alexei Starovoitov
alexei.starovoitov at gmail.com
Fri May 22 11:47:34 PDT 2015
Author: ast
Date: Fri May 22 13:47:33 2015
New Revision: 238038
URL: http://llvm.org/viewvc/llvm-project?rev=238038&view=rev
Log:
[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.
Modified:
llvm/trunk/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp
Modified: llvm/trunk/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp?rev=238038&r1=238037&r2=238038&view=diff
==============================================================================
--- llvm/trunk/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp (original)
+++ llvm/trunk/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp Fri May 22 13:47:33 2015
@@ -68,7 +68,9 @@ void BPFAsmBackend::applyFixup(const MCF
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 {
More information about the llvm-commits
mailing list