]> git.pld-linux.org Git - packages/binutils.git/blame - binutils-bug-13675.patch
- rel 3; upstream fix for noop on < i686; run test suite
[packages/binutils.git] / binutils-bug-13675.patch
CommitLineData
e6026cea
AM
1commit 7eb902bc9272afb419ab6fc5699eb7ed8beb104b
2Author: H.J. Lu <hjl.tools@gmail.com>
3Date: Thu Feb 9 22:51:57 2012 +0000
4
5 Don't use multi byte nop instructions for i386
6
7 bfd/
8
9 2012-02-09 H.J. Lu <hongjiu.lu@intel.com>
10
11 PR ld/13675
12 * cpu-i386.c (bfd_arch_i386_fill): Updated to support multi byte
13 nop instructions.
14 (bfd_arch_i386_short_nop_fill): New.
15 (bfd_arch_i386_long_nop_fill): Likewise.
16 Use bfd_arch_i386_short_nop_fill in 32bit bfd_arch_info
17 initializers. Use bfd_arch_i386_long_nop_fill on 64bit
18 bfd_arch_info initializers.
19
20 * cpu-k1om.c (bfd_arch_i386_fill): Renamed to ...
21 (bfd_arch_i386_short_nop_fill): This.
22 Update bfd_arch_info initializers.
23 * cpu-l1om.c: Likewise.
24
25 ld/testsuite/
26
27 2012-02-09 H.J. Lu <hongjiu.lu@intel.com>
28
29 PR ld/13675
30 * ld-i386/tlsnopic.dd: Update no-op padding.
31 * ld-i386/tlspic.dd: Likewise.
32
33diff --git a/bfd/cpu-i386.c b/bfd/cpu-i386.c
34index f8991cf..4cb59ed 100644
35--- a/bfd/cpu-i386.c
36+++ b/bfd/cpu-i386.c
37@@ -25,7 +25,8 @@
38 #include "libbfd.h"
39 #include "libiberty.h"
40
41-extern void * bfd_arch_i386_fill (bfd_size_type, bfd_boolean, bfd_boolean);
42+extern void * bfd_arch_i386_short_nop_fill (bfd_size_type, bfd_boolean,
43+ bfd_boolean);
44
45 static const bfd_arch_info_type *
46 bfd_i386_compatible (const bfd_arch_info_type *a,
47@@ -41,16 +42,16 @@ bfd_i386_compatible (const bfd_arch_info_type *a,
48 return compat;
49 }
50
51-/* Fill the buffer with zero or nop instruction if CODE is TRUE. */
52+/* Fill the buffer with zero or nop instruction if CODE is TRUE. Use
53+ multi byte nop instructions if LONG_NOP is TRUE. */
54
55-void *
56-bfd_arch_i386_fill (bfd_size_type count,
57- bfd_boolean is_bigendian ATTRIBUTE_UNUSED,
58- bfd_boolean code)
59+static void *
60+bfd_arch_i386_fill (bfd_size_type count, bfd_boolean code,
61+ bfd_boolean long_nop)
62 {
63 /* nop */
64 static const char nop_1[] = { 0x90 };
65- /* nopw */
66+ /* xchg %ax,%ax */
67 static const char nop_2[] = { 0x66, 0x90 };
68 /* nopl (%[re]ax) */
69 static const char nop_3[] = { 0x0f, 0x1f, 0x00 };
70@@ -74,6 +75,7 @@ bfd_arch_i386_fill (bfd_size_type count,
71 static const char *const nops[] =
72 { nop_1, nop_2, nop_3, nop_4, nop_5,
73 nop_6, nop_7, nop_8, nop_9, nop_10 };
74+ bfd_size_type nop_size = long_nop ? ARRAY_SIZE (nops) : 2;
75
76 void *fill = bfd_malloc (count);
77 if (fill == NULL)
78@@ -82,11 +84,11 @@ bfd_arch_i386_fill (bfd_size_type count,
79 if (code)
80 {
81 bfd_byte *p = fill;
82- while (count >= ARRAY_SIZE (nops))
83+ while (count >= nop_size)
84 {
85- memcpy (p, nops[ARRAY_SIZE (nops) - 1], ARRAY_SIZE (nops));
86- p += ARRAY_SIZE (nops);
87- count -= ARRAY_SIZE (nops);
88+ memcpy (p, nops[nop_size - 1], nop_size);
89+ p += nop_size;
90+ count -= nop_size;
91 }
92 if (count != 0)
93 memcpy (p, nops[count - 1], count);
94@@ -97,6 +99,26 @@ bfd_arch_i386_fill (bfd_size_type count,
95 return fill;
96 }
97
98+/* Fill the buffer with zero or short nop instruction if CODE is TRUE. */
99+
100+void *
101+bfd_arch_i386_short_nop_fill (bfd_size_type count,
102+ bfd_boolean is_bigendian ATTRIBUTE_UNUSED,
103+ bfd_boolean code)
104+{
105+ return bfd_arch_i386_fill (count, code, FALSE);
106+}
107+
108+/* Fill the buffer with zero or long nop instruction if CODE is TRUE. */
109+
110+static void *
111+bfd_arch_i386_long_nop_fill (bfd_size_type count,
112+ bfd_boolean is_bigendian ATTRIBUTE_UNUSED,
113+ bfd_boolean code)
114+{
115+ return bfd_arch_i386_fill (count, code, TRUE);
116+}
117+
118 static const bfd_arch_info_type bfd_x64_32_arch_intel_syntax =
119 {
120 64, /* 64 bits in a word */
121@@ -110,7 +132,7 @@ static const bfd_arch_info_type bfd_x64_32_arch_intel_syntax =
122 FALSE,
123 bfd_i386_compatible,
124 bfd_default_scan,
125- bfd_arch_i386_fill,
126+ bfd_arch_i386_long_nop_fill,
127 0
128 };
129
130@@ -127,7 +149,7 @@ static const bfd_arch_info_type bfd_x86_64_arch_intel_syntax =
131 FALSE,
132 bfd_i386_compatible,
133 bfd_default_scan,
134- bfd_arch_i386_fill,
135+ bfd_arch_i386_long_nop_fill,
136 &bfd_x64_32_arch_intel_syntax,
137 };
138
139@@ -144,7 +166,7 @@ static const bfd_arch_info_type bfd_i386_arch_intel_syntax =
140 TRUE,
141 bfd_i386_compatible,
142 bfd_default_scan,
143- bfd_arch_i386_fill,
144+ bfd_arch_i386_short_nop_fill,
145 &bfd_x86_64_arch_intel_syntax
146 };
147
148@@ -161,7 +183,7 @@ static const bfd_arch_info_type i8086_arch =
149 FALSE,
150 bfd_i386_compatible,
151 bfd_default_scan,
152- bfd_arch_i386_fill,
153+ bfd_arch_i386_short_nop_fill,
154 &bfd_i386_arch_intel_syntax
155 };
156
157@@ -178,7 +200,7 @@ static const bfd_arch_info_type bfd_x64_32_arch =
158 FALSE,
159 bfd_i386_compatible,
160 bfd_default_scan,
161- bfd_arch_i386_fill,
162+ bfd_arch_i386_long_nop_fill,
163 &i8086_arch
164 };
165
166@@ -195,7 +217,7 @@ static const bfd_arch_info_type bfd_x86_64_arch =
167 FALSE,
168 bfd_i386_compatible,
169 bfd_default_scan,
170- bfd_arch_i386_fill,
171+ bfd_arch_i386_long_nop_fill,
172 &bfd_x64_32_arch
173 };
174
175@@ -212,6 +234,6 @@ const bfd_arch_info_type bfd_i386_arch =
176 TRUE,
177 bfd_i386_compatible,
178 bfd_default_scan,
179- bfd_arch_i386_fill,
180+ bfd_arch_i386_short_nop_fill,
181 &bfd_x86_64_arch
182 };
183diff --git a/bfd/cpu-k1om.c b/bfd/cpu-k1om.c
184index f9958e4..54b6e58 100644
185--- a/bfd/cpu-k1om.c
186+++ b/bfd/cpu-k1om.c
187@@ -23,7 +23,8 @@
188 #include "bfd.h"
189 #include "libbfd.h"
190
191-extern void * bfd_arch_i386_fill (bfd_size_type, bfd_boolean, bfd_boolean);
192+extern void * bfd_arch_i386_short_nop_fill (bfd_size_type, bfd_boolean,
193+ bfd_boolean);
194
195 static const bfd_arch_info_type bfd_k1om_arch_intel_syntax =
196 {
197@@ -38,7 +39,7 @@ static const bfd_arch_info_type bfd_k1om_arch_intel_syntax =
198 TRUE,
199 bfd_default_compatible,
200 bfd_default_scan,
201- bfd_arch_i386_fill,
202+ bfd_arch_i386_short_nop_fill,
203 0
204 };
205
206@@ -55,6 +56,6 @@ const bfd_arch_info_type bfd_k1om_arch =
207 TRUE,
208 bfd_default_compatible,
209 bfd_default_scan,
210- bfd_arch_i386_fill,
211+ bfd_arch_i386_short_nop_fill,
212 &bfd_k1om_arch_intel_syntax
213 };
214diff --git a/bfd/cpu-l1om.c b/bfd/cpu-l1om.c
215index 0fabd49..46ac3a0 100644
216--- a/bfd/cpu-l1om.c
217+++ b/bfd/cpu-l1om.c
218@@ -23,7 +23,8 @@
219 #include "bfd.h"
220 #include "libbfd.h"
221
222-extern void * bfd_arch_i386_fill (bfd_size_type, bfd_boolean, bfd_boolean);
223+extern void * bfd_arch_i386_short_nop_fill (bfd_size_type, bfd_boolean,
224+ bfd_boolean);
225
226 static const bfd_arch_info_type bfd_l1om_arch_intel_syntax =
227 {
228@@ -38,7 +39,7 @@ static const bfd_arch_info_type bfd_l1om_arch_intel_syntax =
229 TRUE,
230 bfd_default_compatible,
231 bfd_default_scan,
232- bfd_arch_i386_fill,
233+ bfd_arch_i386_short_nop_fill,
234 0
235 };
236
237@@ -55,6 +56,6 @@ const bfd_arch_info_type bfd_l1om_arch =
238 TRUE,
239 bfd_default_compatible,
240 bfd_default_scan,
241- bfd_arch_i386_fill,
242+ bfd_arch_i386_short_nop_fill,
243 &bfd_l1om_arch_intel_syntax
244 };
245diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
246index 037bfa0..b53cb8b 100644
247--- a/ld/testsuite/ChangeLog
248+++ b/ld/testsuite/ChangeLog
249@@ -1,3 +1,9 @@
250+2012-02-09 H.J. Lu <hongjiu.lu@intel.com>
251+
252+ PR ld/13675
253+ * ld-i386/tlsnopic.dd: Update no-op padding.
254+ * ld-i386/tlspic.dd: Likewise.
255+
256 2012-01-31 H.J. Lu <hongjiu.lu@intel.com>
257
258 PR ld/13616
259diff --git a/ld/testsuite/ld-i386/tlsnopic.dd b/ld/testsuite/ld-i386/tlsnopic.dd
260index d6a16d0..027d288 100644
261--- a/ld/testsuite/ld-i386/tlsnopic.dd
262+++ b/ld/testsuite/ld-i386/tlsnopic.dd
263@@ -156,4 +156,5 @@ Disassembly of section .text:
264 10ec: 8b 5d fc[ ]+mov -0x4\(%ebp\),%ebx
265 10ef: c9[ ]+leave *
266 10f0: c3[ ]+ret *
267- 10f1: 0f 1f 00[ ]+nopl \(%eax\)
268+ 10f1: 66 90[ ]+xchg %ax,%ax
269+ 10f3: 90[ ]+nop
270diff --git a/ld/testsuite/ld-i386/tlspic.dd b/ld/testsuite/ld-i386/tlspic.dd
271index d85b385..ace06e6 100644
272--- a/ld/testsuite/ld-i386/tlspic.dd
273+++ b/ld/testsuite/ld-i386/tlspic.dd
274@@ -406,4 +406,5 @@ Disassembly of section .text:
275 [0-9a-f]+: 8b 5d fc[ ]+mov -0x4\(%ebp\),%ebx
276 [0-9a-f]+: c9[ ]+leave *
277 [0-9a-f]+: c3[ ]+ret *
278- [0-9a-f]+: 0f 1f 00[ ]+nopl \(%eax\)
279+ [0-9a-f]+: 66 90[ ]+xchg %ax,%ax
280+ [0-9a-f]+: 90[ ]+nop
This page took 0.136378 seconds and 4 git commands to generate.