diff options
| author | James Molloy <james.molloy@arm.com> | 2016-04-01 09:40:47 +0000 |
|---|---|---|
| committer | James Molloy <james.molloy@arm.com> | 2016-04-01 09:40:47 +0000 |
| commit | b876c72bccdfcc2b57a3c36c0ac8874117a50981 (patch) | |
| tree | 83256f6bdec5fc9729ccc4b8185f465c09ce3bc2 /llvm/test/MC/ARM | |
| parent | c6ad97a3e7bf1d38e1f73f8351695aa833f10c69 (diff) | |
| download | bcm5719-llvm-b876c72bccdfcc2b57a3c36c0ac8874117a50981.tar.gz bcm5719-llvm-b876c72bccdfcc2b57a3c36c0ac8874117a50981.zip | |
Fix for pr24346: arm asm label calculation error in sub
Some ARM instructions encode 32-bit immediates as a 8-bit integer (0-255)
and a 4-bit rotation (0-30, even) in its least significant 12 bits. The
original fixup, FK_Data_4, patches the instruction by the value bit-to-bit,
regardless of the encoding. For example, assuming the label L1 and L2 are
0x0 and 0x104 respectively, the following instruction:
add r0, r0, #(L2 - L1) ; expects 0x104, i.e., 260
would be assembled to the following, which adds 1 to r0, instead of 260:
e2800104 add r0, r0, #4, 2 ; equivalently 1
The new fixup kind fixup_arm_mod_imm takes care of the encoding:
e2800f41 add r0, r0, #260
Patch by Ting-Yuan Huang!
llvm-svn: 265122
Diffstat (limited to 'llvm/test/MC/ARM')
| -rw-r--r-- | llvm/test/MC/ARM/arm_fixups.s | 7 | ||||
| -rw-r--r-- | llvm/test/MC/ARM/modified-immediate-fixup-error.s | 14 | ||||
| -rw-r--r-- | llvm/test/MC/ARM/modified-immediate-fixup.s | 15 |
3 files changed, 36 insertions, 0 deletions
diff --git a/llvm/test/MC/ARM/arm_fixups.s b/llvm/test/MC/ARM/arm_fixups.s index 1f56e128524..a7655092a7a 100644 --- a/llvm/test/MC/ARM/arm_fixups.s +++ b/llvm/test/MC/ARM/arm_fixups.s @@ -32,3 +32,10 @@ @ CHECK: @ fixup A - offset: 0, value: fred, kind: fixup_arm_movw_lo16 @ CHECK-BE: movw r2, :lower16:fred @ encoding: [0xe3,0b0000AAAA,0x20'A',A] @ CHECK-BE: @ fixup A - offset: 0, value: fred, kind: fixup_arm_movw_lo16 + + add r0, r0, #(L1 - L2) + +@ CHECK: add r0, r0, #L1-L2 @ encoding: [A,0b0000AAAA,0x80,0xe2] +@ CHECK: @ fixup A - offset: 0, value: L1-L2, kind: fixup_arm_mod_imm +@ CHECK-BE: add r0, r0, #L1-L2 @ encoding: [0xe2,0x80,0b0000AAAA,A] +@ CHECK-BE: @ fixup A - offset: 0, value: L1-L2, kind: fixup_arm_mod_imm diff --git a/llvm/test/MC/ARM/modified-immediate-fixup-error.s b/llvm/test/MC/ARM/modified-immediate-fixup-error.s new file mode 100644 index 00000000000..2d111751cc1 --- /dev/null +++ b/llvm/test/MC/ARM/modified-immediate-fixup-error.s @@ -0,0 +1,14 @@ +@ PR24346 +@ RUN: not llvm-mc -triple=arm-linux-gnueabi -filetype=obj < %s 2>&1 | FileCheck %s + + .data + .align 8 +L2: + .word 0 + .align 8 + .byte 0 +L1: + + .text +@ CHECK: error: out of range immediate fixup value + add r0, r0, #(L1 - L2) diff --git a/llvm/test/MC/ARM/modified-immediate-fixup.s b/llvm/test/MC/ARM/modified-immediate-fixup.s new file mode 100644 index 00000000000..288814b4009 --- /dev/null +++ b/llvm/test/MC/ARM/modified-immediate-fixup.s @@ -0,0 +1,15 @@ +@ PR24346 +@ RUN: llvm-mc < %s -triple=arm-linux-gnueabi -filetype=obj -o - \ +@ RUN: | llvm-objdump --disassemble -arch=arm - | FileCheck %s + + .data + .align 8 +L2: + .word 0 + .align 8 + .word 0 +L1: + + .text +@ CHECK: add r0, r0, #260 + add r0, r0, #(L1 - L2) |

