aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gas/ChangeLog14
-rw-r--r--gas/NEWS4
-rw-r--r--gas/config/tc-arm.c10
-rw-r--r--gas/doc/c-arm.texi17
-rw-r--r--gas/testsuite/gas/arm/adr.d1
-rw-r--r--gas/testsuite/gas/arm/adrl.d1
-rw-r--r--gas/testsuite/gas/arm/pr21458.d3
7 files changed, 44 insertions, 6 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 33ba540ed27..d22dd1f81f6 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,17 @@
+2018-06-20 Nick Clifton <nickc@redhat.com>
+
+ PR 21458
+ * tc-arm.c (do_adr): Only set the bottom bit of an imported thumb
+ function symbol address if -mthumb-interwork is active.
+ (do_adrl): Likewise.
+ * doc/c-arm.texi: Update descriptions of the -mthumb-interwork
+ option and the ADR and ADRL pseudo-ops.
+ * NEWS: Mention the new behaviour of the ADR and ADRL pseudo-ops.
+ * testsuite/gas/arm/pr21458.d: Add -mthumb-interwork option to
+ assembler command line.
+ * testsuite/gas/arm/adr.d: Likewise.
+ * testsuite/gas/arm/adrl.d: Likewise.
+
2018-06-20 Sebastian Huber <sebastian.huber@embedded-brains.de>
PR gas/23305
diff --git a/gas/NEWS b/gas/NEWS
index 9dfc8450bcf..474ff429c87 100644
--- a/gas/NEWS
+++ b/gas/NEWS
@@ -1,5 +1,9 @@
-*- text -*-
+* The ADR and ADRL pseudo-instructions supported by the ARM assembler
+ now only set the bottom bit of the address of thumb function symbols
+ if the -mthumb-interwork command line option is active.
+
* Add support for the MIPS Global INValidate (GINV) ASE.
* Add support for the MIPS Cyclic Redudancy Check (CRC) ASE.
diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c
index 2529d2a52f0..6a9a655bd4d 100644
--- a/gas/config/tc-arm.c
+++ b/gas/config/tc-arm.c
@@ -8419,11 +8419,12 @@ do_adr (void)
inst.reloc.pc_rel = 1;
inst.reloc.exp.X_add_number -= 8;
- if (inst.reloc.exp.X_op == O_symbol
+ if (support_interwork
+ && inst.reloc.exp.X_op == O_symbol
&& inst.reloc.exp.X_add_symbol != NULL
&& S_IS_DEFINED (inst.reloc.exp.X_add_symbol)
&& THUMB_IS_FUNC (inst.reloc.exp.X_add_symbol))
- inst.reloc.exp.X_add_number += 1;
+ inst.reloc.exp.X_add_number |= 1;
}
/* This is a pseudo-op of the form "adrl rd, label" to be converted
@@ -8443,11 +8444,12 @@ do_adrl (void)
inst.size = INSN_SIZE * 2;
inst.reloc.exp.X_add_number -= 8;
- if (inst.reloc.exp.X_op == O_symbol
+ if (support_interwork
+ && inst.reloc.exp.X_op == O_symbol
&& inst.reloc.exp.X_add_symbol != NULL
&& S_IS_DEFINED (inst.reloc.exp.X_add_symbol)
&& THUMB_IS_FUNC (inst.reloc.exp.X_add_symbol))
- inst.reloc.exp.X_add_number += 1;
+ inst.reloc.exp.X_add_number |= 1;
}
static void
diff --git a/gas/doc/c-arm.texi b/gas/doc/c-arm.texi
index cd533ca540b..4683b8a4bb7 100644
--- a/gas/doc/c-arm.texi
+++ b/gas/doc/c-arm.texi
@@ -318,7 +318,8 @@ instructions; that is, it should behave as though the file starts with a
@cindex @code{-mthumb-interwork} command line option, ARM
@item -mthumb-interwork
This option specifies that the output generated by the assembler should
-be marked as supporting interworking.
+be marked as supporting interworking. It also affects the behaviour
+of the @code{ADR} and @code{ADRL} pseudo opcodes.
@cindex @code{-mimplicit-it} command line option, ARM
@item -mimplicit-it=never
@@ -1061,6 +1062,16 @@ out of range, or if it is not defined in the same file (and section) as
the ADR instruction, then an error will be generated. This instruction
will not make use of the literal pool.
+If @var{label} is a thumb function symbol, and thumb interworking has
+been enabled via the @option{-mthumb-interwork} option then the bottom
+bit of the value stored into @var{register} will be set. This allows
+the following sequence to work as expected:
+
+@smallexample
+ adr r0, thumb_function
+ blx r0
+@end smallexample
+
@cindex @code{ADRL reg,<label>} pseudo op, ARM
@item ADRL
@smallexample
@@ -1077,6 +1088,10 @@ If the label is out of range, or if it is not defined in the same file
(and section) as the ADRL instruction, then an error will be generated.
This instruction will not make use of the literal pool.
+If @var{label} is a thumb function symbol, and thumb interworking has
+been enabled via the @option{-mthumb-interwork} option then the bottom
+bit of the value stored into @var{register} will be set.
+
@end table
For information on the ARM or Thumb instruction sets, see @cite{ARM
diff --git a/gas/testsuite/gas/arm/adr.d b/gas/testsuite/gas/arm/adr.d
index ee74154cb57..13722cd9cdd 100644
--- a/gas/testsuite/gas/arm/adr.d
+++ b/gas/testsuite/gas/arm/adr.d
@@ -1,3 +1,4 @@
+#as: -mthumb-interwork
#objdump: -dr --prefix-addresses --show-raw-insn
#name: ADR
diff --git a/gas/testsuite/gas/arm/adrl.d b/gas/testsuite/gas/arm/adrl.d
index 6276e8d2f31..b6011f1f89c 100644
--- a/gas/testsuite/gas/arm/adrl.d
+++ b/gas/testsuite/gas/arm/adrl.d
@@ -1,3 +1,4 @@
+#as: -mthumb-interwork
#objdump: -dr --prefix-addresses --show-raw-insn
#name: ADRL
diff --git a/gas/testsuite/gas/arm/pr21458.d b/gas/testsuite/gas/arm/pr21458.d
index 5410e7af170..b567d847ddd 100644
--- a/gas/testsuite/gas/arm/pr21458.d
+++ b/gas/testsuite/gas/arm/pr21458.d
@@ -1,8 +1,9 @@
+#as: -mthumb-interwork
#objdump: -d --prefix-addresses --show-raw-insn
#name: ADR(L) for Thumb functions
#skip: *-*-pe *-wince-* *-*-vxworks
-# Test that using ADR(L) on thumb function symbols sets the T bit.
+# Test that using ADR(L) on thumb function symbols sets the T bit when -mthumb-interwork is active.
.*: +file format .*arm.*