[PATCH] D48811: Fix disassembling ARM instructions as big-endian

Nicholas Allegra via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 2 12:24:55 PDT 2018


comex updated this revision to Diff 153766.
comex added a comment.

Fix disassembling ARM instructions as big-endian

ARMv6 and earlier (and ARMv7-R) include optional support for
big-endian instruction encoding, in all three encoding variants:
ARM, Thumb, and Thumb-2.  LLVM already supports assembling these
as big-endian by adding 'eb' to the architecture name in the triple
(e.g.  'armeb', 'armv6eb', 'thumbv7eb'); however, the disassembler
currently ignores the endian choice and always disassembles as
little-endian.  This is a simple patch to fix that, plus a test.

[Sidenote: ARM supports configuring data and instruction endianness
separately, and ARMv7 does not deprecate big-endian *data* encoding.
Thus, the ARM proprietary toolchain and GNU toolchain support targets
where instructions are encoded is little-endian but data accesses
are big-endian.  This is known as BE8 mode (--be8) and is implemented
in a hacky way: the compiler emits big-endian instructions and the
linker swaps them!  LLVM does not currently support BE8 at all.  In
theory, when parsing an ELF file with EF_ARM_BE8 in e_flags, the
disassembler should disassemble as little-endian, i.e. the old
behavior.  However, I think that's out of scope for this patch,
which is just a bugfix.]


Repository:
  rL LLVM

https://reviews.llvm.org/D48811

Files:
  lib/Target/ARM/Disassembler/ARMDisassembler.cpp
  test/MC/Disassembler/ARM/endian.txt

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48811.153766.patch
Type: text/x-patch
Size: 5684 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180702/63df3a8b/attachment.bin>


More information about the llvm-commits mailing list