From 7d9198b2965ec682b3199f2328fa221a1b9c53d1 Mon Sep 17 00:00:00 2001 From: Oliver Stannard Date: Thu, 4 Jan 2018 13:56:40 +0000 Subject: [ARM] Fix endianness of Thumb .inst.w directive Wide Thumb2 instructions should be emitted into the object file as pairs of 16-bit words of the appropriate endianness, not one 32-bit word. Differential revision: https://reviews.llvm.org/D41185 llvm-svn: 321799 --- llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'llvm/lib/Target') diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp index d465da1a7bb..9d73c7629da 100644 --- a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp +++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp @@ -512,9 +512,11 @@ public: assert(IsThumb); EmitThumbMappingSymbol(); + // Thumb wide instructions are emitted as a pair of 16-bit words of the + // appropriate endianness. for (unsigned II = 0, IE = Size; II != IE; II = II + 2) { - const unsigned I0 = LittleEndian ? II + 0 : (Size - II - 1); - const unsigned I1 = LittleEndian ? II + 1 : (Size - II - 2); + const unsigned I0 = LittleEndian ? II + 0 : II + 1; + const unsigned I1 = LittleEndian ? II + 1 : II + 0; Buffer[Size - II - 2] = uint8_t(Inst >> I0 * CHAR_BIT); Buffer[Size - II - 1] = uint8_t(Inst >> I1 * CHAR_BIT); } -- cgit v1.2.3