summaryrefslogtreecommitdiffstats
path: root/poky/meta/recipes-devtools/binutils/binutils/0001-Change-the-ARM-assembler-s-ADR-and-ADRl-pseudo-ops-s.patch
blob: 8604e678da845b1a087befe3f8b80e817445128b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
From fc6141f097056f830a412afebed8d81a9d72b696 Mon Sep 17 00:00:00 2001
From: Nick Clifton <nickc@redhat.com>
Date: Wed, 20 Jun 2018 12:38:10 +0100
Subject: [PATCH] Change the ARM assembler's ADR and ADRl pseudo-ops so that
 they will only set the bottom bit of imported thumb function symbols if the
 -mthumb-interwork option is active.

For more information see the email thread starting here:
https://www.sourceware.org/ml/binutils/2018-05/msg00348.html

	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.
---
 gas/ChangeLog                   | 14 ++++++++++++++
 gas/NEWS                        |  4 ++++
 gas/config/tc-arm.c             | 10 ++++++----
 gas/doc/c-arm.texi              | 17 ++++++++++++++++-
 gas/testsuite/gas/arm/adr.d     |  1 +
 gas/testsuite/gas/arm/adrl.d    |  1 +
 gas/testsuite/gas/arm/pr21458.d |  3 ++-
 7 files changed, 44 insertions(+), 6 deletions(-)

Index: git/gas/config/tc-arm.c
===================================================================
--- git.orig/gas/config/tc-arm.c
+++ git/gas/config/tc-arm.c
@@ -8410,11 +8410,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
@@ -8434,11 +8435,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
Index: git/gas/doc/c-arm.texi
===================================================================
--- git.orig/gas/doc/c-arm.texi
+++ git/gas/doc/c-arm.texi
@@ -317,7 +317,8 @@ instructions; that is, it should behave
 @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
@@ -1060,6 +1061,16 @@ out of range, or if it is not defined in
 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
@@ -1076,6 +1087,10 @@ If the label is out of range, or if it i
 (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
Index: git/gas/testsuite/gas/arm/adr.d
===================================================================
--- git.orig/gas/testsuite/gas/arm/adr.d
+++ git/gas/testsuite/gas/arm/adr.d
@@ -1,3 +1,4 @@
+#as: -mthumb-interwork
 #objdump: -dr --prefix-addresses --show-raw-insn
 #name: ADR
 
Index: git/gas/testsuite/gas/arm/adrl.d
===================================================================
--- git.orig/gas/testsuite/gas/arm/adrl.d
+++ git/gas/testsuite/gas/arm/adrl.d
@@ -1,3 +1,4 @@
+#as: -mthumb-interwork
 #objdump: -dr --prefix-addresses --show-raw-insn
 #name: ADRL
 
Index: git/gas/ChangeLog
===================================================================
--- git.orig/gas/ChangeLog
+++ git/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-02-05  Nick Clifton  <nickc@redhat.com>
 
 	* po/ru.po: Updated Russian translation.
Index: git/gas/NEWS
===================================================================
--- git.orig/gas/NEWS
+++ git/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.
+
 Changes in 2.30:
 
 * Add support for loaction views in DWARF debug line information.
Index: git/gas/testsuite/gas/arm/pr21458.d
===================================================================
--- git.orig/gas/testsuite/gas/arm/pr21458.d
+++ git/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-* *-*-coff *-*-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.*
 
OpenPOWER on IntegriCloud