qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: why arm bootloader is big endian?


From: Peter Maydell
Subject: Re: why arm bootloader is big endian?
Date: Tue, 17 May 2022 11:25:31 +0100

On Tue, 17 May 2022 at 11:19, Liu Jaloo <liu.jaloo@gmail.com> wrote:
>
> from hw/arm/boot.c
>
> static const ARMInsnFixup bootloader[] = {
>     { 0xe28fe004 }, /* add     lr, pc, #4 */
>      ...
> }
>
> $ rasm2 -a arm -d -e 0xe28fe004
> add lr, pc, 4
>
> $ rasm2 --help
> -e           Use big endian instead of little endian
>
> why arm bootloader defalut is big endian?

It is not. This array is an array of 32 bit integers,
one per instruction. The code which writes it to guest
memory reads 32 bits from the array, and writes 32 bits
from the array into guest memory. It will byteswap
each word if the host and guest are different endian
(which in practice for Arm almost always means "if the
host is bigendian", so for x86 host arm guest we don't
need to swap).

rasm2 wants to disassemble a sequence of hex *bytes*,
which means that you need to specify them in the order
they appear in memory. If we've written a little-endian
32-bit value 0xe28fe004 to memory, then the bytes will
be 0x04 0xe0 0x8f 0xe2, and so you either need to
tell rasm2 '04e08fe2' or else cheat and use the -e
option (which will work as long as the insn really is
32 bits, ie you're not dealing with Thumb insns.)

-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]