Re: [PATCH] Make arm_record_test work on big-endian machines

Simon Marchi
2018-03-12T18:54:05Z

On 2018-03-12 13:09, Yao Qi wrote:
> Simon Marchi <simon.marchi@ericsson.com> writes:
>
>> What do you think about the patch below? Functionally, it should be
>> identical
>> to what you suggested, but I think it's clear to fix extract_arm_insn
>> instead.
>>
>
> Patch looks good to me. Thanks.
>
>> +
>> + insn_record->arm_insn
>> + = (uint32_t) extract_unsigned_integer (&buf[0], 2, endian);
>> +
>> + if (insn_size == 4)
>> + {
>> + insn_record->arm_insn <<= 16;
>> + insn_record->arm_insn
>> + |= (uint32_t) extract_unsigned_integer (&buf[2], 2, endian);
>
> Better to add some comments here.

Oh, actually, does my patch get it wrong for ARM instructions? For
them, it seems like in little endian, the four bytes of an instruction
are reversed (as if it was a 4-byte value). So that would explain why
the word swap would only occur under a if (THUMB2_RECORD ==
record_type). There is no test with ARM instructions in
arm_record_test... should there be one?

Simon