diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2011-06-02 15:32:10 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@codesourcery.com> | 2011-06-02 15:32:10 +0000 |
commit | 26d97720ed597caf769e6f16e6e7c1f8e385f9c7 (patch) | |
tree | a0fa857d90a09736000ec903f888b1d3512e499d /gas | |
parent | 65fdb766be229fb9c080ae93cb8277516c640908 (diff) | |
download | gdb-26d97720ed597caf769e6f16e6e7c1f8e385f9c7.zip gdb-26d97720ed597caf769e6f16e6e7c1f8e385f9c7.tar.gz gdb-26d97720ed597caf769e6f16e6e7c1f8e385f9c7.tar.bz2 |
gas/
* config/tc-arm.c (parse_address_main): Handle -0 offsets.
(encode_arm_addr_mode_2): Set default sign of zero here ...
(encode_arm_addr_mode_3): ... and here.
(encode_arm_cp_address): ... and here.
(md_apply_fix): Use default sign of zero here.
gas/testsuite/
* gas/arm/inst.d: Adjust for signed zero offsets.
* gas/arm/ldst-offset0.d: New test.
* gas/arm/ldst-offset0.s: New test.
* gas/arm/offset-1.d: New test.
* gas/arm/offset-1.s: New test.
ld/testsuite/
Adjust tests for zero offset formatting.
* ld-arm/cortex-a8-fix-bcc-plt.d: Adjust.
* ld-arm/farcall-arm-arm-pic-veneer.d: Adjust.
* ld-arm/farcall-arm-thumb.d: Adjust.
* ld-arm/farcall-group-size2.d: Adjust.
* ld-arm/farcall-group.d: Adjust.
* ld-arm/farcall-mix.d: Adjust.
* ld-arm/farcall-mix2.d: Adjust.
* ld-arm/farcall-mixed-lib-v4t.d: Adjust.
* ld-arm/farcall-mixed-lib.d: Adjust.
* ld-arm/farcall-thumb-arm-blx-pic-veneer.d: Adjust.
* ld-arm/farcall-thumb-arm-pic-veneer.d: Adjust.
* ld-arm/farcall-thumb-thumb.d: Adjust.
* ld-arm/ifunc-10.dd: Adjust.
* ld-arm/ifunc-3.dd: Adjust.
* ld-arm/ifunc-4.dd: Adjust.
* ld-arm/ifunc-5.dd: Adjust.
* ld-arm/ifunc-6.dd: Adjust.
* ld-arm/ifunc-7.dd: Adjust.
* ld-arm/ifunc-8.dd: Adjust.
* ld-arm/jump-reloc-veneers-long.d: Adjust.
* ld-arm/tls-longplt-lib.d: Adjust.
* ld-arm/tls-thumb1.d: Adjust.
opcodes/
* arm-dis.c (print_insn_coprocessor): Explicitly print #-0
as address offset.
(print_arm_address): Likewise. Elide positive #0 appropriately.
(print_insn_arm): Likewise.
Diffstat (limited to 'gas')
-rw-r--r-- | gas/ChangeLog | 9 | ||||
-rw-r--r-- | gas/config/tc-arm.c | 86 | ||||
-rw-r--r-- | gas/testsuite/ChangeLog | 9 | ||||
-rw-r--r-- | gas/testsuite/gas/arm/inst.d | 4 | ||||
-rw-r--r-- | gas/testsuite/gas/arm/ldst-offset0.d | 51 | ||||
-rw-r--r-- | gas/testsuite/gas/arm/ldst-offset0.s | 66 | ||||
-rw-r--r-- | gas/testsuite/gas/arm/offset-1.d | 23 | ||||
-rw-r--r-- | gas/testsuite/gas/arm/offset-1.s | 16 |
8 files changed, 249 insertions, 15 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index 6e40507..8d4019b 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,12 @@ +2011-06-02 Jie Zhang jie@codesourcery.com + Nathan Sidwell nathan@codesourcery.com + + * config/tc-arm.c (parse_address_main): Handle -0 offsets. + (encode_arm_addr_mode_2): Set default sign of zero here ... + (encode_arm_addr_mode_3): ... and here. + (encode_arm_cp_address): ... and here. + (md_apply_fix): Use default sign of zero here. + 2011-06-02 Nick Clifton <nickc@redhat.com> * as.c: Fix spelling typo. diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c index 415663d..c17a1dc 100644 --- a/gas/config/tc-arm.c +++ b/gas/config/tc-arm.c @@ -5200,8 +5200,24 @@ parse_address_main (char **str, int i, int group_relocations, } } else - if (my_get_expression (&inst.reloc.exp, &p, GE_IMM_PREFIX)) - return PARSE_OPERAND_FAIL; + { + char *q = p; + if (my_get_expression (&inst.reloc.exp, &p, GE_IMM_PREFIX)) + return PARSE_OPERAND_FAIL; + /* If the offset is 0, find out if it's a +0 or -0. */ + if (inst.reloc.exp.X_op == O_constant + && inst.reloc.exp.X_add_number == 0) + { + skip_whitespace (q); + if (*q == '#') + { + q++; + skip_whitespace (q); + } + if (*q == '-') + inst.operands[i].negative = 1; + } + } } } else if (skip_past_char (&p, ':') == SUCCESS) @@ -5275,6 +5291,7 @@ parse_address_main (char **str, int i, int group_relocations, } else { + char *q = p; if (inst.operands[i].negative) { inst.operands[i].negative = 0; @@ -5282,6 +5299,19 @@ parse_address_main (char **str, int i, int group_relocations, } if (my_get_expression (&inst.reloc.exp, &p, GE_IMM_PREFIX)) return PARSE_OPERAND_FAIL; + /* If the offset is 0, find out if it's a +0 or -0. */ + if (inst.reloc.exp.X_op == O_constant + && inst.reloc.exp.X_add_number == 0) + { + skip_whitespace (q); + if (*q == '#') + { + q++; + skip_whitespace (q); + } + if (*q == '-') + inst.operands[i].negative = 1; + } } } } @@ -7038,7 +7068,12 @@ encode_arm_addr_mode_2 (int i, bfd_boolean is_t) } if (inst.reloc.type == BFD_RELOC_UNUSED) - inst.reloc.type = BFD_RELOC_ARM_OFFSET_IMM; + { + /* Prefer + for zero encoded value. */ + if (!inst.operands[i].negative) + inst.instruction |= INDEX_UP; + inst.reloc.type = BFD_RELOC_ARM_OFFSET_IMM; + } } } @@ -7074,7 +7109,13 @@ encode_arm_addr_mode_3 (int i, bfd_boolean is_t) BAD_PC_WRITEBACK); inst.instruction |= HWOFFSET_IMM; if (inst.reloc.type == BFD_RELOC_UNUSED) - inst.reloc.type = BFD_RELOC_ARM_OFFSET_IMM8; + { + /* Prefer + for zero encoded value. */ + if (!inst.operands[i].negative) + inst.instruction |= INDEX_UP; + + inst.reloc.type = BFD_RELOC_ARM_OFFSET_IMM8; + } } } @@ -7136,6 +7177,10 @@ encode_arm_cp_address (int i, int wb_ok, int unind_ok, int reloc_override) inst.reloc.type = BFD_RELOC_ARM_CP_OFF_IMM; } + /* Prefer + for zero encoded value. */ + if (!inst.operands[i].negative) + inst.instruction |= INDEX_UP; + return SUCCESS; } @@ -20447,7 +20492,7 @@ md_apply_fix (fixS * fixP, value = 0; case BFD_RELOC_ARM_LITERAL: - sign = value >= 0; + sign = value > 0; if (value < 0) value = - value; @@ -20465,14 +20510,19 @@ md_apply_fix (fixS * fixP, } newval = md_chars_to_number (buf, INSN_SIZE); - newval &= 0xff7ff000; - newval |= value | (sign ? INDEX_UP : 0); + if (value == 0) + newval &= 0xfffff000; + else + { + newval &= 0xff7ff000; + newval |= value | (sign ? INDEX_UP : 0); + } md_number_to_chars (buf, newval, INSN_SIZE); break; case BFD_RELOC_ARM_OFFSET_IMM8: case BFD_RELOC_ARM_HWLITERAL: - sign = value >= 0; + sign = value > 0; if (value < 0) value = - value; @@ -20489,8 +20539,13 @@ md_apply_fix (fixS * fixP, } newval = md_chars_to_number (buf, INSN_SIZE); - newval &= 0xff7ff0f0; - newval |= ((value >> 4) << 8) | (value & 0xf) | (sign ? INDEX_UP : 0); + if (value == 0) + newval &= 0xfffff0f0; + else + { + newval &= 0xff7ff0f0; + newval |= ((value >> 4) << 8) | (value & 0xf) | (sign ? INDEX_UP : 0); + } md_number_to_chars (buf, newval, INSN_SIZE); break; @@ -21117,7 +21172,7 @@ md_apply_fix (fixS * fixP, as_bad_where (fixP->fx_file, fixP->fx_line, _("co-processor offset out of range")); cp_off_common: - sign = value >= 0; + sign = value > 0; if (value < 0) value = -value; if (fixP->fx_r_type == BFD_RELOC_ARM_CP_OFF_IMM @@ -21125,8 +21180,13 @@ md_apply_fix (fixS * fixP, newval = md_chars_to_number (buf, INSN_SIZE); else newval = get_thumb32_insn (buf); - newval &= 0xff7fff00; - newval |= (value >> 2) | (sign ? INDEX_UP : 0); + if (value == 0) + newval &= 0xffffff00; + else + { + newval &= 0xff7fff00; + newval |= (value >> 2) | (sign ? INDEX_UP : 0); + } if (fixP->fx_r_type == BFD_RELOC_ARM_CP_OFF_IMM || fixP->fx_r_type == BFD_RELOC_ARM_CP_OFF_IMM_S2) md_number_to_chars (buf, newval, INSN_SIZE); diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index 1f54cfe..f7a7079 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2011-06-02 Jie Zhang <jie@codesourcery.com> + Nathan Sidwell <nathan@codesourcery.com> + + * gas/arm/inst.d: Adjust for signed zero offsets. + * gas/arm/ldst-offset0.d: New test. + * gas/arm/ldst-offset0.s: New test. + * gas/arm/offset-1.d: New test. + * gas/arm/offset-1.s: New test. + 2011-05-31 Paul Brook <paul@codesourcery.com> * gas/arm/arm-idiv-bad.d: New test. diff --git a/gas/testsuite/gas/arm/inst.d b/gas/testsuite/gas/arm/inst.d index e61bbfd..d9bd700 100644 --- a/gas/testsuite/gas/arm/inst.d +++ b/gas/testsuite/gas/arm/inst.d @@ -130,7 +130,7 @@ Disassembly of section .text: 0+1d8 <[^>]*> e6942425 ? ldr r2, \[r4\], r5, lsr #8 0+1dc <[^>]*> e51f0008 ? ldr r0, \[pc, #-8\] ; 0+1dc <[^>]*> 0+1e0 <[^>]*> e5d43000 ? ldrb r3, \[r4\] -0+1e4 <[^>]*> 14f85000 ? ldrbtne r5, \[r8\] +0+1e4 <[^>]*> 14f85000 ? ldrbtne r5, \[r8\], #0 0+1e8 <[^>]*> e5810000 ? str r0, \[r1\] 0+1ec <[^>]*> e7811002 ? str r1, \[r1, r2\] 0+1f0 <[^>]*> e7a43003 ? str r3, \[r4, r3\]! @@ -142,7 +142,7 @@ Disassembly of section .text: 0+208 <[^>]*> e6a42425 ? strt r2, \[r4\], r5, lsr #8 0+20c <[^>]*> e50f1004 ? str r1, \[pc, #-4\] ; 0+210 <[^>]*> 0+210 <[^>]*> e5c71000 ? strb r1, \[r7\] -0+214 <[^>]*> e4e02000 ? strbt r2, \[r0\] +0+214 <[^>]*> e4e02000 ? strbt r2, \[r0\], #0 0+218 <[^>]*> e8900002 ? ldm r0, {r1} 0+21c <[^>]*> 09920038 ? ldmibeq r2, {r3, r4, r5} 0+220 <[^>]*> e853ffff ? ldmda r3, {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, sl, fp, ip, sp, lr, pc}\^ diff --git a/gas/testsuite/gas/arm/ldst-offset0.d b/gas/testsuite/gas/arm/ldst-offset0.d new file mode 100644 index 0000000..5c1f88b --- /dev/null +++ b/gas/testsuite/gas/arm/ldst-offset0.d @@ -0,0 +1,51 @@ +#objdump: -dr --prefix-addresses --show-raw-insn +#name: ARM load/store with 0 offset +#as: + +# Test the standard ARM instructions: + +.*: +file format .*arm.* + +Disassembly of section .text: +0+000 <[^>]*> e5121000 ldr r1, \[r2, #-0\] +0+004 <[^>]*> e5121000 ldr r1, \[r2, #-0\] +0+008 <[^>]*> e5921000 ldr r1, \[r2\] +0+00c <[^>]*> e5921000 ldr r1, \[r2\] +0+010 <[^>]*> e5321000 ldr r1, \[r2, #-0\]! +0+014 <[^>]*> e5321000 ldr r1, \[r2, #-0\]! +0+018 <[^>]*> e5b21000 ldr r1, \[r2, #0\]! +0+01c <[^>]*> e5b21000 ldr r1, \[r2, #0\]! +0+020 <[^>]*> e4121000 ldr r1, \[r2\], #-0 +0+024 <[^>]*> e4121000 ldr r1, \[r2\], #-0 +0+028 <[^>]*> e4921000 ldr r1, \[r2\], #0 +0+02c <[^>]*> e4921000 ldr r1, \[r2\], #0 +0+030 <[^>]*> e5b21000 ldr r1, \[r2, #0\]! +0+034 <[^>]*> e5921000 ldr r1, \[r2\] +0+038 <[^>]*> e4f21000 ldrbt r1, \[r2\], #0 +0+03c <[^>]*> e4721000 ldrbt r1, \[r2\], #-0 +0+040 <[^>]*> e4f21000 ldrbt r1, \[r2\], #0 +0+044 <[^>]*> 5d565300 ldclpl 3, cr5, \[r6, #-0\] +0+048 <[^>]*> 5dd65300 ldclpl 3, cr5, \[r6\] +0+04c <[^>]*> e5021000 str r1, \[r2, #-0\] +0+050 <[^>]*> e5021000 str r1, \[r2, #-0\] +0+054 <[^>]*> e5821000 str r1, \[r2\] +0+058 <[^>]*> e5821000 str r1, \[r2\] +0+05c <[^>]*> e5221000 str r1, \[r2, #-0\]! +0+060 <[^>]*> e5221000 str r1, \[r2, #-0\]! +0+064 <[^>]*> e5a21000 str r1, \[r2, #0\]! +0+068 <[^>]*> e5a21000 str r1, \[r2, #0\]! +0+06c <[^>]*> e4021000 str r1, \[r2\], #-0 +0+070 <[^>]*> e4021000 str r1, \[r2\], #-0 +0+074 <[^>]*> e4821000 str r1, \[r2\], #0 +0+078 <[^>]*> e4821000 str r1, \[r2\], #0 +0+07c <[^>]*> e5a21000 str r1, \[r2, #0\]! +0+080 <[^>]*> e5821000 str r1, \[r2\] +0+084 <[^>]*> e4e21000 strbt r1, \[r2\], #0 +0+088 <[^>]*> e4621000 strbt r1, \[r2\], #-0 +0+08c <[^>]*> e4e21000 strbt r1, \[r2\], #0 +0+090 <[^>]*> 5d465300 stclpl 3, cr5, \[r6, #-0\] +0+094 <[^>]*> 5dc65300 stclpl 3, cr5, \[r6\] +0+098 <[^>]*> e59f0004 ldr r0, \[pc, #4\] ; .* +0+09c <[^>]*> e59f0000 ldr r0, \[pc\] ; .* +0+0a0 <[^>]*> e51f0004 ldr r0, \[pc, #-4\] ; .* +0+0a4 <[^>]*> 00000000 .word 0x00000000 diff --git a/gas/testsuite/gas/arm/ldst-offset0.s b/gas/testsuite/gas/arm/ldst-offset0.s new file mode 100644 index 0000000..9b0900f --- /dev/null +++ b/gas/testsuite/gas/arm/ldst-offset0.s @@ -0,0 +1,66 @@ +@ Test file for ARM load/store instructions with 0 offset + + .text + .syntax unified + ldr r1, [r2, #-0] + ldr r1, [r2, #-1+1] + + ldr r1, [r2, #1-1] + ldr r1, [r2, #0] + + ldr r1, [r2, #-0]! + ldr r1, [r2, #-1+1]! + + ldr r1, [r2, #1-1]! + ldr r1, [r2, #0]! + + ldr r1, [r2], #-0 + ldr r1, [r2], #-1+1 + + ldr r1, [r2], #1-1 + ldr r1, [r2], #0 + + ldr r1, [r2]! + ldr r1, [r2] + + ldrbt r1, [r2], #0 + ldrbt r1, [r2], #-0 + + ldrbt r1, [r2] + + ldclpl p3, c5, [r6, #-0] + ldclpl p3, c5, [r6, #0] + + str r1, [r2, #-0] + str r1, [r2, #-1+1] + + str r1, [r2, #1-1] + str r1, [r2, #0] + + str r1, [r2, #-0]! + str r1, [r2, #-1+1]! + + str r1, [r2, #1-1]! + str r1, [r2, #0]! + + str r1, [r2], #-0 + str r1, [r2], #-1+1 + + str r1, [r2], #1-1 + str r1, [r2], #0 + + str r1, [r2]! + str r1, [r2] + + strbt r1, [r2], #0 + strbt r1, [r2], #-0 + + strbt r1, [r2] + + stclpl p3, c5, [r6, #-0] + stclpl p3, c5, [r6, #0] + + ldr r0,1f + ldr r0,1f + ldr r0,1f +1: .word 0 diff --git a/gas/testsuite/gas/arm/offset-1.d b/gas/testsuite/gas/arm/offset-1.d new file mode 100644 index 0000000..bec9386 --- /dev/null +++ b/gas/testsuite/gas/arm/offset-1.d @@ -0,0 +1,23 @@ +# name: MINUS ZERO OFFSET +# as: +# objdump: -dr --prefix-addresses --show-raw-insn + +.*: +file format .*arm.* + +Disassembly of section .text: +0+00 <[^>]+> e51f0000 ? ldr r0, \[pc, #-0\] ; 0+8 <[^>]+> +0+04 <[^>]+> e59f0000 ? ldr r0, \[pc\] ; 0+c <[^>]+> +0+08 <[^>]+> e5110000 ? ldr r0, \[r1, #-0\] +0+0c <[^>]+> e5910000 ? ldr r0, \[r1\] +0+10 <[^>]+> e4110000 ? ldr r0, \[r1\], #-0 +0+14 <[^>]+> e4910000 ? ldr r0, \[r1\], #0 +0+18 <[^>]+> e15f00b0 ? ldrh r0, \[pc, #-0\] ; 0+20 <[^>]+> +0+1c <[^>]+> e1df00b0 ? ldrh r0, \[pc\] ; 0+24 <[^>]+> +0+20 <[^>]+> e15100b0 ? ldrh r0, \[r1, #-0\] +0+24 <[^>]+> e1d100b0 ? ldrh r0, \[r1\] +0+28 <[^>]+> e05100b0 ? ldrh r0, \[r1\], #-0 +0+2c <[^>]+> e0d100b0 ? ldrh r0, \[r1\], #0 +0+30 <[^>]+> e5310000 ? ldr r0, \[r1, #-0\]! +0+34 <[^>]+> e5b10000 ? ldr r0, \[r1, #0\]! +0+38 <[^>]+> e17100b0 ? ldrh r0, \[r1, #-0\]! +0+3c <[^>]+> e1f100b0 ? ldrh r0, \[r1, #0\]! diff --git a/gas/testsuite/gas/arm/offset-1.s b/gas/testsuite/gas/arm/offset-1.s new file mode 100644 index 0000000..3e99317 --- /dev/null +++ b/gas/testsuite/gas/arm/offset-1.s @@ -0,0 +1,16 @@ + ldr r0, [pc, #-0] + ldr r0, [pc, #0] + ldr r0, [r1, #-0] + ldr r0, [r1, #0] + ldr r0, [r1], #-0 + ldr r0, [r1], #0 + ldrh r0, [pc, #-0] + ldrh r0, [pc, #0] + ldrh r0, [r1, #-0] + ldrh r0, [r1, #0] + ldrh r0, [r1], #-0 + ldrh r0, [r1], #0 + ldr r0, [r1, #-0]! + ldr r0, [r1, #0]! + ldrh r0, [r1, #-0]! + ldrh r0, [r1, #0]! |