This is the mail archive of the binutils@sourceware.org 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
<http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0473l/dom1359731147386.html> is currently broken.

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

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

$ arm-none-eabi-as weird-a53.s
$ arm-none-eabi-objdump -t
(snip)
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 <https://sourceware.org/bugzilla/show_bug.cgi?id=18500> 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.
--C

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]