aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2015-06-18 10:23:16 +0100
committerNick Clifton <nickc@redhat.com>2015-06-18 10:23:16 +0100
commitc12d2c9d48cf18d818f79b89bffda934c354fdac (patch)
treeff33a5f7012f0b0999a2710342a4d96d224d8457 /gas
parent75c11999673ba32027eb17f6df9c37904622ed24 (diff)
downloadgdb-c12d2c9d48cf18d818f79b89bffda934c354fdac.zip
gdb-c12d2c9d48cf18d818f79b89bffda934c354fdac.tar.gz
gdb-c12d2c9d48cf18d818f79b89bffda934c354fdac.tar.bz2
Add support for using the ADR alias in Thumb mode against nearby symbols.
PR gas/18541 gas * config/tc-arm.c (md_apply_fix): Add support for ADR in thumb mode against a nearby symbol. tests * gas/arm/thumb.s: Add test of ADR against a nearby symbol. * gas/arm/thumb.d: Update expected output. * gas/arm/thumb-eabi.d: Likewise.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog6
-rw-r--r--gas/config/tc-arm.c39
-rw-r--r--gas/testsuite/ChangeLog7
-rw-r--r--gas/testsuite/gas/arm/thumb-eabi.d5
-rw-r--r--gas/testsuite/gas/arm/thumb.d5
-rw-r--r--gas/testsuite/gas/arm/thumb.s10
6 files changed, 72 insertions, 0 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 00305e9..0a1326e 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,5 +1,11 @@
2015-06-18 Nick Clifton <nickc@redhat.com>
+ PR gas/18541
+ * config/tc-arm.c (md_apply_fix): Add support for ADR in thumb
+ mode against a nearby symbol.
+
+2015-06-18 Nick Clifton <nickc@redhat.com>
+
PR gas/18481
* config/tc-arm.c (tc_gen_reloc): Include BFD_RELOC_ARM_TLS_LE32
in the same case as BFD_RELOC_ARM_TLS_IS32.
diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c
index 9ccee40..1793965 100644
--- a/gas/config/tc-arm.c
+++ b/gas/config/tc-arm.c
@@ -23158,6 +23158,45 @@ md_apply_fix (fixS * fixP,
}
else if (rs == REG_PC || rs == REG_SP)
{
+ /* PR gas/18541. If the addition is for a defined symbol
+ within range of an ADR instruction then accept it. */
+ if (subtract
+ && value == 4
+ && fixP->fx_addsy != NULL)
+ {
+ subtract = 0;
+
+ if (! S_IS_DEFINED (fixP->fx_addsy)
+ || S_GET_SEGMENT (fixP->fx_addsy) != seg
+ || S_IS_WEAK (fixP->fx_addsy))
+ {
+ as_bad_where (fixP->fx_file, fixP->fx_line,
+ _("address calculation needs a strongly defined nearby symbol"));
+ }
+ else
+ {
+ offsetT v = fixP->fx_where + fixP->fx_frag->fr_address;
+
+ /* Round up to the next 4-byte boundary. */
+ if (v & 3)
+ v = (v + 3) & ~ 3;
+ else
+ v += 4;
+ v = S_GET_VALUE (fixP->fx_addsy) - v;
+
+ if (v & ~0x3fc)
+ {
+ as_bad_where (fixP->fx_file, fixP->fx_line,
+ _("symbol too far away"));
+ }
+ else
+ {
+ fixP->fx_done = 1;
+ value = v;
+ }
+ }
+ }
+
if (subtract || value & ~0x3fc)
as_bad_where (fixP->fx_file, fixP->fx_line,
_("invalid immediate for address calculation (value = 0x%08lX)"),
diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog
index d929e68..64e8cd7 100644
--- a/gas/testsuite/ChangeLog
+++ b/gas/testsuite/ChangeLog
@@ -1,5 +1,12 @@
2015-06-18 Nick Clifton <nickc@redhat.com>
+ PR gas/18541
+ * gas/arm/thumb.s: Add test of ADR against a nearby symbol.
+ * gas/arm/thumb.d: Update expected output.
+ * gas/arm/thumb-eabi.d: Likewise.
+
+2015-06-18 Nick Clifton <nickc@redhat.com>
+
PR gas/18481
* gas/arm/tls.s: Add tests of the tpoff pseudo with a local
symbol.
diff --git a/gas/testsuite/gas/arm/thumb-eabi.d b/gas/testsuite/gas/arm/thumb-eabi.d
index 19fc797..afe076b 100644
--- a/gas/testsuite/gas/arm/thumb-eabi.d
+++ b/gas/testsuite/gas/arm/thumb-eabi.d
@@ -163,3 +163,8 @@ Disassembly of section \.text:
0+942 <[^>]+> 4801 ldr r0, \[pc, #4\] ; \(0+948 <[^>]+>\)
0+944 <[^>]+> 1c08 adds r0, r1, #0
0+946 <[^>]+> 46c0 nop ; \(mov r8, r8\)
+0+948 <[^>]+> a001 add r0, pc, #4 ; \(adr r0, 00000950 <[^>]+>\)
+0+94a <[^>]+> a001 add r0, pc, #4 ; \(adr r0, 00000950 <[^>]+>\)
+0+94c <[^>]+> a000 add r0, pc, #0 ; \(adr r0, 00000950 <[^>]+>\)
+0+94e <[^>]+> 46c0 nop ; \(mov r8, r8\)
+#pass
diff --git a/gas/testsuite/gas/arm/thumb.d b/gas/testsuite/gas/arm/thumb.d
index c928aaf..65d007a 100644
--- a/gas/testsuite/gas/arm/thumb.d
+++ b/gas/testsuite/gas/arm/thumb.d
@@ -163,3 +163,8 @@ Disassembly of section \.text:
0+942 <[^>]+> 4801 ldr r0, \[pc, #4\] ; \(0+948 <[^>]+>\)
0+944 <[^>]+> 1c08 adds r0, r1, #0
0+946 <[^>]+> 46c0 nop ; \(mov r8, r8\)
+0+948 <[^>]+> a001 add r0, pc, #4 ; \(adr r0, 00000950 <[^>]+>\)
+0+94a <[^>]+> a001 add r0, pc, #4 ; \(adr r0, 00000950 <[^>]+>\)
+0+94c <[^>]+> a000 add r0, pc, #0 ; \(adr r0, 00000950 <[^>]+>\)
+0+94e <[^>]+> 46c0 nop ; \(mov r8, r8\)
+#pass
diff --git a/gas/testsuite/gas/arm/thumb.s b/gas/testsuite/gas/arm/thumb.s
index a044bdf..3c759b3 100644
--- a/gas/testsuite/gas/arm/thumb.s
+++ b/gas/testsuite/gas/arm/thumb.s
@@ -201,3 +201,13 @@ forwardonly:
baz:
mov r0, r1
nop
+
+ adr r0, pr18541
+ adr r0, pr18541
+ adr r0, pr18541
+ nop
+ .align
+ .global pr18541
+pr18541:
+ .long 0
+