From 5e73442d4c1ea1261339be580fb0f12bdc4b9e29 Mon Sep 17 00:00:00 2001 From: Sandra Loosemore Date: Tue, 24 Jul 2012 16:38:35 +0000 Subject: [PATCH] 2012-07-24 Sandra Loosemore Jie Zhang gas/ * config/tc-arm.c (md_apply_fix): Use encoding A2 of ADR if offset is negative. gas/testsuite/ * gas/arm/adr.d: New test. * gas/arm/adr.s: New test. --- gas/ChangeLog | 6 ++++++ gas/config/tc-arm.c | 19 ++++++++++++++----- gas/testsuite/ChangeLog | 6 ++++++ gas/testsuite/gas/arm/adr.d | 9 +++++++++ gas/testsuite/gas/arm/adr.s | 5 +++++ 5 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 gas/testsuite/gas/arm/adr.d create mode 100644 gas/testsuite/gas/arm/adr.s diff --git a/gas/ChangeLog b/gas/ChangeLog index ed60ccb353f..f4bbc8d0fac 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,9 @@ +2012-07-24 Sandra Loosemore + Jie Zhang + + * config/tc-arm.c (md_apply_fix): Use encoding A2 of ADR + if offset is negative. + 2012-07-16 Michael Zolotukhin * config/tc-i386.c: Add ADX, RDSEED and PRFCHW asm directives. diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c index 004f7510341..795a1b56173 100644 --- a/gas/config/tc-arm.c +++ b/gas/config/tc-arm.c @@ -20637,13 +20637,22 @@ md_apply_fix (fixS * fixP, } } - newimm = encode_arm_immediate (value); temp = md_chars_to_number (buf, INSN_SIZE); - /* If the instruction will fail, see if we can fix things up by - changing the opcode. */ - if (newimm == (unsigned int) FAIL - && (newimm = negate_data_op (&temp, value)) == (unsigned int) FAIL) + /* If the offset is negative, we should use encoding A2 for ADR. */ + if ((temp & 0xfff0000) == 0x28f0000 && value < 0) + newimm = negate_data_op (&temp, value); + else + { + newimm = encode_arm_immediate (value); + + /* If the instruction will fail, see if we can fix things up by + changing the opcode. */ + if (newimm == (unsigned int) FAIL) + newimm = negate_data_op (&temp, value); + } + + if (newimm == (unsigned int) FAIL) { as_bad_where (fixP->fx_file, fixP->fx_line, _("invalid constant (%lx) after fixup"), diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index 756b9d2651b..85968f89fc5 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2012-07-24 Sandra Loosemore + Jie Zhang + + * gas/arm/adr.d: New test. + * gas/arm/adr.s: New test. + 2012-07-16 Michael Zolotukhin * gas/i386/i386.exp: Run adx, rdseed and prefetchw tests. diff --git a/gas/testsuite/gas/arm/adr.d b/gas/testsuite/gas/arm/adr.d new file mode 100644 index 00000000000..ee74154cb57 --- /dev/null +++ b/gas/testsuite/gas/arm/adr.d @@ -0,0 +1,9 @@ +#objdump: -dr --prefix-addresses --show-raw-insn +#name: ADR + +# Test the `ADR' pseudo-op + +.*: +file format .*arm.* + +Disassembly of section .text: +0+ <.*> 824ff203 subhi pc, pc, #805306368 ; 0x30000000 diff --git a/gas/testsuite/gas/arm/adr.s b/gas/testsuite/gas/arm/adr.s new file mode 100644 index 00000000000..5d8ea2bd400 --- /dev/null +++ b/gas/testsuite/gas/arm/adr.s @@ -0,0 +1,5 @@ + @ test ADR pseudo-op + .text + .global foo +foo: + adrhi pc, . - 0x2ffffff8 -- 2.30.2