This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] [GAS, ARM] Invalid LDR immediate transformation

"Load immediate values using LDR Rd, =const" as described in
<> is currently broken.

The symptom appears with the following fragment that transforms a
'ldr' into a 'cmp':

$ cat weird-a53.s
        .syntax unified
        .align  2
        .global         foo
        .type   foo, %function
         ldr     r12, =#0x99

$ arm-none-eabi-as weird-a53.s
$ arm-none-eabi-objdump -t
Disassembly of section .text:

00000000 <foo>:
     0:   2c99            cmp     r4, #153        ; 0x99
     2:   46c0            nop                     ; (mov r8, r8)

It was originally reported by an internal user on cortex-a53 in
AArch32, but the issue is unrelated to a specific target and shows up
for any architecture supporting this transformation, eg from armv6t2.

The issue happens because a T1 encoding is used with a high register,
and the bits of the register number leak into the opcode, leading to
the transformation into a compare.

It looks like this is exposed in binutils trunk since the changes for
this <> have been
merged into the trunk.

I have attached a patch, tested on an x86_64 host in arm-none-eabi
arm-linux-eabi arm-nacl, no regression.

Waiting for any feedback, thanks.

Attachment: thumb2_ldr_immediate_highregs_armv6t2.patch
Description: Text document

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]