1 |
24 |
jeremybenn |
/* 32-bit ELF support for ARM
|
2 |
|
|
Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
|
3 |
|
|
2008 Free Software Foundation, Inc.
|
4 |
|
|
|
5 |
|
|
This file is part of BFD, the Binary File Descriptor library.
|
6 |
|
|
|
7 |
|
|
This program is free software; you can redistribute it and/or modify
|
8 |
|
|
it under the terms of the GNU General Public License as published by
|
9 |
|
|
the Free Software Foundation; either version 3 of the License, or
|
10 |
|
|
(at your option) any later version.
|
11 |
|
|
|
12 |
|
|
This program is distributed in the hope that it will be useful,
|
13 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
|
|
GNU General Public License for more details.
|
16 |
|
|
|
17 |
|
|
You should have received a copy of the GNU General Public License
|
18 |
|
|
along with this program; if not, write to the Free Software
|
19 |
|
|
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
20 |
|
|
MA 02110-1301, USA. */
|
21 |
|
|
|
22 |
|
|
#include "sysdep.h"
|
23 |
|
|
#include "bfd.h"
|
24 |
|
|
#include "libiberty.h"
|
25 |
|
|
#include "libbfd.h"
|
26 |
|
|
#include "elf-bfd.h"
|
27 |
|
|
#include "elf-vxworks.h"
|
28 |
|
|
#include "elf/arm.h"
|
29 |
|
|
|
30 |
|
|
#ifndef NUM_ELEM
|
31 |
|
|
#define NUM_ELEM(a) (sizeof (a) / (sizeof (a)[0]))
|
32 |
|
|
#endif
|
33 |
|
|
|
34 |
|
|
/* Return the relocation section associated with NAME. HTAB is the
|
35 |
|
|
bfd's elf32_arm_link_hash_entry. */
|
36 |
|
|
#define RELOC_SECTION(HTAB, NAME) \
|
37 |
|
|
((HTAB)->use_rel ? ".rel" NAME : ".rela" NAME)
|
38 |
|
|
|
39 |
|
|
/* Return size of a relocation entry. HTAB is the bfd's
|
40 |
|
|
elf32_arm_link_hash_entry. */
|
41 |
|
|
#define RELOC_SIZE(HTAB) \
|
42 |
|
|
((HTAB)->use_rel \
|
43 |
|
|
? sizeof (Elf32_External_Rel) \
|
44 |
|
|
: sizeof (Elf32_External_Rela))
|
45 |
|
|
|
46 |
|
|
/* Return function to swap relocations in. HTAB is the bfd's
|
47 |
|
|
elf32_arm_link_hash_entry. */
|
48 |
|
|
#define SWAP_RELOC_IN(HTAB) \
|
49 |
|
|
((HTAB)->use_rel \
|
50 |
|
|
? bfd_elf32_swap_reloc_in \
|
51 |
|
|
: bfd_elf32_swap_reloca_in)
|
52 |
|
|
|
53 |
|
|
/* Return function to swap relocations out. HTAB is the bfd's
|
54 |
|
|
elf32_arm_link_hash_entry. */
|
55 |
|
|
#define SWAP_RELOC_OUT(HTAB) \
|
56 |
|
|
((HTAB)->use_rel \
|
57 |
|
|
? bfd_elf32_swap_reloc_out \
|
58 |
|
|
: bfd_elf32_swap_reloca_out)
|
59 |
|
|
|
60 |
|
|
#define elf_info_to_howto 0
|
61 |
|
|
#define elf_info_to_howto_rel elf32_arm_info_to_howto
|
62 |
|
|
|
63 |
|
|
#define ARM_ELF_ABI_VERSION 0
|
64 |
|
|
#define ARM_ELF_OS_ABI_VERSION ELFOSABI_ARM
|
65 |
|
|
|
66 |
|
|
static struct elf_backend_data elf32_arm_vxworks_bed;
|
67 |
|
|
|
68 |
|
|
/* Note: code such as elf32_arm_reloc_type_lookup expect to use e.g.
|
69 |
|
|
R_ARM_PC24 as an index into this, and find the R_ARM_PC24 HOWTO
|
70 |
|
|
in that slot. */
|
71 |
|
|
|
72 |
|
|
static reloc_howto_type elf32_arm_howto_table_1[] =
|
73 |
|
|
{
|
74 |
|
|
/* No relocation */
|
75 |
|
|
HOWTO (R_ARM_NONE, /* type */
|
76 |
|
|
0, /* rightshift */
|
77 |
|
|
0, /* size (0 = byte, 1 = short, 2 = long) */
|
78 |
|
|
0, /* bitsize */
|
79 |
|
|
FALSE, /* pc_relative */
|
80 |
|
|
0, /* bitpos */
|
81 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
82 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
83 |
|
|
"R_ARM_NONE", /* name */
|
84 |
|
|
FALSE, /* partial_inplace */
|
85 |
|
|
0, /* src_mask */
|
86 |
|
|
0, /* dst_mask */
|
87 |
|
|
FALSE), /* pcrel_offset */
|
88 |
|
|
|
89 |
|
|
HOWTO (R_ARM_PC24, /* type */
|
90 |
|
|
2, /* rightshift */
|
91 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
92 |
|
|
24, /* bitsize */
|
93 |
|
|
TRUE, /* pc_relative */
|
94 |
|
|
0, /* bitpos */
|
95 |
|
|
complain_overflow_signed,/* complain_on_overflow */
|
96 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
97 |
|
|
"R_ARM_PC24", /* name */
|
98 |
|
|
FALSE, /* partial_inplace */
|
99 |
|
|
0x00ffffff, /* src_mask */
|
100 |
|
|
0x00ffffff, /* dst_mask */
|
101 |
|
|
TRUE), /* pcrel_offset */
|
102 |
|
|
|
103 |
|
|
/* 32 bit absolute */
|
104 |
|
|
HOWTO (R_ARM_ABS32, /* type */
|
105 |
|
|
0, /* rightshift */
|
106 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
107 |
|
|
32, /* bitsize */
|
108 |
|
|
FALSE, /* pc_relative */
|
109 |
|
|
0, /* bitpos */
|
110 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
111 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
112 |
|
|
"R_ARM_ABS32", /* name */
|
113 |
|
|
FALSE, /* partial_inplace */
|
114 |
|
|
0xffffffff, /* src_mask */
|
115 |
|
|
0xffffffff, /* dst_mask */
|
116 |
|
|
FALSE), /* pcrel_offset */
|
117 |
|
|
|
118 |
|
|
/* standard 32bit pc-relative reloc */
|
119 |
|
|
HOWTO (R_ARM_REL32, /* type */
|
120 |
|
|
0, /* rightshift */
|
121 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
122 |
|
|
32, /* bitsize */
|
123 |
|
|
TRUE, /* pc_relative */
|
124 |
|
|
0, /* bitpos */
|
125 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
126 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
127 |
|
|
"R_ARM_REL32", /* name */
|
128 |
|
|
FALSE, /* partial_inplace */
|
129 |
|
|
0xffffffff, /* src_mask */
|
130 |
|
|
0xffffffff, /* dst_mask */
|
131 |
|
|
TRUE), /* pcrel_offset */
|
132 |
|
|
|
133 |
|
|
/* 8 bit absolute - R_ARM_LDR_PC_G0 in AAELF */
|
134 |
|
|
HOWTO (R_ARM_LDR_PC_G0, /* type */
|
135 |
|
|
0, /* rightshift */
|
136 |
|
|
0, /* size (0 = byte, 1 = short, 2 = long) */
|
137 |
|
|
32, /* bitsize */
|
138 |
|
|
TRUE, /* pc_relative */
|
139 |
|
|
0, /* bitpos */
|
140 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
141 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
142 |
|
|
"R_ARM_LDR_PC_G0", /* name */
|
143 |
|
|
FALSE, /* partial_inplace */
|
144 |
|
|
0xffffffff, /* src_mask */
|
145 |
|
|
0xffffffff, /* dst_mask */
|
146 |
|
|
TRUE), /* pcrel_offset */
|
147 |
|
|
|
148 |
|
|
/* 16 bit absolute */
|
149 |
|
|
HOWTO (R_ARM_ABS16, /* type */
|
150 |
|
|
0, /* rightshift */
|
151 |
|
|
1, /* size (0 = byte, 1 = short, 2 = long) */
|
152 |
|
|
16, /* bitsize */
|
153 |
|
|
FALSE, /* pc_relative */
|
154 |
|
|
0, /* bitpos */
|
155 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
156 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
157 |
|
|
"R_ARM_ABS16", /* name */
|
158 |
|
|
FALSE, /* partial_inplace */
|
159 |
|
|
0x0000ffff, /* src_mask */
|
160 |
|
|
0x0000ffff, /* dst_mask */
|
161 |
|
|
FALSE), /* pcrel_offset */
|
162 |
|
|
|
163 |
|
|
/* 12 bit absolute */
|
164 |
|
|
HOWTO (R_ARM_ABS12, /* type */
|
165 |
|
|
0, /* rightshift */
|
166 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
167 |
|
|
12, /* bitsize */
|
168 |
|
|
FALSE, /* pc_relative */
|
169 |
|
|
0, /* bitpos */
|
170 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
171 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
172 |
|
|
"R_ARM_ABS12", /* name */
|
173 |
|
|
FALSE, /* partial_inplace */
|
174 |
|
|
0x00000fff, /* src_mask */
|
175 |
|
|
0x00000fff, /* dst_mask */
|
176 |
|
|
FALSE), /* pcrel_offset */
|
177 |
|
|
|
178 |
|
|
HOWTO (R_ARM_THM_ABS5, /* type */
|
179 |
|
|
6, /* rightshift */
|
180 |
|
|
1, /* size (0 = byte, 1 = short, 2 = long) */
|
181 |
|
|
5, /* bitsize */
|
182 |
|
|
FALSE, /* pc_relative */
|
183 |
|
|
0, /* bitpos */
|
184 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
185 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
186 |
|
|
"R_ARM_THM_ABS5", /* name */
|
187 |
|
|
FALSE, /* partial_inplace */
|
188 |
|
|
0x000007e0, /* src_mask */
|
189 |
|
|
0x000007e0, /* dst_mask */
|
190 |
|
|
FALSE), /* pcrel_offset */
|
191 |
|
|
|
192 |
|
|
/* 8 bit absolute */
|
193 |
|
|
HOWTO (R_ARM_ABS8, /* type */
|
194 |
|
|
0, /* rightshift */
|
195 |
|
|
0, /* size (0 = byte, 1 = short, 2 = long) */
|
196 |
|
|
8, /* bitsize */
|
197 |
|
|
FALSE, /* pc_relative */
|
198 |
|
|
0, /* bitpos */
|
199 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
200 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
201 |
|
|
"R_ARM_ABS8", /* name */
|
202 |
|
|
FALSE, /* partial_inplace */
|
203 |
|
|
0x000000ff, /* src_mask */
|
204 |
|
|
0x000000ff, /* dst_mask */
|
205 |
|
|
FALSE), /* pcrel_offset */
|
206 |
|
|
|
207 |
|
|
HOWTO (R_ARM_SBREL32, /* type */
|
208 |
|
|
0, /* rightshift */
|
209 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
210 |
|
|
32, /* bitsize */
|
211 |
|
|
FALSE, /* pc_relative */
|
212 |
|
|
0, /* bitpos */
|
213 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
214 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
215 |
|
|
"R_ARM_SBREL32", /* name */
|
216 |
|
|
FALSE, /* partial_inplace */
|
217 |
|
|
0xffffffff, /* src_mask */
|
218 |
|
|
0xffffffff, /* dst_mask */
|
219 |
|
|
FALSE), /* pcrel_offset */
|
220 |
|
|
|
221 |
|
|
HOWTO (R_ARM_THM_CALL, /* type */
|
222 |
|
|
1, /* rightshift */
|
223 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
224 |
|
|
25, /* bitsize */
|
225 |
|
|
TRUE, /* pc_relative */
|
226 |
|
|
0, /* bitpos */
|
227 |
|
|
complain_overflow_signed,/* complain_on_overflow */
|
228 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
229 |
|
|
"R_ARM_THM_CALL", /* name */
|
230 |
|
|
FALSE, /* partial_inplace */
|
231 |
|
|
0x07ff07ff, /* src_mask */
|
232 |
|
|
0x07ff07ff, /* dst_mask */
|
233 |
|
|
TRUE), /* pcrel_offset */
|
234 |
|
|
|
235 |
|
|
HOWTO (R_ARM_THM_PC8, /* type */
|
236 |
|
|
1, /* rightshift */
|
237 |
|
|
1, /* size (0 = byte, 1 = short, 2 = long) */
|
238 |
|
|
8, /* bitsize */
|
239 |
|
|
TRUE, /* pc_relative */
|
240 |
|
|
0, /* bitpos */
|
241 |
|
|
complain_overflow_signed,/* complain_on_overflow */
|
242 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
243 |
|
|
"R_ARM_THM_PC8", /* name */
|
244 |
|
|
FALSE, /* partial_inplace */
|
245 |
|
|
0x000000ff, /* src_mask */
|
246 |
|
|
0x000000ff, /* dst_mask */
|
247 |
|
|
TRUE), /* pcrel_offset */
|
248 |
|
|
|
249 |
|
|
HOWTO (R_ARM_BREL_ADJ, /* type */
|
250 |
|
|
1, /* rightshift */
|
251 |
|
|
1, /* size (0 = byte, 1 = short, 2 = long) */
|
252 |
|
|
32, /* bitsize */
|
253 |
|
|
FALSE, /* pc_relative */
|
254 |
|
|
0, /* bitpos */
|
255 |
|
|
complain_overflow_signed,/* complain_on_overflow */
|
256 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
257 |
|
|
"R_ARM_BREL_ADJ", /* name */
|
258 |
|
|
FALSE, /* partial_inplace */
|
259 |
|
|
0xffffffff, /* src_mask */
|
260 |
|
|
0xffffffff, /* dst_mask */
|
261 |
|
|
FALSE), /* pcrel_offset */
|
262 |
|
|
|
263 |
|
|
HOWTO (R_ARM_SWI24, /* type */
|
264 |
|
|
0, /* rightshift */
|
265 |
|
|
0, /* size (0 = byte, 1 = short, 2 = long) */
|
266 |
|
|
0, /* bitsize */
|
267 |
|
|
FALSE, /* pc_relative */
|
268 |
|
|
0, /* bitpos */
|
269 |
|
|
complain_overflow_signed,/* complain_on_overflow */
|
270 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
271 |
|
|
"R_ARM_SWI24", /* name */
|
272 |
|
|
FALSE, /* partial_inplace */
|
273 |
|
|
0x00000000, /* src_mask */
|
274 |
|
|
0x00000000, /* dst_mask */
|
275 |
|
|
FALSE), /* pcrel_offset */
|
276 |
|
|
|
277 |
|
|
HOWTO (R_ARM_THM_SWI8, /* type */
|
278 |
|
|
0, /* rightshift */
|
279 |
|
|
0, /* size (0 = byte, 1 = short, 2 = long) */
|
280 |
|
|
0, /* bitsize */
|
281 |
|
|
FALSE, /* pc_relative */
|
282 |
|
|
0, /* bitpos */
|
283 |
|
|
complain_overflow_signed,/* complain_on_overflow */
|
284 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
285 |
|
|
"R_ARM_SWI8", /* name */
|
286 |
|
|
FALSE, /* partial_inplace */
|
287 |
|
|
0x00000000, /* src_mask */
|
288 |
|
|
0x00000000, /* dst_mask */
|
289 |
|
|
FALSE), /* pcrel_offset */
|
290 |
|
|
|
291 |
|
|
/* BLX instruction for the ARM. */
|
292 |
|
|
HOWTO (R_ARM_XPC25, /* type */
|
293 |
|
|
2, /* rightshift */
|
294 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
295 |
|
|
25, /* bitsize */
|
296 |
|
|
TRUE, /* pc_relative */
|
297 |
|
|
0, /* bitpos */
|
298 |
|
|
complain_overflow_signed,/* complain_on_overflow */
|
299 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
300 |
|
|
"R_ARM_XPC25", /* name */
|
301 |
|
|
FALSE, /* partial_inplace */
|
302 |
|
|
0x00ffffff, /* src_mask */
|
303 |
|
|
0x00ffffff, /* dst_mask */
|
304 |
|
|
TRUE), /* pcrel_offset */
|
305 |
|
|
|
306 |
|
|
/* BLX instruction for the Thumb. */
|
307 |
|
|
HOWTO (R_ARM_THM_XPC22, /* type */
|
308 |
|
|
2, /* rightshift */
|
309 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
310 |
|
|
22, /* bitsize */
|
311 |
|
|
TRUE, /* pc_relative */
|
312 |
|
|
0, /* bitpos */
|
313 |
|
|
complain_overflow_signed,/* complain_on_overflow */
|
314 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
315 |
|
|
"R_ARM_THM_XPC22", /* name */
|
316 |
|
|
FALSE, /* partial_inplace */
|
317 |
|
|
0x07ff07ff, /* src_mask */
|
318 |
|
|
0x07ff07ff, /* dst_mask */
|
319 |
|
|
TRUE), /* pcrel_offset */
|
320 |
|
|
|
321 |
|
|
/* Dynamic TLS relocations. */
|
322 |
|
|
|
323 |
|
|
HOWTO (R_ARM_TLS_DTPMOD32, /* type */
|
324 |
|
|
0, /* rightshift */
|
325 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
326 |
|
|
32, /* bitsize */
|
327 |
|
|
FALSE, /* pc_relative */
|
328 |
|
|
0, /* bitpos */
|
329 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
330 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
331 |
|
|
"R_ARM_TLS_DTPMOD32", /* name */
|
332 |
|
|
TRUE, /* partial_inplace */
|
333 |
|
|
0xffffffff, /* src_mask */
|
334 |
|
|
0xffffffff, /* dst_mask */
|
335 |
|
|
FALSE), /* pcrel_offset */
|
336 |
|
|
|
337 |
|
|
HOWTO (R_ARM_TLS_DTPOFF32, /* type */
|
338 |
|
|
0, /* rightshift */
|
339 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
340 |
|
|
32, /* bitsize */
|
341 |
|
|
FALSE, /* pc_relative */
|
342 |
|
|
0, /* bitpos */
|
343 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
344 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
345 |
|
|
"R_ARM_TLS_DTPOFF32", /* name */
|
346 |
|
|
TRUE, /* partial_inplace */
|
347 |
|
|
0xffffffff, /* src_mask */
|
348 |
|
|
0xffffffff, /* dst_mask */
|
349 |
|
|
FALSE), /* pcrel_offset */
|
350 |
|
|
|
351 |
|
|
HOWTO (R_ARM_TLS_TPOFF32, /* type */
|
352 |
|
|
0, /* rightshift */
|
353 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
354 |
|
|
32, /* bitsize */
|
355 |
|
|
FALSE, /* pc_relative */
|
356 |
|
|
0, /* bitpos */
|
357 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
358 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
359 |
|
|
"R_ARM_TLS_TPOFF32", /* name */
|
360 |
|
|
TRUE, /* partial_inplace */
|
361 |
|
|
0xffffffff, /* src_mask */
|
362 |
|
|
0xffffffff, /* dst_mask */
|
363 |
|
|
FALSE), /* pcrel_offset */
|
364 |
|
|
|
365 |
|
|
/* Relocs used in ARM Linux */
|
366 |
|
|
|
367 |
|
|
HOWTO (R_ARM_COPY, /* type */
|
368 |
|
|
0, /* rightshift */
|
369 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
370 |
|
|
32, /* bitsize */
|
371 |
|
|
FALSE, /* pc_relative */
|
372 |
|
|
0, /* bitpos */
|
373 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
374 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
375 |
|
|
"R_ARM_COPY", /* name */
|
376 |
|
|
TRUE, /* partial_inplace */
|
377 |
|
|
0xffffffff, /* src_mask */
|
378 |
|
|
0xffffffff, /* dst_mask */
|
379 |
|
|
FALSE), /* pcrel_offset */
|
380 |
|
|
|
381 |
|
|
HOWTO (R_ARM_GLOB_DAT, /* type */
|
382 |
|
|
0, /* rightshift */
|
383 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
384 |
|
|
32, /* bitsize */
|
385 |
|
|
FALSE, /* pc_relative */
|
386 |
|
|
0, /* bitpos */
|
387 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
388 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
389 |
|
|
"R_ARM_GLOB_DAT", /* name */
|
390 |
|
|
TRUE, /* partial_inplace */
|
391 |
|
|
0xffffffff, /* src_mask */
|
392 |
|
|
0xffffffff, /* dst_mask */
|
393 |
|
|
FALSE), /* pcrel_offset */
|
394 |
|
|
|
395 |
|
|
HOWTO (R_ARM_JUMP_SLOT, /* type */
|
396 |
|
|
0, /* rightshift */
|
397 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
398 |
|
|
32, /* bitsize */
|
399 |
|
|
FALSE, /* pc_relative */
|
400 |
|
|
0, /* bitpos */
|
401 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
402 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
403 |
|
|
"R_ARM_JUMP_SLOT", /* name */
|
404 |
|
|
TRUE, /* partial_inplace */
|
405 |
|
|
0xffffffff, /* src_mask */
|
406 |
|
|
0xffffffff, /* dst_mask */
|
407 |
|
|
FALSE), /* pcrel_offset */
|
408 |
|
|
|
409 |
|
|
HOWTO (R_ARM_RELATIVE, /* type */
|
410 |
|
|
0, /* rightshift */
|
411 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
412 |
|
|
32, /* bitsize */
|
413 |
|
|
FALSE, /* pc_relative */
|
414 |
|
|
0, /* bitpos */
|
415 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
416 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
417 |
|
|
"R_ARM_RELATIVE", /* name */
|
418 |
|
|
TRUE, /* partial_inplace */
|
419 |
|
|
0xffffffff, /* src_mask */
|
420 |
|
|
0xffffffff, /* dst_mask */
|
421 |
|
|
FALSE), /* pcrel_offset */
|
422 |
|
|
|
423 |
|
|
HOWTO (R_ARM_GOTOFF32, /* type */
|
424 |
|
|
0, /* rightshift */
|
425 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
426 |
|
|
32, /* bitsize */
|
427 |
|
|
FALSE, /* pc_relative */
|
428 |
|
|
0, /* bitpos */
|
429 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
430 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
431 |
|
|
"R_ARM_GOTOFF32", /* name */
|
432 |
|
|
TRUE, /* partial_inplace */
|
433 |
|
|
0xffffffff, /* src_mask */
|
434 |
|
|
0xffffffff, /* dst_mask */
|
435 |
|
|
FALSE), /* pcrel_offset */
|
436 |
|
|
|
437 |
|
|
HOWTO (R_ARM_GOTPC, /* type */
|
438 |
|
|
0, /* rightshift */
|
439 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
440 |
|
|
32, /* bitsize */
|
441 |
|
|
TRUE, /* pc_relative */
|
442 |
|
|
0, /* bitpos */
|
443 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
444 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
445 |
|
|
"R_ARM_GOTPC", /* name */
|
446 |
|
|
TRUE, /* partial_inplace */
|
447 |
|
|
0xffffffff, /* src_mask */
|
448 |
|
|
0xffffffff, /* dst_mask */
|
449 |
|
|
TRUE), /* pcrel_offset */
|
450 |
|
|
|
451 |
|
|
HOWTO (R_ARM_GOT32, /* type */
|
452 |
|
|
0, /* rightshift */
|
453 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
454 |
|
|
32, /* bitsize */
|
455 |
|
|
FALSE, /* pc_relative */
|
456 |
|
|
0, /* bitpos */
|
457 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
458 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
459 |
|
|
"R_ARM_GOT32", /* name */
|
460 |
|
|
TRUE, /* partial_inplace */
|
461 |
|
|
0xffffffff, /* src_mask */
|
462 |
|
|
0xffffffff, /* dst_mask */
|
463 |
|
|
FALSE), /* pcrel_offset */
|
464 |
|
|
|
465 |
|
|
HOWTO (R_ARM_PLT32, /* type */
|
466 |
|
|
2, /* rightshift */
|
467 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
468 |
|
|
24, /* bitsize */
|
469 |
|
|
TRUE, /* pc_relative */
|
470 |
|
|
0, /* bitpos */
|
471 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
472 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
473 |
|
|
"R_ARM_PLT32", /* name */
|
474 |
|
|
FALSE, /* partial_inplace */
|
475 |
|
|
0x00ffffff, /* src_mask */
|
476 |
|
|
0x00ffffff, /* dst_mask */
|
477 |
|
|
TRUE), /* pcrel_offset */
|
478 |
|
|
|
479 |
|
|
HOWTO (R_ARM_CALL, /* type */
|
480 |
|
|
2, /* rightshift */
|
481 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
482 |
|
|
24, /* bitsize */
|
483 |
|
|
TRUE, /* pc_relative */
|
484 |
|
|
0, /* bitpos */
|
485 |
|
|
complain_overflow_signed,/* complain_on_overflow */
|
486 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
487 |
|
|
"R_ARM_CALL", /* name */
|
488 |
|
|
FALSE, /* partial_inplace */
|
489 |
|
|
0x00ffffff, /* src_mask */
|
490 |
|
|
0x00ffffff, /* dst_mask */
|
491 |
|
|
TRUE), /* pcrel_offset */
|
492 |
|
|
|
493 |
|
|
HOWTO (R_ARM_JUMP24, /* type */
|
494 |
|
|
2, /* rightshift */
|
495 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
496 |
|
|
24, /* bitsize */
|
497 |
|
|
TRUE, /* pc_relative */
|
498 |
|
|
0, /* bitpos */
|
499 |
|
|
complain_overflow_signed,/* complain_on_overflow */
|
500 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
501 |
|
|
"R_ARM_JUMP24", /* name */
|
502 |
|
|
FALSE, /* partial_inplace */
|
503 |
|
|
0x00ffffff, /* src_mask */
|
504 |
|
|
0x00ffffff, /* dst_mask */
|
505 |
|
|
TRUE), /* pcrel_offset */
|
506 |
|
|
|
507 |
|
|
HOWTO (R_ARM_THM_JUMP24, /* type */
|
508 |
|
|
1, /* rightshift */
|
509 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
510 |
|
|
24, /* bitsize */
|
511 |
|
|
TRUE, /* pc_relative */
|
512 |
|
|
0, /* bitpos */
|
513 |
|
|
complain_overflow_signed,/* complain_on_overflow */
|
514 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
515 |
|
|
"R_ARM_THM_JUMP24", /* name */
|
516 |
|
|
FALSE, /* partial_inplace */
|
517 |
|
|
0x07ff2fff, /* src_mask */
|
518 |
|
|
0x07ff2fff, /* dst_mask */
|
519 |
|
|
TRUE), /* pcrel_offset */
|
520 |
|
|
|
521 |
|
|
HOWTO (R_ARM_BASE_ABS, /* type */
|
522 |
|
|
0, /* rightshift */
|
523 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
524 |
|
|
32, /* bitsize */
|
525 |
|
|
FALSE, /* pc_relative */
|
526 |
|
|
0, /* bitpos */
|
527 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
528 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
529 |
|
|
"R_ARM_BASE_ABS", /* name */
|
530 |
|
|
FALSE, /* partial_inplace */
|
531 |
|
|
0xffffffff, /* src_mask */
|
532 |
|
|
0xffffffff, /* dst_mask */
|
533 |
|
|
FALSE), /* pcrel_offset */
|
534 |
|
|
|
535 |
|
|
HOWTO (R_ARM_ALU_PCREL7_0, /* type */
|
536 |
|
|
0, /* rightshift */
|
537 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
538 |
|
|
12, /* bitsize */
|
539 |
|
|
TRUE, /* pc_relative */
|
540 |
|
|
0, /* bitpos */
|
541 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
542 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
543 |
|
|
"R_ARM_ALU_PCREL_7_0", /* name */
|
544 |
|
|
FALSE, /* partial_inplace */
|
545 |
|
|
0x00000fff, /* src_mask */
|
546 |
|
|
0x00000fff, /* dst_mask */
|
547 |
|
|
TRUE), /* pcrel_offset */
|
548 |
|
|
|
549 |
|
|
HOWTO (R_ARM_ALU_PCREL15_8, /* type */
|
550 |
|
|
0, /* rightshift */
|
551 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
552 |
|
|
12, /* bitsize */
|
553 |
|
|
TRUE, /* pc_relative */
|
554 |
|
|
8, /* bitpos */
|
555 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
556 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
557 |
|
|
"R_ARM_ALU_PCREL_15_8",/* name */
|
558 |
|
|
FALSE, /* partial_inplace */
|
559 |
|
|
0x00000fff, /* src_mask */
|
560 |
|
|
0x00000fff, /* dst_mask */
|
561 |
|
|
TRUE), /* pcrel_offset */
|
562 |
|
|
|
563 |
|
|
HOWTO (R_ARM_ALU_PCREL23_15, /* type */
|
564 |
|
|
0, /* rightshift */
|
565 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
566 |
|
|
12, /* bitsize */
|
567 |
|
|
TRUE, /* pc_relative */
|
568 |
|
|
16, /* bitpos */
|
569 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
570 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
571 |
|
|
"R_ARM_ALU_PCREL_23_15",/* name */
|
572 |
|
|
FALSE, /* partial_inplace */
|
573 |
|
|
0x00000fff, /* src_mask */
|
574 |
|
|
0x00000fff, /* dst_mask */
|
575 |
|
|
TRUE), /* pcrel_offset */
|
576 |
|
|
|
577 |
|
|
HOWTO (R_ARM_LDR_SBREL_11_0, /* type */
|
578 |
|
|
0, /* rightshift */
|
579 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
580 |
|
|
12, /* bitsize */
|
581 |
|
|
FALSE, /* pc_relative */
|
582 |
|
|
0, /* bitpos */
|
583 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
584 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
585 |
|
|
"R_ARM_LDR_SBREL_11_0",/* name */
|
586 |
|
|
FALSE, /* partial_inplace */
|
587 |
|
|
0x00000fff, /* src_mask */
|
588 |
|
|
0x00000fff, /* dst_mask */
|
589 |
|
|
FALSE), /* pcrel_offset */
|
590 |
|
|
|
591 |
|
|
HOWTO (R_ARM_ALU_SBREL_19_12, /* type */
|
592 |
|
|
0, /* rightshift */
|
593 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
594 |
|
|
8, /* bitsize */
|
595 |
|
|
FALSE, /* pc_relative */
|
596 |
|
|
12, /* bitpos */
|
597 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
598 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
599 |
|
|
"R_ARM_ALU_SBREL_19_12",/* name */
|
600 |
|
|
FALSE, /* partial_inplace */
|
601 |
|
|
0x000ff000, /* src_mask */
|
602 |
|
|
0x000ff000, /* dst_mask */
|
603 |
|
|
FALSE), /* pcrel_offset */
|
604 |
|
|
|
605 |
|
|
HOWTO (R_ARM_ALU_SBREL_27_20, /* type */
|
606 |
|
|
0, /* rightshift */
|
607 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
608 |
|
|
8, /* bitsize */
|
609 |
|
|
FALSE, /* pc_relative */
|
610 |
|
|
20, /* bitpos */
|
611 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
612 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
613 |
|
|
"R_ARM_ALU_SBREL_27_20",/* name */
|
614 |
|
|
FALSE, /* partial_inplace */
|
615 |
|
|
0x0ff00000, /* src_mask */
|
616 |
|
|
0x0ff00000, /* dst_mask */
|
617 |
|
|
FALSE), /* pcrel_offset */
|
618 |
|
|
|
619 |
|
|
HOWTO (R_ARM_TARGET1, /* type */
|
620 |
|
|
0, /* rightshift */
|
621 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
622 |
|
|
32, /* bitsize */
|
623 |
|
|
FALSE, /* pc_relative */
|
624 |
|
|
0, /* bitpos */
|
625 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
626 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
627 |
|
|
"R_ARM_TARGET1", /* name */
|
628 |
|
|
FALSE, /* partial_inplace */
|
629 |
|
|
0xffffffff, /* src_mask */
|
630 |
|
|
0xffffffff, /* dst_mask */
|
631 |
|
|
FALSE), /* pcrel_offset */
|
632 |
|
|
|
633 |
|
|
HOWTO (R_ARM_ROSEGREL32, /* type */
|
634 |
|
|
0, /* rightshift */
|
635 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
636 |
|
|
32, /* bitsize */
|
637 |
|
|
FALSE, /* pc_relative */
|
638 |
|
|
0, /* bitpos */
|
639 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
640 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
641 |
|
|
"R_ARM_ROSEGREL32", /* name */
|
642 |
|
|
FALSE, /* partial_inplace */
|
643 |
|
|
0xffffffff, /* src_mask */
|
644 |
|
|
0xffffffff, /* dst_mask */
|
645 |
|
|
FALSE), /* pcrel_offset */
|
646 |
|
|
|
647 |
|
|
HOWTO (R_ARM_V4BX, /* type */
|
648 |
|
|
0, /* rightshift */
|
649 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
650 |
|
|
32, /* bitsize */
|
651 |
|
|
FALSE, /* pc_relative */
|
652 |
|
|
0, /* bitpos */
|
653 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
654 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
655 |
|
|
"R_ARM_V4BX", /* name */
|
656 |
|
|
FALSE, /* partial_inplace */
|
657 |
|
|
0xffffffff, /* src_mask */
|
658 |
|
|
0xffffffff, /* dst_mask */
|
659 |
|
|
FALSE), /* pcrel_offset */
|
660 |
|
|
|
661 |
|
|
HOWTO (R_ARM_TARGET2, /* type */
|
662 |
|
|
0, /* rightshift */
|
663 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
664 |
|
|
32, /* bitsize */
|
665 |
|
|
FALSE, /* pc_relative */
|
666 |
|
|
0, /* bitpos */
|
667 |
|
|
complain_overflow_signed,/* complain_on_overflow */
|
668 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
669 |
|
|
"R_ARM_TARGET2", /* name */
|
670 |
|
|
FALSE, /* partial_inplace */
|
671 |
|
|
0xffffffff, /* src_mask */
|
672 |
|
|
0xffffffff, /* dst_mask */
|
673 |
|
|
TRUE), /* pcrel_offset */
|
674 |
|
|
|
675 |
|
|
HOWTO (R_ARM_PREL31, /* type */
|
676 |
|
|
0, /* rightshift */
|
677 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
678 |
|
|
31, /* bitsize */
|
679 |
|
|
TRUE, /* pc_relative */
|
680 |
|
|
0, /* bitpos */
|
681 |
|
|
complain_overflow_signed,/* complain_on_overflow */
|
682 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
683 |
|
|
"R_ARM_PREL31", /* name */
|
684 |
|
|
FALSE, /* partial_inplace */
|
685 |
|
|
0x7fffffff, /* src_mask */
|
686 |
|
|
0x7fffffff, /* dst_mask */
|
687 |
|
|
TRUE), /* pcrel_offset */
|
688 |
|
|
|
689 |
|
|
HOWTO (R_ARM_MOVW_ABS_NC, /* type */
|
690 |
|
|
0, /* rightshift */
|
691 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
692 |
|
|
16, /* bitsize */
|
693 |
|
|
FALSE, /* pc_relative */
|
694 |
|
|
0, /* bitpos */
|
695 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
696 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
697 |
|
|
"R_ARM_MOVW_ABS_NC", /* name */
|
698 |
|
|
FALSE, /* partial_inplace */
|
699 |
|
|
0x0000ffff, /* src_mask */
|
700 |
|
|
0x0000ffff, /* dst_mask */
|
701 |
|
|
FALSE), /* pcrel_offset */
|
702 |
|
|
|
703 |
|
|
HOWTO (R_ARM_MOVT_ABS, /* type */
|
704 |
|
|
0, /* rightshift */
|
705 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
706 |
|
|
16, /* bitsize */
|
707 |
|
|
FALSE, /* pc_relative */
|
708 |
|
|
0, /* bitpos */
|
709 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
710 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
711 |
|
|
"R_ARM_MOVT_ABS", /* name */
|
712 |
|
|
FALSE, /* partial_inplace */
|
713 |
|
|
0x0000ffff, /* src_mask */
|
714 |
|
|
0x0000ffff, /* dst_mask */
|
715 |
|
|
FALSE), /* pcrel_offset */
|
716 |
|
|
|
717 |
|
|
HOWTO (R_ARM_MOVW_PREL_NC, /* type */
|
718 |
|
|
0, /* rightshift */
|
719 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
720 |
|
|
16, /* bitsize */
|
721 |
|
|
TRUE, /* pc_relative */
|
722 |
|
|
0, /* bitpos */
|
723 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
724 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
725 |
|
|
"R_ARM_MOVW_PREL_NC", /* name */
|
726 |
|
|
FALSE, /* partial_inplace */
|
727 |
|
|
0x0000ffff, /* src_mask */
|
728 |
|
|
0x0000ffff, /* dst_mask */
|
729 |
|
|
TRUE), /* pcrel_offset */
|
730 |
|
|
|
731 |
|
|
HOWTO (R_ARM_MOVT_PREL, /* type */
|
732 |
|
|
0, /* rightshift */
|
733 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
734 |
|
|
16, /* bitsize */
|
735 |
|
|
TRUE, /* pc_relative */
|
736 |
|
|
0, /* bitpos */
|
737 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
738 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
739 |
|
|
"R_ARM_MOVT_PREL", /* name */
|
740 |
|
|
FALSE, /* partial_inplace */
|
741 |
|
|
0x0000ffff, /* src_mask */
|
742 |
|
|
0x0000ffff, /* dst_mask */
|
743 |
|
|
TRUE), /* pcrel_offset */
|
744 |
|
|
|
745 |
|
|
HOWTO (R_ARM_THM_MOVW_ABS_NC, /* type */
|
746 |
|
|
0, /* rightshift */
|
747 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
748 |
|
|
16, /* bitsize */
|
749 |
|
|
FALSE, /* pc_relative */
|
750 |
|
|
0, /* bitpos */
|
751 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
752 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
753 |
|
|
"R_ARM_THM_MOVW_ABS_NC",/* name */
|
754 |
|
|
FALSE, /* partial_inplace */
|
755 |
|
|
0x040f70ff, /* src_mask */
|
756 |
|
|
0x040f70ff, /* dst_mask */
|
757 |
|
|
FALSE), /* pcrel_offset */
|
758 |
|
|
|
759 |
|
|
HOWTO (R_ARM_THM_MOVT_ABS, /* type */
|
760 |
|
|
0, /* rightshift */
|
761 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
762 |
|
|
16, /* bitsize */
|
763 |
|
|
FALSE, /* pc_relative */
|
764 |
|
|
0, /* bitpos */
|
765 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
766 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
767 |
|
|
"R_ARM_THM_MOVT_ABS", /* name */
|
768 |
|
|
FALSE, /* partial_inplace */
|
769 |
|
|
0x040f70ff, /* src_mask */
|
770 |
|
|
0x040f70ff, /* dst_mask */
|
771 |
|
|
FALSE), /* pcrel_offset */
|
772 |
|
|
|
773 |
|
|
HOWTO (R_ARM_THM_MOVW_PREL_NC,/* type */
|
774 |
|
|
0, /* rightshift */
|
775 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
776 |
|
|
16, /* bitsize */
|
777 |
|
|
TRUE, /* pc_relative */
|
778 |
|
|
0, /* bitpos */
|
779 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
780 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
781 |
|
|
"R_ARM_THM_MOVW_PREL_NC",/* name */
|
782 |
|
|
FALSE, /* partial_inplace */
|
783 |
|
|
0x040f70ff, /* src_mask */
|
784 |
|
|
0x040f70ff, /* dst_mask */
|
785 |
|
|
TRUE), /* pcrel_offset */
|
786 |
|
|
|
787 |
|
|
HOWTO (R_ARM_THM_MOVT_PREL, /* type */
|
788 |
|
|
0, /* rightshift */
|
789 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
790 |
|
|
16, /* bitsize */
|
791 |
|
|
TRUE, /* pc_relative */
|
792 |
|
|
0, /* bitpos */
|
793 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
794 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
795 |
|
|
"R_ARM_THM_MOVT_PREL", /* name */
|
796 |
|
|
FALSE, /* partial_inplace */
|
797 |
|
|
0x040f70ff, /* src_mask */
|
798 |
|
|
0x040f70ff, /* dst_mask */
|
799 |
|
|
TRUE), /* pcrel_offset */
|
800 |
|
|
|
801 |
|
|
HOWTO (R_ARM_THM_JUMP19, /* type */
|
802 |
|
|
1, /* rightshift */
|
803 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
804 |
|
|
19, /* bitsize */
|
805 |
|
|
TRUE, /* pc_relative */
|
806 |
|
|
0, /* bitpos */
|
807 |
|
|
complain_overflow_signed,/* complain_on_overflow */
|
808 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
809 |
|
|
"R_ARM_THM_JUMP19", /* name */
|
810 |
|
|
FALSE, /* partial_inplace */
|
811 |
|
|
0x043f2fff, /* src_mask */
|
812 |
|
|
0x043f2fff, /* dst_mask */
|
813 |
|
|
TRUE), /* pcrel_offset */
|
814 |
|
|
|
815 |
|
|
HOWTO (R_ARM_THM_JUMP6, /* type */
|
816 |
|
|
1, /* rightshift */
|
817 |
|
|
1, /* size (0 = byte, 1 = short, 2 = long) */
|
818 |
|
|
6, /* bitsize */
|
819 |
|
|
TRUE, /* pc_relative */
|
820 |
|
|
0, /* bitpos */
|
821 |
|
|
complain_overflow_unsigned,/* complain_on_overflow */
|
822 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
823 |
|
|
"R_ARM_THM_JUMP6", /* name */
|
824 |
|
|
FALSE, /* partial_inplace */
|
825 |
|
|
0x02f8, /* src_mask */
|
826 |
|
|
0x02f8, /* dst_mask */
|
827 |
|
|
TRUE), /* pcrel_offset */
|
828 |
|
|
|
829 |
|
|
/* These are declared as 13-bit signed relocations because we can
|
830 |
|
|
address -4095 .. 4095(base) by altering ADDW to SUBW or vice
|
831 |
|
|
versa. */
|
832 |
|
|
HOWTO (R_ARM_THM_ALU_PREL_11_0,/* type */
|
833 |
|
|
0, /* rightshift */
|
834 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
835 |
|
|
13, /* bitsize */
|
836 |
|
|
TRUE, /* pc_relative */
|
837 |
|
|
0, /* bitpos */
|
838 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
839 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
840 |
|
|
"R_ARM_THM_ALU_PREL_11_0",/* name */
|
841 |
|
|
FALSE, /* partial_inplace */
|
842 |
|
|
0xffffffff, /* src_mask */
|
843 |
|
|
0xffffffff, /* dst_mask */
|
844 |
|
|
TRUE), /* pcrel_offset */
|
845 |
|
|
|
846 |
|
|
HOWTO (R_ARM_THM_PC12, /* type */
|
847 |
|
|
0, /* rightshift */
|
848 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
849 |
|
|
13, /* bitsize */
|
850 |
|
|
TRUE, /* pc_relative */
|
851 |
|
|
0, /* bitpos */
|
852 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
853 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
854 |
|
|
"R_ARM_THM_PC12", /* name */
|
855 |
|
|
FALSE, /* partial_inplace */
|
856 |
|
|
0xffffffff, /* src_mask */
|
857 |
|
|
0xffffffff, /* dst_mask */
|
858 |
|
|
TRUE), /* pcrel_offset */
|
859 |
|
|
|
860 |
|
|
HOWTO (R_ARM_ABS32_NOI, /* type */
|
861 |
|
|
0, /* rightshift */
|
862 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
863 |
|
|
32, /* bitsize */
|
864 |
|
|
FALSE, /* pc_relative */
|
865 |
|
|
0, /* bitpos */
|
866 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
867 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
868 |
|
|
"R_ARM_ABS32_NOI", /* name */
|
869 |
|
|
FALSE, /* partial_inplace */
|
870 |
|
|
0xffffffff, /* src_mask */
|
871 |
|
|
0xffffffff, /* dst_mask */
|
872 |
|
|
FALSE), /* pcrel_offset */
|
873 |
|
|
|
874 |
|
|
HOWTO (R_ARM_REL32_NOI, /* type */
|
875 |
|
|
0, /* rightshift */
|
876 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
877 |
|
|
32, /* bitsize */
|
878 |
|
|
TRUE, /* pc_relative */
|
879 |
|
|
0, /* bitpos */
|
880 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
881 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
882 |
|
|
"R_ARM_REL32_NOI", /* name */
|
883 |
|
|
FALSE, /* partial_inplace */
|
884 |
|
|
0xffffffff, /* src_mask */
|
885 |
|
|
0xffffffff, /* dst_mask */
|
886 |
|
|
FALSE), /* pcrel_offset */
|
887 |
|
|
|
888 |
|
|
/* Group relocations. */
|
889 |
|
|
|
890 |
|
|
HOWTO (R_ARM_ALU_PC_G0_NC, /* type */
|
891 |
|
|
0, /* rightshift */
|
892 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
893 |
|
|
32, /* bitsize */
|
894 |
|
|
TRUE, /* pc_relative */
|
895 |
|
|
0, /* bitpos */
|
896 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
897 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
898 |
|
|
"R_ARM_ALU_PC_G0_NC", /* name */
|
899 |
|
|
FALSE, /* partial_inplace */
|
900 |
|
|
0xffffffff, /* src_mask */
|
901 |
|
|
0xffffffff, /* dst_mask */
|
902 |
|
|
TRUE), /* pcrel_offset */
|
903 |
|
|
|
904 |
|
|
HOWTO (R_ARM_ALU_PC_G0, /* type */
|
905 |
|
|
0, /* rightshift */
|
906 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
907 |
|
|
32, /* bitsize */
|
908 |
|
|
TRUE, /* pc_relative */
|
909 |
|
|
0, /* bitpos */
|
910 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
911 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
912 |
|
|
"R_ARM_ALU_PC_G0", /* name */
|
913 |
|
|
FALSE, /* partial_inplace */
|
914 |
|
|
0xffffffff, /* src_mask */
|
915 |
|
|
0xffffffff, /* dst_mask */
|
916 |
|
|
TRUE), /* pcrel_offset */
|
917 |
|
|
|
918 |
|
|
HOWTO (R_ARM_ALU_PC_G1_NC, /* type */
|
919 |
|
|
0, /* rightshift */
|
920 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
921 |
|
|
32, /* bitsize */
|
922 |
|
|
TRUE, /* pc_relative */
|
923 |
|
|
0, /* bitpos */
|
924 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
925 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
926 |
|
|
"R_ARM_ALU_PC_G1_NC", /* name */
|
927 |
|
|
FALSE, /* partial_inplace */
|
928 |
|
|
0xffffffff, /* src_mask */
|
929 |
|
|
0xffffffff, /* dst_mask */
|
930 |
|
|
TRUE), /* pcrel_offset */
|
931 |
|
|
|
932 |
|
|
HOWTO (R_ARM_ALU_PC_G1, /* type */
|
933 |
|
|
0, /* rightshift */
|
934 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
935 |
|
|
32, /* bitsize */
|
936 |
|
|
TRUE, /* pc_relative */
|
937 |
|
|
0, /* bitpos */
|
938 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
939 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
940 |
|
|
"R_ARM_ALU_PC_G1", /* name */
|
941 |
|
|
FALSE, /* partial_inplace */
|
942 |
|
|
0xffffffff, /* src_mask */
|
943 |
|
|
0xffffffff, /* dst_mask */
|
944 |
|
|
TRUE), /* pcrel_offset */
|
945 |
|
|
|
946 |
|
|
HOWTO (R_ARM_ALU_PC_G2, /* type */
|
947 |
|
|
0, /* rightshift */
|
948 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
949 |
|
|
32, /* bitsize */
|
950 |
|
|
TRUE, /* pc_relative */
|
951 |
|
|
0, /* bitpos */
|
952 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
953 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
954 |
|
|
"R_ARM_ALU_PC_G2", /* name */
|
955 |
|
|
FALSE, /* partial_inplace */
|
956 |
|
|
0xffffffff, /* src_mask */
|
957 |
|
|
0xffffffff, /* dst_mask */
|
958 |
|
|
TRUE), /* pcrel_offset */
|
959 |
|
|
|
960 |
|
|
HOWTO (R_ARM_LDR_PC_G1, /* type */
|
961 |
|
|
0, /* rightshift */
|
962 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
963 |
|
|
32, /* bitsize */
|
964 |
|
|
TRUE, /* pc_relative */
|
965 |
|
|
0, /* bitpos */
|
966 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
967 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
968 |
|
|
"R_ARM_LDR_PC_G1", /* name */
|
969 |
|
|
FALSE, /* partial_inplace */
|
970 |
|
|
0xffffffff, /* src_mask */
|
971 |
|
|
0xffffffff, /* dst_mask */
|
972 |
|
|
TRUE), /* pcrel_offset */
|
973 |
|
|
|
974 |
|
|
HOWTO (R_ARM_LDR_PC_G2, /* type */
|
975 |
|
|
0, /* rightshift */
|
976 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
977 |
|
|
32, /* bitsize */
|
978 |
|
|
TRUE, /* pc_relative */
|
979 |
|
|
0, /* bitpos */
|
980 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
981 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
982 |
|
|
"R_ARM_LDR_PC_G2", /* name */
|
983 |
|
|
FALSE, /* partial_inplace */
|
984 |
|
|
0xffffffff, /* src_mask */
|
985 |
|
|
0xffffffff, /* dst_mask */
|
986 |
|
|
TRUE), /* pcrel_offset */
|
987 |
|
|
|
988 |
|
|
HOWTO (R_ARM_LDRS_PC_G0, /* type */
|
989 |
|
|
0, /* rightshift */
|
990 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
991 |
|
|
32, /* bitsize */
|
992 |
|
|
TRUE, /* pc_relative */
|
993 |
|
|
0, /* bitpos */
|
994 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
995 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
996 |
|
|
"R_ARM_LDRS_PC_G0", /* name */
|
997 |
|
|
FALSE, /* partial_inplace */
|
998 |
|
|
0xffffffff, /* src_mask */
|
999 |
|
|
0xffffffff, /* dst_mask */
|
1000 |
|
|
TRUE), /* pcrel_offset */
|
1001 |
|
|
|
1002 |
|
|
HOWTO (R_ARM_LDRS_PC_G1, /* type */
|
1003 |
|
|
0, /* rightshift */
|
1004 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1005 |
|
|
32, /* bitsize */
|
1006 |
|
|
TRUE, /* pc_relative */
|
1007 |
|
|
0, /* bitpos */
|
1008 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
1009 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1010 |
|
|
"R_ARM_LDRS_PC_G1", /* name */
|
1011 |
|
|
FALSE, /* partial_inplace */
|
1012 |
|
|
0xffffffff, /* src_mask */
|
1013 |
|
|
0xffffffff, /* dst_mask */
|
1014 |
|
|
TRUE), /* pcrel_offset */
|
1015 |
|
|
|
1016 |
|
|
HOWTO (R_ARM_LDRS_PC_G2, /* type */
|
1017 |
|
|
0, /* rightshift */
|
1018 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1019 |
|
|
32, /* bitsize */
|
1020 |
|
|
TRUE, /* pc_relative */
|
1021 |
|
|
0, /* bitpos */
|
1022 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
1023 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1024 |
|
|
"R_ARM_LDRS_PC_G2", /* name */
|
1025 |
|
|
FALSE, /* partial_inplace */
|
1026 |
|
|
0xffffffff, /* src_mask */
|
1027 |
|
|
0xffffffff, /* dst_mask */
|
1028 |
|
|
TRUE), /* pcrel_offset */
|
1029 |
|
|
|
1030 |
|
|
HOWTO (R_ARM_LDC_PC_G0, /* type */
|
1031 |
|
|
0, /* rightshift */
|
1032 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1033 |
|
|
32, /* bitsize */
|
1034 |
|
|
TRUE, /* pc_relative */
|
1035 |
|
|
0, /* bitpos */
|
1036 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
1037 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1038 |
|
|
"R_ARM_LDC_PC_G0", /* name */
|
1039 |
|
|
FALSE, /* partial_inplace */
|
1040 |
|
|
0xffffffff, /* src_mask */
|
1041 |
|
|
0xffffffff, /* dst_mask */
|
1042 |
|
|
TRUE), /* pcrel_offset */
|
1043 |
|
|
|
1044 |
|
|
HOWTO (R_ARM_LDC_PC_G1, /* type */
|
1045 |
|
|
0, /* rightshift */
|
1046 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1047 |
|
|
32, /* bitsize */
|
1048 |
|
|
TRUE, /* pc_relative */
|
1049 |
|
|
0, /* bitpos */
|
1050 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
1051 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1052 |
|
|
"R_ARM_LDC_PC_G1", /* name */
|
1053 |
|
|
FALSE, /* partial_inplace */
|
1054 |
|
|
0xffffffff, /* src_mask */
|
1055 |
|
|
0xffffffff, /* dst_mask */
|
1056 |
|
|
TRUE), /* pcrel_offset */
|
1057 |
|
|
|
1058 |
|
|
HOWTO (R_ARM_LDC_PC_G2, /* type */
|
1059 |
|
|
0, /* rightshift */
|
1060 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1061 |
|
|
32, /* bitsize */
|
1062 |
|
|
TRUE, /* pc_relative */
|
1063 |
|
|
0, /* bitpos */
|
1064 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
1065 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1066 |
|
|
"R_ARM_LDC_PC_G2", /* name */
|
1067 |
|
|
FALSE, /* partial_inplace */
|
1068 |
|
|
0xffffffff, /* src_mask */
|
1069 |
|
|
0xffffffff, /* dst_mask */
|
1070 |
|
|
TRUE), /* pcrel_offset */
|
1071 |
|
|
|
1072 |
|
|
HOWTO (R_ARM_ALU_SB_G0_NC, /* type */
|
1073 |
|
|
0, /* rightshift */
|
1074 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1075 |
|
|
32, /* bitsize */
|
1076 |
|
|
TRUE, /* pc_relative */
|
1077 |
|
|
0, /* bitpos */
|
1078 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
1079 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1080 |
|
|
"R_ARM_ALU_SB_G0_NC", /* name */
|
1081 |
|
|
FALSE, /* partial_inplace */
|
1082 |
|
|
0xffffffff, /* src_mask */
|
1083 |
|
|
0xffffffff, /* dst_mask */
|
1084 |
|
|
TRUE), /* pcrel_offset */
|
1085 |
|
|
|
1086 |
|
|
HOWTO (R_ARM_ALU_SB_G0, /* type */
|
1087 |
|
|
0, /* rightshift */
|
1088 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1089 |
|
|
32, /* bitsize */
|
1090 |
|
|
TRUE, /* pc_relative */
|
1091 |
|
|
0, /* bitpos */
|
1092 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
1093 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1094 |
|
|
"R_ARM_ALU_SB_G0", /* name */
|
1095 |
|
|
FALSE, /* partial_inplace */
|
1096 |
|
|
0xffffffff, /* src_mask */
|
1097 |
|
|
0xffffffff, /* dst_mask */
|
1098 |
|
|
TRUE), /* pcrel_offset */
|
1099 |
|
|
|
1100 |
|
|
HOWTO (R_ARM_ALU_SB_G1_NC, /* type */
|
1101 |
|
|
0, /* rightshift */
|
1102 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1103 |
|
|
32, /* bitsize */
|
1104 |
|
|
TRUE, /* pc_relative */
|
1105 |
|
|
0, /* bitpos */
|
1106 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
1107 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1108 |
|
|
"R_ARM_ALU_SB_G1_NC", /* name */
|
1109 |
|
|
FALSE, /* partial_inplace */
|
1110 |
|
|
0xffffffff, /* src_mask */
|
1111 |
|
|
0xffffffff, /* dst_mask */
|
1112 |
|
|
TRUE), /* pcrel_offset */
|
1113 |
|
|
|
1114 |
|
|
HOWTO (R_ARM_ALU_SB_G1, /* type */
|
1115 |
|
|
0, /* rightshift */
|
1116 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1117 |
|
|
32, /* bitsize */
|
1118 |
|
|
TRUE, /* pc_relative */
|
1119 |
|
|
0, /* bitpos */
|
1120 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
1121 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1122 |
|
|
"R_ARM_ALU_SB_G1", /* name */
|
1123 |
|
|
FALSE, /* partial_inplace */
|
1124 |
|
|
0xffffffff, /* src_mask */
|
1125 |
|
|
0xffffffff, /* dst_mask */
|
1126 |
|
|
TRUE), /* pcrel_offset */
|
1127 |
|
|
|
1128 |
|
|
HOWTO (R_ARM_ALU_SB_G2, /* type */
|
1129 |
|
|
0, /* rightshift */
|
1130 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1131 |
|
|
32, /* bitsize */
|
1132 |
|
|
TRUE, /* pc_relative */
|
1133 |
|
|
0, /* bitpos */
|
1134 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
1135 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1136 |
|
|
"R_ARM_ALU_SB_G2", /* name */
|
1137 |
|
|
FALSE, /* partial_inplace */
|
1138 |
|
|
0xffffffff, /* src_mask */
|
1139 |
|
|
0xffffffff, /* dst_mask */
|
1140 |
|
|
TRUE), /* pcrel_offset */
|
1141 |
|
|
|
1142 |
|
|
HOWTO (R_ARM_LDR_SB_G0, /* type */
|
1143 |
|
|
0, /* rightshift */
|
1144 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1145 |
|
|
32, /* bitsize */
|
1146 |
|
|
TRUE, /* pc_relative */
|
1147 |
|
|
0, /* bitpos */
|
1148 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
1149 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1150 |
|
|
"R_ARM_LDR_SB_G0", /* name */
|
1151 |
|
|
FALSE, /* partial_inplace */
|
1152 |
|
|
0xffffffff, /* src_mask */
|
1153 |
|
|
0xffffffff, /* dst_mask */
|
1154 |
|
|
TRUE), /* pcrel_offset */
|
1155 |
|
|
|
1156 |
|
|
HOWTO (R_ARM_LDR_SB_G1, /* type */
|
1157 |
|
|
0, /* rightshift */
|
1158 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1159 |
|
|
32, /* bitsize */
|
1160 |
|
|
TRUE, /* pc_relative */
|
1161 |
|
|
0, /* bitpos */
|
1162 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
1163 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1164 |
|
|
"R_ARM_LDR_SB_G1", /* name */
|
1165 |
|
|
FALSE, /* partial_inplace */
|
1166 |
|
|
0xffffffff, /* src_mask */
|
1167 |
|
|
0xffffffff, /* dst_mask */
|
1168 |
|
|
TRUE), /* pcrel_offset */
|
1169 |
|
|
|
1170 |
|
|
HOWTO (R_ARM_LDR_SB_G2, /* type */
|
1171 |
|
|
0, /* rightshift */
|
1172 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1173 |
|
|
32, /* bitsize */
|
1174 |
|
|
TRUE, /* pc_relative */
|
1175 |
|
|
0, /* bitpos */
|
1176 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
1177 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1178 |
|
|
"R_ARM_LDR_SB_G2", /* name */
|
1179 |
|
|
FALSE, /* partial_inplace */
|
1180 |
|
|
0xffffffff, /* src_mask */
|
1181 |
|
|
0xffffffff, /* dst_mask */
|
1182 |
|
|
TRUE), /* pcrel_offset */
|
1183 |
|
|
|
1184 |
|
|
HOWTO (R_ARM_LDRS_SB_G0, /* type */
|
1185 |
|
|
0, /* rightshift */
|
1186 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1187 |
|
|
32, /* bitsize */
|
1188 |
|
|
TRUE, /* pc_relative */
|
1189 |
|
|
0, /* bitpos */
|
1190 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
1191 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1192 |
|
|
"R_ARM_LDRS_SB_G0", /* name */
|
1193 |
|
|
FALSE, /* partial_inplace */
|
1194 |
|
|
0xffffffff, /* src_mask */
|
1195 |
|
|
0xffffffff, /* dst_mask */
|
1196 |
|
|
TRUE), /* pcrel_offset */
|
1197 |
|
|
|
1198 |
|
|
HOWTO (R_ARM_LDRS_SB_G1, /* type */
|
1199 |
|
|
0, /* rightshift */
|
1200 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1201 |
|
|
32, /* bitsize */
|
1202 |
|
|
TRUE, /* pc_relative */
|
1203 |
|
|
0, /* bitpos */
|
1204 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
1205 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1206 |
|
|
"R_ARM_LDRS_SB_G1", /* name */
|
1207 |
|
|
FALSE, /* partial_inplace */
|
1208 |
|
|
0xffffffff, /* src_mask */
|
1209 |
|
|
0xffffffff, /* dst_mask */
|
1210 |
|
|
TRUE), /* pcrel_offset */
|
1211 |
|
|
|
1212 |
|
|
HOWTO (R_ARM_LDRS_SB_G2, /* type */
|
1213 |
|
|
0, /* rightshift */
|
1214 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1215 |
|
|
32, /* bitsize */
|
1216 |
|
|
TRUE, /* pc_relative */
|
1217 |
|
|
0, /* bitpos */
|
1218 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
1219 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1220 |
|
|
"R_ARM_LDRS_SB_G2", /* name */
|
1221 |
|
|
FALSE, /* partial_inplace */
|
1222 |
|
|
0xffffffff, /* src_mask */
|
1223 |
|
|
0xffffffff, /* dst_mask */
|
1224 |
|
|
TRUE), /* pcrel_offset */
|
1225 |
|
|
|
1226 |
|
|
HOWTO (R_ARM_LDC_SB_G0, /* type */
|
1227 |
|
|
0, /* rightshift */
|
1228 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1229 |
|
|
32, /* bitsize */
|
1230 |
|
|
TRUE, /* pc_relative */
|
1231 |
|
|
0, /* bitpos */
|
1232 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
1233 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1234 |
|
|
"R_ARM_LDC_SB_G0", /* name */
|
1235 |
|
|
FALSE, /* partial_inplace */
|
1236 |
|
|
0xffffffff, /* src_mask */
|
1237 |
|
|
0xffffffff, /* dst_mask */
|
1238 |
|
|
TRUE), /* pcrel_offset */
|
1239 |
|
|
|
1240 |
|
|
HOWTO (R_ARM_LDC_SB_G1, /* type */
|
1241 |
|
|
0, /* rightshift */
|
1242 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1243 |
|
|
32, /* bitsize */
|
1244 |
|
|
TRUE, /* pc_relative */
|
1245 |
|
|
0, /* bitpos */
|
1246 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
1247 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1248 |
|
|
"R_ARM_LDC_SB_G1", /* name */
|
1249 |
|
|
FALSE, /* partial_inplace */
|
1250 |
|
|
0xffffffff, /* src_mask */
|
1251 |
|
|
0xffffffff, /* dst_mask */
|
1252 |
|
|
TRUE), /* pcrel_offset */
|
1253 |
|
|
|
1254 |
|
|
HOWTO (R_ARM_LDC_SB_G2, /* type */
|
1255 |
|
|
0, /* rightshift */
|
1256 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1257 |
|
|
32, /* bitsize */
|
1258 |
|
|
TRUE, /* pc_relative */
|
1259 |
|
|
0, /* bitpos */
|
1260 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
1261 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1262 |
|
|
"R_ARM_LDC_SB_G2", /* name */
|
1263 |
|
|
FALSE, /* partial_inplace */
|
1264 |
|
|
0xffffffff, /* src_mask */
|
1265 |
|
|
0xffffffff, /* dst_mask */
|
1266 |
|
|
TRUE), /* pcrel_offset */
|
1267 |
|
|
|
1268 |
|
|
/* End of group relocations. */
|
1269 |
|
|
|
1270 |
|
|
HOWTO (R_ARM_MOVW_BREL_NC, /* type */
|
1271 |
|
|
0, /* rightshift */
|
1272 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1273 |
|
|
16, /* bitsize */
|
1274 |
|
|
FALSE, /* pc_relative */
|
1275 |
|
|
0, /* bitpos */
|
1276 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
1277 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1278 |
|
|
"R_ARM_MOVW_BREL_NC", /* name */
|
1279 |
|
|
FALSE, /* partial_inplace */
|
1280 |
|
|
0x0000ffff, /* src_mask */
|
1281 |
|
|
0x0000ffff, /* dst_mask */
|
1282 |
|
|
FALSE), /* pcrel_offset */
|
1283 |
|
|
|
1284 |
|
|
HOWTO (R_ARM_MOVT_BREL, /* type */
|
1285 |
|
|
0, /* rightshift */
|
1286 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1287 |
|
|
16, /* bitsize */
|
1288 |
|
|
FALSE, /* pc_relative */
|
1289 |
|
|
0, /* bitpos */
|
1290 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
1291 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1292 |
|
|
"R_ARM_MOVT_BREL", /* name */
|
1293 |
|
|
FALSE, /* partial_inplace */
|
1294 |
|
|
0x0000ffff, /* src_mask */
|
1295 |
|
|
0x0000ffff, /* dst_mask */
|
1296 |
|
|
FALSE), /* pcrel_offset */
|
1297 |
|
|
|
1298 |
|
|
HOWTO (R_ARM_MOVW_BREL, /* type */
|
1299 |
|
|
0, /* rightshift */
|
1300 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1301 |
|
|
16, /* bitsize */
|
1302 |
|
|
FALSE, /* pc_relative */
|
1303 |
|
|
0, /* bitpos */
|
1304 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
1305 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1306 |
|
|
"R_ARM_MOVW_BREL", /* name */
|
1307 |
|
|
FALSE, /* partial_inplace */
|
1308 |
|
|
0x0000ffff, /* src_mask */
|
1309 |
|
|
0x0000ffff, /* dst_mask */
|
1310 |
|
|
FALSE), /* pcrel_offset */
|
1311 |
|
|
|
1312 |
|
|
HOWTO (R_ARM_THM_MOVW_BREL_NC,/* type */
|
1313 |
|
|
0, /* rightshift */
|
1314 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1315 |
|
|
16, /* bitsize */
|
1316 |
|
|
FALSE, /* pc_relative */
|
1317 |
|
|
0, /* bitpos */
|
1318 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
1319 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1320 |
|
|
"R_ARM_THM_MOVW_BREL_NC",/* name */
|
1321 |
|
|
FALSE, /* partial_inplace */
|
1322 |
|
|
0x040f70ff, /* src_mask */
|
1323 |
|
|
0x040f70ff, /* dst_mask */
|
1324 |
|
|
FALSE), /* pcrel_offset */
|
1325 |
|
|
|
1326 |
|
|
HOWTO (R_ARM_THM_MOVT_BREL, /* type */
|
1327 |
|
|
0, /* rightshift */
|
1328 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1329 |
|
|
16, /* bitsize */
|
1330 |
|
|
FALSE, /* pc_relative */
|
1331 |
|
|
0, /* bitpos */
|
1332 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
1333 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1334 |
|
|
"R_ARM_THM_MOVT_BREL", /* name */
|
1335 |
|
|
FALSE, /* partial_inplace */
|
1336 |
|
|
0x040f70ff, /* src_mask */
|
1337 |
|
|
0x040f70ff, /* dst_mask */
|
1338 |
|
|
FALSE), /* pcrel_offset */
|
1339 |
|
|
|
1340 |
|
|
HOWTO (R_ARM_THM_MOVW_BREL, /* type */
|
1341 |
|
|
0, /* rightshift */
|
1342 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1343 |
|
|
16, /* bitsize */
|
1344 |
|
|
FALSE, /* pc_relative */
|
1345 |
|
|
0, /* bitpos */
|
1346 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
1347 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1348 |
|
|
"R_ARM_THM_MOVW_BREL", /* name */
|
1349 |
|
|
FALSE, /* partial_inplace */
|
1350 |
|
|
0x040f70ff, /* src_mask */
|
1351 |
|
|
0x040f70ff, /* dst_mask */
|
1352 |
|
|
FALSE), /* pcrel_offset */
|
1353 |
|
|
|
1354 |
|
|
EMPTY_HOWTO (90), /* unallocated */
|
1355 |
|
|
EMPTY_HOWTO (91),
|
1356 |
|
|
EMPTY_HOWTO (92),
|
1357 |
|
|
EMPTY_HOWTO (93),
|
1358 |
|
|
|
1359 |
|
|
HOWTO (R_ARM_PLT32_ABS, /* type */
|
1360 |
|
|
0, /* rightshift */
|
1361 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1362 |
|
|
32, /* bitsize */
|
1363 |
|
|
FALSE, /* pc_relative */
|
1364 |
|
|
0, /* bitpos */
|
1365 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
1366 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1367 |
|
|
"R_ARM_PLT32_ABS", /* name */
|
1368 |
|
|
FALSE, /* partial_inplace */
|
1369 |
|
|
0xffffffff, /* src_mask */
|
1370 |
|
|
0xffffffff, /* dst_mask */
|
1371 |
|
|
FALSE), /* pcrel_offset */
|
1372 |
|
|
|
1373 |
|
|
HOWTO (R_ARM_GOT_ABS, /* type */
|
1374 |
|
|
0, /* rightshift */
|
1375 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1376 |
|
|
32, /* bitsize */
|
1377 |
|
|
FALSE, /* pc_relative */
|
1378 |
|
|
0, /* bitpos */
|
1379 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
1380 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1381 |
|
|
"R_ARM_GOT_ABS", /* name */
|
1382 |
|
|
FALSE, /* partial_inplace */
|
1383 |
|
|
0xffffffff, /* src_mask */
|
1384 |
|
|
0xffffffff, /* dst_mask */
|
1385 |
|
|
FALSE), /* pcrel_offset */
|
1386 |
|
|
|
1387 |
|
|
HOWTO (R_ARM_GOT_PREL, /* type */
|
1388 |
|
|
0, /* rightshift */
|
1389 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1390 |
|
|
32, /* bitsize */
|
1391 |
|
|
TRUE, /* pc_relative */
|
1392 |
|
|
0, /* bitpos */
|
1393 |
|
|
complain_overflow_dont, /* complain_on_overflow */
|
1394 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1395 |
|
|
"R_ARM_GOT_PREL", /* name */
|
1396 |
|
|
FALSE, /* partial_inplace */
|
1397 |
|
|
0xffffffff, /* src_mask */
|
1398 |
|
|
0xffffffff, /* dst_mask */
|
1399 |
|
|
TRUE), /* pcrel_offset */
|
1400 |
|
|
|
1401 |
|
|
HOWTO (R_ARM_GOT_BREL12, /* type */
|
1402 |
|
|
0, /* rightshift */
|
1403 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1404 |
|
|
12, /* bitsize */
|
1405 |
|
|
FALSE, /* pc_relative */
|
1406 |
|
|
0, /* bitpos */
|
1407 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
1408 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1409 |
|
|
"R_ARM_GOT_BREL12", /* name */
|
1410 |
|
|
FALSE, /* partial_inplace */
|
1411 |
|
|
0x00000fff, /* src_mask */
|
1412 |
|
|
0x00000fff, /* dst_mask */
|
1413 |
|
|
FALSE), /* pcrel_offset */
|
1414 |
|
|
|
1415 |
|
|
HOWTO (R_ARM_GOTOFF12, /* type */
|
1416 |
|
|
0, /* rightshift */
|
1417 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1418 |
|
|
12, /* bitsize */
|
1419 |
|
|
FALSE, /* pc_relative */
|
1420 |
|
|
0, /* bitpos */
|
1421 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
1422 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1423 |
|
|
"R_ARM_GOTOFF12", /* name */
|
1424 |
|
|
FALSE, /* partial_inplace */
|
1425 |
|
|
0x00000fff, /* src_mask */
|
1426 |
|
|
0x00000fff, /* dst_mask */
|
1427 |
|
|
FALSE), /* pcrel_offset */
|
1428 |
|
|
|
1429 |
|
|
EMPTY_HOWTO (R_ARM_GOTRELAX), /* reserved for future GOT-load optimizations */
|
1430 |
|
|
|
1431 |
|
|
/* GNU extension to record C++ vtable member usage */
|
1432 |
|
|
HOWTO (R_ARM_GNU_VTENTRY, /* type */
|
1433 |
|
|
0, /* rightshift */
|
1434 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1435 |
|
|
0, /* bitsize */
|
1436 |
|
|
FALSE, /* pc_relative */
|
1437 |
|
|
0, /* bitpos */
|
1438 |
|
|
complain_overflow_dont, /* complain_on_overflow */
|
1439 |
|
|
_bfd_elf_rel_vtable_reloc_fn, /* special_function */
|
1440 |
|
|
"R_ARM_GNU_VTENTRY", /* name */
|
1441 |
|
|
FALSE, /* partial_inplace */
|
1442 |
|
|
0, /* src_mask */
|
1443 |
|
|
0, /* dst_mask */
|
1444 |
|
|
FALSE), /* pcrel_offset */
|
1445 |
|
|
|
1446 |
|
|
/* GNU extension to record C++ vtable hierarchy */
|
1447 |
|
|
HOWTO (R_ARM_GNU_VTINHERIT, /* type */
|
1448 |
|
|
0, /* rightshift */
|
1449 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1450 |
|
|
0, /* bitsize */
|
1451 |
|
|
FALSE, /* pc_relative */
|
1452 |
|
|
0, /* bitpos */
|
1453 |
|
|
complain_overflow_dont, /* complain_on_overflow */
|
1454 |
|
|
NULL, /* special_function */
|
1455 |
|
|
"R_ARM_GNU_VTINHERIT", /* name */
|
1456 |
|
|
FALSE, /* partial_inplace */
|
1457 |
|
|
0, /* src_mask */
|
1458 |
|
|
0, /* dst_mask */
|
1459 |
|
|
FALSE), /* pcrel_offset */
|
1460 |
|
|
|
1461 |
|
|
HOWTO (R_ARM_THM_JUMP11, /* type */
|
1462 |
|
|
1, /* rightshift */
|
1463 |
|
|
1, /* size (0 = byte, 1 = short, 2 = long) */
|
1464 |
|
|
11, /* bitsize */
|
1465 |
|
|
TRUE, /* pc_relative */
|
1466 |
|
|
0, /* bitpos */
|
1467 |
|
|
complain_overflow_signed, /* complain_on_overflow */
|
1468 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1469 |
|
|
"R_ARM_THM_JUMP11", /* name */
|
1470 |
|
|
FALSE, /* partial_inplace */
|
1471 |
|
|
0x000007ff, /* src_mask */
|
1472 |
|
|
0x000007ff, /* dst_mask */
|
1473 |
|
|
TRUE), /* pcrel_offset */
|
1474 |
|
|
|
1475 |
|
|
HOWTO (R_ARM_THM_JUMP8, /* type */
|
1476 |
|
|
1, /* rightshift */
|
1477 |
|
|
1, /* size (0 = byte, 1 = short, 2 = long) */
|
1478 |
|
|
8, /* bitsize */
|
1479 |
|
|
TRUE, /* pc_relative */
|
1480 |
|
|
0, /* bitpos */
|
1481 |
|
|
complain_overflow_signed, /* complain_on_overflow */
|
1482 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1483 |
|
|
"R_ARM_THM_JUMP8", /* name */
|
1484 |
|
|
FALSE, /* partial_inplace */
|
1485 |
|
|
0x000000ff, /* src_mask */
|
1486 |
|
|
0x000000ff, /* dst_mask */
|
1487 |
|
|
TRUE), /* pcrel_offset */
|
1488 |
|
|
|
1489 |
|
|
/* TLS relocations */
|
1490 |
|
|
HOWTO (R_ARM_TLS_GD32, /* type */
|
1491 |
|
|
0, /* rightshift */
|
1492 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1493 |
|
|
32, /* bitsize */
|
1494 |
|
|
FALSE, /* pc_relative */
|
1495 |
|
|
0, /* bitpos */
|
1496 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
1497 |
|
|
NULL, /* special_function */
|
1498 |
|
|
"R_ARM_TLS_GD32", /* name */
|
1499 |
|
|
TRUE, /* partial_inplace */
|
1500 |
|
|
0xffffffff, /* src_mask */
|
1501 |
|
|
0xffffffff, /* dst_mask */
|
1502 |
|
|
FALSE), /* pcrel_offset */
|
1503 |
|
|
|
1504 |
|
|
HOWTO (R_ARM_TLS_LDM32, /* type */
|
1505 |
|
|
0, /* rightshift */
|
1506 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1507 |
|
|
32, /* bitsize */
|
1508 |
|
|
FALSE, /* pc_relative */
|
1509 |
|
|
0, /* bitpos */
|
1510 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
1511 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1512 |
|
|
"R_ARM_TLS_LDM32", /* name */
|
1513 |
|
|
TRUE, /* partial_inplace */
|
1514 |
|
|
0xffffffff, /* src_mask */
|
1515 |
|
|
0xffffffff, /* dst_mask */
|
1516 |
|
|
FALSE), /* pcrel_offset */
|
1517 |
|
|
|
1518 |
|
|
HOWTO (R_ARM_TLS_LDO32, /* type */
|
1519 |
|
|
0, /* rightshift */
|
1520 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1521 |
|
|
32, /* bitsize */
|
1522 |
|
|
FALSE, /* pc_relative */
|
1523 |
|
|
0, /* bitpos */
|
1524 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
1525 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1526 |
|
|
"R_ARM_TLS_LDO32", /* name */
|
1527 |
|
|
TRUE, /* partial_inplace */
|
1528 |
|
|
0xffffffff, /* src_mask */
|
1529 |
|
|
0xffffffff, /* dst_mask */
|
1530 |
|
|
FALSE), /* pcrel_offset */
|
1531 |
|
|
|
1532 |
|
|
HOWTO (R_ARM_TLS_IE32, /* type */
|
1533 |
|
|
0, /* rightshift */
|
1534 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1535 |
|
|
32, /* bitsize */
|
1536 |
|
|
FALSE, /* pc_relative */
|
1537 |
|
|
0, /* bitpos */
|
1538 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
1539 |
|
|
NULL, /* special_function */
|
1540 |
|
|
"R_ARM_TLS_IE32", /* name */
|
1541 |
|
|
TRUE, /* partial_inplace */
|
1542 |
|
|
0xffffffff, /* src_mask */
|
1543 |
|
|
0xffffffff, /* dst_mask */
|
1544 |
|
|
FALSE), /* pcrel_offset */
|
1545 |
|
|
|
1546 |
|
|
HOWTO (R_ARM_TLS_LE32, /* type */
|
1547 |
|
|
0, /* rightshift */
|
1548 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1549 |
|
|
32, /* bitsize */
|
1550 |
|
|
FALSE, /* pc_relative */
|
1551 |
|
|
0, /* bitpos */
|
1552 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
1553 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1554 |
|
|
"R_ARM_TLS_LE32", /* name */
|
1555 |
|
|
TRUE, /* partial_inplace */
|
1556 |
|
|
0xffffffff, /* src_mask */
|
1557 |
|
|
0xffffffff, /* dst_mask */
|
1558 |
|
|
FALSE), /* pcrel_offset */
|
1559 |
|
|
|
1560 |
|
|
HOWTO (R_ARM_TLS_LDO12, /* type */
|
1561 |
|
|
0, /* rightshift */
|
1562 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1563 |
|
|
12, /* bitsize */
|
1564 |
|
|
FALSE, /* pc_relative */
|
1565 |
|
|
0, /* bitpos */
|
1566 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
1567 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1568 |
|
|
"R_ARM_TLS_LDO12", /* name */
|
1569 |
|
|
FALSE, /* partial_inplace */
|
1570 |
|
|
0x00000fff, /* src_mask */
|
1571 |
|
|
0x00000fff, /* dst_mask */
|
1572 |
|
|
FALSE), /* pcrel_offset */
|
1573 |
|
|
|
1574 |
|
|
HOWTO (R_ARM_TLS_LE12, /* type */
|
1575 |
|
|
0, /* rightshift */
|
1576 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1577 |
|
|
12, /* bitsize */
|
1578 |
|
|
FALSE, /* pc_relative */
|
1579 |
|
|
0, /* bitpos */
|
1580 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
1581 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1582 |
|
|
"R_ARM_TLS_LE12", /* name */
|
1583 |
|
|
FALSE, /* partial_inplace */
|
1584 |
|
|
0x00000fff, /* src_mask */
|
1585 |
|
|
0x00000fff, /* dst_mask */
|
1586 |
|
|
FALSE), /* pcrel_offset */
|
1587 |
|
|
|
1588 |
|
|
HOWTO (R_ARM_TLS_IE12GP, /* type */
|
1589 |
|
|
0, /* rightshift */
|
1590 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1591 |
|
|
12, /* bitsize */
|
1592 |
|
|
FALSE, /* pc_relative */
|
1593 |
|
|
0, /* bitpos */
|
1594 |
|
|
complain_overflow_bitfield,/* complain_on_overflow */
|
1595 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1596 |
|
|
"R_ARM_TLS_IE12GP", /* name */
|
1597 |
|
|
FALSE, /* partial_inplace */
|
1598 |
|
|
0x00000fff, /* src_mask */
|
1599 |
|
|
0x00000fff, /* dst_mask */
|
1600 |
|
|
FALSE), /* pcrel_offset */
|
1601 |
|
|
};
|
1602 |
|
|
|
1603 |
|
|
/* 112-127 private relocations
|
1604 |
|
|
128 R_ARM_ME_TOO, obsolete
|
1605 |
|
|
129-255 unallocated in AAELF.
|
1606 |
|
|
|
1607 |
|
|
249-255 extended, currently unused, relocations: */
|
1608 |
|
|
|
1609 |
|
|
static reloc_howto_type elf32_arm_howto_table_2[4] =
|
1610 |
|
|
{
|
1611 |
|
|
HOWTO (R_ARM_RREL32, /* type */
|
1612 |
|
|
0, /* rightshift */
|
1613 |
|
|
0, /* size (0 = byte, 1 = short, 2 = long) */
|
1614 |
|
|
0, /* bitsize */
|
1615 |
|
|
FALSE, /* pc_relative */
|
1616 |
|
|
0, /* bitpos */
|
1617 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
1618 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1619 |
|
|
"R_ARM_RREL32", /* name */
|
1620 |
|
|
FALSE, /* partial_inplace */
|
1621 |
|
|
0, /* src_mask */
|
1622 |
|
|
0, /* dst_mask */
|
1623 |
|
|
FALSE), /* pcrel_offset */
|
1624 |
|
|
|
1625 |
|
|
HOWTO (R_ARM_RABS32, /* type */
|
1626 |
|
|
0, /* rightshift */
|
1627 |
|
|
0, /* size (0 = byte, 1 = short, 2 = long) */
|
1628 |
|
|
0, /* bitsize */
|
1629 |
|
|
FALSE, /* pc_relative */
|
1630 |
|
|
0, /* bitpos */
|
1631 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
1632 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1633 |
|
|
"R_ARM_RABS32", /* name */
|
1634 |
|
|
FALSE, /* partial_inplace */
|
1635 |
|
|
0, /* src_mask */
|
1636 |
|
|
0, /* dst_mask */
|
1637 |
|
|
FALSE), /* pcrel_offset */
|
1638 |
|
|
|
1639 |
|
|
HOWTO (R_ARM_RPC24, /* type */
|
1640 |
|
|
0, /* rightshift */
|
1641 |
|
|
0, /* size (0 = byte, 1 = short, 2 = long) */
|
1642 |
|
|
0, /* bitsize */
|
1643 |
|
|
FALSE, /* pc_relative */
|
1644 |
|
|
0, /* bitpos */
|
1645 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
1646 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1647 |
|
|
"R_ARM_RPC24", /* name */
|
1648 |
|
|
FALSE, /* partial_inplace */
|
1649 |
|
|
0, /* src_mask */
|
1650 |
|
|
0, /* dst_mask */
|
1651 |
|
|
FALSE), /* pcrel_offset */
|
1652 |
|
|
|
1653 |
|
|
HOWTO (R_ARM_RBASE, /* type */
|
1654 |
|
|
0, /* rightshift */
|
1655 |
|
|
0, /* size (0 = byte, 1 = short, 2 = long) */
|
1656 |
|
|
0, /* bitsize */
|
1657 |
|
|
FALSE, /* pc_relative */
|
1658 |
|
|
0, /* bitpos */
|
1659 |
|
|
complain_overflow_dont,/* complain_on_overflow */
|
1660 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
1661 |
|
|
"R_ARM_RBASE", /* name */
|
1662 |
|
|
FALSE, /* partial_inplace */
|
1663 |
|
|
0, /* src_mask */
|
1664 |
|
|
0, /* dst_mask */
|
1665 |
|
|
FALSE) /* pcrel_offset */
|
1666 |
|
|
};
|
1667 |
|
|
|
1668 |
|
|
static reloc_howto_type *
|
1669 |
|
|
elf32_arm_howto_from_type (unsigned int r_type)
|
1670 |
|
|
{
|
1671 |
|
|
if (r_type < NUM_ELEM (elf32_arm_howto_table_1))
|
1672 |
|
|
return &elf32_arm_howto_table_1[r_type];
|
1673 |
|
|
|
1674 |
|
|
if (r_type >= R_ARM_RREL32
|
1675 |
|
|
&& r_type < R_ARM_RREL32 + NUM_ELEM (elf32_arm_howto_table_2))
|
1676 |
|
|
return &elf32_arm_howto_table_2[r_type - R_ARM_RREL32];
|
1677 |
|
|
|
1678 |
|
|
return NULL;
|
1679 |
|
|
}
|
1680 |
|
|
|
1681 |
|
|
static void
|
1682 |
|
|
elf32_arm_info_to_howto (bfd * abfd ATTRIBUTE_UNUSED, arelent * bfd_reloc,
|
1683 |
|
|
Elf_Internal_Rela * elf_reloc)
|
1684 |
|
|
{
|
1685 |
|
|
unsigned int r_type;
|
1686 |
|
|
|
1687 |
|
|
r_type = ELF32_R_TYPE (elf_reloc->r_info);
|
1688 |
|
|
bfd_reloc->howto = elf32_arm_howto_from_type (r_type);
|
1689 |
|
|
}
|
1690 |
|
|
|
1691 |
|
|
struct elf32_arm_reloc_map
|
1692 |
|
|
{
|
1693 |
|
|
bfd_reloc_code_real_type bfd_reloc_val;
|
1694 |
|
|
unsigned char elf_reloc_val;
|
1695 |
|
|
};
|
1696 |
|
|
|
1697 |
|
|
/* All entries in this list must also be present in elf32_arm_howto_table. */
|
1698 |
|
|
static const struct elf32_arm_reloc_map elf32_arm_reloc_map[] =
|
1699 |
|
|
{
|
1700 |
|
|
{BFD_RELOC_NONE, R_ARM_NONE},
|
1701 |
|
|
{BFD_RELOC_ARM_PCREL_BRANCH, R_ARM_PC24},
|
1702 |
|
|
{BFD_RELOC_ARM_PCREL_CALL, R_ARM_CALL},
|
1703 |
|
|
{BFD_RELOC_ARM_PCREL_JUMP, R_ARM_JUMP24},
|
1704 |
|
|
{BFD_RELOC_ARM_PCREL_BLX, R_ARM_XPC25},
|
1705 |
|
|
{BFD_RELOC_THUMB_PCREL_BLX, R_ARM_THM_XPC22},
|
1706 |
|
|
{BFD_RELOC_32, R_ARM_ABS32},
|
1707 |
|
|
{BFD_RELOC_32_PCREL, R_ARM_REL32},
|
1708 |
|
|
{BFD_RELOC_8, R_ARM_ABS8},
|
1709 |
|
|
{BFD_RELOC_16, R_ARM_ABS16},
|
1710 |
|
|
{BFD_RELOC_ARM_OFFSET_IMM, R_ARM_ABS12},
|
1711 |
|
|
{BFD_RELOC_ARM_THUMB_OFFSET, R_ARM_THM_ABS5},
|
1712 |
|
|
{BFD_RELOC_THUMB_PCREL_BRANCH25, R_ARM_THM_JUMP24},
|
1713 |
|
|
{BFD_RELOC_THUMB_PCREL_BRANCH23, R_ARM_THM_CALL},
|
1714 |
|
|
{BFD_RELOC_THUMB_PCREL_BRANCH12, R_ARM_THM_JUMP11},
|
1715 |
|
|
{BFD_RELOC_THUMB_PCREL_BRANCH20, R_ARM_THM_JUMP19},
|
1716 |
|
|
{BFD_RELOC_THUMB_PCREL_BRANCH9, R_ARM_THM_JUMP8},
|
1717 |
|
|
{BFD_RELOC_THUMB_PCREL_BRANCH7, R_ARM_THM_JUMP6},
|
1718 |
|
|
{BFD_RELOC_ARM_GLOB_DAT, R_ARM_GLOB_DAT},
|
1719 |
|
|
{BFD_RELOC_ARM_JUMP_SLOT, R_ARM_JUMP_SLOT},
|
1720 |
|
|
{BFD_RELOC_ARM_RELATIVE, R_ARM_RELATIVE},
|
1721 |
|
|
{BFD_RELOC_ARM_GOTOFF, R_ARM_GOTOFF32},
|
1722 |
|
|
{BFD_RELOC_ARM_GOTPC, R_ARM_GOTPC},
|
1723 |
|
|
{BFD_RELOC_ARM_GOT32, R_ARM_GOT32},
|
1724 |
|
|
{BFD_RELOC_ARM_PLT32, R_ARM_PLT32},
|
1725 |
|
|
{BFD_RELOC_ARM_TARGET1, R_ARM_TARGET1},
|
1726 |
|
|
{BFD_RELOC_ARM_ROSEGREL32, R_ARM_ROSEGREL32},
|
1727 |
|
|
{BFD_RELOC_ARM_SBREL32, R_ARM_SBREL32},
|
1728 |
|
|
{BFD_RELOC_ARM_PREL31, R_ARM_PREL31},
|
1729 |
|
|
{BFD_RELOC_ARM_TARGET2, R_ARM_TARGET2},
|
1730 |
|
|
{BFD_RELOC_ARM_PLT32, R_ARM_PLT32},
|
1731 |
|
|
{BFD_RELOC_ARM_TLS_GD32, R_ARM_TLS_GD32},
|
1732 |
|
|
{BFD_RELOC_ARM_TLS_LDO32, R_ARM_TLS_LDO32},
|
1733 |
|
|
{BFD_RELOC_ARM_TLS_LDM32, R_ARM_TLS_LDM32},
|
1734 |
|
|
{BFD_RELOC_ARM_TLS_DTPMOD32, R_ARM_TLS_DTPMOD32},
|
1735 |
|
|
{BFD_RELOC_ARM_TLS_DTPOFF32, R_ARM_TLS_DTPOFF32},
|
1736 |
|
|
{BFD_RELOC_ARM_TLS_TPOFF32, R_ARM_TLS_TPOFF32},
|
1737 |
|
|
{BFD_RELOC_ARM_TLS_IE32, R_ARM_TLS_IE32},
|
1738 |
|
|
{BFD_RELOC_ARM_TLS_LE32, R_ARM_TLS_LE32},
|
1739 |
|
|
{BFD_RELOC_VTABLE_INHERIT, R_ARM_GNU_VTINHERIT},
|
1740 |
|
|
{BFD_RELOC_VTABLE_ENTRY, R_ARM_GNU_VTENTRY},
|
1741 |
|
|
{BFD_RELOC_ARM_MOVW, R_ARM_MOVW_ABS_NC},
|
1742 |
|
|
{BFD_RELOC_ARM_MOVT, R_ARM_MOVT_ABS},
|
1743 |
|
|
{BFD_RELOC_ARM_MOVW_PCREL, R_ARM_MOVW_PREL_NC},
|
1744 |
|
|
{BFD_RELOC_ARM_MOVT_PCREL, R_ARM_MOVT_PREL},
|
1745 |
|
|
{BFD_RELOC_ARM_THUMB_MOVW, R_ARM_THM_MOVW_ABS_NC},
|
1746 |
|
|
{BFD_RELOC_ARM_THUMB_MOVT, R_ARM_THM_MOVT_ABS},
|
1747 |
|
|
{BFD_RELOC_ARM_THUMB_MOVW_PCREL, R_ARM_THM_MOVW_PREL_NC},
|
1748 |
|
|
{BFD_RELOC_ARM_THUMB_MOVT_PCREL, R_ARM_THM_MOVT_PREL},
|
1749 |
|
|
{BFD_RELOC_ARM_ALU_PC_G0_NC, R_ARM_ALU_PC_G0_NC},
|
1750 |
|
|
{BFD_RELOC_ARM_ALU_PC_G0, R_ARM_ALU_PC_G0},
|
1751 |
|
|
{BFD_RELOC_ARM_ALU_PC_G1_NC, R_ARM_ALU_PC_G1_NC},
|
1752 |
|
|
{BFD_RELOC_ARM_ALU_PC_G1, R_ARM_ALU_PC_G1},
|
1753 |
|
|
{BFD_RELOC_ARM_ALU_PC_G2, R_ARM_ALU_PC_G2},
|
1754 |
|
|
{BFD_RELOC_ARM_LDR_PC_G0, R_ARM_LDR_PC_G0},
|
1755 |
|
|
{BFD_RELOC_ARM_LDR_PC_G1, R_ARM_LDR_PC_G1},
|
1756 |
|
|
{BFD_RELOC_ARM_LDR_PC_G2, R_ARM_LDR_PC_G2},
|
1757 |
|
|
{BFD_RELOC_ARM_LDRS_PC_G0, R_ARM_LDRS_PC_G0},
|
1758 |
|
|
{BFD_RELOC_ARM_LDRS_PC_G1, R_ARM_LDRS_PC_G1},
|
1759 |
|
|
{BFD_RELOC_ARM_LDRS_PC_G2, R_ARM_LDRS_PC_G2},
|
1760 |
|
|
{BFD_RELOC_ARM_LDC_PC_G0, R_ARM_LDC_PC_G0},
|
1761 |
|
|
{BFD_RELOC_ARM_LDC_PC_G1, R_ARM_LDC_PC_G1},
|
1762 |
|
|
{BFD_RELOC_ARM_LDC_PC_G2, R_ARM_LDC_PC_G2},
|
1763 |
|
|
{BFD_RELOC_ARM_ALU_SB_G0_NC, R_ARM_ALU_SB_G0_NC},
|
1764 |
|
|
{BFD_RELOC_ARM_ALU_SB_G0, R_ARM_ALU_SB_G0},
|
1765 |
|
|
{BFD_RELOC_ARM_ALU_SB_G1_NC, R_ARM_ALU_SB_G1_NC},
|
1766 |
|
|
{BFD_RELOC_ARM_ALU_SB_G1, R_ARM_ALU_SB_G1},
|
1767 |
|
|
{BFD_RELOC_ARM_ALU_SB_G2, R_ARM_ALU_SB_G2},
|
1768 |
|
|
{BFD_RELOC_ARM_LDR_SB_G0, R_ARM_LDR_SB_G0},
|
1769 |
|
|
{BFD_RELOC_ARM_LDR_SB_G1, R_ARM_LDR_SB_G1},
|
1770 |
|
|
{BFD_RELOC_ARM_LDR_SB_G2, R_ARM_LDR_SB_G2},
|
1771 |
|
|
{BFD_RELOC_ARM_LDRS_SB_G0, R_ARM_LDRS_SB_G0},
|
1772 |
|
|
{BFD_RELOC_ARM_LDRS_SB_G1, R_ARM_LDRS_SB_G1},
|
1773 |
|
|
{BFD_RELOC_ARM_LDRS_SB_G2, R_ARM_LDRS_SB_G2},
|
1774 |
|
|
{BFD_RELOC_ARM_LDC_SB_G0, R_ARM_LDC_SB_G0},
|
1775 |
|
|
{BFD_RELOC_ARM_LDC_SB_G1, R_ARM_LDC_SB_G1},
|
1776 |
|
|
{BFD_RELOC_ARM_LDC_SB_G2, R_ARM_LDC_SB_G2},
|
1777 |
|
|
{BFD_RELOC_ARM_V4BX, R_ARM_V4BX}
|
1778 |
|
|
};
|
1779 |
|
|
|
1780 |
|
|
static reloc_howto_type *
|
1781 |
|
|
elf32_arm_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
|
1782 |
|
|
bfd_reloc_code_real_type code)
|
1783 |
|
|
{
|
1784 |
|
|
unsigned int i;
|
1785 |
|
|
for (i = 0; i < NUM_ELEM (elf32_arm_reloc_map); i ++)
|
1786 |
|
|
if (elf32_arm_reloc_map[i].bfd_reloc_val == code)
|
1787 |
|
|
return elf32_arm_howto_from_type (elf32_arm_reloc_map[i].elf_reloc_val);
|
1788 |
|
|
|
1789 |
|
|
return NULL;
|
1790 |
|
|
}
|
1791 |
|
|
|
1792 |
|
|
static reloc_howto_type *
|
1793 |
|
|
elf32_arm_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
|
1794 |
|
|
const char *r_name)
|
1795 |
|
|
{
|
1796 |
|
|
unsigned int i;
|
1797 |
|
|
|
1798 |
|
|
for (i = 0;
|
1799 |
|
|
i < (sizeof (elf32_arm_howto_table_1)
|
1800 |
|
|
/ sizeof (elf32_arm_howto_table_1[0]));
|
1801 |
|
|
i++)
|
1802 |
|
|
if (elf32_arm_howto_table_1[i].name != NULL
|
1803 |
|
|
&& strcasecmp (elf32_arm_howto_table_1[i].name, r_name) == 0)
|
1804 |
|
|
return &elf32_arm_howto_table_1[i];
|
1805 |
|
|
|
1806 |
|
|
for (i = 0;
|
1807 |
|
|
i < (sizeof (elf32_arm_howto_table_2)
|
1808 |
|
|
/ sizeof (elf32_arm_howto_table_2[0]));
|
1809 |
|
|
i++)
|
1810 |
|
|
if (elf32_arm_howto_table_2[i].name != NULL
|
1811 |
|
|
&& strcasecmp (elf32_arm_howto_table_2[i].name, r_name) == 0)
|
1812 |
|
|
return &elf32_arm_howto_table_2[i];
|
1813 |
|
|
|
1814 |
|
|
return NULL;
|
1815 |
|
|
}
|
1816 |
|
|
|
1817 |
|
|
/* Support for core dump NOTE sections */
|
1818 |
|
|
static bfd_boolean
|
1819 |
|
|
elf32_arm_nabi_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
|
1820 |
|
|
{
|
1821 |
|
|
int offset;
|
1822 |
|
|
size_t size;
|
1823 |
|
|
|
1824 |
|
|
switch (note->descsz)
|
1825 |
|
|
{
|
1826 |
|
|
default:
|
1827 |
|
|
return FALSE;
|
1828 |
|
|
|
1829 |
|
|
case 148: /* Linux/ARM 32-bit*/
|
1830 |
|
|
/* pr_cursig */
|
1831 |
|
|
elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
|
1832 |
|
|
|
1833 |
|
|
/* pr_pid */
|
1834 |
|
|
elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
|
1835 |
|
|
|
1836 |
|
|
/* pr_reg */
|
1837 |
|
|
offset = 72;
|
1838 |
|
|
size = 72;
|
1839 |
|
|
|
1840 |
|
|
break;
|
1841 |
|
|
}
|
1842 |
|
|
|
1843 |
|
|
/* Make a ".reg/999" section. */
|
1844 |
|
|
return _bfd_elfcore_make_pseudosection (abfd, ".reg",
|
1845 |
|
|
size, note->descpos + offset);
|
1846 |
|
|
}
|
1847 |
|
|
|
1848 |
|
|
static bfd_boolean
|
1849 |
|
|
elf32_arm_nabi_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
|
1850 |
|
|
{
|
1851 |
|
|
switch (note->descsz)
|
1852 |
|
|
{
|
1853 |
|
|
default:
|
1854 |
|
|
return FALSE;
|
1855 |
|
|
|
1856 |
|
|
case 124: /* Linux/ARM elf_prpsinfo */
|
1857 |
|
|
elf_tdata (abfd)->core_program
|
1858 |
|
|
= _bfd_elfcore_strndup (abfd, note->descdata + 28, 16);
|
1859 |
|
|
elf_tdata (abfd)->core_command
|
1860 |
|
|
= _bfd_elfcore_strndup (abfd, note->descdata + 44, 80);
|
1861 |
|
|
}
|
1862 |
|
|
|
1863 |
|
|
/* Note that for some reason, a spurious space is tacked
|
1864 |
|
|
onto the end of the args in some (at least one anyway)
|
1865 |
|
|
implementations, so strip it off if it exists. */
|
1866 |
|
|
|
1867 |
|
|
{
|
1868 |
|
|
char *command = elf_tdata (abfd)->core_command;
|
1869 |
|
|
int n = strlen (command);
|
1870 |
|
|
|
1871 |
|
|
if (0 < n && command[n - 1] == ' ')
|
1872 |
|
|
command[n - 1] = '\0';
|
1873 |
|
|
}
|
1874 |
|
|
|
1875 |
|
|
return TRUE;
|
1876 |
|
|
}
|
1877 |
|
|
|
1878 |
|
|
#define TARGET_LITTLE_SYM bfd_elf32_littlearm_vec
|
1879 |
|
|
#define TARGET_LITTLE_NAME "elf32-littlearm"
|
1880 |
|
|
#define TARGET_BIG_SYM bfd_elf32_bigarm_vec
|
1881 |
|
|
#define TARGET_BIG_NAME "elf32-bigarm"
|
1882 |
|
|
|
1883 |
|
|
#define elf_backend_grok_prstatus elf32_arm_nabi_grok_prstatus
|
1884 |
|
|
#define elf_backend_grok_psinfo elf32_arm_nabi_grok_psinfo
|
1885 |
|
|
|
1886 |
|
|
typedef unsigned long int insn32;
|
1887 |
|
|
typedef unsigned short int insn16;
|
1888 |
|
|
|
1889 |
|
|
/* In lieu of proper flags, assume all EABIv4 or later objects are
|
1890 |
|
|
interworkable. */
|
1891 |
|
|
#define INTERWORK_FLAG(abfd) \
|
1892 |
|
|
(EF_ARM_EABI_VERSION (elf_elfheader (abfd)->e_flags) >= EF_ARM_EABI_VER4 \
|
1893 |
|
|
|| (elf_elfheader (abfd)->e_flags & EF_ARM_INTERWORK))
|
1894 |
|
|
|
1895 |
|
|
/* The linker script knows the section names for placement.
|
1896 |
|
|
The entry_names are used to do simple name mangling on the stubs.
|
1897 |
|
|
Given a function name, and its type, the stub can be found. The
|
1898 |
|
|
name can be changed. The only requirement is the %s be present. */
|
1899 |
|
|
#define THUMB2ARM_GLUE_SECTION_NAME ".glue_7t"
|
1900 |
|
|
#define THUMB2ARM_GLUE_ENTRY_NAME "__%s_from_thumb"
|
1901 |
|
|
|
1902 |
|
|
#define ARM2THUMB_GLUE_SECTION_NAME ".glue_7"
|
1903 |
|
|
#define ARM2THUMB_GLUE_ENTRY_NAME "__%s_from_arm"
|
1904 |
|
|
|
1905 |
|
|
#define VFP11_ERRATUM_VENEER_SECTION_NAME ".vfp11_veneer"
|
1906 |
|
|
#define VFP11_ERRATUM_VENEER_ENTRY_NAME "__vfp11_veneer_%x"
|
1907 |
|
|
|
1908 |
|
|
#define ARM_BX_GLUE_SECTION_NAME ".v4_bx"
|
1909 |
|
|
#define ARM_BX_GLUE_ENTRY_NAME "__bx_r%d"
|
1910 |
|
|
|
1911 |
|
|
/* The name of the dynamic interpreter. This is put in the .interp
|
1912 |
|
|
section. */
|
1913 |
|
|
#define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1"
|
1914 |
|
|
|
1915 |
|
|
#ifdef FOUR_WORD_PLT
|
1916 |
|
|
|
1917 |
|
|
/* The first entry in a procedure linkage table looks like
|
1918 |
|
|
this. It is set up so that any shared library function that is
|
1919 |
|
|
called before the relocation has been set up calls the dynamic
|
1920 |
|
|
linker first. */
|
1921 |
|
|
static const bfd_vma elf32_arm_plt0_entry [] =
|
1922 |
|
|
{
|
1923 |
|
|
0xe52de004, /* str lr, [sp, #-4]! */
|
1924 |
|
|
0xe59fe010, /* ldr lr, [pc, #16] */
|
1925 |
|
|
0xe08fe00e, /* add lr, pc, lr */
|
1926 |
|
|
0xe5bef008, /* ldr pc, [lr, #8]! */
|
1927 |
|
|
};
|
1928 |
|
|
|
1929 |
|
|
/* Subsequent entries in a procedure linkage table look like
|
1930 |
|
|
this. */
|
1931 |
|
|
static const bfd_vma elf32_arm_plt_entry [] =
|
1932 |
|
|
{
|
1933 |
|
|
0xe28fc600, /* add ip, pc, #NN */
|
1934 |
|
|
0xe28cca00, /* add ip, ip, #NN */
|
1935 |
|
|
0xe5bcf000, /* ldr pc, [ip, #NN]! */
|
1936 |
|
|
0x00000000, /* unused */
|
1937 |
|
|
};
|
1938 |
|
|
|
1939 |
|
|
#else
|
1940 |
|
|
|
1941 |
|
|
/* The first entry in a procedure linkage table looks like
|
1942 |
|
|
this. It is set up so that any shared library function that is
|
1943 |
|
|
called before the relocation has been set up calls the dynamic
|
1944 |
|
|
linker first. */
|
1945 |
|
|
static const bfd_vma elf32_arm_plt0_entry [] =
|
1946 |
|
|
{
|
1947 |
|
|
0xe52de004, /* str lr, [sp, #-4]! */
|
1948 |
|
|
0xe59fe004, /* ldr lr, [pc, #4] */
|
1949 |
|
|
0xe08fe00e, /* add lr, pc, lr */
|
1950 |
|
|
0xe5bef008, /* ldr pc, [lr, #8]! */
|
1951 |
|
|
0x00000000, /* &GOT[0] - . */
|
1952 |
|
|
};
|
1953 |
|
|
|
1954 |
|
|
/* Subsequent entries in a procedure linkage table look like
|
1955 |
|
|
this. */
|
1956 |
|
|
static const bfd_vma elf32_arm_plt_entry [] =
|
1957 |
|
|
{
|
1958 |
|
|
0xe28fc600, /* add ip, pc, #0xNN00000 */
|
1959 |
|
|
0xe28cca00, /* add ip, ip, #0xNN000 */
|
1960 |
|
|
0xe5bcf000, /* ldr pc, [ip, #0xNNN]! */
|
1961 |
|
|
};
|
1962 |
|
|
|
1963 |
|
|
#endif
|
1964 |
|
|
|
1965 |
|
|
/* The format of the first entry in the procedure linkage table
|
1966 |
|
|
for a VxWorks executable. */
|
1967 |
|
|
static const bfd_vma elf32_arm_vxworks_exec_plt0_entry[] =
|
1968 |
|
|
{
|
1969 |
|
|
0xe52dc008, /* str ip,[sp,#-8]! */
|
1970 |
|
|
0xe59fc000, /* ldr ip,[pc] */
|
1971 |
|
|
0xe59cf008, /* ldr pc,[ip,#8] */
|
1972 |
|
|
0x00000000, /* .long _GLOBAL_OFFSET_TABLE_ */
|
1973 |
|
|
};
|
1974 |
|
|
|
1975 |
|
|
/* The format of subsequent entries in a VxWorks executable. */
|
1976 |
|
|
static const bfd_vma elf32_arm_vxworks_exec_plt_entry[] =
|
1977 |
|
|
{
|
1978 |
|
|
0xe59fc000, /* ldr ip,[pc] */
|
1979 |
|
|
0xe59cf000, /* ldr pc,[ip] */
|
1980 |
|
|
0x00000000, /* .long @got */
|
1981 |
|
|
0xe59fc000, /* ldr ip,[pc] */
|
1982 |
|
|
0xea000000, /* b _PLT */
|
1983 |
|
|
0x00000000, /* .long @pltindex*sizeof(Elf32_Rela) */
|
1984 |
|
|
};
|
1985 |
|
|
|
1986 |
|
|
/* The format of entries in a VxWorks shared library. */
|
1987 |
|
|
static const bfd_vma elf32_arm_vxworks_shared_plt_entry[] =
|
1988 |
|
|
{
|
1989 |
|
|
0xe59fc000, /* ldr ip,[pc] */
|
1990 |
|
|
0xe79cf009, /* ldr pc,[ip,r9] */
|
1991 |
|
|
0x00000000, /* .long @got */
|
1992 |
|
|
0xe59fc000, /* ldr ip,[pc] */
|
1993 |
|
|
0xe599f008, /* ldr pc,[r9,#8] */
|
1994 |
|
|
0x00000000, /* .long @pltindex*sizeof(Elf32_Rela) */
|
1995 |
|
|
};
|
1996 |
|
|
|
1997 |
|
|
/* An initial stub used if the PLT entry is referenced from Thumb code. */
|
1998 |
|
|
#define PLT_THUMB_STUB_SIZE 4
|
1999 |
|
|
static const bfd_vma elf32_arm_plt_thumb_stub [] =
|
2000 |
|
|
{
|
2001 |
|
|
0x4778, /* bx pc */
|
2002 |
|
|
0x46c0 /* nop */
|
2003 |
|
|
};
|
2004 |
|
|
|
2005 |
|
|
/* The entries in a PLT when using a DLL-based target with multiple
|
2006 |
|
|
address spaces. */
|
2007 |
|
|
static const bfd_vma elf32_arm_symbian_plt_entry [] =
|
2008 |
|
|
{
|
2009 |
|
|
0xe51ff004, /* ldr pc, [pc, #-4] */
|
2010 |
|
|
0x00000000, /* dcd R_ARM_GLOB_DAT(X) */
|
2011 |
|
|
};
|
2012 |
|
|
|
2013 |
|
|
/* Used to build a map of a section. This is required for mixed-endian
|
2014 |
|
|
code/data. */
|
2015 |
|
|
|
2016 |
|
|
typedef struct elf32_elf_section_map
|
2017 |
|
|
{
|
2018 |
|
|
bfd_vma vma;
|
2019 |
|
|
char type;
|
2020 |
|
|
}
|
2021 |
|
|
elf32_arm_section_map;
|
2022 |
|
|
|
2023 |
|
|
/* Information about a VFP11 erratum veneer, or a branch to such a veneer. */
|
2024 |
|
|
|
2025 |
|
|
typedef enum
|
2026 |
|
|
{
|
2027 |
|
|
VFP11_ERRATUM_BRANCH_TO_ARM_VENEER,
|
2028 |
|
|
VFP11_ERRATUM_BRANCH_TO_THUMB_VENEER,
|
2029 |
|
|
VFP11_ERRATUM_ARM_VENEER,
|
2030 |
|
|
VFP11_ERRATUM_THUMB_VENEER
|
2031 |
|
|
}
|
2032 |
|
|
elf32_vfp11_erratum_type;
|
2033 |
|
|
|
2034 |
|
|
typedef struct elf32_vfp11_erratum_list
|
2035 |
|
|
{
|
2036 |
|
|
struct elf32_vfp11_erratum_list *next;
|
2037 |
|
|
bfd_vma vma;
|
2038 |
|
|
union
|
2039 |
|
|
{
|
2040 |
|
|
struct
|
2041 |
|
|
{
|
2042 |
|
|
struct elf32_vfp11_erratum_list *veneer;
|
2043 |
|
|
unsigned int vfp_insn;
|
2044 |
|
|
} b;
|
2045 |
|
|
struct
|
2046 |
|
|
{
|
2047 |
|
|
struct elf32_vfp11_erratum_list *branch;
|
2048 |
|
|
unsigned int id;
|
2049 |
|
|
} v;
|
2050 |
|
|
} u;
|
2051 |
|
|
elf32_vfp11_erratum_type type;
|
2052 |
|
|
}
|
2053 |
|
|
elf32_vfp11_erratum_list;
|
2054 |
|
|
|
2055 |
|
|
typedef struct _arm_elf_section_data
|
2056 |
|
|
{
|
2057 |
|
|
struct bfd_elf_section_data elf;
|
2058 |
|
|
unsigned int mapcount;
|
2059 |
|
|
unsigned int mapsize;
|
2060 |
|
|
elf32_arm_section_map *map;
|
2061 |
|
|
unsigned int erratumcount;
|
2062 |
|
|
elf32_vfp11_erratum_list *erratumlist;
|
2063 |
|
|
}
|
2064 |
|
|
_arm_elf_section_data;
|
2065 |
|
|
|
2066 |
|
|
#define elf32_arm_section_data(sec) \
|
2067 |
|
|
((_arm_elf_section_data *) elf_section_data (sec))
|
2068 |
|
|
|
2069 |
|
|
/* The size of the thread control block. */
|
2070 |
|
|
#define TCB_SIZE 8
|
2071 |
|
|
|
2072 |
|
|
struct elf_arm_obj_tdata
|
2073 |
|
|
{
|
2074 |
|
|
struct elf_obj_tdata root;
|
2075 |
|
|
|
2076 |
|
|
/* tls_type for each local got entry. */
|
2077 |
|
|
char *local_got_tls_type;
|
2078 |
|
|
|
2079 |
|
|
/* Zero to warn when linking objects with incompatible enum sizes. */
|
2080 |
|
|
int no_enum_size_warning;
|
2081 |
|
|
};
|
2082 |
|
|
|
2083 |
|
|
#define elf_arm_tdata(bfd) \
|
2084 |
|
|
((struct elf_arm_obj_tdata *) (bfd)->tdata.any)
|
2085 |
|
|
|
2086 |
|
|
#define elf32_arm_local_got_tls_type(bfd) \
|
2087 |
|
|
(elf_arm_tdata (bfd)->local_got_tls_type)
|
2088 |
|
|
|
2089 |
|
|
#define is_arm_elf(bfd) \
|
2090 |
|
|
(bfd_get_flavour (bfd) == bfd_target_elf_flavour \
|
2091 |
|
|
&& elf_tdata (bfd) != NULL \
|
2092 |
|
|
&& elf_object_id (bfd) == ARM_ELF_TDATA)
|
2093 |
|
|
|
2094 |
|
|
static bfd_boolean
|
2095 |
|
|
elf32_arm_mkobject (bfd *abfd)
|
2096 |
|
|
{
|
2097 |
|
|
return bfd_elf_allocate_object (abfd, sizeof (struct elf_arm_obj_tdata),
|
2098 |
|
|
ARM_ELF_TDATA);
|
2099 |
|
|
}
|
2100 |
|
|
|
2101 |
|
|
/* The ARM linker needs to keep track of the number of relocs that it
|
2102 |
|
|
decides to copy in check_relocs for each symbol. This is so that
|
2103 |
|
|
it can discard PC relative relocs if it doesn't need them when
|
2104 |
|
|
linking with -Bsymbolic. We store the information in a field
|
2105 |
|
|
extending the regular ELF linker hash table. */
|
2106 |
|
|
|
2107 |
|
|
/* This structure keeps track of the number of relocs we have copied
|
2108 |
|
|
for a given symbol. */
|
2109 |
|
|
struct elf32_arm_relocs_copied
|
2110 |
|
|
{
|
2111 |
|
|
/* Next section. */
|
2112 |
|
|
struct elf32_arm_relocs_copied * next;
|
2113 |
|
|
/* A section in dynobj. */
|
2114 |
|
|
asection * section;
|
2115 |
|
|
/* Number of relocs copied in this section. */
|
2116 |
|
|
bfd_size_type count;
|
2117 |
|
|
/* Number of PC-relative relocs copied in this section. */
|
2118 |
|
|
bfd_size_type pc_count;
|
2119 |
|
|
};
|
2120 |
|
|
|
2121 |
|
|
#define elf32_arm_hash_entry(ent) ((struct elf32_arm_link_hash_entry *)(ent))
|
2122 |
|
|
|
2123 |
|
|
/* Arm ELF linker hash entry. */
|
2124 |
|
|
struct elf32_arm_link_hash_entry
|
2125 |
|
|
{
|
2126 |
|
|
struct elf_link_hash_entry root;
|
2127 |
|
|
|
2128 |
|
|
/* Number of PC relative relocs copied for this symbol. */
|
2129 |
|
|
struct elf32_arm_relocs_copied * relocs_copied;
|
2130 |
|
|
|
2131 |
|
|
/* We reference count Thumb references to a PLT entry separately,
|
2132 |
|
|
so that we can emit the Thumb trampoline only if needed. */
|
2133 |
|
|
bfd_signed_vma plt_thumb_refcount;
|
2134 |
|
|
|
2135 |
|
|
/* Some references from Thumb code may be eliminated by BL->BLX
|
2136 |
|
|
conversion, so record them separately. */
|
2137 |
|
|
bfd_signed_vma plt_maybe_thumb_refcount;
|
2138 |
|
|
|
2139 |
|
|
/* Since PLT entries have variable size if the Thumb prologue is
|
2140 |
|
|
used, we need to record the index into .got.plt instead of
|
2141 |
|
|
recomputing it from the PLT offset. */
|
2142 |
|
|
bfd_signed_vma plt_got_offset;
|
2143 |
|
|
|
2144 |
|
|
#define GOT_UNKNOWN 0
|
2145 |
|
|
#define GOT_NORMAL 1
|
2146 |
|
|
#define GOT_TLS_GD 2
|
2147 |
|
|
#define GOT_TLS_IE 4
|
2148 |
|
|
unsigned char tls_type;
|
2149 |
|
|
|
2150 |
|
|
/* The symbol marking the real symbol location for exported thumb
|
2151 |
|
|
symbols with Arm stubs. */
|
2152 |
|
|
struct elf_link_hash_entry *export_glue;
|
2153 |
|
|
};
|
2154 |
|
|
|
2155 |
|
|
/* Traverse an arm ELF linker hash table. */
|
2156 |
|
|
#define elf32_arm_link_hash_traverse(table, func, info) \
|
2157 |
|
|
(elf_link_hash_traverse \
|
2158 |
|
|
(&(table)->root, \
|
2159 |
|
|
(bfd_boolean (*) (struct elf_link_hash_entry *, void *)) (func), \
|
2160 |
|
|
(info)))
|
2161 |
|
|
|
2162 |
|
|
/* Get the ARM elf linker hash table from a link_info structure. */
|
2163 |
|
|
#define elf32_arm_hash_table(info) \
|
2164 |
|
|
((struct elf32_arm_link_hash_table *) ((info)->hash))
|
2165 |
|
|
|
2166 |
|
|
/* ARM ELF linker hash table. */
|
2167 |
|
|
struct elf32_arm_link_hash_table
|
2168 |
|
|
{
|
2169 |
|
|
/* The main hash table. */
|
2170 |
|
|
struct elf_link_hash_table root;
|
2171 |
|
|
|
2172 |
|
|
/* The size in bytes of the section containing the Thumb-to-ARM glue. */
|
2173 |
|
|
bfd_size_type thumb_glue_size;
|
2174 |
|
|
|
2175 |
|
|
/* The size in bytes of the section containing the ARM-to-Thumb glue. */
|
2176 |
|
|
bfd_size_type arm_glue_size;
|
2177 |
|
|
|
2178 |
|
|
/* The size in bytes of section containing the ARMv4 BX veneers. */
|
2179 |
|
|
bfd_size_type bx_glue_size;
|
2180 |
|
|
|
2181 |
|
|
/* Offsets of ARMv4 BX veneers. Bit1 set if present, and Bit0 set when
|
2182 |
|
|
veneer has been populated. */
|
2183 |
|
|
bfd_vma bx_glue_offset[15];
|
2184 |
|
|
|
2185 |
|
|
/* The size in bytes of the section containing glue for VFP11 erratum
|
2186 |
|
|
veneers. */
|
2187 |
|
|
bfd_size_type vfp11_erratum_glue_size;
|
2188 |
|
|
|
2189 |
|
|
/* An arbitrary input BFD chosen to hold the glue sections. */
|
2190 |
|
|
bfd * bfd_of_glue_owner;
|
2191 |
|
|
|
2192 |
|
|
/* Nonzero to output a BE8 image. */
|
2193 |
|
|
int byteswap_code;
|
2194 |
|
|
|
2195 |
|
|
/* Zero if R_ARM_TARGET1 means R_ARM_ABS32.
|
2196 |
|
|
Nonzero if R_ARM_TARGET1 means R_ARM_REL32. */
|
2197 |
|
|
int target1_is_rel;
|
2198 |
|
|
|
2199 |
|
|
/* The relocation to use for R_ARM_TARGET2 relocations. */
|
2200 |
|
|
int target2_reloc;
|
2201 |
|
|
|
2202 |
|
|
/* 0 = Ignore R_ARM_V4BX.
|
2203 |
|
|
1 = Convert BX to MOV PC.
|
2204 |
|
|
2 = Generate v4 interworing stubs. */
|
2205 |
|
|
int fix_v4bx;
|
2206 |
|
|
|
2207 |
|
|
/* Nonzero if the ARM/Thumb BLX instructions are available for use. */
|
2208 |
|
|
int use_blx;
|
2209 |
|
|
|
2210 |
|
|
/* What sort of code sequences we should look for which may trigger the
|
2211 |
|
|
VFP11 denorm erratum. */
|
2212 |
|
|
bfd_arm_vfp11_fix vfp11_fix;
|
2213 |
|
|
|
2214 |
|
|
/* Global counter for the number of fixes we have emitted. */
|
2215 |
|
|
int num_vfp11_fixes;
|
2216 |
|
|
|
2217 |
|
|
/* Nonzero to force PIC branch veneers. */
|
2218 |
|
|
int pic_veneer;
|
2219 |
|
|
|
2220 |
|
|
/* The number of bytes in the initial entry in the PLT. */
|
2221 |
|
|
bfd_size_type plt_header_size;
|
2222 |
|
|
|
2223 |
|
|
/* The number of bytes in the subsequent PLT etries. */
|
2224 |
|
|
bfd_size_type plt_entry_size;
|
2225 |
|
|
|
2226 |
|
|
/* True if the target system is VxWorks. */
|
2227 |
|
|
int vxworks_p;
|
2228 |
|
|
|
2229 |
|
|
/* True if the target system is Symbian OS. */
|
2230 |
|
|
int symbian_p;
|
2231 |
|
|
|
2232 |
|
|
/* True if the target uses REL relocations. */
|
2233 |
|
|
int use_rel;
|
2234 |
|
|
|
2235 |
|
|
/* Short-cuts to get to dynamic linker sections. */
|
2236 |
|
|
asection *sgot;
|
2237 |
|
|
asection *sgotplt;
|
2238 |
|
|
asection *srelgot;
|
2239 |
|
|
asection *splt;
|
2240 |
|
|
asection *srelplt;
|
2241 |
|
|
asection *sdynbss;
|
2242 |
|
|
asection *srelbss;
|
2243 |
|
|
|
2244 |
|
|
/* The (unloaded but important) VxWorks .rela.plt.unloaded section. */
|
2245 |
|
|
asection *srelplt2;
|
2246 |
|
|
|
2247 |
|
|
/* Data for R_ARM_TLS_LDM32 relocations. */
|
2248 |
|
|
union {
|
2249 |
|
|
bfd_signed_vma refcount;
|
2250 |
|
|
bfd_vma offset;
|
2251 |
|
|
} tls_ldm_got;
|
2252 |
|
|
|
2253 |
|
|
/* Small local sym to section mapping cache. */
|
2254 |
|
|
struct sym_sec_cache sym_sec;
|
2255 |
|
|
|
2256 |
|
|
/* For convenience in allocate_dynrelocs. */
|
2257 |
|
|
bfd * obfd;
|
2258 |
|
|
};
|
2259 |
|
|
|
2260 |
|
|
/* Create an entry in an ARM ELF linker hash table. */
|
2261 |
|
|
|
2262 |
|
|
static struct bfd_hash_entry *
|
2263 |
|
|
elf32_arm_link_hash_newfunc (struct bfd_hash_entry * entry,
|
2264 |
|
|
struct bfd_hash_table * table,
|
2265 |
|
|
const char * string)
|
2266 |
|
|
{
|
2267 |
|
|
struct elf32_arm_link_hash_entry * ret =
|
2268 |
|
|
(struct elf32_arm_link_hash_entry *) entry;
|
2269 |
|
|
|
2270 |
|
|
/* Allocate the structure if it has not already been allocated by a
|
2271 |
|
|
subclass. */
|
2272 |
|
|
if (ret == (struct elf32_arm_link_hash_entry *) NULL)
|
2273 |
|
|
ret = bfd_hash_allocate (table, sizeof (struct elf32_arm_link_hash_entry));
|
2274 |
|
|
if (ret == NULL)
|
2275 |
|
|
return (struct bfd_hash_entry *) ret;
|
2276 |
|
|
|
2277 |
|
|
/* Call the allocation method of the superclass. */
|
2278 |
|
|
ret = ((struct elf32_arm_link_hash_entry *)
|
2279 |
|
|
_bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret,
|
2280 |
|
|
table, string));
|
2281 |
|
|
if (ret != NULL)
|
2282 |
|
|
{
|
2283 |
|
|
ret->relocs_copied = NULL;
|
2284 |
|
|
ret->tls_type = GOT_UNKNOWN;
|
2285 |
|
|
ret->plt_thumb_refcount = 0;
|
2286 |
|
|
ret->plt_maybe_thumb_refcount = 0;
|
2287 |
|
|
ret->plt_got_offset = -1;
|
2288 |
|
|
ret->export_glue = NULL;
|
2289 |
|
|
}
|
2290 |
|
|
|
2291 |
|
|
return (struct bfd_hash_entry *) ret;
|
2292 |
|
|
}
|
2293 |
|
|
|
2294 |
|
|
/* Return true if NAME is the name of the relocation section associated
|
2295 |
|
|
with S. */
|
2296 |
|
|
|
2297 |
|
|
static bfd_boolean
|
2298 |
|
|
reloc_section_p (struct elf32_arm_link_hash_table *htab,
|
2299 |
|
|
const char *name, asection *s)
|
2300 |
|
|
{
|
2301 |
|
|
if (htab->use_rel)
|
2302 |
|
|
return CONST_STRNEQ (name, ".rel") && strcmp (s->name, name + 4) == 0;
|
2303 |
|
|
else
|
2304 |
|
|
return CONST_STRNEQ (name, ".rela") && strcmp (s->name, name + 5) == 0;
|
2305 |
|
|
}
|
2306 |
|
|
|
2307 |
|
|
/* Create .got, .gotplt, and .rel(a).got sections in DYNOBJ, and set up
|
2308 |
|
|
shortcuts to them in our hash table. */
|
2309 |
|
|
|
2310 |
|
|
static bfd_boolean
|
2311 |
|
|
create_got_section (bfd *dynobj, struct bfd_link_info *info)
|
2312 |
|
|
{
|
2313 |
|
|
struct elf32_arm_link_hash_table *htab;
|
2314 |
|
|
|
2315 |
|
|
htab = elf32_arm_hash_table (info);
|
2316 |
|
|
/* BPABI objects never have a GOT, or associated sections. */
|
2317 |
|
|
if (htab->symbian_p)
|
2318 |
|
|
return TRUE;
|
2319 |
|
|
|
2320 |
|
|
if (! _bfd_elf_create_got_section (dynobj, info))
|
2321 |
|
|
return FALSE;
|
2322 |
|
|
|
2323 |
|
|
htab->sgot = bfd_get_section_by_name (dynobj, ".got");
|
2324 |
|
|
htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
|
2325 |
|
|
if (!htab->sgot || !htab->sgotplt)
|
2326 |
|
|
abort ();
|
2327 |
|
|
|
2328 |
|
|
htab->srelgot = bfd_make_section_with_flags (dynobj,
|
2329 |
|
|
RELOC_SECTION (htab, ".got"),
|
2330 |
|
|
(SEC_ALLOC | SEC_LOAD
|
2331 |
|
|
| SEC_HAS_CONTENTS
|
2332 |
|
|
| SEC_IN_MEMORY
|
2333 |
|
|
| SEC_LINKER_CREATED
|
2334 |
|
|
| SEC_READONLY));
|
2335 |
|
|
if (htab->srelgot == NULL
|
2336 |
|
|
|| ! bfd_set_section_alignment (dynobj, htab->srelgot, 2))
|
2337 |
|
|
return FALSE;
|
2338 |
|
|
return TRUE;
|
2339 |
|
|
}
|
2340 |
|
|
|
2341 |
|
|
/* Create .plt, .rel(a).plt, .got, .got.plt, .rel(a).got, .dynbss, and
|
2342 |
|
|
.rel(a).bss sections in DYNOBJ, and set up shortcuts to them in our
|
2343 |
|
|
hash table. */
|
2344 |
|
|
|
2345 |
|
|
static bfd_boolean
|
2346 |
|
|
elf32_arm_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info)
|
2347 |
|
|
{
|
2348 |
|
|
struct elf32_arm_link_hash_table *htab;
|
2349 |
|
|
|
2350 |
|
|
htab = elf32_arm_hash_table (info);
|
2351 |
|
|
if (!htab->sgot && !create_got_section (dynobj, info))
|
2352 |
|
|
return FALSE;
|
2353 |
|
|
|
2354 |
|
|
if (!_bfd_elf_create_dynamic_sections (dynobj, info))
|
2355 |
|
|
return FALSE;
|
2356 |
|
|
|
2357 |
|
|
htab->splt = bfd_get_section_by_name (dynobj, ".plt");
|
2358 |
|
|
htab->srelplt = bfd_get_section_by_name (dynobj,
|
2359 |
|
|
RELOC_SECTION (htab, ".plt"));
|
2360 |
|
|
htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss");
|
2361 |
|
|
if (!info->shared)
|
2362 |
|
|
htab->srelbss = bfd_get_section_by_name (dynobj,
|
2363 |
|
|
RELOC_SECTION (htab, ".bss"));
|
2364 |
|
|
|
2365 |
|
|
if (htab->vxworks_p)
|
2366 |
|
|
{
|
2367 |
|
|
if (!elf_vxworks_create_dynamic_sections (dynobj, info, &htab->srelplt2))
|
2368 |
|
|
return FALSE;
|
2369 |
|
|
|
2370 |
|
|
if (info->shared)
|
2371 |
|
|
{
|
2372 |
|
|
htab->plt_header_size = 0;
|
2373 |
|
|
htab->plt_entry_size
|
2374 |
|
|
= 4 * ARRAY_SIZE (elf32_arm_vxworks_shared_plt_entry);
|
2375 |
|
|
}
|
2376 |
|
|
else
|
2377 |
|
|
{
|
2378 |
|
|
htab->plt_header_size
|
2379 |
|
|
= 4 * ARRAY_SIZE (elf32_arm_vxworks_exec_plt0_entry);
|
2380 |
|
|
htab->plt_entry_size
|
2381 |
|
|
= 4 * ARRAY_SIZE (elf32_arm_vxworks_exec_plt_entry);
|
2382 |
|
|
}
|
2383 |
|
|
}
|
2384 |
|
|
|
2385 |
|
|
if (!htab->splt
|
2386 |
|
|
|| !htab->srelplt
|
2387 |
|
|
|| !htab->sdynbss
|
2388 |
|
|
|| (!info->shared && !htab->srelbss))
|
2389 |
|
|
abort ();
|
2390 |
|
|
|
2391 |
|
|
return TRUE;
|
2392 |
|
|
}
|
2393 |
|
|
|
2394 |
|
|
/* Copy the extra info we tack onto an elf_link_hash_entry. */
|
2395 |
|
|
|
2396 |
|
|
static void
|
2397 |
|
|
elf32_arm_copy_indirect_symbol (struct bfd_link_info *info,
|
2398 |
|
|
struct elf_link_hash_entry *dir,
|
2399 |
|
|
struct elf_link_hash_entry *ind)
|
2400 |
|
|
{
|
2401 |
|
|
struct elf32_arm_link_hash_entry *edir, *eind;
|
2402 |
|
|
|
2403 |
|
|
edir = (struct elf32_arm_link_hash_entry *) dir;
|
2404 |
|
|
eind = (struct elf32_arm_link_hash_entry *) ind;
|
2405 |
|
|
|
2406 |
|
|
if (eind->relocs_copied != NULL)
|
2407 |
|
|
{
|
2408 |
|
|
if (edir->relocs_copied != NULL)
|
2409 |
|
|
{
|
2410 |
|
|
struct elf32_arm_relocs_copied **pp;
|
2411 |
|
|
struct elf32_arm_relocs_copied *p;
|
2412 |
|
|
|
2413 |
|
|
/* Add reloc counts against the indirect sym to the direct sym
|
2414 |
|
|
list. Merge any entries against the same section. */
|
2415 |
|
|
for (pp = &eind->relocs_copied; (p = *pp) != NULL; )
|
2416 |
|
|
{
|
2417 |
|
|
struct elf32_arm_relocs_copied *q;
|
2418 |
|
|
|
2419 |
|
|
for (q = edir->relocs_copied; q != NULL; q = q->next)
|
2420 |
|
|
if (q->section == p->section)
|
2421 |
|
|
{
|
2422 |
|
|
q->pc_count += p->pc_count;
|
2423 |
|
|
q->count += p->count;
|
2424 |
|
|
*pp = p->next;
|
2425 |
|
|
break;
|
2426 |
|
|
}
|
2427 |
|
|
if (q == NULL)
|
2428 |
|
|
pp = &p->next;
|
2429 |
|
|
}
|
2430 |
|
|
*pp = edir->relocs_copied;
|
2431 |
|
|
}
|
2432 |
|
|
|
2433 |
|
|
edir->relocs_copied = eind->relocs_copied;
|
2434 |
|
|
eind->relocs_copied = NULL;
|
2435 |
|
|
}
|
2436 |
|
|
|
2437 |
|
|
if (ind->root.type == bfd_link_hash_indirect)
|
2438 |
|
|
{
|
2439 |
|
|
/* Copy over PLT info. */
|
2440 |
|
|
edir->plt_thumb_refcount += eind->plt_thumb_refcount;
|
2441 |
|
|
eind->plt_thumb_refcount = 0;
|
2442 |
|
|
edir->plt_maybe_thumb_refcount += eind->plt_maybe_thumb_refcount;
|
2443 |
|
|
eind->plt_maybe_thumb_refcount = 0;
|
2444 |
|
|
|
2445 |
|
|
if (dir->got.refcount <= 0)
|
2446 |
|
|
{
|
2447 |
|
|
edir->tls_type = eind->tls_type;
|
2448 |
|
|
eind->tls_type = GOT_UNKNOWN;
|
2449 |
|
|
}
|
2450 |
|
|
}
|
2451 |
|
|
|
2452 |
|
|
_bfd_elf_link_hash_copy_indirect (info, dir, ind);
|
2453 |
|
|
}
|
2454 |
|
|
|
2455 |
|
|
/* Create an ARM elf linker hash table. */
|
2456 |
|
|
|
2457 |
|
|
static struct bfd_link_hash_table *
|
2458 |
|
|
elf32_arm_link_hash_table_create (bfd *abfd)
|
2459 |
|
|
{
|
2460 |
|
|
struct elf32_arm_link_hash_table *ret;
|
2461 |
|
|
bfd_size_type amt = sizeof (struct elf32_arm_link_hash_table);
|
2462 |
|
|
|
2463 |
|
|
ret = bfd_malloc (amt);
|
2464 |
|
|
if (ret == NULL)
|
2465 |
|
|
return NULL;
|
2466 |
|
|
|
2467 |
|
|
if (!_bfd_elf_link_hash_table_init (& ret->root, abfd,
|
2468 |
|
|
elf32_arm_link_hash_newfunc,
|
2469 |
|
|
sizeof (struct elf32_arm_link_hash_entry)))
|
2470 |
|
|
{
|
2471 |
|
|
free (ret);
|
2472 |
|
|
return NULL;
|
2473 |
|
|
}
|
2474 |
|
|
|
2475 |
|
|
ret->sgot = NULL;
|
2476 |
|
|
ret->sgotplt = NULL;
|
2477 |
|
|
ret->srelgot = NULL;
|
2478 |
|
|
ret->splt = NULL;
|
2479 |
|
|
ret->srelplt = NULL;
|
2480 |
|
|
ret->sdynbss = NULL;
|
2481 |
|
|
ret->srelbss = NULL;
|
2482 |
|
|
ret->srelplt2 = NULL;
|
2483 |
|
|
ret->thumb_glue_size = 0;
|
2484 |
|
|
ret->arm_glue_size = 0;
|
2485 |
|
|
ret->bx_glue_size = 0;
|
2486 |
|
|
memset (ret->bx_glue_offset, 0, sizeof(ret->bx_glue_offset));
|
2487 |
|
|
ret->vfp11_fix = BFD_ARM_VFP11_FIX_NONE;
|
2488 |
|
|
ret->vfp11_erratum_glue_size = 0;
|
2489 |
|
|
ret->num_vfp11_fixes = 0;
|
2490 |
|
|
ret->bfd_of_glue_owner = NULL;
|
2491 |
|
|
ret->byteswap_code = 0;
|
2492 |
|
|
ret->target1_is_rel = 0;
|
2493 |
|
|
ret->target2_reloc = R_ARM_NONE;
|
2494 |
|
|
#ifdef FOUR_WORD_PLT
|
2495 |
|
|
ret->plt_header_size = 16;
|
2496 |
|
|
ret->plt_entry_size = 16;
|
2497 |
|
|
#else
|
2498 |
|
|
ret->plt_header_size = 20;
|
2499 |
|
|
ret->plt_entry_size = 12;
|
2500 |
|
|
#endif
|
2501 |
|
|
ret->fix_v4bx = 0;
|
2502 |
|
|
ret->use_blx = 0;
|
2503 |
|
|
ret->vxworks_p = 0;
|
2504 |
|
|
ret->symbian_p = 0;
|
2505 |
|
|
ret->use_rel = 1;
|
2506 |
|
|
ret->sym_sec.abfd = NULL;
|
2507 |
|
|
ret->obfd = abfd;
|
2508 |
|
|
ret->tls_ldm_got.refcount = 0;
|
2509 |
|
|
|
2510 |
|
|
return &ret->root.root;
|
2511 |
|
|
}
|
2512 |
|
|
|
2513 |
|
|
/* Locate the Thumb encoded calling stub for NAME. */
|
2514 |
|
|
|
2515 |
|
|
static struct elf_link_hash_entry *
|
2516 |
|
|
find_thumb_glue (struct bfd_link_info *link_info,
|
2517 |
|
|
const char *name,
|
2518 |
|
|
char **error_message)
|
2519 |
|
|
{
|
2520 |
|
|
char *tmp_name;
|
2521 |
|
|
struct elf_link_hash_entry *hash;
|
2522 |
|
|
struct elf32_arm_link_hash_table *hash_table;
|
2523 |
|
|
|
2524 |
|
|
/* We need a pointer to the armelf specific hash table. */
|
2525 |
|
|
hash_table = elf32_arm_hash_table (link_info);
|
2526 |
|
|
|
2527 |
|
|
tmp_name = bfd_malloc ((bfd_size_type) strlen (name)
|
2528 |
|
|
+ strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1);
|
2529 |
|
|
|
2530 |
|
|
BFD_ASSERT (tmp_name);
|
2531 |
|
|
|
2532 |
|
|
sprintf (tmp_name, THUMB2ARM_GLUE_ENTRY_NAME, name);
|
2533 |
|
|
|
2534 |
|
|
hash = elf_link_hash_lookup
|
2535 |
|
|
(&(hash_table)->root, tmp_name, FALSE, FALSE, TRUE);
|
2536 |
|
|
|
2537 |
|
|
if (hash == NULL
|
2538 |
|
|
&& asprintf (error_message, _("unable to find THUMB glue '%s' for '%s'"),
|
2539 |
|
|
tmp_name, name) == -1)
|
2540 |
|
|
*error_message = (char *) bfd_errmsg (bfd_error_system_call);
|
2541 |
|
|
|
2542 |
|
|
free (tmp_name);
|
2543 |
|
|
|
2544 |
|
|
return hash;
|
2545 |
|
|
}
|
2546 |
|
|
|
2547 |
|
|
/* Locate the ARM encoded calling stub for NAME. */
|
2548 |
|
|
|
2549 |
|
|
static struct elf_link_hash_entry *
|
2550 |
|
|
find_arm_glue (struct bfd_link_info *link_info,
|
2551 |
|
|
const char *name,
|
2552 |
|
|
char **error_message)
|
2553 |
|
|
{
|
2554 |
|
|
char *tmp_name;
|
2555 |
|
|
struct elf_link_hash_entry *myh;
|
2556 |
|
|
struct elf32_arm_link_hash_table *hash_table;
|
2557 |
|
|
|
2558 |
|
|
/* We need a pointer to the elfarm specific hash table. */
|
2559 |
|
|
hash_table = elf32_arm_hash_table (link_info);
|
2560 |
|
|
|
2561 |
|
|
tmp_name = bfd_malloc ((bfd_size_type) strlen (name)
|
2562 |
|
|
+ strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1);
|
2563 |
|
|
|
2564 |
|
|
BFD_ASSERT (tmp_name);
|
2565 |
|
|
|
2566 |
|
|
sprintf (tmp_name, ARM2THUMB_GLUE_ENTRY_NAME, name);
|
2567 |
|
|
|
2568 |
|
|
myh = elf_link_hash_lookup
|
2569 |
|
|
(&(hash_table)->root, tmp_name, FALSE, FALSE, TRUE);
|
2570 |
|
|
|
2571 |
|
|
if (myh == NULL
|
2572 |
|
|
&& asprintf (error_message, _("unable to find ARM glue '%s' for '%s'"),
|
2573 |
|
|
tmp_name, name) == -1)
|
2574 |
|
|
*error_message = (char *) bfd_errmsg (bfd_error_system_call);
|
2575 |
|
|
|
2576 |
|
|
free (tmp_name);
|
2577 |
|
|
|
2578 |
|
|
return myh;
|
2579 |
|
|
}
|
2580 |
|
|
|
2581 |
|
|
/* ARM->Thumb glue (static images):
|
2582 |
|
|
|
2583 |
|
|
.arm
|
2584 |
|
|
__func_from_arm:
|
2585 |
|
|
ldr r12, __func_addr
|
2586 |
|
|
bx r12
|
2587 |
|
|
__func_addr:
|
2588 |
|
|
.word func @ behave as if you saw a ARM_32 reloc.
|
2589 |
|
|
|
2590 |
|
|
(v5t static images)
|
2591 |
|
|
.arm
|
2592 |
|
|
__func_from_arm:
|
2593 |
|
|
ldr pc, __func_addr
|
2594 |
|
|
__func_addr:
|
2595 |
|
|
.word func @ behave as if you saw a ARM_32 reloc.
|
2596 |
|
|
|
2597 |
|
|
(relocatable images)
|
2598 |
|
|
.arm
|
2599 |
|
|
__func_from_arm:
|
2600 |
|
|
ldr r12, __func_offset
|
2601 |
|
|
add r12, r12, pc
|
2602 |
|
|
bx r12
|
2603 |
|
|
__func_offset:
|
2604 |
|
|
.word func - .
|
2605 |
|
|
*/
|
2606 |
|
|
|
2607 |
|
|
#define ARM2THUMB_STATIC_GLUE_SIZE 12
|
2608 |
|
|
static const insn32 a2t1_ldr_insn = 0xe59fc000;
|
2609 |
|
|
static const insn32 a2t2_bx_r12_insn = 0xe12fff1c;
|
2610 |
|
|
static const insn32 a2t3_func_addr_insn = 0x00000001;
|
2611 |
|
|
|
2612 |
|
|
#define ARM2THUMB_V5_STATIC_GLUE_SIZE 8
|
2613 |
|
|
static const insn32 a2t1v5_ldr_insn = 0xe51ff004;
|
2614 |
|
|
static const insn32 a2t2v5_func_addr_insn = 0x00000001;
|
2615 |
|
|
|
2616 |
|
|
#define ARM2THUMB_PIC_GLUE_SIZE 16
|
2617 |
|
|
static const insn32 a2t1p_ldr_insn = 0xe59fc004;
|
2618 |
|
|
static const insn32 a2t2p_add_pc_insn = 0xe08cc00f;
|
2619 |
|
|
static const insn32 a2t3p_bx_r12_insn = 0xe12fff1c;
|
2620 |
|
|
|
2621 |
|
|
/* Thumb->ARM: Thumb->(non-interworking aware) ARM
|
2622 |
|
|
|
2623 |
|
|
.thumb .thumb
|
2624 |
|
|
.align 2 .align 2
|
2625 |
|
|
__func_from_thumb: __func_from_thumb:
|
2626 |
|
|
bx pc push {r6, lr}
|
2627 |
|
|
nop ldr r6, __func_addr
|
2628 |
|
|
.arm mov lr, pc
|
2629 |
|
|
__func_change_to_arm: bx r6
|
2630 |
|
|
b func .arm
|
2631 |
|
|
__func_back_to_thumb:
|
2632 |
|
|
ldmia r13! {r6, lr}
|
2633 |
|
|
bx lr
|
2634 |
|
|
__func_addr:
|
2635 |
|
|
.word func */
|
2636 |
|
|
|
2637 |
|
|
#define THUMB2ARM_GLUE_SIZE 8
|
2638 |
|
|
static const insn16 t2a1_bx_pc_insn = 0x4778;
|
2639 |
|
|
static const insn16 t2a2_noop_insn = 0x46c0;
|
2640 |
|
|
static const insn32 t2a3_b_insn = 0xea000000;
|
2641 |
|
|
|
2642 |
|
|
#define VFP11_ERRATUM_VENEER_SIZE 8
|
2643 |
|
|
|
2644 |
|
|
#define ARM_BX_VENEER_SIZE 12
|
2645 |
|
|
static const insn32 armbx1_tst_insn = 0xe3100001;
|
2646 |
|
|
static const insn32 armbx2_moveq_insn = 0x01a0f000;
|
2647 |
|
|
static const insn32 armbx3_bx_insn = 0xe12fff10;
|
2648 |
|
|
|
2649 |
|
|
#ifndef ELFARM_NABI_C_INCLUDED
|
2650 |
|
|
bfd_boolean
|
2651 |
|
|
bfd_elf32_arm_allocate_interworking_sections (struct bfd_link_info * info)
|
2652 |
|
|
{
|
2653 |
|
|
asection * s;
|
2654 |
|
|
bfd_byte * foo;
|
2655 |
|
|
struct elf32_arm_link_hash_table * globals;
|
2656 |
|
|
|
2657 |
|
|
globals = elf32_arm_hash_table (info);
|
2658 |
|
|
|
2659 |
|
|
BFD_ASSERT (globals != NULL);
|
2660 |
|
|
|
2661 |
|
|
if (globals->arm_glue_size != 0)
|
2662 |
|
|
{
|
2663 |
|
|
BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
|
2664 |
|
|
|
2665 |
|
|
s = bfd_get_section_by_name (globals->bfd_of_glue_owner,
|
2666 |
|
|
ARM2THUMB_GLUE_SECTION_NAME);
|
2667 |
|
|
|
2668 |
|
|
BFD_ASSERT (s != NULL);
|
2669 |
|
|
|
2670 |
|
|
foo = bfd_alloc (globals->bfd_of_glue_owner, globals->arm_glue_size);
|
2671 |
|
|
|
2672 |
|
|
BFD_ASSERT (s->size == globals->arm_glue_size);
|
2673 |
|
|
s->contents = foo;
|
2674 |
|
|
}
|
2675 |
|
|
|
2676 |
|
|
if (globals->thumb_glue_size != 0)
|
2677 |
|
|
{
|
2678 |
|
|
BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
|
2679 |
|
|
|
2680 |
|
|
s = bfd_get_section_by_name
|
2681 |
|
|
(globals->bfd_of_glue_owner, THUMB2ARM_GLUE_SECTION_NAME);
|
2682 |
|
|
|
2683 |
|
|
BFD_ASSERT (s != NULL);
|
2684 |
|
|
|
2685 |
|
|
foo = bfd_alloc (globals->bfd_of_glue_owner, globals->thumb_glue_size);
|
2686 |
|
|
|
2687 |
|
|
BFD_ASSERT (s->size == globals->thumb_glue_size);
|
2688 |
|
|
s->contents = foo;
|
2689 |
|
|
}
|
2690 |
|
|
|
2691 |
|
|
if (globals->vfp11_erratum_glue_size != 0)
|
2692 |
|
|
{
|
2693 |
|
|
BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
|
2694 |
|
|
|
2695 |
|
|
s = bfd_get_section_by_name
|
2696 |
|
|
(globals->bfd_of_glue_owner, VFP11_ERRATUM_VENEER_SECTION_NAME);
|
2697 |
|
|
|
2698 |
|
|
BFD_ASSERT (s != NULL);
|
2699 |
|
|
|
2700 |
|
|
foo = bfd_alloc (globals->bfd_of_glue_owner,
|
2701 |
|
|
globals->vfp11_erratum_glue_size);
|
2702 |
|
|
|
2703 |
|
|
BFD_ASSERT (s->size == globals->vfp11_erratum_glue_size);
|
2704 |
|
|
s->contents = foo;
|
2705 |
|
|
}
|
2706 |
|
|
|
2707 |
|
|
if (globals->bx_glue_size != 0)
|
2708 |
|
|
{
|
2709 |
|
|
BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
|
2710 |
|
|
|
2711 |
|
|
s = bfd_get_section_by_name (globals->bfd_of_glue_owner,
|
2712 |
|
|
ARM_BX_GLUE_SECTION_NAME);
|
2713 |
|
|
|
2714 |
|
|
BFD_ASSERT (s != NULL);
|
2715 |
|
|
|
2716 |
|
|
foo = bfd_alloc (globals->bfd_of_glue_owner, globals->bx_glue_size);
|
2717 |
|
|
|
2718 |
|
|
BFD_ASSERT (s->size == globals->bx_glue_size);
|
2719 |
|
|
s->contents = foo;
|
2720 |
|
|
}
|
2721 |
|
|
|
2722 |
|
|
return TRUE;
|
2723 |
|
|
}
|
2724 |
|
|
|
2725 |
|
|
/* Allocate space and symbols for calling a Thumb function from Arm mode.
|
2726 |
|
|
returns the symbol identifying teh stub. */
|
2727 |
|
|
static struct elf_link_hash_entry *
|
2728 |
|
|
record_arm_to_thumb_glue (struct bfd_link_info * link_info,
|
2729 |
|
|
struct elf_link_hash_entry * h)
|
2730 |
|
|
{
|
2731 |
|
|
const char * name = h->root.root.string;
|
2732 |
|
|
asection * s;
|
2733 |
|
|
char * tmp_name;
|
2734 |
|
|
struct elf_link_hash_entry * myh;
|
2735 |
|
|
struct bfd_link_hash_entry * bh;
|
2736 |
|
|
struct elf32_arm_link_hash_table * globals;
|
2737 |
|
|
bfd_vma val;
|
2738 |
|
|
bfd_size_type size;
|
2739 |
|
|
|
2740 |
|
|
globals = elf32_arm_hash_table (link_info);
|
2741 |
|
|
|
2742 |
|
|
BFD_ASSERT (globals != NULL);
|
2743 |
|
|
BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
|
2744 |
|
|
|
2745 |
|
|
s = bfd_get_section_by_name
|
2746 |
|
|
(globals->bfd_of_glue_owner, ARM2THUMB_GLUE_SECTION_NAME);
|
2747 |
|
|
|
2748 |
|
|
BFD_ASSERT (s != NULL);
|
2749 |
|
|
|
2750 |
|
|
tmp_name = bfd_malloc ((bfd_size_type) strlen (name) + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1);
|
2751 |
|
|
|
2752 |
|
|
BFD_ASSERT (tmp_name);
|
2753 |
|
|
|
2754 |
|
|
sprintf (tmp_name, ARM2THUMB_GLUE_ENTRY_NAME, name);
|
2755 |
|
|
|
2756 |
|
|
myh = elf_link_hash_lookup
|
2757 |
|
|
(&(globals)->root, tmp_name, FALSE, FALSE, TRUE);
|
2758 |
|
|
|
2759 |
|
|
if (myh != NULL)
|
2760 |
|
|
{
|
2761 |
|
|
/* We've already seen this guy. */
|
2762 |
|
|
free (tmp_name);
|
2763 |
|
|
return myh;
|
2764 |
|
|
}
|
2765 |
|
|
|
2766 |
|
|
/* The only trick here is using hash_table->arm_glue_size as the value.
|
2767 |
|
|
Even though the section isn't allocated yet, this is where we will be
|
2768 |
|
|
putting it. */
|
2769 |
|
|
bh = NULL;
|
2770 |
|
|
val = globals->arm_glue_size + 1;
|
2771 |
|
|
_bfd_generic_link_add_one_symbol (link_info, globals->bfd_of_glue_owner,
|
2772 |
|
|
tmp_name, BSF_GLOBAL, s, val,
|
2773 |
|
|
NULL, TRUE, FALSE, &bh);
|
2774 |
|
|
|
2775 |
|
|
myh = (struct elf_link_hash_entry *) bh;
|
2776 |
|
|
myh->type = ELF_ST_INFO (STB_LOCAL, STT_FUNC);
|
2777 |
|
|
myh->forced_local = 1;
|
2778 |
|
|
|
2779 |
|
|
free (tmp_name);
|
2780 |
|
|
|
2781 |
|
|
if (link_info->shared || globals->root.is_relocatable_executable
|
2782 |
|
|
|| globals->pic_veneer)
|
2783 |
|
|
size = ARM2THUMB_PIC_GLUE_SIZE;
|
2784 |
|
|
else if (globals->use_blx)
|
2785 |
|
|
size = ARM2THUMB_V5_STATIC_GLUE_SIZE;
|
2786 |
|
|
else
|
2787 |
|
|
size = ARM2THUMB_STATIC_GLUE_SIZE;
|
2788 |
|
|
|
2789 |
|
|
s->size += size;
|
2790 |
|
|
globals->arm_glue_size += size;
|
2791 |
|
|
|
2792 |
|
|
return myh;
|
2793 |
|
|
}
|
2794 |
|
|
|
2795 |
|
|
static void
|
2796 |
|
|
record_thumb_to_arm_glue (struct bfd_link_info *link_info,
|
2797 |
|
|
struct elf_link_hash_entry *h)
|
2798 |
|
|
{
|
2799 |
|
|
const char *name = h->root.root.string;
|
2800 |
|
|
asection *s;
|
2801 |
|
|
char *tmp_name;
|
2802 |
|
|
struct elf_link_hash_entry *myh;
|
2803 |
|
|
struct bfd_link_hash_entry *bh;
|
2804 |
|
|
struct elf32_arm_link_hash_table *hash_table;
|
2805 |
|
|
bfd_vma val;
|
2806 |
|
|
|
2807 |
|
|
hash_table = elf32_arm_hash_table (link_info);
|
2808 |
|
|
|
2809 |
|
|
BFD_ASSERT (hash_table != NULL);
|
2810 |
|
|
BFD_ASSERT (hash_table->bfd_of_glue_owner != NULL);
|
2811 |
|
|
|
2812 |
|
|
s = bfd_get_section_by_name
|
2813 |
|
|
(hash_table->bfd_of_glue_owner, THUMB2ARM_GLUE_SECTION_NAME);
|
2814 |
|
|
|
2815 |
|
|
BFD_ASSERT (s != NULL);
|
2816 |
|
|
|
2817 |
|
|
tmp_name = bfd_malloc ((bfd_size_type) strlen (name)
|
2818 |
|
|
+ strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1);
|
2819 |
|
|
|
2820 |
|
|
BFD_ASSERT (tmp_name);
|
2821 |
|
|
|
2822 |
|
|
sprintf (tmp_name, THUMB2ARM_GLUE_ENTRY_NAME, name);
|
2823 |
|
|
|
2824 |
|
|
myh = elf_link_hash_lookup
|
2825 |
|
|
(&(hash_table)->root, tmp_name, FALSE, FALSE, TRUE);
|
2826 |
|
|
|
2827 |
|
|
if (myh != NULL)
|
2828 |
|
|
{
|
2829 |
|
|
/* We've already seen this guy. */
|
2830 |
|
|
free (tmp_name);
|
2831 |
|
|
return;
|
2832 |
|
|
}
|
2833 |
|
|
|
2834 |
|
|
bh = NULL;
|
2835 |
|
|
val = hash_table->thumb_glue_size + 1;
|
2836 |
|
|
_bfd_generic_link_add_one_symbol (link_info, hash_table->bfd_of_glue_owner,
|
2837 |
|
|
tmp_name, BSF_GLOBAL, s, val,
|
2838 |
|
|
NULL, TRUE, FALSE, &bh);
|
2839 |
|
|
|
2840 |
|
|
/* If we mark it 'Thumb', the disassembler will do a better job. */
|
2841 |
|
|
myh = (struct elf_link_hash_entry *) bh;
|
2842 |
|
|
myh->type = ELF_ST_INFO (STB_LOCAL, STT_ARM_TFUNC);
|
2843 |
|
|
myh->forced_local = 1;
|
2844 |
|
|
|
2845 |
|
|
free (tmp_name);
|
2846 |
|
|
|
2847 |
|
|
#define CHANGE_TO_ARM "__%s_change_to_arm"
|
2848 |
|
|
#define BACK_FROM_ARM "__%s_back_from_arm"
|
2849 |
|
|
|
2850 |
|
|
/* Allocate another symbol to mark where we switch to Arm mode. */
|
2851 |
|
|
tmp_name = bfd_malloc ((bfd_size_type) strlen (name)
|
2852 |
|
|
+ strlen (CHANGE_TO_ARM) + 1);
|
2853 |
|
|
|
2854 |
|
|
BFD_ASSERT (tmp_name);
|
2855 |
|
|
|
2856 |
|
|
sprintf (tmp_name, CHANGE_TO_ARM, name);
|
2857 |
|
|
|
2858 |
|
|
bh = NULL;
|
2859 |
|
|
val = hash_table->thumb_glue_size + 4,
|
2860 |
|
|
_bfd_generic_link_add_one_symbol (link_info, hash_table->bfd_of_glue_owner,
|
2861 |
|
|
tmp_name, BSF_LOCAL, s, val,
|
2862 |
|
|
NULL, TRUE, FALSE, &bh);
|
2863 |
|
|
|
2864 |
|
|
free (tmp_name);
|
2865 |
|
|
|
2866 |
|
|
s->size += THUMB2ARM_GLUE_SIZE;
|
2867 |
|
|
hash_table->thumb_glue_size += THUMB2ARM_GLUE_SIZE;
|
2868 |
|
|
|
2869 |
|
|
return;
|
2870 |
|
|
}
|
2871 |
|
|
|
2872 |
|
|
|
2873 |
|
|
/* Allocate space for ARMv4 BX veneers. */
|
2874 |
|
|
|
2875 |
|
|
static void
|
2876 |
|
|
record_arm_bx_glue (struct bfd_link_info * link_info, int reg)
|
2877 |
|
|
{
|
2878 |
|
|
asection * s;
|
2879 |
|
|
struct elf32_arm_link_hash_table *globals;
|
2880 |
|
|
char *tmp_name;
|
2881 |
|
|
struct elf_link_hash_entry *myh;
|
2882 |
|
|
struct bfd_link_hash_entry *bh;
|
2883 |
|
|
bfd_vma val;
|
2884 |
|
|
|
2885 |
|
|
/* BX PC does not need a veneer. */
|
2886 |
|
|
if (reg == 15)
|
2887 |
|
|
return;
|
2888 |
|
|
|
2889 |
|
|
globals = elf32_arm_hash_table (link_info);
|
2890 |
|
|
|
2891 |
|
|
BFD_ASSERT (globals != NULL);
|
2892 |
|
|
BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
|
2893 |
|
|
|
2894 |
|
|
/* Check if this veneer has already been allocated. */
|
2895 |
|
|
if (globals->bx_glue_offset[reg])
|
2896 |
|
|
return;
|
2897 |
|
|
|
2898 |
|
|
s = bfd_get_section_by_name
|
2899 |
|
|
(globals->bfd_of_glue_owner, ARM_BX_GLUE_SECTION_NAME);
|
2900 |
|
|
|
2901 |
|
|
BFD_ASSERT (s != NULL);
|
2902 |
|
|
|
2903 |
|
|
/* Add symbol for veneer. */
|
2904 |
|
|
tmp_name = bfd_malloc ((bfd_size_type) strlen (ARM_BX_GLUE_ENTRY_NAME) + 1);
|
2905 |
|
|
|
2906 |
|
|
BFD_ASSERT (tmp_name);
|
2907 |
|
|
|
2908 |
|
|
sprintf (tmp_name, ARM_BX_GLUE_ENTRY_NAME, reg);
|
2909 |
|
|
|
2910 |
|
|
myh = elf_link_hash_lookup
|
2911 |
|
|
(&(globals)->root, tmp_name, FALSE, FALSE, FALSE);
|
2912 |
|
|
|
2913 |
|
|
BFD_ASSERT (myh == NULL);
|
2914 |
|
|
|
2915 |
|
|
bh = NULL;
|
2916 |
|
|
val = globals->bx_glue_size;
|
2917 |
|
|
_bfd_generic_link_add_one_symbol (link_info, globals->bfd_of_glue_owner,
|
2918 |
|
|
tmp_name, BSF_FUNCTION | BSF_LOCAL, s, val,
|
2919 |
|
|
NULL, TRUE, FALSE, &bh);
|
2920 |
|
|
|
2921 |
|
|
myh = (struct elf_link_hash_entry *) bh;
|
2922 |
|
|
myh->type = ELF_ST_INFO (STB_LOCAL, STT_FUNC);
|
2923 |
|
|
myh->forced_local = 1;
|
2924 |
|
|
|
2925 |
|
|
s->size += ARM_BX_VENEER_SIZE;
|
2926 |
|
|
globals->bx_glue_offset[reg] = globals->bx_glue_size | 2;
|
2927 |
|
|
globals->bx_glue_size += ARM_BX_VENEER_SIZE;
|
2928 |
|
|
}
|
2929 |
|
|
|
2930 |
|
|
|
2931 |
|
|
/* Add an entry to the code/data map for section SEC. */
|
2932 |
|
|
|
2933 |
|
|
static void
|
2934 |
|
|
elf32_arm_section_map_add (asection *sec, char type, bfd_vma vma)
|
2935 |
|
|
{
|
2936 |
|
|
struct _arm_elf_section_data *sec_data = elf32_arm_section_data (sec);
|
2937 |
|
|
unsigned int newidx;
|
2938 |
|
|
|
2939 |
|
|
if (sec_data->map == NULL)
|
2940 |
|
|
{
|
2941 |
|
|
sec_data->map = bfd_malloc (sizeof (elf32_arm_section_map));
|
2942 |
|
|
sec_data->mapcount = 0;
|
2943 |
|
|
sec_data->mapsize = 1;
|
2944 |
|
|
}
|
2945 |
|
|
|
2946 |
|
|
newidx = sec_data->mapcount++;
|
2947 |
|
|
|
2948 |
|
|
if (sec_data->mapcount > sec_data->mapsize)
|
2949 |
|
|
{
|
2950 |
|
|
sec_data->mapsize *= 2;
|
2951 |
|
|
sec_data->map = bfd_realloc_or_free (sec_data->map, sec_data->mapsize
|
2952 |
|
|
* sizeof (elf32_arm_section_map));
|
2953 |
|
|
}
|
2954 |
|
|
|
2955 |
|
|
if (sec_data->map)
|
2956 |
|
|
{
|
2957 |
|
|
sec_data->map[newidx].vma = vma;
|
2958 |
|
|
sec_data->map[newidx].type = type;
|
2959 |
|
|
}
|
2960 |
|
|
}
|
2961 |
|
|
|
2962 |
|
|
|
2963 |
|
|
/* Record information about a VFP11 denorm-erratum veneer. Only ARM-mode
|
2964 |
|
|
veneers are handled for now. */
|
2965 |
|
|
|
2966 |
|
|
static bfd_vma
|
2967 |
|
|
record_vfp11_erratum_veneer (struct bfd_link_info *link_info,
|
2968 |
|
|
elf32_vfp11_erratum_list *branch,
|
2969 |
|
|
bfd *branch_bfd,
|
2970 |
|
|
asection *branch_sec,
|
2971 |
|
|
unsigned int offset)
|
2972 |
|
|
{
|
2973 |
|
|
asection *s;
|
2974 |
|
|
struct elf32_arm_link_hash_table *hash_table;
|
2975 |
|
|
char *tmp_name;
|
2976 |
|
|
struct elf_link_hash_entry *myh;
|
2977 |
|
|
struct bfd_link_hash_entry *bh;
|
2978 |
|
|
bfd_vma val;
|
2979 |
|
|
struct _arm_elf_section_data *sec_data;
|
2980 |
|
|
int errcount;
|
2981 |
|
|
elf32_vfp11_erratum_list *newerr;
|
2982 |
|
|
|
2983 |
|
|
hash_table = elf32_arm_hash_table (link_info);
|
2984 |
|
|
|
2985 |
|
|
BFD_ASSERT (hash_table != NULL);
|
2986 |
|
|
BFD_ASSERT (hash_table->bfd_of_glue_owner != NULL);
|
2987 |
|
|
|
2988 |
|
|
s = bfd_get_section_by_name
|
2989 |
|
|
(hash_table->bfd_of_glue_owner, VFP11_ERRATUM_VENEER_SECTION_NAME);
|
2990 |
|
|
|
2991 |
|
|
sec_data = elf32_arm_section_data (s);
|
2992 |
|
|
|
2993 |
|
|
BFD_ASSERT (s != NULL);
|
2994 |
|
|
|
2995 |
|
|
tmp_name = bfd_malloc ((bfd_size_type) strlen
|
2996 |
|
|
(VFP11_ERRATUM_VENEER_ENTRY_NAME) + 10);
|
2997 |
|
|
|
2998 |
|
|
BFD_ASSERT (tmp_name);
|
2999 |
|
|
|
3000 |
|
|
sprintf (tmp_name, VFP11_ERRATUM_VENEER_ENTRY_NAME,
|
3001 |
|
|
hash_table->num_vfp11_fixes);
|
3002 |
|
|
|
3003 |
|
|
myh = elf_link_hash_lookup
|
3004 |
|
|
(&(hash_table)->root, tmp_name, FALSE, FALSE, FALSE);
|
3005 |
|
|
|
3006 |
|
|
BFD_ASSERT (myh == NULL);
|
3007 |
|
|
|
3008 |
|
|
bh = NULL;
|
3009 |
|
|
val = hash_table->vfp11_erratum_glue_size;
|
3010 |
|
|
_bfd_generic_link_add_one_symbol (link_info, hash_table->bfd_of_glue_owner,
|
3011 |
|
|
tmp_name, BSF_FUNCTION | BSF_LOCAL, s, val,
|
3012 |
|
|
NULL, TRUE, FALSE, &bh);
|
3013 |
|
|
|
3014 |
|
|
myh = (struct elf_link_hash_entry *) bh;
|
3015 |
|
|
myh->type = ELF_ST_INFO (STB_LOCAL, STT_FUNC);
|
3016 |
|
|
myh->forced_local = 1;
|
3017 |
|
|
|
3018 |
|
|
/* Link veneer back to calling location. */
|
3019 |
|
|
errcount = ++(sec_data->erratumcount);
|
3020 |
|
|
newerr = bfd_zmalloc (sizeof (elf32_vfp11_erratum_list));
|
3021 |
|
|
|
3022 |
|
|
newerr->type = VFP11_ERRATUM_ARM_VENEER;
|
3023 |
|
|
newerr->vma = -1;
|
3024 |
|
|
newerr->u.v.branch = branch;
|
3025 |
|
|
newerr->u.v.id = hash_table->num_vfp11_fixes;
|
3026 |
|
|
branch->u.b.veneer = newerr;
|
3027 |
|
|
|
3028 |
|
|
newerr->next = sec_data->erratumlist;
|
3029 |
|
|
sec_data->erratumlist = newerr;
|
3030 |
|
|
|
3031 |
|
|
/* A symbol for the return from the veneer. */
|
3032 |
|
|
sprintf (tmp_name, VFP11_ERRATUM_VENEER_ENTRY_NAME "_r",
|
3033 |
|
|
hash_table->num_vfp11_fixes);
|
3034 |
|
|
|
3035 |
|
|
myh = elf_link_hash_lookup
|
3036 |
|
|
(&(hash_table)->root, tmp_name, FALSE, FALSE, FALSE);
|
3037 |
|
|
|
3038 |
|
|
if (myh != NULL)
|
3039 |
|
|
abort ();
|
3040 |
|
|
|
3041 |
|
|
bh = NULL;
|
3042 |
|
|
val = offset + 4;
|
3043 |
|
|
_bfd_generic_link_add_one_symbol (link_info, branch_bfd, tmp_name, BSF_LOCAL,
|
3044 |
|
|
branch_sec, val, NULL, TRUE, FALSE, &bh);
|
3045 |
|
|
|
3046 |
|
|
myh = (struct elf_link_hash_entry *) bh;
|
3047 |
|
|
myh->type = ELF_ST_INFO (STB_LOCAL, STT_FUNC);
|
3048 |
|
|
myh->forced_local = 1;
|
3049 |
|
|
|
3050 |
|
|
free (tmp_name);
|
3051 |
|
|
|
3052 |
|
|
/* Generate a mapping symbol for the veneer section, and explicitly add an
|
3053 |
|
|
entry for that symbol to the code/data map for the section. */
|
3054 |
|
|
if (hash_table->vfp11_erratum_glue_size == 0)
|
3055 |
|
|
{
|
3056 |
|
|
bh = NULL;
|
3057 |
|
|
/* FIXME: Creates an ARM symbol. Thumb mode will need attention if it
|
3058 |
|
|
ever requires this erratum fix. */
|
3059 |
|
|
_bfd_generic_link_add_one_symbol (link_info,
|
3060 |
|
|
hash_table->bfd_of_glue_owner, "$a",
|
3061 |
|
|
BSF_LOCAL, s, 0, NULL,
|
3062 |
|
|
TRUE, FALSE, &bh);
|
3063 |
|
|
|
3064 |
|
|
myh = (struct elf_link_hash_entry *) bh;
|
3065 |
|
|
myh->type = ELF_ST_INFO (STB_LOCAL, STT_NOTYPE);
|
3066 |
|
|
myh->forced_local = 1;
|
3067 |
|
|
|
3068 |
|
|
/* The elf32_arm_init_maps function only cares about symbols from input
|
3069 |
|
|
BFDs. We must make a note of this generated mapping symbol
|
3070 |
|
|
ourselves so that code byteswapping works properly in
|
3071 |
|
|
elf32_arm_write_section. */
|
3072 |
|
|
elf32_arm_section_map_add (s, 'a', 0);
|
3073 |
|
|
}
|
3074 |
|
|
|
3075 |
|
|
s->size += VFP11_ERRATUM_VENEER_SIZE;
|
3076 |
|
|
hash_table->vfp11_erratum_glue_size += VFP11_ERRATUM_VENEER_SIZE;
|
3077 |
|
|
hash_table->num_vfp11_fixes++;
|
3078 |
|
|
|
3079 |
|
|
/* The offset of the veneer. */
|
3080 |
|
|
return val;
|
3081 |
|
|
}
|
3082 |
|
|
|
3083 |
|
|
/* Add the glue sections to ABFD. This function is called from the
|
3084 |
|
|
linker scripts in ld/emultempl/{armelf}.em. */
|
3085 |
|
|
|
3086 |
|
|
bfd_boolean
|
3087 |
|
|
bfd_elf32_arm_add_glue_sections_to_bfd (bfd *abfd,
|
3088 |
|
|
struct bfd_link_info *info)
|
3089 |
|
|
{
|
3090 |
|
|
flagword flags;
|
3091 |
|
|
asection *sec;
|
3092 |
|
|
|
3093 |
|
|
/* If we are only performing a partial
|
3094 |
|
|
link do not bother adding the glue. */
|
3095 |
|
|
if (info->relocatable)
|
3096 |
|
|
return TRUE;
|
3097 |
|
|
|
3098 |
|
|
sec = bfd_get_section_by_name (abfd, ARM2THUMB_GLUE_SECTION_NAME);
|
3099 |
|
|
|
3100 |
|
|
if (sec == NULL)
|
3101 |
|
|
{
|
3102 |
|
|
/* Note: we do not include the flag SEC_LINKER_CREATED, as this
|
3103 |
|
|
will prevent elf_link_input_bfd() from processing the contents
|
3104 |
|
|
of this section. */
|
3105 |
|
|
flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
|
3106 |
|
|
| SEC_CODE | SEC_READONLY);
|
3107 |
|
|
|
3108 |
|
|
sec = bfd_make_section_with_flags (abfd,
|
3109 |
|
|
ARM2THUMB_GLUE_SECTION_NAME,
|
3110 |
|
|
flags);
|
3111 |
|
|
|
3112 |
|
|
if (sec == NULL
|
3113 |
|
|
|| !bfd_set_section_alignment (abfd, sec, 2))
|
3114 |
|
|
return FALSE;
|
3115 |
|
|
|
3116 |
|
|
/* Set the gc mark to prevent the section from being removed by garbage
|
3117 |
|
|
collection, despite the fact that no relocs refer to this section. */
|
3118 |
|
|
sec->gc_mark = 1;
|
3119 |
|
|
}
|
3120 |
|
|
|
3121 |
|
|
sec = bfd_get_section_by_name (abfd, THUMB2ARM_GLUE_SECTION_NAME);
|
3122 |
|
|
|
3123 |
|
|
if (sec == NULL)
|
3124 |
|
|
{
|
3125 |
|
|
flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
|
3126 |
|
|
| SEC_CODE | SEC_READONLY);
|
3127 |
|
|
|
3128 |
|
|
sec = bfd_make_section_with_flags (abfd,
|
3129 |
|
|
THUMB2ARM_GLUE_SECTION_NAME,
|
3130 |
|
|
flags);
|
3131 |
|
|
|
3132 |
|
|
if (sec == NULL
|
3133 |
|
|
|| !bfd_set_section_alignment (abfd, sec, 2))
|
3134 |
|
|
return FALSE;
|
3135 |
|
|
|
3136 |
|
|
sec->gc_mark = 1;
|
3137 |
|
|
}
|
3138 |
|
|
|
3139 |
|
|
sec = bfd_get_section_by_name (abfd, VFP11_ERRATUM_VENEER_SECTION_NAME);
|
3140 |
|
|
|
3141 |
|
|
if (sec == NULL)
|
3142 |
|
|
{
|
3143 |
|
|
flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
|
3144 |
|
|
| SEC_CODE | SEC_READONLY);
|
3145 |
|
|
|
3146 |
|
|
sec = bfd_make_section_with_flags (abfd,
|
3147 |
|
|
VFP11_ERRATUM_VENEER_SECTION_NAME,
|
3148 |
|
|
flags);
|
3149 |
|
|
|
3150 |
|
|
if (sec == NULL
|
3151 |
|
|
|| !bfd_set_section_alignment (abfd, sec, 2))
|
3152 |
|
|
return FALSE;
|
3153 |
|
|
|
3154 |
|
|
sec->gc_mark = 1;
|
3155 |
|
|
}
|
3156 |
|
|
|
3157 |
|
|
sec = bfd_get_section_by_name (abfd, ARM_BX_GLUE_SECTION_NAME);
|
3158 |
|
|
|
3159 |
|
|
if (sec == NULL)
|
3160 |
|
|
{
|
3161 |
|
|
flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
|
3162 |
|
|
| SEC_CODE | SEC_READONLY);
|
3163 |
|
|
|
3164 |
|
|
sec = bfd_make_section_with_flags (abfd,
|
3165 |
|
|
ARM_BX_GLUE_SECTION_NAME,
|
3166 |
|
|
flags);
|
3167 |
|
|
|
3168 |
|
|
if (sec == NULL
|
3169 |
|
|
|| !bfd_set_section_alignment (abfd, sec, 2))
|
3170 |
|
|
return FALSE;
|
3171 |
|
|
|
3172 |
|
|
sec->gc_mark = 1;
|
3173 |
|
|
}
|
3174 |
|
|
|
3175 |
|
|
return TRUE;
|
3176 |
|
|
}
|
3177 |
|
|
|
3178 |
|
|
/* Select a BFD to be used to hold the sections used by the glue code.
|
3179 |
|
|
This function is called from the linker scripts in ld/emultempl/
|
3180 |
|
|
{armelf/pe}.em */
|
3181 |
|
|
|
3182 |
|
|
bfd_boolean
|
3183 |
|
|
bfd_elf32_arm_get_bfd_for_interworking (bfd *abfd, struct bfd_link_info *info)
|
3184 |
|
|
{
|
3185 |
|
|
struct elf32_arm_link_hash_table *globals;
|
3186 |
|
|
|
3187 |
|
|
/* If we are only performing a partial link
|
3188 |
|
|
do not bother getting a bfd to hold the glue. */
|
3189 |
|
|
if (info->relocatable)
|
3190 |
|
|
return TRUE;
|
3191 |
|
|
|
3192 |
|
|
/* Make sure we don't attach the glue sections to a dynamic object. */
|
3193 |
|
|
BFD_ASSERT (!(abfd->flags & DYNAMIC));
|
3194 |
|
|
|
3195 |
|
|
globals = elf32_arm_hash_table (info);
|
3196 |
|
|
|
3197 |
|
|
BFD_ASSERT (globals != NULL);
|
3198 |
|
|
|
3199 |
|
|
if (globals->bfd_of_glue_owner != NULL)
|
3200 |
|
|
return TRUE;
|
3201 |
|
|
|
3202 |
|
|
/* Save the bfd for later use. */
|
3203 |
|
|
globals->bfd_of_glue_owner = abfd;
|
3204 |
|
|
|
3205 |
|
|
return TRUE;
|
3206 |
|
|
}
|
3207 |
|
|
|
3208 |
|
|
static void check_use_blx(struct elf32_arm_link_hash_table *globals)
|
3209 |
|
|
{
|
3210 |
|
|
if (bfd_elf_get_obj_attr_int (globals->obfd, OBJ_ATTR_PROC,
|
3211 |
|
|
Tag_CPU_arch) > 2)
|
3212 |
|
|
globals->use_blx = 1;
|
3213 |
|
|
}
|
3214 |
|
|
|
3215 |
|
|
bfd_boolean
|
3216 |
|
|
bfd_elf32_arm_process_before_allocation (bfd *abfd,
|
3217 |
|
|
struct bfd_link_info *link_info)
|
3218 |
|
|
{
|
3219 |
|
|
Elf_Internal_Shdr *symtab_hdr;
|
3220 |
|
|
Elf_Internal_Rela *internal_relocs = NULL;
|
3221 |
|
|
Elf_Internal_Rela *irel, *irelend;
|
3222 |
|
|
bfd_byte *contents = NULL;
|
3223 |
|
|
|
3224 |
|
|
asection *sec;
|
3225 |
|
|
struct elf32_arm_link_hash_table *globals;
|
3226 |
|
|
|
3227 |
|
|
/* If we are only performing a partial link do not bother
|
3228 |
|
|
to construct any glue. */
|
3229 |
|
|
if (link_info->relocatable)
|
3230 |
|
|
return TRUE;
|
3231 |
|
|
|
3232 |
|
|
/* Here we have a bfd that is to be included on the link. We have a
|
3233 |
|
|
hook to do reloc rummaging, before section sizes are nailed down. */
|
3234 |
|
|
globals = elf32_arm_hash_table (link_info);
|
3235 |
|
|
|
3236 |
|
|
BFD_ASSERT (globals != NULL);
|
3237 |
|
|
|
3238 |
|
|
check_use_blx (globals);
|
3239 |
|
|
|
3240 |
|
|
if (globals->byteswap_code && !bfd_big_endian (abfd))
|
3241 |
|
|
{
|
3242 |
|
|
_bfd_error_handler (_("%B: BE8 images only valid in big-endian mode."),
|
3243 |
|
|
abfd);
|
3244 |
|
|
return FALSE;
|
3245 |
|
|
}
|
3246 |
|
|
|
3247 |
|
|
/* PR 5398: If we have not decided to include any loadable sections in
|
3248 |
|
|
the output then we will not have a glue owner bfd. This is OK, it
|
3249 |
|
|
just means that there is nothing else for us to do here. */
|
3250 |
|
|
if (globals->bfd_of_glue_owner == NULL)
|
3251 |
|
|
return TRUE;
|
3252 |
|
|
|
3253 |
|
|
/* Rummage around all the relocs and map the glue vectors. */
|
3254 |
|
|
sec = abfd->sections;
|
3255 |
|
|
|
3256 |
|
|
if (sec == NULL)
|
3257 |
|
|
return TRUE;
|
3258 |
|
|
|
3259 |
|
|
for (; sec != NULL; sec = sec->next)
|
3260 |
|
|
{
|
3261 |
|
|
if (sec->reloc_count == 0)
|
3262 |
|
|
continue;
|
3263 |
|
|
|
3264 |
|
|
if ((sec->flags & SEC_EXCLUDE) != 0)
|
3265 |
|
|
continue;
|
3266 |
|
|
|
3267 |
|
|
symtab_hdr = & elf_symtab_hdr (abfd);
|
3268 |
|
|
|
3269 |
|
|
/* Load the relocs. */
|
3270 |
|
|
internal_relocs
|
3271 |
|
|
= _bfd_elf_link_read_relocs (abfd, sec, (void *) NULL,
|
3272 |
|
|
(Elf_Internal_Rela *) NULL, FALSE);
|
3273 |
|
|
|
3274 |
|
|
if (internal_relocs == NULL)
|
3275 |
|
|
goto error_return;
|
3276 |
|
|
|
3277 |
|
|
irelend = internal_relocs + sec->reloc_count;
|
3278 |
|
|
for (irel = internal_relocs; irel < irelend; irel++)
|
3279 |
|
|
{
|
3280 |
|
|
long r_type;
|
3281 |
|
|
unsigned long r_index;
|
3282 |
|
|
|
3283 |
|
|
struct elf_link_hash_entry *h;
|
3284 |
|
|
|
3285 |
|
|
r_type = ELF32_R_TYPE (irel->r_info);
|
3286 |
|
|
r_index = ELF32_R_SYM (irel->r_info);
|
3287 |
|
|
|
3288 |
|
|
/* These are the only relocation types we care about. */
|
3289 |
|
|
if ( r_type != R_ARM_PC24
|
3290 |
|
|
&& r_type != R_ARM_PLT32
|
3291 |
|
|
&& r_type != R_ARM_CALL
|
3292 |
|
|
&& r_type != R_ARM_JUMP24
|
3293 |
|
|
&& r_type != R_ARM_THM_CALL
|
3294 |
|
|
&& r_type != R_ARM_THM_JUMP24
|
3295 |
|
|
&& (r_type != R_ARM_V4BX || globals->fix_v4bx < 2))
|
3296 |
|
|
continue;
|
3297 |
|
|
|
3298 |
|
|
/* Get the section contents if we haven't done so already. */
|
3299 |
|
|
if (contents == NULL)
|
3300 |
|
|
{
|
3301 |
|
|
/* Get cached copy if it exists. */
|
3302 |
|
|
if (elf_section_data (sec)->this_hdr.contents != NULL)
|
3303 |
|
|
contents = elf_section_data (sec)->this_hdr.contents;
|
3304 |
|
|
else
|
3305 |
|
|
{
|
3306 |
|
|
/* Go get them off disk. */
|
3307 |
|
|
if (! bfd_malloc_and_get_section (abfd, sec, &contents))
|
3308 |
|
|
goto error_return;
|
3309 |
|
|
}
|
3310 |
|
|
}
|
3311 |
|
|
|
3312 |
|
|
if (r_type == R_ARM_V4BX)
|
3313 |
|
|
{
|
3314 |
|
|
int reg;
|
3315 |
|
|
|
3316 |
|
|
reg = bfd_get_32 (abfd, contents + irel->r_offset) & 0xf;
|
3317 |
|
|
record_arm_bx_glue (link_info, reg);
|
3318 |
|
|
continue;
|
3319 |
|
|
}
|
3320 |
|
|
|
3321 |
|
|
/* If the relocation is not against a symbol it cannot concern us. */
|
3322 |
|
|
h = NULL;
|
3323 |
|
|
|
3324 |
|
|
/* We don't care about local symbols. */
|
3325 |
|
|
if (r_index < symtab_hdr->sh_info)
|
3326 |
|
|
continue;
|
3327 |
|
|
|
3328 |
|
|
/* This is an external symbol. */
|
3329 |
|
|
r_index -= symtab_hdr->sh_info;
|
3330 |
|
|
h = (struct elf_link_hash_entry *)
|
3331 |
|
|
elf_sym_hashes (abfd)[r_index];
|
3332 |
|
|
|
3333 |
|
|
/* If the relocation is against a static symbol it must be within
|
3334 |
|
|
the current section and so cannot be a cross ARM/Thumb relocation. */
|
3335 |
|
|
if (h == NULL)
|
3336 |
|
|
continue;
|
3337 |
|
|
|
3338 |
|
|
/* If the call will go through a PLT entry then we do not need
|
3339 |
|
|
glue. */
|
3340 |
|
|
if (globals->splt != NULL && h->plt.offset != (bfd_vma) -1)
|
3341 |
|
|
continue;
|
3342 |
|
|
|
3343 |
|
|
switch (r_type)
|
3344 |
|
|
{
|
3345 |
|
|
case R_ARM_PC24:
|
3346 |
|
|
case R_ARM_PLT32:
|
3347 |
|
|
case R_ARM_CALL:
|
3348 |
|
|
case R_ARM_JUMP24:
|
3349 |
|
|
/* This one is a call from arm code. We need to look up
|
3350 |
|
|
the target of the call. If it is a thumb target, we
|
3351 |
|
|
insert glue. */
|
3352 |
|
|
if (ELF_ST_TYPE(h->type) == STT_ARM_TFUNC
|
3353 |
|
|
&& !(r_type == R_ARM_CALL && globals->use_blx))
|
3354 |
|
|
record_arm_to_thumb_glue (link_info, h);
|
3355 |
|
|
break;
|
3356 |
|
|
|
3357 |
|
|
case R_ARM_THM_CALL:
|
3358 |
|
|
case R_ARM_THM_JUMP24:
|
3359 |
|
|
/* This one is a call from thumb code. We look
|
3360 |
|
|
up the target of the call. If it is not a thumb
|
3361 |
|
|
target, we insert glue. */
|
3362 |
|
|
if (ELF_ST_TYPE (h->type) != STT_ARM_TFUNC
|
3363 |
|
|
&& !(globals->use_blx && r_type == R_ARM_THM_CALL)
|
3364 |
|
|
&& h->root.type != bfd_link_hash_undefweak)
|
3365 |
|
|
record_thumb_to_arm_glue (link_info, h);
|
3366 |
|
|
break;
|
3367 |
|
|
|
3368 |
|
|
default:
|
3369 |
|
|
abort ();
|
3370 |
|
|
}
|
3371 |
|
|
}
|
3372 |
|
|
|
3373 |
|
|
if (contents != NULL
|
3374 |
|
|
&& elf_section_data (sec)->this_hdr.contents != contents)
|
3375 |
|
|
free (contents);
|
3376 |
|
|
contents = NULL;
|
3377 |
|
|
|
3378 |
|
|
if (internal_relocs != NULL
|
3379 |
|
|
&& elf_section_data (sec)->relocs != internal_relocs)
|
3380 |
|
|
free (internal_relocs);
|
3381 |
|
|
internal_relocs = NULL;
|
3382 |
|
|
}
|
3383 |
|
|
|
3384 |
|
|
return TRUE;
|
3385 |
|
|
|
3386 |
|
|
error_return:
|
3387 |
|
|
if (contents != NULL
|
3388 |
|
|
&& elf_section_data (sec)->this_hdr.contents != contents)
|
3389 |
|
|
free (contents);
|
3390 |
|
|
if (internal_relocs != NULL
|
3391 |
|
|
&& elf_section_data (sec)->relocs != internal_relocs)
|
3392 |
|
|
free (internal_relocs);
|
3393 |
|
|
|
3394 |
|
|
return FALSE;
|
3395 |
|
|
}
|
3396 |
|
|
#endif
|
3397 |
|
|
|
3398 |
|
|
|
3399 |
|
|
/* Initialise maps of ARM/Thumb/data for input BFDs. */
|
3400 |
|
|
|
3401 |
|
|
void
|
3402 |
|
|
bfd_elf32_arm_init_maps (bfd *abfd)
|
3403 |
|
|
{
|
3404 |
|
|
Elf_Internal_Sym *isymbuf;
|
3405 |
|
|
Elf_Internal_Shdr *hdr;
|
3406 |
|
|
unsigned int i, localsyms;
|
3407 |
|
|
|
3408 |
|
|
if ((abfd->flags & DYNAMIC) != 0)
|
3409 |
|
|
return;
|
3410 |
|
|
|
3411 |
|
|
hdr = & elf_symtab_hdr (abfd);
|
3412 |
|
|
localsyms = hdr->sh_info;
|
3413 |
|
|
|
3414 |
|
|
/* Obtain a buffer full of symbols for this BFD. The hdr->sh_info field
|
3415 |
|
|
should contain the number of local symbols, which should come before any
|
3416 |
|
|
global symbols. Mapping symbols are always local. */
|
3417 |
|
|
isymbuf = bfd_elf_get_elf_syms (abfd, hdr, localsyms, 0, NULL, NULL,
|
3418 |
|
|
NULL);
|
3419 |
|
|
|
3420 |
|
|
/* No internal symbols read? Skip this BFD. */
|
3421 |
|
|
if (isymbuf == NULL)
|
3422 |
|
|
return;
|
3423 |
|
|
|
3424 |
|
|
for (i = 0; i < localsyms; i++)
|
3425 |
|
|
{
|
3426 |
|
|
Elf_Internal_Sym *isym = &isymbuf[i];
|
3427 |
|
|
asection *sec = bfd_section_from_elf_index (abfd, isym->st_shndx);
|
3428 |
|
|
const char *name;
|
3429 |
|
|
|
3430 |
|
|
if (sec != NULL
|
3431 |
|
|
&& ELF_ST_BIND (isym->st_info) == STB_LOCAL)
|
3432 |
|
|
{
|
3433 |
|
|
name = bfd_elf_string_from_elf_section (abfd,
|
3434 |
|
|
hdr->sh_link, isym->st_name);
|
3435 |
|
|
|
3436 |
|
|
if (bfd_is_arm_special_symbol_name (name,
|
3437 |
|
|
BFD_ARM_SPECIAL_SYM_TYPE_MAP))
|
3438 |
|
|
elf32_arm_section_map_add (sec, name[1], isym->st_value);
|
3439 |
|
|
}
|
3440 |
|
|
}
|
3441 |
|
|
}
|
3442 |
|
|
|
3443 |
|
|
|
3444 |
|
|
void
|
3445 |
|
|
bfd_elf32_arm_set_vfp11_fix (bfd *obfd, struct bfd_link_info *link_info)
|
3446 |
|
|
{
|
3447 |
|
|
struct elf32_arm_link_hash_table *globals = elf32_arm_hash_table (link_info);
|
3448 |
|
|
obj_attribute *out_attr = elf_known_obj_attributes_proc (obfd);
|
3449 |
|
|
|
3450 |
|
|
/* We assume that ARMv7+ does not need the VFP11 denorm erratum fix. */
|
3451 |
|
|
if (out_attr[Tag_CPU_arch].i >= TAG_CPU_ARCH_V7)
|
3452 |
|
|
{
|
3453 |
|
|
switch (globals->vfp11_fix)
|
3454 |
|
|
{
|
3455 |
|
|
case BFD_ARM_VFP11_FIX_DEFAULT:
|
3456 |
|
|
case BFD_ARM_VFP11_FIX_NONE:
|
3457 |
|
|
globals->vfp11_fix = BFD_ARM_VFP11_FIX_NONE;
|
3458 |
|
|
break;
|
3459 |
|
|
|
3460 |
|
|
default:
|
3461 |
|
|
/* Give a warning, but do as the user requests anyway. */
|
3462 |
|
|
(*_bfd_error_handler) (_("%B: warning: selected VFP11 erratum "
|
3463 |
|
|
"workaround is not necessary for target architecture"), obfd);
|
3464 |
|
|
}
|
3465 |
|
|
}
|
3466 |
|
|
else if (globals->vfp11_fix == BFD_ARM_VFP11_FIX_DEFAULT)
|
3467 |
|
|
/* For earlier architectures, we might need the workaround, but do not
|
3468 |
|
|
enable it by default. If users is running with broken hardware, they
|
3469 |
|
|
must enable the erratum fix explicitly. */
|
3470 |
|
|
globals->vfp11_fix = BFD_ARM_VFP11_FIX_NONE;
|
3471 |
|
|
}
|
3472 |
|
|
|
3473 |
|
|
|
3474 |
|
|
enum bfd_arm_vfp11_pipe {
|
3475 |
|
|
VFP11_FMAC,
|
3476 |
|
|
VFP11_LS,
|
3477 |
|
|
VFP11_DS,
|
3478 |
|
|
VFP11_BAD
|
3479 |
|
|
};
|
3480 |
|
|
|
3481 |
|
|
/* Return a VFP register number. This is encoded as RX:X for single-precision
|
3482 |
|
|
registers, or X:RX for double-precision registers, where RX is the group of
|
3483 |
|
|
four bits in the instruction encoding and X is the single extension bit.
|
3484 |
|
|
RX and X fields are specified using their lowest (starting) bit. The return
|
3485 |
|
|
value is:
|
3486 |
|
|
|
3487 |
|
|
0...31: single-precision registers s0...s31
|
3488 |
|
|
32...63: double-precision registers d0...d31.
|
3489 |
|
|
|
3490 |
|
|
Although X should be zero for VFP11 (encoding d0...d15 only), we might
|
3491 |
|
|
encounter VFP3 instructions, so we allow the full range for DP registers. */
|
3492 |
|
|
|
3493 |
|
|
static unsigned int
|
3494 |
|
|
bfd_arm_vfp11_regno (unsigned int insn, bfd_boolean is_double, unsigned int rx,
|
3495 |
|
|
unsigned int x)
|
3496 |
|
|
{
|
3497 |
|
|
if (is_double)
|
3498 |
|
|
return (((insn >> rx) & 0xf) | (((insn >> x) & 1) << 4)) + 32;
|
3499 |
|
|
else
|
3500 |
|
|
return (((insn >> rx) & 0xf) << 1) | ((insn >> x) & 1);
|
3501 |
|
|
}
|
3502 |
|
|
|
3503 |
|
|
/* Set bits in *WMASK according to a register number REG as encoded by
|
3504 |
|
|
bfd_arm_vfp11_regno(). Ignore d16-d31. */
|
3505 |
|
|
|
3506 |
|
|
static void
|
3507 |
|
|
bfd_arm_vfp11_write_mask (unsigned int *wmask, unsigned int reg)
|
3508 |
|
|
{
|
3509 |
|
|
if (reg < 32)
|
3510 |
|
|
*wmask |= 1 << reg;
|
3511 |
|
|
else if (reg < 48)
|
3512 |
|
|
*wmask |= 3 << ((reg - 32) * 2);
|
3513 |
|
|
}
|
3514 |
|
|
|
3515 |
|
|
/* Return TRUE if WMASK overwrites anything in REGS. */
|
3516 |
|
|
|
3517 |
|
|
static bfd_boolean
|
3518 |
|
|
bfd_arm_vfp11_antidependency (unsigned int wmask, int *regs, int numregs)
|
3519 |
|
|
{
|
3520 |
|
|
int i;
|
3521 |
|
|
|
3522 |
|
|
for (i = 0; i < numregs; i++)
|
3523 |
|
|
{
|
3524 |
|
|
unsigned int reg = regs[i];
|
3525 |
|
|
|
3526 |
|
|
if (reg < 32 && (wmask & (1 << reg)) != 0)
|
3527 |
|
|
return TRUE;
|
3528 |
|
|
|
3529 |
|
|
reg -= 32;
|
3530 |
|
|
|
3531 |
|
|
if (reg >= 16)
|
3532 |
|
|
continue;
|
3533 |
|
|
|
3534 |
|
|
if ((wmask & (3 << (reg * 2))) != 0)
|
3535 |
|
|
return TRUE;
|
3536 |
|
|
}
|
3537 |
|
|
|
3538 |
|
|
return FALSE;
|
3539 |
|
|
}
|
3540 |
|
|
|
3541 |
|
|
/* In this function, we're interested in two things: finding input registers
|
3542 |
|
|
for VFP data-processing instructions, and finding the set of registers which
|
3543 |
|
|
arbitrary VFP instructions may write to. We use a 32-bit unsigned int to
|
3544 |
|
|
hold the written set, so FLDM etc. are easy to deal with (we're only
|
3545 |
|
|
interested in 32 SP registers or 16 dp registers, due to the VFP version
|
3546 |
|
|
implemented by the chip in question). DP registers are marked by setting
|
3547 |
|
|
both SP registers in the write mask). */
|
3548 |
|
|
|
3549 |
|
|
static enum bfd_arm_vfp11_pipe
|
3550 |
|
|
bfd_arm_vfp11_insn_decode (unsigned int insn, unsigned int *destmask, int *regs,
|
3551 |
|
|
int *numregs)
|
3552 |
|
|
{
|
3553 |
|
|
enum bfd_arm_vfp11_pipe pipe = VFP11_BAD;
|
3554 |
|
|
bfd_boolean is_double = ((insn & 0xf00) == 0xb00) ? 1 : 0;
|
3555 |
|
|
|
3556 |
|
|
if ((insn & 0x0f000e10) == 0x0e000a00) /* A data-processing insn. */
|
3557 |
|
|
{
|
3558 |
|
|
unsigned int pqrs;
|
3559 |
|
|
unsigned int fd = bfd_arm_vfp11_regno (insn, is_double, 12, 22);
|
3560 |
|
|
unsigned int fm = bfd_arm_vfp11_regno (insn, is_double, 0, 5);
|
3561 |
|
|
|
3562 |
|
|
pqrs = ((insn & 0x00800000) >> 20)
|
3563 |
|
|
| ((insn & 0x00300000) >> 19)
|
3564 |
|
|
| ((insn & 0x00000040) >> 6);
|
3565 |
|
|
|
3566 |
|
|
switch (pqrs)
|
3567 |
|
|
{
|
3568 |
|
|
case 0: /* fmac[sd]. */
|
3569 |
|
|
case 1: /* fnmac[sd]. */
|
3570 |
|
|
case 2: /* fmsc[sd]. */
|
3571 |
|
|
case 3: /* fnmsc[sd]. */
|
3572 |
|
|
pipe = VFP11_FMAC;
|
3573 |
|
|
bfd_arm_vfp11_write_mask (destmask, fd);
|
3574 |
|
|
regs[0] = fd;
|
3575 |
|
|
regs[1] = bfd_arm_vfp11_regno (insn, is_double, 16, 7); /* Fn. */
|
3576 |
|
|
regs[2] = fm;
|
3577 |
|
|
*numregs = 3;
|
3578 |
|
|
break;
|
3579 |
|
|
|
3580 |
|
|
case 4: /* fmul[sd]. */
|
3581 |
|
|
case 5: /* fnmul[sd]. */
|
3582 |
|
|
case 6: /* fadd[sd]. */
|
3583 |
|
|
case 7: /* fsub[sd]. */
|
3584 |
|
|
pipe = VFP11_FMAC;
|
3585 |
|
|
goto vfp_binop;
|
3586 |
|
|
|
3587 |
|
|
case 8: /* fdiv[sd]. */
|
3588 |
|
|
pipe = VFP11_DS;
|
3589 |
|
|
vfp_binop:
|
3590 |
|
|
bfd_arm_vfp11_write_mask (destmask, fd);
|
3591 |
|
|
regs[0] = bfd_arm_vfp11_regno (insn, is_double, 16, 7); /* Fn. */
|
3592 |
|
|
regs[1] = fm;
|
3593 |
|
|
*numregs = 2;
|
3594 |
|
|
break;
|
3595 |
|
|
|
3596 |
|
|
case 15: /* extended opcode. */
|
3597 |
|
|
{
|
3598 |
|
|
unsigned int extn = ((insn >> 15) & 0x1e)
|
3599 |
|
|
| ((insn >> 7) & 1);
|
3600 |
|
|
|
3601 |
|
|
switch (extn)
|
3602 |
|
|
{
|
3603 |
|
|
case 0: /* fcpy[sd]. */
|
3604 |
|
|
case 1: /* fabs[sd]. */
|
3605 |
|
|
case 2: /* fneg[sd]. */
|
3606 |
|
|
case 8: /* fcmp[sd]. */
|
3607 |
|
|
case 9: /* fcmpe[sd]. */
|
3608 |
|
|
case 10: /* fcmpz[sd]. */
|
3609 |
|
|
case 11: /* fcmpez[sd]. */
|
3610 |
|
|
case 16: /* fuito[sd]. */
|
3611 |
|
|
case 17: /* fsito[sd]. */
|
3612 |
|
|
case 24: /* ftoui[sd]. */
|
3613 |
|
|
case 25: /* ftouiz[sd]. */
|
3614 |
|
|
case 26: /* ftosi[sd]. */
|
3615 |
|
|
case 27: /* ftosiz[sd]. */
|
3616 |
|
|
/* These instructions will not bounce due to underflow. */
|
3617 |
|
|
*numregs = 0;
|
3618 |
|
|
pipe = VFP11_FMAC;
|
3619 |
|
|
break;
|
3620 |
|
|
|
3621 |
|
|
case 3: /* fsqrt[sd]. */
|
3622 |
|
|
/* fsqrt cannot underflow, but it can (perhaps) overwrite
|
3623 |
|
|
registers to cause the erratum in previous instructions. */
|
3624 |
|
|
bfd_arm_vfp11_write_mask (destmask, fd);
|
3625 |
|
|
pipe = VFP11_DS;
|
3626 |
|
|
break;
|
3627 |
|
|
|
3628 |
|
|
case 15: /* fcvt{ds,sd}. */
|
3629 |
|
|
{
|
3630 |
|
|
int rnum = 0;
|
3631 |
|
|
|
3632 |
|
|
bfd_arm_vfp11_write_mask (destmask, fd);
|
3633 |
|
|
|
3634 |
|
|
/* Only FCVTSD can underflow. */
|
3635 |
|
|
if ((insn & 0x100) != 0)
|
3636 |
|
|
regs[rnum++] = fm;
|
3637 |
|
|
|
3638 |
|
|
*numregs = rnum;
|
3639 |
|
|
|
3640 |
|
|
pipe = VFP11_FMAC;
|
3641 |
|
|
}
|
3642 |
|
|
break;
|
3643 |
|
|
|
3644 |
|
|
default:
|
3645 |
|
|
return VFP11_BAD;
|
3646 |
|
|
}
|
3647 |
|
|
}
|
3648 |
|
|
break;
|
3649 |
|
|
|
3650 |
|
|
default:
|
3651 |
|
|
return VFP11_BAD;
|
3652 |
|
|
}
|
3653 |
|
|
}
|
3654 |
|
|
/* Two-register transfer. */
|
3655 |
|
|
else if ((insn & 0x0fe00ed0) == 0x0c400a10)
|
3656 |
|
|
{
|
3657 |
|
|
unsigned int fm = bfd_arm_vfp11_regno (insn, is_double, 0, 5);
|
3658 |
|
|
|
3659 |
|
|
if ((insn & 0x100000) == 0)
|
3660 |
|
|
{
|
3661 |
|
|
if (is_double)
|
3662 |
|
|
bfd_arm_vfp11_write_mask (destmask, fm);
|
3663 |
|
|
else
|
3664 |
|
|
{
|
3665 |
|
|
bfd_arm_vfp11_write_mask (destmask, fm);
|
3666 |
|
|
bfd_arm_vfp11_write_mask (destmask, fm + 1);
|
3667 |
|
|
}
|
3668 |
|
|
}
|
3669 |
|
|
|
3670 |
|
|
pipe = VFP11_LS;
|
3671 |
|
|
}
|
3672 |
|
|
else if ((insn & 0x0e100e00) == 0x0c100a00) /* A load insn. */
|
3673 |
|
|
{
|
3674 |
|
|
int fd = bfd_arm_vfp11_regno (insn, is_double, 12, 22);
|
3675 |
|
|
unsigned int puw = ((insn >> 21) & 0x1) | (((insn >> 23) & 3) << 1);
|
3676 |
|
|
|
3677 |
|
|
switch (puw)
|
3678 |
|
|
{
|
3679 |
|
|
case 0: /* Two-reg transfer. We should catch these above. */
|
3680 |
|
|
abort ();
|
3681 |
|
|
|
3682 |
|
|
case 2: /* fldm[sdx]. */
|
3683 |
|
|
case 3:
|
3684 |
|
|
case 5:
|
3685 |
|
|
{
|
3686 |
|
|
unsigned int i, offset = insn & 0xff;
|
3687 |
|
|
|
3688 |
|
|
if (is_double)
|
3689 |
|
|
offset >>= 1;
|
3690 |
|
|
|
3691 |
|
|
for (i = fd; i < fd + offset; i++)
|
3692 |
|
|
bfd_arm_vfp11_write_mask (destmask, i);
|
3693 |
|
|
}
|
3694 |
|
|
break;
|
3695 |
|
|
|
3696 |
|
|
case 4: /* fld[sd]. */
|
3697 |
|
|
case 6:
|
3698 |
|
|
bfd_arm_vfp11_write_mask (destmask, fd);
|
3699 |
|
|
break;
|
3700 |
|
|
|
3701 |
|
|
default:
|
3702 |
|
|
return VFP11_BAD;
|
3703 |
|
|
}
|
3704 |
|
|
|
3705 |
|
|
pipe = VFP11_LS;
|
3706 |
|
|
}
|
3707 |
|
|
/* Single-register transfer. Note L==0. */
|
3708 |
|
|
else if ((insn & 0x0f100e10) == 0x0e000a10)
|
3709 |
|
|
{
|
3710 |
|
|
unsigned int opcode = (insn >> 21) & 7;
|
3711 |
|
|
unsigned int fn = bfd_arm_vfp11_regno (insn, is_double, 16, 7);
|
3712 |
|
|
|
3713 |
|
|
switch (opcode)
|
3714 |
|
|
{
|
3715 |
|
|
case 0: /* fmsr/fmdlr. */
|
3716 |
|
|
case 1: /* fmdhr. */
|
3717 |
|
|
/* Mark fmdhr and fmdlr as writing to the whole of the DP
|
3718 |
|
|
destination register. I don't know if this is exactly right,
|
3719 |
|
|
but it is the conservative choice. */
|
3720 |
|
|
bfd_arm_vfp11_write_mask (destmask, fn);
|
3721 |
|
|
break;
|
3722 |
|
|
|
3723 |
|
|
case 7: /* fmxr. */
|
3724 |
|
|
break;
|
3725 |
|
|
}
|
3726 |
|
|
|
3727 |
|
|
pipe = VFP11_LS;
|
3728 |
|
|
}
|
3729 |
|
|
|
3730 |
|
|
return pipe;
|
3731 |
|
|
}
|
3732 |
|
|
|
3733 |
|
|
|
3734 |
|
|
static int elf32_arm_compare_mapping (const void * a, const void * b);
|
3735 |
|
|
|
3736 |
|
|
|
3737 |
|
|
/* Look for potentially-troublesome code sequences which might trigger the
|
3738 |
|
|
VFP11 denormal/antidependency erratum. See, e.g., the ARM1136 errata sheet
|
3739 |
|
|
(available from ARM) for details of the erratum. A short version is
|
3740 |
|
|
described in ld.texinfo. */
|
3741 |
|
|
|
3742 |
|
|
bfd_boolean
|
3743 |
|
|
bfd_elf32_arm_vfp11_erratum_scan (bfd *abfd, struct bfd_link_info *link_info)
|
3744 |
|
|
{
|
3745 |
|
|
asection *sec;
|
3746 |
|
|
bfd_byte *contents = NULL;
|
3747 |
|
|
int state = 0;
|
3748 |
|
|
int regs[3], numregs = 0;
|
3749 |
|
|
struct elf32_arm_link_hash_table *globals = elf32_arm_hash_table (link_info);
|
3750 |
|
|
int use_vector = (globals->vfp11_fix == BFD_ARM_VFP11_FIX_VECTOR);
|
3751 |
|
|
|
3752 |
|
|
/* We use a simple FSM to match troublesome VFP11 instruction sequences.
|
3753 |
|
|
The states transition as follows:
|
3754 |
|
|
|
3755 |
|
|
|
3756 |
|
|
A VFP FMAC-pipeline instruction has been seen. Fill
|
3757 |
|
|
regs[0]..regs[numregs-1] with its input operands. Remember this
|
3758 |
|
|
instruction in 'first_fmac'.
|
3759 |
|
|
|
3760 |
|
|
1 -> 2
|
3761 |
|
|
Any instruction, except for a VFP instruction which overwrites
|
3762 |
|
|
regs[*].
|
3763 |
|
|
|
3764 |
|
|
1 -> 3 [ -> 0 ] or
|
3765 |
|
|
2 -> 3 [ -> 0 ]
|
3766 |
|
|
A VFP instruction has been seen which overwrites any of regs[*].
|
3767 |
|
|
We must make a veneer! Reset state to 0 before examining next
|
3768 |
|
|
instruction.
|
3769 |
|
|
|
3770 |
|
|
2 -> 0
|
3771 |
|
|
If we fail to match anything in state 2, reset to state 0 and reset
|
3772 |
|
|
the instruction pointer to the instruction after 'first_fmac'.
|
3773 |
|
|
|
3774 |
|
|
If the VFP11 vector mode is in use, there must be at least two unrelated
|
3775 |
|
|
instructions between anti-dependent VFP11 instructions to properly avoid
|
3776 |
|
|
triggering the erratum, hence the use of the extra state 1.
|
3777 |
|
|
*/
|
3778 |
|
|
|
3779 |
|
|
/* If we are only performing a partial link do not bother
|
3780 |
|
|
to construct any glue. */
|
3781 |
|
|
if (link_info->relocatable)
|
3782 |
|
|
return TRUE;
|
3783 |
|
|
|
3784 |
|
|
/* Skip if this bfd does not correspond to an ELF image. */
|
3785 |
|
|
if (! is_arm_elf (abfd))
|
3786 |
|
|
return TRUE;
|
3787 |
|
|
|
3788 |
|
|
/* We should have chosen a fix type by the time we get here. */
|
3789 |
|
|
BFD_ASSERT (globals->vfp11_fix != BFD_ARM_VFP11_FIX_DEFAULT);
|
3790 |
|
|
|
3791 |
|
|
if (globals->vfp11_fix == BFD_ARM_VFP11_FIX_NONE)
|
3792 |
|
|
return TRUE;
|
3793 |
|
|
|
3794 |
|
|
for (sec = abfd->sections; sec != NULL; sec = sec->next)
|
3795 |
|
|
{
|
3796 |
|
|
unsigned int i, span, first_fmac = 0, veneer_of_insn = 0;
|
3797 |
|
|
struct _arm_elf_section_data *sec_data;
|
3798 |
|
|
|
3799 |
|
|
/* If we don't have executable progbits, we're not interested in this
|
3800 |
|
|
section. Also skip if section is to be excluded. */
|
3801 |
|
|
if (elf_section_type (sec) != SHT_PROGBITS
|
3802 |
|
|
|| (elf_section_flags (sec) & SHF_EXECINSTR) == 0
|
3803 |
|
|
|| (sec->flags & SEC_EXCLUDE) != 0
|
3804 |
|
|
|| strcmp (sec->name, VFP11_ERRATUM_VENEER_SECTION_NAME) == 0)
|
3805 |
|
|
continue;
|
3806 |
|
|
|
3807 |
|
|
sec_data = elf32_arm_section_data (sec);
|
3808 |
|
|
|
3809 |
|
|
if (sec_data->mapcount == 0)
|
3810 |
|
|
continue;
|
3811 |
|
|
|
3812 |
|
|
if (elf_section_data (sec)->this_hdr.contents != NULL)
|
3813 |
|
|
contents = elf_section_data (sec)->this_hdr.contents;
|
3814 |
|
|
else if (! bfd_malloc_and_get_section (abfd, sec, &contents))
|
3815 |
|
|
goto error_return;
|
3816 |
|
|
|
3817 |
|
|
qsort (sec_data->map, sec_data->mapcount, sizeof (elf32_arm_section_map),
|
3818 |
|
|
elf32_arm_compare_mapping);
|
3819 |
|
|
|
3820 |
|
|
for (span = 0; span < sec_data->mapcount; span++)
|
3821 |
|
|
{
|
3822 |
|
|
unsigned int span_start = sec_data->map[span].vma;
|
3823 |
|
|
unsigned int span_end = (span == sec_data->mapcount - 1)
|
3824 |
|
|
? sec->size : sec_data->map[span + 1].vma;
|
3825 |
|
|
char span_type = sec_data->map[span].type;
|
3826 |
|
|
|
3827 |
|
|
/* FIXME: Only ARM mode is supported at present. We may need to
|
3828 |
|
|
support Thumb-2 mode also at some point. */
|
3829 |
|
|
if (span_type != 'a')
|
3830 |
|
|
continue;
|
3831 |
|
|
|
3832 |
|
|
for (i = span_start; i < span_end;)
|
3833 |
|
|
{
|
3834 |
|
|
unsigned int next_i = i + 4;
|
3835 |
|
|
unsigned int insn = bfd_big_endian (abfd)
|
3836 |
|
|
? (contents[i] << 24)
|
3837 |
|
|
| (contents[i + 1] << 16)
|
3838 |
|
|
| (contents[i + 2] << 8)
|
3839 |
|
|
| contents[i + 3]
|
3840 |
|
|
: (contents[i + 3] << 24)
|
3841 |
|
|
| (contents[i + 2] << 16)
|
3842 |
|
|
| (contents[i + 1] << 8)
|
3843 |
|
|
| contents[i];
|
3844 |
|
|
unsigned int writemask = 0;
|
3845 |
|
|
enum bfd_arm_vfp11_pipe pipe;
|
3846 |
|
|
|
3847 |
|
|
switch (state)
|
3848 |
|
|
{
|
3849 |
|
|
case 0:
|
3850 |
|
|
pipe = bfd_arm_vfp11_insn_decode (insn, &writemask, regs,
|
3851 |
|
|
&numregs);
|
3852 |
|
|
/* I'm assuming the VFP11 erratum can trigger with denorm
|
3853 |
|
|
operands on either the FMAC or the DS pipeline. This might
|
3854 |
|
|
lead to slightly overenthusiastic veneer insertion. */
|
3855 |
|
|
if (pipe == VFP11_FMAC || pipe == VFP11_DS)
|
3856 |
|
|
{
|
3857 |
|
|
state = use_vector ? 1 : 2;
|
3858 |
|
|
first_fmac = i;
|
3859 |
|
|
veneer_of_insn = insn;
|
3860 |
|
|
}
|
3861 |
|
|
break;
|
3862 |
|
|
|
3863 |
|
|
case 1:
|
3864 |
|
|
{
|
3865 |
|
|
int other_regs[3], other_numregs;
|
3866 |
|
|
pipe = bfd_arm_vfp11_insn_decode (insn, &writemask,
|
3867 |
|
|
other_regs,
|
3868 |
|
|
&other_numregs);
|
3869 |
|
|
if (pipe != VFP11_BAD
|
3870 |
|
|
&& bfd_arm_vfp11_antidependency (writemask, regs,
|
3871 |
|
|
numregs))
|
3872 |
|
|
state = 3;
|
3873 |
|
|
else
|
3874 |
|
|
state = 2;
|
3875 |
|
|
}
|
3876 |
|
|
break;
|
3877 |
|
|
|
3878 |
|
|
case 2:
|
3879 |
|
|
{
|
3880 |
|
|
int other_regs[3], other_numregs;
|
3881 |
|
|
pipe = bfd_arm_vfp11_insn_decode (insn, &writemask,
|
3882 |
|
|
other_regs,
|
3883 |
|
|
&other_numregs);
|
3884 |
|
|
if (pipe != VFP11_BAD
|
3885 |
|
|
&& bfd_arm_vfp11_antidependency (writemask, regs,
|
3886 |
|
|
numregs))
|
3887 |
|
|
state = 3;
|
3888 |
|
|
else
|
3889 |
|
|
{
|
3890 |
|
|
state = 0;
|
3891 |
|
|
next_i = first_fmac + 4;
|
3892 |
|
|
}
|
3893 |
|
|
}
|
3894 |
|
|
break;
|
3895 |
|
|
|
3896 |
|
|
case 3:
|
3897 |
|
|
abort (); /* Should be unreachable. */
|
3898 |
|
|
}
|
3899 |
|
|
|
3900 |
|
|
if (state == 3)
|
3901 |
|
|
{
|
3902 |
|
|
elf32_vfp11_erratum_list *newerr
|
3903 |
|
|
= bfd_zmalloc (sizeof (elf32_vfp11_erratum_list));
|
3904 |
|
|
int errcount;
|
3905 |
|
|
|
3906 |
|
|
errcount = ++(elf32_arm_section_data (sec)->erratumcount);
|
3907 |
|
|
|
3908 |
|
|
newerr->u.b.vfp_insn = veneer_of_insn;
|
3909 |
|
|
|
3910 |
|
|
switch (span_type)
|
3911 |
|
|
{
|
3912 |
|
|
case 'a':
|
3913 |
|
|
newerr->type = VFP11_ERRATUM_BRANCH_TO_ARM_VENEER;
|
3914 |
|
|
break;
|
3915 |
|
|
|
3916 |
|
|
default:
|
3917 |
|
|
abort ();
|
3918 |
|
|
}
|
3919 |
|
|
|
3920 |
|
|
record_vfp11_erratum_veneer (link_info, newerr, abfd, sec,
|
3921 |
|
|
first_fmac);
|
3922 |
|
|
|
3923 |
|
|
newerr->vma = -1;
|
3924 |
|
|
|
3925 |
|
|
newerr->next = sec_data->erratumlist;
|
3926 |
|
|
sec_data->erratumlist = newerr;
|
3927 |
|
|
|
3928 |
|
|
state = 0;
|
3929 |
|
|
}
|
3930 |
|
|
|
3931 |
|
|
i = next_i;
|
3932 |
|
|
}
|
3933 |
|
|
}
|
3934 |
|
|
|
3935 |
|
|
if (contents != NULL
|
3936 |
|
|
&& elf_section_data (sec)->this_hdr.contents != contents)
|
3937 |
|
|
free (contents);
|
3938 |
|
|
contents = NULL;
|
3939 |
|
|
}
|
3940 |
|
|
|
3941 |
|
|
return TRUE;
|
3942 |
|
|
|
3943 |
|
|
error_return:
|
3944 |
|
|
if (contents != NULL
|
3945 |
|
|
&& elf_section_data (sec)->this_hdr.contents != contents)
|
3946 |
|
|
free (contents);
|
3947 |
|
|
|
3948 |
|
|
return FALSE;
|
3949 |
|
|
}
|
3950 |
|
|
|
3951 |
|
|
/* Find virtual-memory addresses for VFP11 erratum veneers and return locations
|
3952 |
|
|
after sections have been laid out, using specially-named symbols. */
|
3953 |
|
|
|
3954 |
|
|
void
|
3955 |
|
|
bfd_elf32_arm_vfp11_fix_veneer_locations (bfd *abfd,
|
3956 |
|
|
struct bfd_link_info *link_info)
|
3957 |
|
|
{
|
3958 |
|
|
asection *sec;
|
3959 |
|
|
struct elf32_arm_link_hash_table *globals;
|
3960 |
|
|
char *tmp_name;
|
3961 |
|
|
|
3962 |
|
|
if (link_info->relocatable)
|
3963 |
|
|
return;
|
3964 |
|
|
|
3965 |
|
|
/* Skip if this bfd does not correspond to an ELF image. */
|
3966 |
|
|
if (! is_arm_elf (abfd))
|
3967 |
|
|
return;
|
3968 |
|
|
|
3969 |
|
|
globals = elf32_arm_hash_table (link_info);
|
3970 |
|
|
|
3971 |
|
|
tmp_name = bfd_malloc ((bfd_size_type) strlen
|
3972 |
|
|
(VFP11_ERRATUM_VENEER_ENTRY_NAME) + 10);
|
3973 |
|
|
|
3974 |
|
|
for (sec = abfd->sections; sec != NULL; sec = sec->next)
|
3975 |
|
|
{
|
3976 |
|
|
struct _arm_elf_section_data *sec_data = elf32_arm_section_data (sec);
|
3977 |
|
|
elf32_vfp11_erratum_list *errnode = sec_data->erratumlist;
|
3978 |
|
|
|
3979 |
|
|
for (; errnode != NULL; errnode = errnode->next)
|
3980 |
|
|
{
|
3981 |
|
|
struct elf_link_hash_entry *myh;
|
3982 |
|
|
bfd_vma vma;
|
3983 |
|
|
|
3984 |
|
|
switch (errnode->type)
|
3985 |
|
|
{
|
3986 |
|
|
case VFP11_ERRATUM_BRANCH_TO_ARM_VENEER:
|
3987 |
|
|
case VFP11_ERRATUM_BRANCH_TO_THUMB_VENEER:
|
3988 |
|
|
/* Find veneer symbol. */
|
3989 |
|
|
sprintf (tmp_name, VFP11_ERRATUM_VENEER_ENTRY_NAME,
|
3990 |
|
|
errnode->u.b.veneer->u.v.id);
|
3991 |
|
|
|
3992 |
|
|
myh = elf_link_hash_lookup
|
3993 |
|
|
(&(globals)->root, tmp_name, FALSE, FALSE, TRUE);
|
3994 |
|
|
|
3995 |
|
|
if (myh == NULL)
|
3996 |
|
|
(*_bfd_error_handler) (_("%B: unable to find VFP11 veneer "
|
3997 |
|
|
"`%s'"), abfd, tmp_name);
|
3998 |
|
|
|
3999 |
|
|
vma = myh->root.u.def.section->output_section->vma
|
4000 |
|
|
+ myh->root.u.def.section->output_offset
|
4001 |
|
|
+ myh->root.u.def.value;
|
4002 |
|
|
|
4003 |
|
|
errnode->u.b.veneer->vma = vma;
|
4004 |
|
|
break;
|
4005 |
|
|
|
4006 |
|
|
case VFP11_ERRATUM_ARM_VENEER:
|
4007 |
|
|
case VFP11_ERRATUM_THUMB_VENEER:
|
4008 |
|
|
/* Find return location. */
|
4009 |
|
|
sprintf (tmp_name, VFP11_ERRATUM_VENEER_ENTRY_NAME "_r",
|
4010 |
|
|
errnode->u.v.id);
|
4011 |
|
|
|
4012 |
|
|
myh = elf_link_hash_lookup
|
4013 |
|
|
(&(globals)->root, tmp_name, FALSE, FALSE, TRUE);
|
4014 |
|
|
|
4015 |
|
|
if (myh == NULL)
|
4016 |
|
|
(*_bfd_error_handler) (_("%B: unable to find VFP11 veneer "
|
4017 |
|
|
"`%s'"), abfd, tmp_name);
|
4018 |
|
|
|
4019 |
|
|
vma = myh->root.u.def.section->output_section->vma
|
4020 |
|
|
+ myh->root.u.def.section->output_offset
|
4021 |
|
|
+ myh->root.u.def.value;
|
4022 |
|
|
|
4023 |
|
|
errnode->u.v.branch->vma = vma;
|
4024 |
|
|
break;
|
4025 |
|
|
|
4026 |
|
|
default:
|
4027 |
|
|
abort ();
|
4028 |
|
|
}
|
4029 |
|
|
}
|
4030 |
|
|
}
|
4031 |
|
|
|
4032 |
|
|
free (tmp_name);
|
4033 |
|
|
}
|
4034 |
|
|
|
4035 |
|
|
|
4036 |
|
|
/* Set target relocation values needed during linking. */
|
4037 |
|
|
|
4038 |
|
|
void
|
4039 |
|
|
bfd_elf32_arm_set_target_relocs (struct bfd *output_bfd,
|
4040 |
|
|
struct bfd_link_info *link_info,
|
4041 |
|
|
int target1_is_rel,
|
4042 |
|
|
char * target2_type,
|
4043 |
|
|
int fix_v4bx,
|
4044 |
|
|
int use_blx,
|
4045 |
|
|
bfd_arm_vfp11_fix vfp11_fix,
|
4046 |
|
|
int no_enum_warn, int pic_veneer)
|
4047 |
|
|
{
|
4048 |
|
|
struct elf32_arm_link_hash_table *globals;
|
4049 |
|
|
|
4050 |
|
|
globals = elf32_arm_hash_table (link_info);
|
4051 |
|
|
|
4052 |
|
|
globals->target1_is_rel = target1_is_rel;
|
4053 |
|
|
if (strcmp (target2_type, "rel") == 0)
|
4054 |
|
|
globals->target2_reloc = R_ARM_REL32;
|
4055 |
|
|
else if (strcmp (target2_type, "abs") == 0)
|
4056 |
|
|
globals->target2_reloc = R_ARM_ABS32;
|
4057 |
|
|
else if (strcmp (target2_type, "got-rel") == 0)
|
4058 |
|
|
globals->target2_reloc = R_ARM_GOT_PREL;
|
4059 |
|
|
else
|
4060 |
|
|
{
|
4061 |
|
|
_bfd_error_handler (_("Invalid TARGET2 relocation type '%s'."),
|
4062 |
|
|
target2_type);
|
4063 |
|
|
}
|
4064 |
|
|
globals->fix_v4bx = fix_v4bx;
|
4065 |
|
|
globals->use_blx |= use_blx;
|
4066 |
|
|
globals->vfp11_fix = vfp11_fix;
|
4067 |
|
|
globals->pic_veneer = pic_veneer;
|
4068 |
|
|
|
4069 |
|
|
BFD_ASSERT (is_arm_elf (output_bfd));
|
4070 |
|
|
elf_arm_tdata (output_bfd)->no_enum_size_warning = no_enum_warn;
|
4071 |
|
|
}
|
4072 |
|
|
|
4073 |
|
|
/* The thumb form of a long branch is a bit finicky, because the offset
|
4074 |
|
|
encoding is split over two fields, each in it's own instruction. They
|
4075 |
|
|
can occur in any order. So given a thumb form of long branch, and an
|
4076 |
|
|
offset, insert the offset into the thumb branch and return finished
|
4077 |
|
|
instruction.
|
4078 |
|
|
|
4079 |
|
|
It takes two thumb instructions to encode the target address. Each has
|
4080 |
|
|
11 bits to invest. The upper 11 bits are stored in one (identified by
|
4081 |
|
|
H-0.. see below), the lower 11 bits are stored in the other (identified
|
4082 |
|
|
by H-1).
|
4083 |
|
|
|
4084 |
|
|
Combine together and shifted left by 1 (it's a half word address) and
|
4085 |
|
|
there you have it.
|
4086 |
|
|
|
4087 |
|
|
Op: 1111 = F,
|
4088 |
|
|
H-0, upper address-0 = 000
|
4089 |
|
|
Op: 1111 = F,
|
4090 |
|
|
H-1, lower address-0 = 800
|
4091 |
|
|
|
4092 |
|
|
They can be ordered either way, but the arm tools I've seen always put
|
4093 |
|
|
the lower one first. It probably doesn't matter. krk@cygnus.com
|
4094 |
|
|
|
4095 |
|
|
XXX: Actually the order does matter. The second instruction (H-1)
|
4096 |
|
|
moves the computed address into the PC, so it must be the second one
|
4097 |
|
|
in the sequence. The problem, however is that whilst little endian code
|
4098 |
|
|
stores the instructions in HI then LOW order, big endian code does the
|
4099 |
|
|
reverse. nickc@cygnus.com. */
|
4100 |
|
|
|
4101 |
|
|
#define LOW_HI_ORDER 0xF800F000
|
4102 |
|
|
#define HI_LOW_ORDER 0xF000F800
|
4103 |
|
|
|
4104 |
|
|
static insn32
|
4105 |
|
|
insert_thumb_branch (insn32 br_insn, int rel_off)
|
4106 |
|
|
{
|
4107 |
|
|
unsigned int low_bits;
|
4108 |
|
|
unsigned int high_bits;
|
4109 |
|
|
|
4110 |
|
|
BFD_ASSERT ((rel_off & 1) != 1);
|
4111 |
|
|
|
4112 |
|
|
rel_off >>= 1; /* Half word aligned address. */
|
4113 |
|
|
low_bits = rel_off & 0x000007FF; /* The bottom 11 bits. */
|
4114 |
|
|
high_bits = (rel_off >> 11) & 0x000007FF; /* The top 11 bits. */
|
4115 |
|
|
|
4116 |
|
|
if ((br_insn & LOW_HI_ORDER) == LOW_HI_ORDER)
|
4117 |
|
|
br_insn = LOW_HI_ORDER | (low_bits << 16) | high_bits;
|
4118 |
|
|
else if ((br_insn & HI_LOW_ORDER) == HI_LOW_ORDER)
|
4119 |
|
|
br_insn = HI_LOW_ORDER | (high_bits << 16) | low_bits;
|
4120 |
|
|
else
|
4121 |
|
|
/* FIXME: abort is probably not the right call. krk@cygnus.com */
|
4122 |
|
|
abort (); /* Error - not a valid branch instruction form. */
|
4123 |
|
|
|
4124 |
|
|
return br_insn;
|
4125 |
|
|
}
|
4126 |
|
|
|
4127 |
|
|
|
4128 |
|
|
/* Store an Arm insn into an output section not processed by
|
4129 |
|
|
elf32_arm_write_section. */
|
4130 |
|
|
|
4131 |
|
|
static void
|
4132 |
|
|
put_arm_insn (struct elf32_arm_link_hash_table *htab,
|
4133 |
|
|
bfd * output_bfd, bfd_vma val, void * ptr)
|
4134 |
|
|
{
|
4135 |
|
|
if (htab->byteswap_code != bfd_little_endian (output_bfd))
|
4136 |
|
|
bfd_putl32 (val, ptr);
|
4137 |
|
|
else
|
4138 |
|
|
bfd_putb32 (val, ptr);
|
4139 |
|
|
}
|
4140 |
|
|
|
4141 |
|
|
|
4142 |
|
|
/* Store a 16-bit Thumb insn into an output section not processed by
|
4143 |
|
|
elf32_arm_write_section. */
|
4144 |
|
|
|
4145 |
|
|
static void
|
4146 |
|
|
put_thumb_insn (struct elf32_arm_link_hash_table *htab,
|
4147 |
|
|
bfd * output_bfd, bfd_vma val, void * ptr)
|
4148 |
|
|
{
|
4149 |
|
|
if (htab->byteswap_code != bfd_little_endian (output_bfd))
|
4150 |
|
|
bfd_putl16 (val, ptr);
|
4151 |
|
|
else
|
4152 |
|
|
bfd_putb16 (val, ptr);
|
4153 |
|
|
}
|
4154 |
|
|
|
4155 |
|
|
|
4156 |
|
|
/* Thumb code calling an ARM function. */
|
4157 |
|
|
|
4158 |
|
|
static int
|
4159 |
|
|
elf32_thumb_to_arm_stub (struct bfd_link_info * info,
|
4160 |
|
|
const char * name,
|
4161 |
|
|
bfd * input_bfd,
|
4162 |
|
|
bfd * output_bfd,
|
4163 |
|
|
asection * input_section,
|
4164 |
|
|
bfd_byte * hit_data,
|
4165 |
|
|
asection * sym_sec,
|
4166 |
|
|
bfd_vma offset,
|
4167 |
|
|
bfd_signed_vma addend,
|
4168 |
|
|
bfd_vma val,
|
4169 |
|
|
char **error_message)
|
4170 |
|
|
{
|
4171 |
|
|
asection * s = 0;
|
4172 |
|
|
bfd_vma my_offset;
|
4173 |
|
|
unsigned long int tmp;
|
4174 |
|
|
long int ret_offset;
|
4175 |
|
|
struct elf_link_hash_entry * myh;
|
4176 |
|
|
struct elf32_arm_link_hash_table * globals;
|
4177 |
|
|
|
4178 |
|
|
myh = find_thumb_glue (info, name, error_message);
|
4179 |
|
|
if (myh == NULL)
|
4180 |
|
|
return FALSE;
|
4181 |
|
|
|
4182 |
|
|
globals = elf32_arm_hash_table (info);
|
4183 |
|
|
|
4184 |
|
|
BFD_ASSERT (globals != NULL);
|
4185 |
|
|
BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
|
4186 |
|
|
|
4187 |
|
|
my_offset = myh->root.u.def.value;
|
4188 |
|
|
|
4189 |
|
|
s = bfd_get_section_by_name (globals->bfd_of_glue_owner,
|
4190 |
|
|
THUMB2ARM_GLUE_SECTION_NAME);
|
4191 |
|
|
|
4192 |
|
|
BFD_ASSERT (s != NULL);
|
4193 |
|
|
BFD_ASSERT (s->contents != NULL);
|
4194 |
|
|
BFD_ASSERT (s->output_section != NULL);
|
4195 |
|
|
|
4196 |
|
|
if ((my_offset & 0x01) == 0x01)
|
4197 |
|
|
{
|
4198 |
|
|
if (sym_sec != NULL
|
4199 |
|
|
&& sym_sec->owner != NULL
|
4200 |
|
|
&& !INTERWORK_FLAG (sym_sec->owner))
|
4201 |
|
|
{
|
4202 |
|
|
(*_bfd_error_handler)
|
4203 |
|
|
(_("%B(%s): warning: interworking not enabled.\n"
|
4204 |
|
|
" first occurrence: %B: thumb call to arm"),
|
4205 |
|
|
sym_sec->owner, input_bfd, name);
|
4206 |
|
|
|
4207 |
|
|
return FALSE;
|
4208 |
|
|
}
|
4209 |
|
|
|
4210 |
|
|
--my_offset;
|
4211 |
|
|
myh->root.u.def.value = my_offset;
|
4212 |
|
|
|
4213 |
|
|
put_thumb_insn (globals, output_bfd, (bfd_vma) t2a1_bx_pc_insn,
|
4214 |
|
|
s->contents + my_offset);
|
4215 |
|
|
|
4216 |
|
|
put_thumb_insn (globals, output_bfd, (bfd_vma) t2a2_noop_insn,
|
4217 |
|
|
s->contents + my_offset + 2);
|
4218 |
|
|
|
4219 |
|
|
ret_offset =
|
4220 |
|
|
/* Address of destination of the stub. */
|
4221 |
|
|
((bfd_signed_vma) val)
|
4222 |
|
|
- ((bfd_signed_vma)
|
4223 |
|
|
/* Offset from the start of the current section
|
4224 |
|
|
to the start of the stubs. */
|
4225 |
|
|
(s->output_offset
|
4226 |
|
|
/* Offset of the start of this stub from the start of the stubs. */
|
4227 |
|
|
+ my_offset
|
4228 |
|
|
/* Address of the start of the current section. */
|
4229 |
|
|
+ s->output_section->vma)
|
4230 |
|
|
/* The branch instruction is 4 bytes into the stub. */
|
4231 |
|
|
+ 4
|
4232 |
|
|
/* ARM branches work from the pc of the instruction + 8. */
|
4233 |
|
|
+ 8);
|
4234 |
|
|
|
4235 |
|
|
put_arm_insn (globals, output_bfd,
|
4236 |
|
|
(bfd_vma) t2a3_b_insn | ((ret_offset >> 2) & 0x00FFFFFF),
|
4237 |
|
|
s->contents + my_offset + 4);
|
4238 |
|
|
}
|
4239 |
|
|
|
4240 |
|
|
BFD_ASSERT (my_offset <= globals->thumb_glue_size);
|
4241 |
|
|
|
4242 |
|
|
/* Now go back and fix up the original BL insn to point to here. */
|
4243 |
|
|
ret_offset =
|
4244 |
|
|
/* Address of where the stub is located. */
|
4245 |
|
|
(s->output_section->vma + s->output_offset + my_offset)
|
4246 |
|
|
/* Address of where the BL is located. */
|
4247 |
|
|
- (input_section->output_section->vma + input_section->output_offset
|
4248 |
|
|
+ offset)
|
4249 |
|
|
/* Addend in the relocation. */
|
4250 |
|
|
- addend
|
4251 |
|
|
/* Biassing for PC-relative addressing. */
|
4252 |
|
|
- 8;
|
4253 |
|
|
|
4254 |
|
|
tmp = bfd_get_32 (input_bfd, hit_data
|
4255 |
|
|
- input_section->vma);
|
4256 |
|
|
|
4257 |
|
|
bfd_put_32 (output_bfd,
|
4258 |
|
|
(bfd_vma) insert_thumb_branch (tmp, ret_offset),
|
4259 |
|
|
hit_data - input_section->vma);
|
4260 |
|
|
|
4261 |
|
|
return TRUE;
|
4262 |
|
|
}
|
4263 |
|
|
|
4264 |
|
|
/* Populate an Arm to Thumb stub. Returns the stub symbol. */
|
4265 |
|
|
|
4266 |
|
|
static struct elf_link_hash_entry *
|
4267 |
|
|
elf32_arm_create_thumb_stub (struct bfd_link_info * info,
|
4268 |
|
|
const char * name,
|
4269 |
|
|
bfd * input_bfd,
|
4270 |
|
|
bfd * output_bfd,
|
4271 |
|
|
asection * sym_sec,
|
4272 |
|
|
bfd_vma val,
|
4273 |
|
|
asection *s,
|
4274 |
|
|
char **error_message)
|
4275 |
|
|
{
|
4276 |
|
|
bfd_vma my_offset;
|
4277 |
|
|
long int ret_offset;
|
4278 |
|
|
struct elf_link_hash_entry * myh;
|
4279 |
|
|
struct elf32_arm_link_hash_table * globals;
|
4280 |
|
|
|
4281 |
|
|
myh = find_arm_glue (info, name, error_message);
|
4282 |
|
|
if (myh == NULL)
|
4283 |
|
|
return NULL;
|
4284 |
|
|
|
4285 |
|
|
globals = elf32_arm_hash_table (info);
|
4286 |
|
|
|
4287 |
|
|
BFD_ASSERT (globals != NULL);
|
4288 |
|
|
BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
|
4289 |
|
|
|
4290 |
|
|
my_offset = myh->root.u.def.value;
|
4291 |
|
|
|
4292 |
|
|
if ((my_offset & 0x01) == 0x01)
|
4293 |
|
|
{
|
4294 |
|
|
if (sym_sec != NULL
|
4295 |
|
|
&& sym_sec->owner != NULL
|
4296 |
|
|
&& !INTERWORK_FLAG (sym_sec->owner))
|
4297 |
|
|
{
|
4298 |
|
|
(*_bfd_error_handler)
|
4299 |
|
|
(_("%B(%s): warning: interworking not enabled.\n"
|
4300 |
|
|
" first occurrence: %B: arm call to thumb"),
|
4301 |
|
|
sym_sec->owner, input_bfd, name);
|
4302 |
|
|
}
|
4303 |
|
|
|
4304 |
|
|
--my_offset;
|
4305 |
|
|
myh->root.u.def.value = my_offset;
|
4306 |
|
|
|
4307 |
|
|
if (info->shared || globals->root.is_relocatable_executable
|
4308 |
|
|
|| globals->pic_veneer)
|
4309 |
|
|
{
|
4310 |
|
|
/* For relocatable objects we can't use absolute addresses,
|
4311 |
|
|
so construct the address from a relative offset. */
|
4312 |
|
|
/* TODO: If the offset is small it's probably worth
|
4313 |
|
|
constructing the address with adds. */
|
4314 |
|
|
put_arm_insn (globals, output_bfd, (bfd_vma) a2t1p_ldr_insn,
|
4315 |
|
|
s->contents + my_offset);
|
4316 |
|
|
put_arm_insn (globals, output_bfd, (bfd_vma) a2t2p_add_pc_insn,
|
4317 |
|
|
s->contents + my_offset + 4);
|
4318 |
|
|
put_arm_insn (globals, output_bfd, (bfd_vma) a2t3p_bx_r12_insn,
|
4319 |
|
|
s->contents + my_offset + 8);
|
4320 |
|
|
/* Adjust the offset by 4 for the position of the add,
|
4321 |
|
|
and 8 for the pipeline offset. */
|
4322 |
|
|
ret_offset = (val - (s->output_offset
|
4323 |
|
|
+ s->output_section->vma
|
4324 |
|
|
+ my_offset + 12))
|
4325 |
|
|
| 1;
|
4326 |
|
|
bfd_put_32 (output_bfd, ret_offset,
|
4327 |
|
|
s->contents + my_offset + 12);
|
4328 |
|
|
}
|
4329 |
|
|
else if (globals->use_blx)
|
4330 |
|
|
{
|
4331 |
|
|
put_arm_insn (globals, output_bfd, (bfd_vma) a2t1v5_ldr_insn,
|
4332 |
|
|
s->contents + my_offset);
|
4333 |
|
|
|
4334 |
|
|
/* It's a thumb address. Add the low order bit. */
|
4335 |
|
|
bfd_put_32 (output_bfd, val | a2t2v5_func_addr_insn,
|
4336 |
|
|
s->contents + my_offset + 4);
|
4337 |
|
|
}
|
4338 |
|
|
else
|
4339 |
|
|
{
|
4340 |
|
|
put_arm_insn (globals, output_bfd, (bfd_vma) a2t1_ldr_insn,
|
4341 |
|
|
s->contents + my_offset);
|
4342 |
|
|
|
4343 |
|
|
put_arm_insn (globals, output_bfd, (bfd_vma) a2t2_bx_r12_insn,
|
4344 |
|
|
s->contents + my_offset + 4);
|
4345 |
|
|
|
4346 |
|
|
/* It's a thumb address. Add the low order bit. */
|
4347 |
|
|
bfd_put_32 (output_bfd, val | a2t3_func_addr_insn,
|
4348 |
|
|
s->contents + my_offset + 8);
|
4349 |
|
|
}
|
4350 |
|
|
}
|
4351 |
|
|
|
4352 |
|
|
BFD_ASSERT (my_offset <= globals->arm_glue_size);
|
4353 |
|
|
|
4354 |
|
|
return myh;
|
4355 |
|
|
}
|
4356 |
|
|
|
4357 |
|
|
/* Arm code calling a Thumb function. */
|
4358 |
|
|
|
4359 |
|
|
static int
|
4360 |
|
|
elf32_arm_to_thumb_stub (struct bfd_link_info * info,
|
4361 |
|
|
const char * name,
|
4362 |
|
|
bfd * input_bfd,
|
4363 |
|
|
bfd * output_bfd,
|
4364 |
|
|
asection * input_section,
|
4365 |
|
|
bfd_byte * hit_data,
|
4366 |
|
|
asection * sym_sec,
|
4367 |
|
|
bfd_vma offset,
|
4368 |
|
|
bfd_signed_vma addend,
|
4369 |
|
|
bfd_vma val,
|
4370 |
|
|
char **error_message)
|
4371 |
|
|
{
|
4372 |
|
|
unsigned long int tmp;
|
4373 |
|
|
bfd_vma my_offset;
|
4374 |
|
|
asection * s;
|
4375 |
|
|
long int ret_offset;
|
4376 |
|
|
struct elf_link_hash_entry * myh;
|
4377 |
|
|
struct elf32_arm_link_hash_table * globals;
|
4378 |
|
|
|
4379 |
|
|
globals = elf32_arm_hash_table (info);
|
4380 |
|
|
|
4381 |
|
|
BFD_ASSERT (globals != NULL);
|
4382 |
|
|
BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
|
4383 |
|
|
|
4384 |
|
|
s = bfd_get_section_by_name (globals->bfd_of_glue_owner,
|
4385 |
|
|
ARM2THUMB_GLUE_SECTION_NAME);
|
4386 |
|
|
BFD_ASSERT (s != NULL);
|
4387 |
|
|
BFD_ASSERT (s->contents != NULL);
|
4388 |
|
|
BFD_ASSERT (s->output_section != NULL);
|
4389 |
|
|
|
4390 |
|
|
myh = elf32_arm_create_thumb_stub (info, name, input_bfd, output_bfd,
|
4391 |
|
|
sym_sec, val, s, error_message);
|
4392 |
|
|
if (!myh)
|
4393 |
|
|
return FALSE;
|
4394 |
|
|
|
4395 |
|
|
my_offset = myh->root.u.def.value;
|
4396 |
|
|
tmp = bfd_get_32 (input_bfd, hit_data);
|
4397 |
|
|
tmp = tmp & 0xFF000000;
|
4398 |
|
|
|
4399 |
|
|
/* Somehow these are both 4 too far, so subtract 8. */
|
4400 |
|
|
ret_offset = (s->output_offset
|
4401 |
|
|
+ my_offset
|
4402 |
|
|
+ s->output_section->vma
|
4403 |
|
|
- (input_section->output_offset
|
4404 |
|
|
+ input_section->output_section->vma
|
4405 |
|
|
+ offset + addend)
|
4406 |
|
|
- 8);
|
4407 |
|
|
|
4408 |
|
|
tmp = tmp | ((ret_offset >> 2) & 0x00FFFFFF);
|
4409 |
|
|
|
4410 |
|
|
bfd_put_32 (output_bfd, (bfd_vma) tmp, hit_data - input_section->vma);
|
4411 |
|
|
|
4412 |
|
|
return TRUE;
|
4413 |
|
|
}
|
4414 |
|
|
|
4415 |
|
|
/* Populate Arm stub for an exported Thumb function. */
|
4416 |
|
|
|
4417 |
|
|
static bfd_boolean
|
4418 |
|
|
elf32_arm_to_thumb_export_stub (struct elf_link_hash_entry *h, void * inf)
|
4419 |
|
|
{
|
4420 |
|
|
struct bfd_link_info * info = (struct bfd_link_info *) inf;
|
4421 |
|
|
asection * s;
|
4422 |
|
|
struct elf_link_hash_entry * myh;
|
4423 |
|
|
struct elf32_arm_link_hash_entry *eh;
|
4424 |
|
|
struct elf32_arm_link_hash_table * globals;
|
4425 |
|
|
asection *sec;
|
4426 |
|
|
bfd_vma val;
|
4427 |
|
|
char *error_message;
|
4428 |
|
|
|
4429 |
|
|
eh = elf32_arm_hash_entry(h);
|
4430 |
|
|
/* Allocate stubs for exported Thumb functions on v4t. */
|
4431 |
|
|
if (eh->export_glue == NULL)
|
4432 |
|
|
return TRUE;
|
4433 |
|
|
|
4434 |
|
|
globals = elf32_arm_hash_table (info);
|
4435 |
|
|
|
4436 |
|
|
BFD_ASSERT (globals != NULL);
|
4437 |
|
|
BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
|
4438 |
|
|
|
4439 |
|
|
s = bfd_get_section_by_name (globals->bfd_of_glue_owner,
|
4440 |
|
|
ARM2THUMB_GLUE_SECTION_NAME);
|
4441 |
|
|
BFD_ASSERT (s != NULL);
|
4442 |
|
|
BFD_ASSERT (s->contents != NULL);
|
4443 |
|
|
BFD_ASSERT (s->output_section != NULL);
|
4444 |
|
|
|
4445 |
|
|
sec = eh->export_glue->root.u.def.section;
|
4446 |
|
|
|
4447 |
|
|
BFD_ASSERT (sec->output_section != NULL);
|
4448 |
|
|
|
4449 |
|
|
val = eh->export_glue->root.u.def.value + sec->output_offset
|
4450 |
|
|
+ sec->output_section->vma;
|
4451 |
|
|
myh = elf32_arm_create_thumb_stub (info, h->root.root.string,
|
4452 |
|
|
h->root.u.def.section->owner,
|
4453 |
|
|
globals->obfd, sec, val, s,
|
4454 |
|
|
&error_message);
|
4455 |
|
|
BFD_ASSERT (myh);
|
4456 |
|
|
return TRUE;
|
4457 |
|
|
}
|
4458 |
|
|
|
4459 |
|
|
/* Populate ARMv4 BX veneers. Returns the absolute adress of the veneer. */
|
4460 |
|
|
|
4461 |
|
|
static bfd_vma
|
4462 |
|
|
elf32_arm_bx_glue (struct bfd_link_info * info, int reg)
|
4463 |
|
|
{
|
4464 |
|
|
bfd_byte *p;
|
4465 |
|
|
bfd_vma glue_addr;
|
4466 |
|
|
asection *s;
|
4467 |
|
|
struct elf32_arm_link_hash_table *globals;
|
4468 |
|
|
|
4469 |
|
|
globals = elf32_arm_hash_table (info);
|
4470 |
|
|
|
4471 |
|
|
BFD_ASSERT (globals != NULL);
|
4472 |
|
|
BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
|
4473 |
|
|
|
4474 |
|
|
s = bfd_get_section_by_name (globals->bfd_of_glue_owner,
|
4475 |
|
|
ARM_BX_GLUE_SECTION_NAME);
|
4476 |
|
|
BFD_ASSERT (s != NULL);
|
4477 |
|
|
BFD_ASSERT (s->contents != NULL);
|
4478 |
|
|
BFD_ASSERT (s->output_section != NULL);
|
4479 |
|
|
|
4480 |
|
|
BFD_ASSERT (globals->bx_glue_offset[reg] & 2);
|
4481 |
|
|
|
4482 |
|
|
glue_addr = globals->bx_glue_offset[reg] & ~(bfd_vma)3;
|
4483 |
|
|
|
4484 |
|
|
if ((globals->bx_glue_offset[reg] & 1) == 0)
|
4485 |
|
|
{
|
4486 |
|
|
p = s->contents + glue_addr;
|
4487 |
|
|
bfd_put_32 (globals->obfd, armbx1_tst_insn + (reg << 16), p);
|
4488 |
|
|
bfd_put_32 (globals->obfd, armbx2_moveq_insn + reg, p + 4);
|
4489 |
|
|
bfd_put_32 (globals->obfd, armbx3_bx_insn + reg, p + 8);
|
4490 |
|
|
globals->bx_glue_offset[reg] |= 1;
|
4491 |
|
|
}
|
4492 |
|
|
|
4493 |
|
|
return glue_addr + s->output_section->vma + s->output_offset;
|
4494 |
|
|
}
|
4495 |
|
|
|
4496 |
|
|
/* Generate Arm stubs for exported Thumb symbols. */
|
4497 |
|
|
static void
|
4498 |
|
|
elf32_arm_begin_write_processing (bfd *abfd ATTRIBUTE_UNUSED,
|
4499 |
|
|
struct bfd_link_info *link_info)
|
4500 |
|
|
{
|
4501 |
|
|
struct elf32_arm_link_hash_table * globals;
|
4502 |
|
|
|
4503 |
|
|
if (!link_info)
|
4504 |
|
|
return;
|
4505 |
|
|
|
4506 |
|
|
globals = elf32_arm_hash_table (link_info);
|
4507 |
|
|
/* If blx is available then exported Thumb symbols are OK and there is
|
4508 |
|
|
nothing to do. */
|
4509 |
|
|
if (globals->use_blx)
|
4510 |
|
|
return;
|
4511 |
|
|
|
4512 |
|
|
elf_link_hash_traverse (&globals->root, elf32_arm_to_thumb_export_stub,
|
4513 |
|
|
link_info);
|
4514 |
|
|
}
|
4515 |
|
|
|
4516 |
|
|
/* Some relocations map to different relocations depending on the
|
4517 |
|
|
target. Return the real relocation. */
|
4518 |
|
|
static int
|
4519 |
|
|
arm_real_reloc_type (struct elf32_arm_link_hash_table * globals,
|
4520 |
|
|
int r_type)
|
4521 |
|
|
{
|
4522 |
|
|
switch (r_type)
|
4523 |
|
|
{
|
4524 |
|
|
case R_ARM_TARGET1:
|
4525 |
|
|
if (globals->target1_is_rel)
|
4526 |
|
|
return R_ARM_REL32;
|
4527 |
|
|
else
|
4528 |
|
|
return R_ARM_ABS32;
|
4529 |
|
|
|
4530 |
|
|
case R_ARM_TARGET2:
|
4531 |
|
|
return globals->target2_reloc;
|
4532 |
|
|
|
4533 |
|
|
default:
|
4534 |
|
|
return r_type;
|
4535 |
|
|
}
|
4536 |
|
|
}
|
4537 |
|
|
|
4538 |
|
|
/* Return the base VMA address which should be subtracted from real addresses
|
4539 |
|
|
when resolving @dtpoff relocation.
|
4540 |
|
|
This is PT_TLS segment p_vaddr. */
|
4541 |
|
|
|
4542 |
|
|
static bfd_vma
|
4543 |
|
|
dtpoff_base (struct bfd_link_info *info)
|
4544 |
|
|
{
|
4545 |
|
|
/* If tls_sec is NULL, we should have signalled an error already. */
|
4546 |
|
|
if (elf_hash_table (info)->tls_sec == NULL)
|
4547 |
|
|
return 0;
|
4548 |
|
|
return elf_hash_table (info)->tls_sec->vma;
|
4549 |
|
|
}
|
4550 |
|
|
|
4551 |
|
|
/* Return the relocation value for @tpoff relocation
|
4552 |
|
|
if STT_TLS virtual address is ADDRESS. */
|
4553 |
|
|
|
4554 |
|
|
static bfd_vma
|
4555 |
|
|
tpoff (struct bfd_link_info *info, bfd_vma address)
|
4556 |
|
|
{
|
4557 |
|
|
struct elf_link_hash_table *htab = elf_hash_table (info);
|
4558 |
|
|
bfd_vma base;
|
4559 |
|
|
|
4560 |
|
|
/* If tls_sec is NULL, we should have signalled an error already. */
|
4561 |
|
|
if (htab->tls_sec == NULL)
|
4562 |
|
|
return 0;
|
4563 |
|
|
base = align_power ((bfd_vma) TCB_SIZE, htab->tls_sec->alignment_power);
|
4564 |
|
|
return address - htab->tls_sec->vma + base;
|
4565 |
|
|
}
|
4566 |
|
|
|
4567 |
|
|
/* Perform an R_ARM_ABS12 relocation on the field pointed to by DATA.
|
4568 |
|
|
VALUE is the relocation value. */
|
4569 |
|
|
|
4570 |
|
|
static bfd_reloc_status_type
|
4571 |
|
|
elf32_arm_abs12_reloc (bfd *abfd, void *data, bfd_vma value)
|
4572 |
|
|
{
|
4573 |
|
|
if (value > 0xfff)
|
4574 |
|
|
return bfd_reloc_overflow;
|
4575 |
|
|
|
4576 |
|
|
value |= bfd_get_32 (abfd, data) & 0xfffff000;
|
4577 |
|
|
bfd_put_32 (abfd, value, data);
|
4578 |
|
|
return bfd_reloc_ok;
|
4579 |
|
|
}
|
4580 |
|
|
|
4581 |
|
|
/* For a given value of n, calculate the value of G_n as required to
|
4582 |
|
|
deal with group relocations. We return it in the form of an
|
4583 |
|
|
encoded constant-and-rotation, together with the final residual. If n is
|
4584 |
|
|
specified as less than zero, then final_residual is filled with the
|
4585 |
|
|
input value and no further action is performed. */
|
4586 |
|
|
|
4587 |
|
|
static bfd_vma
|
4588 |
|
|
calculate_group_reloc_mask (bfd_vma value, int n, bfd_vma *final_residual)
|
4589 |
|
|
{
|
4590 |
|
|
int current_n;
|
4591 |
|
|
bfd_vma g_n;
|
4592 |
|
|
bfd_vma encoded_g_n = 0;
|
4593 |
|
|
bfd_vma residual = value; /* Also known as Y_n. */
|
4594 |
|
|
|
4595 |
|
|
for (current_n = 0; current_n <= n; current_n++)
|
4596 |
|
|
{
|
4597 |
|
|
int shift;
|
4598 |
|
|
|
4599 |
|
|
/* Calculate which part of the value to mask. */
|
4600 |
|
|
if (residual == 0)
|
4601 |
|
|
shift = 0;
|
4602 |
|
|
else
|
4603 |
|
|
{
|
4604 |
|
|
int msb;
|
4605 |
|
|
|
4606 |
|
|
/* Determine the most significant bit in the residual and
|
4607 |
|
|
align the resulting value to a 2-bit boundary. */
|
4608 |
|
|
for (msb = 30; msb >= 0; msb -= 2)
|
4609 |
|
|
if (residual & (3 << msb))
|
4610 |
|
|
break;
|
4611 |
|
|
|
4612 |
|
|
/* The desired shift is now (msb - 6), or zero, whichever
|
4613 |
|
|
is the greater. */
|
4614 |
|
|
shift = msb - 6;
|
4615 |
|
|
if (shift < 0)
|
4616 |
|
|
shift = 0;
|
4617 |
|
|
}
|
4618 |
|
|
|
4619 |
|
|
/* Calculate g_n in 32-bit as well as encoded constant+rotation form. */
|
4620 |
|
|
g_n = residual & (0xff << shift);
|
4621 |
|
|
encoded_g_n = (g_n >> shift)
|
4622 |
|
|
| ((g_n <= 0xff ? 0 : (32 - shift) / 2) << 8);
|
4623 |
|
|
|
4624 |
|
|
/* Calculate the residual for the next time around. */
|
4625 |
|
|
residual &= ~g_n;
|
4626 |
|
|
}
|
4627 |
|
|
|
4628 |
|
|
*final_residual = residual;
|
4629 |
|
|
|
4630 |
|
|
return encoded_g_n;
|
4631 |
|
|
}
|
4632 |
|
|
|
4633 |
|
|
/* Given an ARM instruction, determine whether it is an ADD or a SUB.
|
4634 |
|
|
Returns 1 if it is an ADD, -1 if it is a SUB, and 0 otherwise. */
|
4635 |
|
|
static int
|
4636 |
|
|
identify_add_or_sub(bfd_vma insn)
|
4637 |
|
|
{
|
4638 |
|
|
int opcode = insn & 0x1e00000;
|
4639 |
|
|
|
4640 |
|
|
if (opcode == 1 << 23) /* ADD */
|
4641 |
|
|
return 1;
|
4642 |
|
|
|
4643 |
|
|
if (opcode == 1 << 22) /* SUB */
|
4644 |
|
|
return -1;
|
4645 |
|
|
|
4646 |
|
|
return 0;
|
4647 |
|
|
}
|
4648 |
|
|
|
4649 |
|
|
/* Determine if we're dealing with a Thumb-2 object. */
|
4650 |
|
|
|
4651 |
|
|
static int using_thumb2 (struct elf32_arm_link_hash_table *globals)
|
4652 |
|
|
{
|
4653 |
|
|
int arch = bfd_elf_get_obj_attr_int (globals->obfd, OBJ_ATTR_PROC,
|
4654 |
|
|
Tag_CPU_arch);
|
4655 |
|
|
return arch == TAG_CPU_ARCH_V6T2 || arch >= TAG_CPU_ARCH_V7;
|
4656 |
|
|
}
|
4657 |
|
|
|
4658 |
|
|
/* Perform a relocation as part of a final link. */
|
4659 |
|
|
|
4660 |
|
|
static bfd_reloc_status_type
|
4661 |
|
|
elf32_arm_final_link_relocate (reloc_howto_type * howto,
|
4662 |
|
|
bfd * input_bfd,
|
4663 |
|
|
bfd * output_bfd,
|
4664 |
|
|
asection * input_section,
|
4665 |
|
|
bfd_byte * contents,
|
4666 |
|
|
Elf_Internal_Rela * rel,
|
4667 |
|
|
bfd_vma value,
|
4668 |
|
|
struct bfd_link_info * info,
|
4669 |
|
|
asection * sym_sec,
|
4670 |
|
|
const char * sym_name,
|
4671 |
|
|
int sym_flags,
|
4672 |
|
|
struct elf_link_hash_entry * h,
|
4673 |
|
|
bfd_boolean * unresolved_reloc_p,
|
4674 |
|
|
char **error_message)
|
4675 |
|
|
{
|
4676 |
|
|
unsigned long r_type = howto->type;
|
4677 |
|
|
unsigned long r_symndx;
|
4678 |
|
|
bfd_byte * hit_data = contents + rel->r_offset;
|
4679 |
|
|
bfd * dynobj = NULL;
|
4680 |
|
|
Elf_Internal_Shdr * symtab_hdr;
|
4681 |
|
|
struct elf_link_hash_entry ** sym_hashes;
|
4682 |
|
|
bfd_vma * local_got_offsets;
|
4683 |
|
|
asection * sgot = NULL;
|
4684 |
|
|
asection * splt = NULL;
|
4685 |
|
|
asection * sreloc = NULL;
|
4686 |
|
|
bfd_vma addend;
|
4687 |
|
|
bfd_signed_vma signed_addend;
|
4688 |
|
|
struct elf32_arm_link_hash_table * globals;
|
4689 |
|
|
|
4690 |
|
|
globals = elf32_arm_hash_table (info);
|
4691 |
|
|
|
4692 |
|
|
BFD_ASSERT (is_arm_elf (input_bfd));
|
4693 |
|
|
|
4694 |
|
|
/* Some relocation types map to different relocations depending on the
|
4695 |
|
|
target. We pick the right one here. */
|
4696 |
|
|
r_type = arm_real_reloc_type (globals, r_type);
|
4697 |
|
|
if (r_type != howto->type)
|
4698 |
|
|
howto = elf32_arm_howto_from_type (r_type);
|
4699 |
|
|
|
4700 |
|
|
/* If the start address has been set, then set the EF_ARM_HASENTRY
|
4701 |
|
|
flag. Setting this more than once is redundant, but the cost is
|
4702 |
|
|
not too high, and it keeps the code simple.
|
4703 |
|
|
|
4704 |
|
|
The test is done here, rather than somewhere else, because the
|
4705 |
|
|
start address is only set just before the final link commences.
|
4706 |
|
|
|
4707 |
|
|
Note - if the user deliberately sets a start address of 0, the
|
4708 |
|
|
flag will not be set. */
|
4709 |
|
|
if (bfd_get_start_address (output_bfd) != 0)
|
4710 |
|
|
elf_elfheader (output_bfd)->e_flags |= EF_ARM_HASENTRY;
|
4711 |
|
|
|
4712 |
|
|
dynobj = elf_hash_table (info)->dynobj;
|
4713 |
|
|
if (dynobj)
|
4714 |
|
|
{
|
4715 |
|
|
sgot = bfd_get_section_by_name (dynobj, ".got");
|
4716 |
|
|
splt = bfd_get_section_by_name (dynobj, ".plt");
|
4717 |
|
|
}
|
4718 |
|
|
symtab_hdr = & elf_symtab_hdr (input_bfd);
|
4719 |
|
|
sym_hashes = elf_sym_hashes (input_bfd);
|
4720 |
|
|
local_got_offsets = elf_local_got_offsets (input_bfd);
|
4721 |
|
|
r_symndx = ELF32_R_SYM (rel->r_info);
|
4722 |
|
|
|
4723 |
|
|
if (globals->use_rel)
|
4724 |
|
|
{
|
4725 |
|
|
addend = bfd_get_32 (input_bfd, hit_data) & howto->src_mask;
|
4726 |
|
|
|
4727 |
|
|
if (addend & ((howto->src_mask + 1) >> 1))
|
4728 |
|
|
{
|
4729 |
|
|
signed_addend = -1;
|
4730 |
|
|
signed_addend &= ~ howto->src_mask;
|
4731 |
|
|
signed_addend |= addend;
|
4732 |
|
|
}
|
4733 |
|
|
else
|
4734 |
|
|
signed_addend = addend;
|
4735 |
|
|
}
|
4736 |
|
|
else
|
4737 |
|
|
addend = signed_addend = rel->r_addend;
|
4738 |
|
|
|
4739 |
|
|
switch (r_type)
|
4740 |
|
|
{
|
4741 |
|
|
case R_ARM_NONE:
|
4742 |
|
|
/* We don't need to find a value for this symbol. It's just a
|
4743 |
|
|
marker. */
|
4744 |
|
|
*unresolved_reloc_p = FALSE;
|
4745 |
|
|
return bfd_reloc_ok;
|
4746 |
|
|
|
4747 |
|
|
case R_ARM_ABS12:
|
4748 |
|
|
if (!globals->vxworks_p)
|
4749 |
|
|
return elf32_arm_abs12_reloc (input_bfd, hit_data, value + addend);
|
4750 |
|
|
|
4751 |
|
|
case R_ARM_PC24:
|
4752 |
|
|
case R_ARM_ABS32:
|
4753 |
|
|
case R_ARM_ABS32_NOI:
|
4754 |
|
|
case R_ARM_REL32:
|
4755 |
|
|
case R_ARM_REL32_NOI:
|
4756 |
|
|
case R_ARM_CALL:
|
4757 |
|
|
case R_ARM_JUMP24:
|
4758 |
|
|
case R_ARM_XPC25:
|
4759 |
|
|
case R_ARM_PREL31:
|
4760 |
|
|
case R_ARM_PLT32:
|
4761 |
|
|
/* Handle relocations which should use the PLT entry. ABS32/REL32
|
4762 |
|
|
will use the symbol's value, which may point to a PLT entry, but we
|
4763 |
|
|
don't need to handle that here. If we created a PLT entry, all
|
4764 |
|
|
branches in this object should go to it. */
|
4765 |
|
|
if ((r_type != R_ARM_ABS32 && r_type != R_ARM_REL32
|
4766 |
|
|
&& r_type != R_ARM_ABS32_NOI && r_type != R_ARM_REL32_NOI)
|
4767 |
|
|
&& h != NULL
|
4768 |
|
|
&& splt != NULL
|
4769 |
|
|
&& h->plt.offset != (bfd_vma) -1)
|
4770 |
|
|
{
|
4771 |
|
|
/* If we've created a .plt section, and assigned a PLT entry to
|
4772 |
|
|
this function, it should not be known to bind locally. If
|
4773 |
|
|
it were, we would have cleared the PLT entry. */
|
4774 |
|
|
BFD_ASSERT (!SYMBOL_CALLS_LOCAL (info, h));
|
4775 |
|
|
|
4776 |
|
|
value = (splt->output_section->vma
|
4777 |
|
|
+ splt->output_offset
|
4778 |
|
|
+ h->plt.offset);
|
4779 |
|
|
*unresolved_reloc_p = FALSE;
|
4780 |
|
|
return _bfd_final_link_relocate (howto, input_bfd, input_section,
|
4781 |
|
|
contents, rel->r_offset, value,
|
4782 |
|
|
rel->r_addend);
|
4783 |
|
|
}
|
4784 |
|
|
|
4785 |
|
|
/* When generating a shared object or relocatable executable, these
|
4786 |
|
|
relocations are copied into the output file to be resolved at
|
4787 |
|
|
run time. */
|
4788 |
|
|
if ((info->shared || globals->root.is_relocatable_executable)
|
4789 |
|
|
&& (input_section->flags & SEC_ALLOC)
|
4790 |
|
|
&& ((r_type != R_ARM_REL32 && r_type != R_ARM_REL32_NOI)
|
4791 |
|
|
|| !SYMBOL_CALLS_LOCAL (info, h))
|
4792 |
|
|
&& (h == NULL
|
4793 |
|
|
|| ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|
4794 |
|
|
|| h->root.type != bfd_link_hash_undefweak)
|
4795 |
|
|
&& r_type != R_ARM_PC24
|
4796 |
|
|
&& r_type != R_ARM_CALL
|
4797 |
|
|
&& r_type != R_ARM_JUMP24
|
4798 |
|
|
&& r_type != R_ARM_PREL31
|
4799 |
|
|
&& r_type != R_ARM_PLT32)
|
4800 |
|
|
{
|
4801 |
|
|
Elf_Internal_Rela outrel;
|
4802 |
|
|
bfd_byte *loc;
|
4803 |
|
|
bfd_boolean skip, relocate;
|
4804 |
|
|
|
4805 |
|
|
*unresolved_reloc_p = FALSE;
|
4806 |
|
|
|
4807 |
|
|
if (sreloc == NULL)
|
4808 |
|
|
{
|
4809 |
|
|
const char * name;
|
4810 |
|
|
|
4811 |
|
|
name = (bfd_elf_string_from_elf_section
|
4812 |
|
|
(input_bfd,
|
4813 |
|
|
elf_elfheader (input_bfd)->e_shstrndx,
|
4814 |
|
|
elf_section_data (input_section)->rel_hdr.sh_name));
|
4815 |
|
|
if (name == NULL)
|
4816 |
|
|
return bfd_reloc_notsupported;
|
4817 |
|
|
|
4818 |
|
|
BFD_ASSERT (reloc_section_p (globals, name, input_section));
|
4819 |
|
|
|
4820 |
|
|
sreloc = bfd_get_section_by_name (dynobj, name);
|
4821 |
|
|
BFD_ASSERT (sreloc != NULL);
|
4822 |
|
|
}
|
4823 |
|
|
|
4824 |
|
|
skip = FALSE;
|
4825 |
|
|
relocate = FALSE;
|
4826 |
|
|
|
4827 |
|
|
outrel.r_addend = addend;
|
4828 |
|
|
outrel.r_offset =
|
4829 |
|
|
_bfd_elf_section_offset (output_bfd, info, input_section,
|
4830 |
|
|
rel->r_offset);
|
4831 |
|
|
if (outrel.r_offset == (bfd_vma) -1)
|
4832 |
|
|
skip = TRUE;
|
4833 |
|
|
else if (outrel.r_offset == (bfd_vma) -2)
|
4834 |
|
|
skip = TRUE, relocate = TRUE;
|
4835 |
|
|
outrel.r_offset += (input_section->output_section->vma
|
4836 |
|
|
+ input_section->output_offset);
|
4837 |
|
|
|
4838 |
|
|
if (skip)
|
4839 |
|
|
memset (&outrel, 0, sizeof outrel);
|
4840 |
|
|
else if (h != NULL
|
4841 |
|
|
&& h->dynindx != -1
|
4842 |
|
|
&& (!info->shared
|
4843 |
|
|
|| !info->symbolic
|
4844 |
|
|
|| !h->def_regular))
|
4845 |
|
|
outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
|
4846 |
|
|
else
|
4847 |
|
|
{
|
4848 |
|
|
int symbol;
|
4849 |
|
|
|
4850 |
|
|
/* This symbol is local, or marked to become local. */
|
4851 |
|
|
if (sym_flags == STT_ARM_TFUNC)
|
4852 |
|
|
value |= 1;
|
4853 |
|
|
if (globals->symbian_p)
|
4854 |
|
|
{
|
4855 |
|
|
asection *osec;
|
4856 |
|
|
|
4857 |
|
|
/* On Symbian OS, the data segment and text segement
|
4858 |
|
|
can be relocated independently. Therefore, we
|
4859 |
|
|
must indicate the segment to which this
|
4860 |
|
|
relocation is relative. The BPABI allows us to
|
4861 |
|
|
use any symbol in the right segment; we just use
|
4862 |
|
|
the section symbol as it is convenient. (We
|
4863 |
|
|
cannot use the symbol given by "h" directly as it
|
4864 |
|
|
will not appear in the dynamic symbol table.)
|
4865 |
|
|
|
4866 |
|
|
Note that the dynamic linker ignores the section
|
4867 |
|
|
symbol value, so we don't subtract osec->vma
|
4868 |
|
|
from the emitted reloc addend. */
|
4869 |
|
|
if (sym_sec)
|
4870 |
|
|
osec = sym_sec->output_section;
|
4871 |
|
|
else
|
4872 |
|
|
osec = input_section->output_section;
|
4873 |
|
|
symbol = elf_section_data (osec)->dynindx;
|
4874 |
|
|
if (symbol == 0)
|
4875 |
|
|
{
|
4876 |
|
|
struct elf_link_hash_table *htab = elf_hash_table (info);
|
4877 |
|
|
|
4878 |
|
|
if ((osec->flags & SEC_READONLY) == 0
|
4879 |
|
|
&& htab->data_index_section != NULL)
|
4880 |
|
|
osec = htab->data_index_section;
|
4881 |
|
|
else
|
4882 |
|
|
osec = htab->text_index_section;
|
4883 |
|
|
symbol = elf_section_data (osec)->dynindx;
|
4884 |
|
|
}
|
4885 |
|
|
BFD_ASSERT (symbol != 0);
|
4886 |
|
|
}
|
4887 |
|
|
else
|
4888 |
|
|
/* On SVR4-ish systems, the dynamic loader cannot
|
4889 |
|
|
relocate the text and data segments independently,
|
4890 |
|
|
so the symbol does not matter. */
|
4891 |
|
|
symbol = 0;
|
4892 |
|
|
outrel.r_info = ELF32_R_INFO (symbol, R_ARM_RELATIVE);
|
4893 |
|
|
if (globals->use_rel)
|
4894 |
|
|
relocate = TRUE;
|
4895 |
|
|
else
|
4896 |
|
|
outrel.r_addend += value;
|
4897 |
|
|
}
|
4898 |
|
|
|
4899 |
|
|
loc = sreloc->contents;
|
4900 |
|
|
loc += sreloc->reloc_count++ * RELOC_SIZE (globals);
|
4901 |
|
|
SWAP_RELOC_OUT (globals) (output_bfd, &outrel, loc);
|
4902 |
|
|
|
4903 |
|
|
/* If this reloc is against an external symbol, we do not want to
|
4904 |
|
|
fiddle with the addend. Otherwise, we need to include the symbol
|
4905 |
|
|
value so that it becomes an addend for the dynamic reloc. */
|
4906 |
|
|
if (! relocate)
|
4907 |
|
|
return bfd_reloc_ok;
|
4908 |
|
|
|
4909 |
|
|
return _bfd_final_link_relocate (howto, input_bfd, input_section,
|
4910 |
|
|
contents, rel->r_offset, value,
|
4911 |
|
|
(bfd_vma) 0);
|
4912 |
|
|
}
|
4913 |
|
|
else switch (r_type)
|
4914 |
|
|
{
|
4915 |
|
|
case R_ARM_ABS12:
|
4916 |
|
|
return elf32_arm_abs12_reloc (input_bfd, hit_data, value + addend);
|
4917 |
|
|
|
4918 |
|
|
case R_ARM_XPC25: /* Arm BLX instruction. */
|
4919 |
|
|
case R_ARM_CALL:
|
4920 |
|
|
case R_ARM_JUMP24:
|
4921 |
|
|
case R_ARM_PC24: /* Arm B/BL instruction */
|
4922 |
|
|
case R_ARM_PLT32:
|
4923 |
|
|
if (r_type == R_ARM_XPC25)
|
4924 |
|
|
{
|
4925 |
|
|
/* Check for Arm calling Arm function. */
|
4926 |
|
|
/* FIXME: Should we translate the instruction into a BL
|
4927 |
|
|
instruction instead ? */
|
4928 |
|
|
if (sym_flags != STT_ARM_TFUNC)
|
4929 |
|
|
(*_bfd_error_handler)
|
4930 |
|
|
(_("\%B: Warning: Arm BLX instruction targets Arm function '%s'."),
|
4931 |
|
|
input_bfd,
|
4932 |
|
|
h ? h->root.root.string : "(local)");
|
4933 |
|
|
}
|
4934 |
|
|
else if (r_type != R_ARM_CALL || !globals->use_blx)
|
4935 |
|
|
{
|
4936 |
|
|
/* Check for Arm calling Thumb function. */
|
4937 |
|
|
if (sym_flags == STT_ARM_TFUNC)
|
4938 |
|
|
{
|
4939 |
|
|
if (elf32_arm_to_thumb_stub (info, sym_name, input_bfd,
|
4940 |
|
|
output_bfd, input_section,
|
4941 |
|
|
hit_data, sym_sec, rel->r_offset,
|
4942 |
|
|
signed_addend, value,
|
4943 |
|
|
error_message))
|
4944 |
|
|
return bfd_reloc_ok;
|
4945 |
|
|
else
|
4946 |
|
|
return bfd_reloc_dangerous;
|
4947 |
|
|
}
|
4948 |
|
|
}
|
4949 |
|
|
|
4950 |
|
|
/* The ARM ELF ABI says that this reloc is computed as: S - P + A
|
4951 |
|
|
where:
|
4952 |
|
|
S is the address of the symbol in the relocation.
|
4953 |
|
|
P is address of the instruction being relocated.
|
4954 |
|
|
A is the addend (extracted from the instruction) in bytes.
|
4955 |
|
|
|
4956 |
|
|
S is held in 'value'.
|
4957 |
|
|
P is the base address of the section containing the
|
4958 |
|
|
instruction plus the offset of the reloc into that
|
4959 |
|
|
section, ie:
|
4960 |
|
|
(input_section->output_section->vma +
|
4961 |
|
|
input_section->output_offset +
|
4962 |
|
|
rel->r_offset).
|
4963 |
|
|
A is the addend, converted into bytes, ie:
|
4964 |
|
|
(signed_addend * 4)
|
4965 |
|
|
|
4966 |
|
|
Note: None of these operations have knowledge of the pipeline
|
4967 |
|
|
size of the processor, thus it is up to the assembler to
|
4968 |
|
|
encode this information into the addend. */
|
4969 |
|
|
value -= (input_section->output_section->vma
|
4970 |
|
|
+ input_section->output_offset);
|
4971 |
|
|
value -= rel->r_offset;
|
4972 |
|
|
if (globals->use_rel)
|
4973 |
|
|
value += (signed_addend << howto->size);
|
4974 |
|
|
else
|
4975 |
|
|
/* RELA addends do not have to be adjusted by howto->size. */
|
4976 |
|
|
value += signed_addend;
|
4977 |
|
|
|
4978 |
|
|
signed_addend = value;
|
4979 |
|
|
signed_addend >>= howto->rightshift;
|
4980 |
|
|
|
4981 |
|
|
/* A branch to an undefined weak symbol is turned into a jump to
|
4982 |
|
|
the next instruction. */
|
4983 |
|
|
if (h && h->root.type == bfd_link_hash_undefweak)
|
4984 |
|
|
{
|
4985 |
|
|
value = (bfd_get_32 (input_bfd, hit_data) & 0xf0000000)
|
4986 |
|
|
| 0x0affffff;
|
4987 |
|
|
}
|
4988 |
|
|
else
|
4989 |
|
|
{
|
4990 |
|
|
/* Perform a signed range check. */
|
4991 |
|
|
if ( signed_addend > ((bfd_signed_vma) (howto->dst_mask >> 1))
|
4992 |
|
|
|| signed_addend < - ((bfd_signed_vma) ((howto->dst_mask + 1) >> 1)))
|
4993 |
|
|
return bfd_reloc_overflow;
|
4994 |
|
|
|
4995 |
|
|
addend = (value & 2);
|
4996 |
|
|
|
4997 |
|
|
value = (signed_addend & howto->dst_mask)
|
4998 |
|
|
| (bfd_get_32 (input_bfd, hit_data) & (~ howto->dst_mask));
|
4999 |
|
|
|
5000 |
|
|
/* Set the H bit in the BLX instruction. */
|
5001 |
|
|
if (sym_flags == STT_ARM_TFUNC)
|
5002 |
|
|
{
|
5003 |
|
|
if (addend)
|
5004 |
|
|
value |= (1 << 24);
|
5005 |
|
|
else
|
5006 |
|
|
value &= ~(bfd_vma)(1 << 24);
|
5007 |
|
|
}
|
5008 |
|
|
if (r_type == R_ARM_CALL)
|
5009 |
|
|
{
|
5010 |
|
|
/* Select the correct instruction (BL or BLX). */
|
5011 |
|
|
if (sym_flags == STT_ARM_TFUNC)
|
5012 |
|
|
value |= (1 << 28);
|
5013 |
|
|
else
|
5014 |
|
|
{
|
5015 |
|
|
value &= ~(bfd_vma)(1 << 28);
|
5016 |
|
|
value |= (1 << 24);
|
5017 |
|
|
}
|
5018 |
|
|
}
|
5019 |
|
|
}
|
5020 |
|
|
break;
|
5021 |
|
|
|
5022 |
|
|
case R_ARM_ABS32:
|
5023 |
|
|
value += addend;
|
5024 |
|
|
if (sym_flags == STT_ARM_TFUNC)
|
5025 |
|
|
value |= 1;
|
5026 |
|
|
break;
|
5027 |
|
|
|
5028 |
|
|
case R_ARM_ABS32_NOI:
|
5029 |
|
|
value += addend;
|
5030 |
|
|
break;
|
5031 |
|
|
|
5032 |
|
|
case R_ARM_REL32:
|
5033 |
|
|
value += addend;
|
5034 |
|
|
if (sym_flags == STT_ARM_TFUNC)
|
5035 |
|
|
value |= 1;
|
5036 |
|
|
value -= (input_section->output_section->vma
|
5037 |
|
|
+ input_section->output_offset + rel->r_offset);
|
5038 |
|
|
break;
|
5039 |
|
|
|
5040 |
|
|
case R_ARM_REL32_NOI:
|
5041 |
|
|
value += addend;
|
5042 |
|
|
value -= (input_section->output_section->vma
|
5043 |
|
|
+ input_section->output_offset + rel->r_offset);
|
5044 |
|
|
break;
|
5045 |
|
|
|
5046 |
|
|
case R_ARM_PREL31:
|
5047 |
|
|
value -= (input_section->output_section->vma
|
5048 |
|
|
+ input_section->output_offset + rel->r_offset);
|
5049 |
|
|
value += signed_addend;
|
5050 |
|
|
if (! h || h->root.type != bfd_link_hash_undefweak)
|
5051 |
|
|
{
|
5052 |
|
|
/* Check for overflow */
|
5053 |
|
|
if ((value ^ (value >> 1)) & (1 << 30))
|
5054 |
|
|
return bfd_reloc_overflow;
|
5055 |
|
|
}
|
5056 |
|
|
value &= 0x7fffffff;
|
5057 |
|
|
value |= (bfd_get_32 (input_bfd, hit_data) & 0x80000000);
|
5058 |
|
|
if (sym_flags == STT_ARM_TFUNC)
|
5059 |
|
|
value |= 1;
|
5060 |
|
|
break;
|
5061 |
|
|
}
|
5062 |
|
|
|
5063 |
|
|
bfd_put_32 (input_bfd, value, hit_data);
|
5064 |
|
|
return bfd_reloc_ok;
|
5065 |
|
|
|
5066 |
|
|
case R_ARM_ABS8:
|
5067 |
|
|
value += addend;
|
5068 |
|
|
if ((long) value > 0x7f || (long) value < -0x80)
|
5069 |
|
|
return bfd_reloc_overflow;
|
5070 |
|
|
|
5071 |
|
|
bfd_put_8 (input_bfd, value, hit_data);
|
5072 |
|
|
return bfd_reloc_ok;
|
5073 |
|
|
|
5074 |
|
|
case R_ARM_ABS16:
|
5075 |
|
|
value += addend;
|
5076 |
|
|
|
5077 |
|
|
if ((long) value > 0x7fff || (long) value < -0x8000)
|
5078 |
|
|
return bfd_reloc_overflow;
|
5079 |
|
|
|
5080 |
|
|
bfd_put_16 (input_bfd, value, hit_data);
|
5081 |
|
|
return bfd_reloc_ok;
|
5082 |
|
|
|
5083 |
|
|
case R_ARM_THM_ABS5:
|
5084 |
|
|
/* Support ldr and str instructions for the thumb. */
|
5085 |
|
|
if (globals->use_rel)
|
5086 |
|
|
{
|
5087 |
|
|
/* Need to refetch addend. */
|
5088 |
|
|
addend = bfd_get_16 (input_bfd, hit_data) & howto->src_mask;
|
5089 |
|
|
/* ??? Need to determine shift amount from operand size. */
|
5090 |
|
|
addend >>= howto->rightshift;
|
5091 |
|
|
}
|
5092 |
|
|
value += addend;
|
5093 |
|
|
|
5094 |
|
|
/* ??? Isn't value unsigned? */
|
5095 |
|
|
if ((long) value > 0x1f || (long) value < -0x10)
|
5096 |
|
|
return bfd_reloc_overflow;
|
5097 |
|
|
|
5098 |
|
|
/* ??? Value needs to be properly shifted into place first. */
|
5099 |
|
|
value |= bfd_get_16 (input_bfd, hit_data) & 0xf83f;
|
5100 |
|
|
bfd_put_16 (input_bfd, value, hit_data);
|
5101 |
|
|
return bfd_reloc_ok;
|
5102 |
|
|
|
5103 |
|
|
case R_ARM_THM_ALU_PREL_11_0:
|
5104 |
|
|
/* Corresponds to: addw.w reg, pc, #offset (and similarly for subw). */
|
5105 |
|
|
{
|
5106 |
|
|
bfd_vma insn;
|
5107 |
|
|
bfd_signed_vma relocation;
|
5108 |
|
|
|
5109 |
|
|
insn = (bfd_get_16 (input_bfd, hit_data) << 16)
|
5110 |
|
|
| bfd_get_16 (input_bfd, hit_data + 2);
|
5111 |
|
|
|
5112 |
|
|
if (globals->use_rel)
|
5113 |
|
|
{
|
5114 |
|
|
signed_addend = (insn & 0xff) | ((insn & 0x7000) >> 4)
|
5115 |
|
|
| ((insn & (1 << 26)) >> 15);
|
5116 |
|
|
if (insn & 0xf00000)
|
5117 |
|
|
signed_addend = -signed_addend;
|
5118 |
|
|
}
|
5119 |
|
|
|
5120 |
|
|
relocation = value + signed_addend;
|
5121 |
|
|
relocation -= (input_section->output_section->vma
|
5122 |
|
|
+ input_section->output_offset
|
5123 |
|
|
+ rel->r_offset);
|
5124 |
|
|
|
5125 |
|
|
value = abs (relocation);
|
5126 |
|
|
|
5127 |
|
|
if (value >= 0x1000)
|
5128 |
|
|
return bfd_reloc_overflow;
|
5129 |
|
|
|
5130 |
|
|
insn = (insn & 0xfb0f8f00) | (value & 0xff)
|
5131 |
|
|
| ((value & 0x700) << 4)
|
5132 |
|
|
| ((value & 0x800) << 15);
|
5133 |
|
|
if (relocation < 0)
|
5134 |
|
|
insn |= 0xa00000;
|
5135 |
|
|
|
5136 |
|
|
bfd_put_16 (input_bfd, insn >> 16, hit_data);
|
5137 |
|
|
bfd_put_16 (input_bfd, insn & 0xffff, hit_data + 2);
|
5138 |
|
|
|
5139 |
|
|
return bfd_reloc_ok;
|
5140 |
|
|
}
|
5141 |
|
|
|
5142 |
|
|
case R_ARM_THM_PC12:
|
5143 |
|
|
/* Corresponds to: ldr.w reg, [pc, #offset]. */
|
5144 |
|
|
{
|
5145 |
|
|
bfd_vma insn;
|
5146 |
|
|
bfd_signed_vma relocation;
|
5147 |
|
|
|
5148 |
|
|
insn = (bfd_get_16 (input_bfd, hit_data) << 16)
|
5149 |
|
|
| bfd_get_16 (input_bfd, hit_data + 2);
|
5150 |
|
|
|
5151 |
|
|
if (globals->use_rel)
|
5152 |
|
|
{
|
5153 |
|
|
signed_addend = insn & 0xfff;
|
5154 |
|
|
if (!(insn & (1 << 23)))
|
5155 |
|
|
signed_addend = -signed_addend;
|
5156 |
|
|
}
|
5157 |
|
|
|
5158 |
|
|
relocation = value + signed_addend;
|
5159 |
|
|
relocation -= (input_section->output_section->vma
|
5160 |
|
|
+ input_section->output_offset
|
5161 |
|
|
+ rel->r_offset);
|
5162 |
|
|
|
5163 |
|
|
value = abs (relocation);
|
5164 |
|
|
|
5165 |
|
|
if (value >= 0x1000)
|
5166 |
|
|
return bfd_reloc_overflow;
|
5167 |
|
|
|
5168 |
|
|
insn = (insn & 0xff7ff000) | value;
|
5169 |
|
|
if (relocation >= 0)
|
5170 |
|
|
insn |= (1 << 23);
|
5171 |
|
|
|
5172 |
|
|
bfd_put_16 (input_bfd, insn >> 16, hit_data);
|
5173 |
|
|
bfd_put_16 (input_bfd, insn & 0xffff, hit_data + 2);
|
5174 |
|
|
|
5175 |
|
|
return bfd_reloc_ok;
|
5176 |
|
|
}
|
5177 |
|
|
|
5178 |
|
|
case R_ARM_THM_XPC22:
|
5179 |
|
|
case R_ARM_THM_CALL:
|
5180 |
|
|
case R_ARM_THM_JUMP24:
|
5181 |
|
|
/* Thumb BL (branch long instruction). */
|
5182 |
|
|
{
|
5183 |
|
|
bfd_vma relocation;
|
5184 |
|
|
bfd_vma reloc_sign;
|
5185 |
|
|
bfd_boolean overflow = FALSE;
|
5186 |
|
|
bfd_vma upper_insn = bfd_get_16 (input_bfd, hit_data);
|
5187 |
|
|
bfd_vma lower_insn = bfd_get_16 (input_bfd, hit_data + 2);
|
5188 |
|
|
bfd_signed_vma reloc_signed_max;
|
5189 |
|
|
bfd_signed_vma reloc_signed_min;
|
5190 |
|
|
bfd_vma check;
|
5191 |
|
|
bfd_signed_vma signed_check;
|
5192 |
|
|
int bitsize;
|
5193 |
|
|
int thumb2 = using_thumb2 (globals);
|
5194 |
|
|
|
5195 |
|
|
/* A branch to an undefined weak symbol is turned into a jump to
|
5196 |
|
|
the next instruction. */
|
5197 |
|
|
if (h && h->root.type == bfd_link_hash_undefweak)
|
5198 |
|
|
{
|
5199 |
|
|
bfd_put_16 (input_bfd, 0xe000, hit_data);
|
5200 |
|
|
bfd_put_16 (input_bfd, 0xbf00, hit_data + 2);
|
5201 |
|
|
return bfd_reloc_ok;
|
5202 |
|
|
}
|
5203 |
|
|
|
5204 |
|
|
/* Fetch the addend. We use the Thumb-2 encoding (backwards compatible
|
5205 |
|
|
with Thumb-1) involving the J1 and J2 bits. */
|
5206 |
|
|
if (globals->use_rel)
|
5207 |
|
|
{
|
5208 |
|
|
bfd_vma s = (upper_insn & (1 << 10)) >> 10;
|
5209 |
|
|
bfd_vma upper = upper_insn & 0x3ff;
|
5210 |
|
|
bfd_vma lower = lower_insn & 0x7ff;
|
5211 |
|
|
bfd_vma j1 = (lower_insn & (1 << 13)) >> 13;
|
5212 |
|
|
bfd_vma j2 = (lower_insn & (1 << 11)) >> 11;
|
5213 |
|
|
bfd_vma i1 = j1 ^ s ? 0 : 1;
|
5214 |
|
|
bfd_vma i2 = j2 ^ s ? 0 : 1;
|
5215 |
|
|
|
5216 |
|
|
addend = (i1 << 23) | (i2 << 22) | (upper << 12) | (lower << 1);
|
5217 |
|
|
/* Sign extend. */
|
5218 |
|
|
addend = (addend | ((s ? 0 : 1) << 24)) - (1 << 24);
|
5219 |
|
|
|
5220 |
|
|
signed_addend = addend;
|
5221 |
|
|
}
|
5222 |
|
|
|
5223 |
|
|
if (r_type == R_ARM_THM_XPC22)
|
5224 |
|
|
{
|
5225 |
|
|
/* Check for Thumb to Thumb call. */
|
5226 |
|
|
/* FIXME: Should we translate the instruction into a BL
|
5227 |
|
|
instruction instead ? */
|
5228 |
|
|
if (sym_flags == STT_ARM_TFUNC)
|
5229 |
|
|
(*_bfd_error_handler)
|
5230 |
|
|
(_("%B: Warning: Thumb BLX instruction targets thumb function '%s'."),
|
5231 |
|
|
input_bfd,
|
5232 |
|
|
h ? h->root.root.string : "(local)");
|
5233 |
|
|
}
|
5234 |
|
|
else
|
5235 |
|
|
{
|
5236 |
|
|
/* If it is not a call to Thumb, assume call to Arm.
|
5237 |
|
|
If it is a call relative to a section name, then it is not a
|
5238 |
|
|
function call at all, but rather a long jump. Calls through
|
5239 |
|
|
the PLT do not require stubs. */
|
5240 |
|
|
if (sym_flags != STT_ARM_TFUNC && sym_flags != STT_SECTION
|
5241 |
|
|
&& (h == NULL || splt == NULL
|
5242 |
|
|
|| h->plt.offset == (bfd_vma) -1))
|
5243 |
|
|
{
|
5244 |
|
|
if (globals->use_blx && r_type == R_ARM_THM_CALL)
|
5245 |
|
|
{
|
5246 |
|
|
/* Convert BL to BLX. */
|
5247 |
|
|
lower_insn = (lower_insn & ~0x1000) | 0x0800;
|
5248 |
|
|
}
|
5249 |
|
|
else if (elf32_thumb_to_arm_stub
|
5250 |
|
|
(info, sym_name, input_bfd, output_bfd, input_section,
|
5251 |
|
|
hit_data, sym_sec, rel->r_offset, signed_addend, value,
|
5252 |
|
|
error_message))
|
5253 |
|
|
return bfd_reloc_ok;
|
5254 |
|
|
else
|
5255 |
|
|
return bfd_reloc_dangerous;
|
5256 |
|
|
}
|
5257 |
|
|
else if (sym_flags == STT_ARM_TFUNC && globals->use_blx
|
5258 |
|
|
&& r_type == R_ARM_THM_CALL)
|
5259 |
|
|
{
|
5260 |
|
|
/* Make sure this is a BL. */
|
5261 |
|
|
lower_insn |= 0x1800;
|
5262 |
|
|
}
|
5263 |
|
|
}
|
5264 |
|
|
|
5265 |
|
|
/* Handle calls via the PLT. */
|
5266 |
|
|
if (h != NULL && splt != NULL && h->plt.offset != (bfd_vma) -1)
|
5267 |
|
|
{
|
5268 |
|
|
value = (splt->output_section->vma
|
5269 |
|
|
+ splt->output_offset
|
5270 |
|
|
+ h->plt.offset);
|
5271 |
|
|
if (globals->use_blx && r_type == R_ARM_THM_CALL)
|
5272 |
|
|
{
|
5273 |
|
|
/* If the Thumb BLX instruction is available, convert the
|
5274 |
|
|
BL to a BLX instruction to call the ARM-mode PLT entry. */
|
5275 |
|
|
lower_insn = (lower_insn & ~0x1000) | 0x0800;
|
5276 |
|
|
}
|
5277 |
|
|
else
|
5278 |
|
|
/* Target the Thumb stub before the ARM PLT entry. */
|
5279 |
|
|
value -= PLT_THUMB_STUB_SIZE;
|
5280 |
|
|
*unresolved_reloc_p = FALSE;
|
5281 |
|
|
}
|
5282 |
|
|
|
5283 |
|
|
relocation = value + signed_addend;
|
5284 |
|
|
|
5285 |
|
|
relocation -= (input_section->output_section->vma
|
5286 |
|
|
+ input_section->output_offset
|
5287 |
|
|
+ rel->r_offset);
|
5288 |
|
|
|
5289 |
|
|
check = relocation >> howto->rightshift;
|
5290 |
|
|
|
5291 |
|
|
/* If this is a signed value, the rightshift just dropped
|
5292 |
|
|
leading 1 bits (assuming twos complement). */
|
5293 |
|
|
if ((bfd_signed_vma) relocation >= 0)
|
5294 |
|
|
signed_check = check;
|
5295 |
|
|
else
|
5296 |
|
|
signed_check = check | ~((bfd_vma) -1 >> howto->rightshift);
|
5297 |
|
|
|
5298 |
|
|
/* Calculate the permissable maximum and minimum values for
|
5299 |
|
|
this relocation according to whether we're relocating for
|
5300 |
|
|
Thumb-2 or not. */
|
5301 |
|
|
bitsize = howto->bitsize;
|
5302 |
|
|
if (!thumb2)
|
5303 |
|
|
bitsize -= 2;
|
5304 |
|
|
reloc_signed_max = ((1 << (bitsize - 1)) - 1) >> howto->rightshift;
|
5305 |
|
|
reloc_signed_min = ~reloc_signed_max;
|
5306 |
|
|
|
5307 |
|
|
/* Assumes two's complement. */
|
5308 |
|
|
if (signed_check > reloc_signed_max || signed_check < reloc_signed_min)
|
5309 |
|
|
overflow = TRUE;
|
5310 |
|
|
|
5311 |
|
|
if ((lower_insn & 0x5000) == 0x4000)
|
5312 |
|
|
/* For a BLX instruction, make sure that the relocation is rounded up
|
5313 |
|
|
to a word boundary. This follows the semantics of the instruction
|
5314 |
|
|
which specifies that bit 1 of the target address will come from bit
|
5315 |
|
|
1 of the base address. */
|
5316 |
|
|
relocation = (relocation + 2) & ~ 3;
|
5317 |
|
|
|
5318 |
|
|
/* Put RELOCATION back into the insn. Assumes two's complement.
|
5319 |
|
|
We use the Thumb-2 encoding, which is safe even if dealing with
|
5320 |
|
|
a Thumb-1 instruction by virtue of our overflow check above. */
|
5321 |
|
|
reloc_sign = (signed_check < 0) ? 1 : 0;
|
5322 |
|
|
upper_insn = (upper_insn & ~(bfd_vma) 0x7ff)
|
5323 |
|
|
| ((relocation >> 12) & 0x3ff)
|
5324 |
|
|
| (reloc_sign << 10);
|
5325 |
|
|
lower_insn = (lower_insn & ~(bfd_vma) 0x2fff)
|
5326 |
|
|
| (((!((relocation >> 23) & 1)) ^ reloc_sign) << 13)
|
5327 |
|
|
| (((!((relocation >> 22) & 1)) ^ reloc_sign) << 11)
|
5328 |
|
|
| ((relocation >> 1) & 0x7ff);
|
5329 |
|
|
|
5330 |
|
|
/* Put the relocated value back in the object file: */
|
5331 |
|
|
bfd_put_16 (input_bfd, upper_insn, hit_data);
|
5332 |
|
|
bfd_put_16 (input_bfd, lower_insn, hit_data + 2);
|
5333 |
|
|
|
5334 |
|
|
return (overflow ? bfd_reloc_overflow : bfd_reloc_ok);
|
5335 |
|
|
}
|
5336 |
|
|
break;
|
5337 |
|
|
|
5338 |
|
|
case R_ARM_THM_JUMP19:
|
5339 |
|
|
/* Thumb32 conditional branch instruction. */
|
5340 |
|
|
{
|
5341 |
|
|
bfd_vma relocation;
|
5342 |
|
|
bfd_boolean overflow = FALSE;
|
5343 |
|
|
bfd_vma upper_insn = bfd_get_16 (input_bfd, hit_data);
|
5344 |
|
|
bfd_vma lower_insn = bfd_get_16 (input_bfd, hit_data + 2);
|
5345 |
|
|
bfd_signed_vma reloc_signed_max = 0xffffe;
|
5346 |
|
|
bfd_signed_vma reloc_signed_min = -0x100000;
|
5347 |
|
|
bfd_signed_vma signed_check;
|
5348 |
|
|
|
5349 |
|
|
/* Need to refetch the addend, reconstruct the top three bits,
|
5350 |
|
|
and squish the two 11 bit pieces together. */
|
5351 |
|
|
if (globals->use_rel)
|
5352 |
|
|
{
|
5353 |
|
|
bfd_vma S = (upper_insn & 0x0400) >> 10;
|
5354 |
|
|
bfd_vma upper = (upper_insn & 0x003f);
|
5355 |
|
|
bfd_vma J1 = (lower_insn & 0x2000) >> 13;
|
5356 |
|
|
bfd_vma J2 = (lower_insn & 0x0800) >> 11;
|
5357 |
|
|
bfd_vma lower = (lower_insn & 0x07ff);
|
5358 |
|
|
|
5359 |
|
|
upper |= J1 << 6;
|
5360 |
|
|
upper |= J2 << 7;
|
5361 |
|
|
upper |= (!S) << 8;
|
5362 |
|
|
upper -= 0x0100; /* Sign extend. */
|
5363 |
|
|
|
5364 |
|
|
addend = (upper << 12) | (lower << 1);
|
5365 |
|
|
signed_addend = addend;
|
5366 |
|
|
}
|
5367 |
|
|
|
5368 |
|
|
/* Handle calls via the PLT. */
|
5369 |
|
|
if (h != NULL && splt != NULL && h->plt.offset != (bfd_vma) -1)
|
5370 |
|
|
{
|
5371 |
|
|
value = (splt->output_section->vma
|
5372 |
|
|
+ splt->output_offset
|
5373 |
|
|
+ h->plt.offset);
|
5374 |
|
|
/* Target the Thumb stub before the ARM PLT entry. */
|
5375 |
|
|
value -= PLT_THUMB_STUB_SIZE;
|
5376 |
|
|
*unresolved_reloc_p = FALSE;
|
5377 |
|
|
}
|
5378 |
|
|
|
5379 |
|
|
/* ??? Should handle interworking? GCC might someday try to
|
5380 |
|
|
use this for tail calls. */
|
5381 |
|
|
|
5382 |
|
|
relocation = value + signed_addend;
|
5383 |
|
|
relocation -= (input_section->output_section->vma
|
5384 |
|
|
+ input_section->output_offset
|
5385 |
|
|
+ rel->r_offset);
|
5386 |
|
|
signed_check = (bfd_signed_vma) relocation;
|
5387 |
|
|
|
5388 |
|
|
if (signed_check > reloc_signed_max || signed_check < reloc_signed_min)
|
5389 |
|
|
overflow = TRUE;
|
5390 |
|
|
|
5391 |
|
|
/* Put RELOCATION back into the insn. */
|
5392 |
|
|
{
|
5393 |
|
|
bfd_vma S = (relocation & 0x00100000) >> 20;
|
5394 |
|
|
bfd_vma J2 = (relocation & 0x00080000) >> 19;
|
5395 |
|
|
bfd_vma J1 = (relocation & 0x00040000) >> 18;
|
5396 |
|
|
bfd_vma hi = (relocation & 0x0003f000) >> 12;
|
5397 |
|
|
bfd_vma lo = (relocation & 0x00000ffe) >> 1;
|
5398 |
|
|
|
5399 |
|
|
upper_insn = (upper_insn & 0xfbc0) | (S << 10) | hi;
|
5400 |
|
|
lower_insn = (lower_insn & 0xd000) | (J1 << 13) | (J2 << 11) | lo;
|
5401 |
|
|
}
|
5402 |
|
|
|
5403 |
|
|
/* Put the relocated value back in the object file: */
|
5404 |
|
|
bfd_put_16 (input_bfd, upper_insn, hit_data);
|
5405 |
|
|
bfd_put_16 (input_bfd, lower_insn, hit_data + 2);
|
5406 |
|
|
|
5407 |
|
|
return (overflow ? bfd_reloc_overflow : bfd_reloc_ok);
|
5408 |
|
|
}
|
5409 |
|
|
|
5410 |
|
|
case R_ARM_THM_JUMP11:
|
5411 |
|
|
case R_ARM_THM_JUMP8:
|
5412 |
|
|
case R_ARM_THM_JUMP6:
|
5413 |
|
|
/* Thumb B (branch) instruction). */
|
5414 |
|
|
{
|
5415 |
|
|
bfd_signed_vma relocation;
|
5416 |
|
|
bfd_signed_vma reloc_signed_max = (1 << (howto->bitsize - 1)) - 1;
|
5417 |
|
|
bfd_signed_vma reloc_signed_min = ~ reloc_signed_max;
|
5418 |
|
|
bfd_signed_vma signed_check;
|
5419 |
|
|
|
5420 |
|
|
/* CZB cannot jump backward. */
|
5421 |
|
|
if (r_type == R_ARM_THM_JUMP6)
|
5422 |
|
|
reloc_signed_min = 0;
|
5423 |
|
|
|
5424 |
|
|
if (globals->use_rel)
|
5425 |
|
|
{
|
5426 |
|
|
/* Need to refetch addend. */
|
5427 |
|
|
addend = bfd_get_16 (input_bfd, hit_data) & howto->src_mask;
|
5428 |
|
|
if (addend & ((howto->src_mask + 1) >> 1))
|
5429 |
|
|
{
|
5430 |
|
|
signed_addend = -1;
|
5431 |
|
|
signed_addend &= ~ howto->src_mask;
|
5432 |
|
|
signed_addend |= addend;
|
5433 |
|
|
}
|
5434 |
|
|
else
|
5435 |
|
|
signed_addend = addend;
|
5436 |
|
|
/* The value in the insn has been right shifted. We need to
|
5437 |
|
|
undo this, so that we can perform the address calculation
|
5438 |
|
|
in terms of bytes. */
|
5439 |
|
|
signed_addend <<= howto->rightshift;
|
5440 |
|
|
}
|
5441 |
|
|
relocation = value + signed_addend;
|
5442 |
|
|
|
5443 |
|
|
relocation -= (input_section->output_section->vma
|
5444 |
|
|
+ input_section->output_offset
|
5445 |
|
|
+ rel->r_offset);
|
5446 |
|
|
|
5447 |
|
|
relocation >>= howto->rightshift;
|
5448 |
|
|
signed_check = relocation;
|
5449 |
|
|
|
5450 |
|
|
if (r_type == R_ARM_THM_JUMP6)
|
5451 |
|
|
relocation = ((relocation & 0x0020) << 4) | ((relocation & 0x001f) << 3);
|
5452 |
|
|
else
|
5453 |
|
|
relocation &= howto->dst_mask;
|
5454 |
|
|
relocation |= (bfd_get_16 (input_bfd, hit_data) & (~ howto->dst_mask));
|
5455 |
|
|
|
5456 |
|
|
bfd_put_16 (input_bfd, relocation, hit_data);
|
5457 |
|
|
|
5458 |
|
|
/* Assumes two's complement. */
|
5459 |
|
|
if (signed_check > reloc_signed_max || signed_check < reloc_signed_min)
|
5460 |
|
|
return bfd_reloc_overflow;
|
5461 |
|
|
|
5462 |
|
|
return bfd_reloc_ok;
|
5463 |
|
|
}
|
5464 |
|
|
|
5465 |
|
|
case R_ARM_ALU_PCREL7_0:
|
5466 |
|
|
case R_ARM_ALU_PCREL15_8:
|
5467 |
|
|
case R_ARM_ALU_PCREL23_15:
|
5468 |
|
|
{
|
5469 |
|
|
bfd_vma insn;
|
5470 |
|
|
bfd_vma relocation;
|
5471 |
|
|
|
5472 |
|
|
insn = bfd_get_32 (input_bfd, hit_data);
|
5473 |
|
|
if (globals->use_rel)
|
5474 |
|
|
{
|
5475 |
|
|
/* Extract the addend. */
|
5476 |
|
|
addend = (insn & 0xff) << ((insn & 0xf00) >> 7);
|
5477 |
|
|
signed_addend = addend;
|
5478 |
|
|
}
|
5479 |
|
|
relocation = value + signed_addend;
|
5480 |
|
|
|
5481 |
|
|
relocation -= (input_section->output_section->vma
|
5482 |
|
|
+ input_section->output_offset
|
5483 |
|
|
+ rel->r_offset);
|
5484 |
|
|
insn = (insn & ~0xfff)
|
5485 |
|
|
| ((howto->bitpos << 7) & 0xf00)
|
5486 |
|
|
| ((relocation >> howto->bitpos) & 0xff);
|
5487 |
|
|
bfd_put_32 (input_bfd, value, hit_data);
|
5488 |
|
|
}
|
5489 |
|
|
return bfd_reloc_ok;
|
5490 |
|
|
|
5491 |
|
|
case R_ARM_GNU_VTINHERIT:
|
5492 |
|
|
case R_ARM_GNU_VTENTRY:
|
5493 |
|
|
return bfd_reloc_ok;
|
5494 |
|
|
|
5495 |
|
|
case R_ARM_GOTOFF32:
|
5496 |
|
|
/* Relocation is relative to the start of the
|
5497 |
|
|
global offset table. */
|
5498 |
|
|
|
5499 |
|
|
BFD_ASSERT (sgot != NULL);
|
5500 |
|
|
if (sgot == NULL)
|
5501 |
|
|
return bfd_reloc_notsupported;
|
5502 |
|
|
|
5503 |
|
|
/* If we are addressing a Thumb function, we need to adjust the
|
5504 |
|
|
address by one, so that attempts to call the function pointer will
|
5505 |
|
|
correctly interpret it as Thumb code. */
|
5506 |
|
|
if (sym_flags == STT_ARM_TFUNC)
|
5507 |
|
|
value += 1;
|
5508 |
|
|
|
5509 |
|
|
/* Note that sgot->output_offset is not involved in this
|
5510 |
|
|
calculation. We always want the start of .got. If we
|
5511 |
|
|
define _GLOBAL_OFFSET_TABLE in a different way, as is
|
5512 |
|
|
permitted by the ABI, we might have to change this
|
5513 |
|
|
calculation. */
|
5514 |
|
|
value -= sgot->output_section->vma;
|
5515 |
|
|
return _bfd_final_link_relocate (howto, input_bfd, input_section,
|
5516 |
|
|
contents, rel->r_offset, value,
|
5517 |
|
|
rel->r_addend);
|
5518 |
|
|
|
5519 |
|
|
case R_ARM_GOTPC:
|
5520 |
|
|
/* Use global offset table as symbol value. */
|
5521 |
|
|
BFD_ASSERT (sgot != NULL);
|
5522 |
|
|
|
5523 |
|
|
if (sgot == NULL)
|
5524 |
|
|
return bfd_reloc_notsupported;
|
5525 |
|
|
|
5526 |
|
|
*unresolved_reloc_p = FALSE;
|
5527 |
|
|
value = sgot->output_section->vma;
|
5528 |
|
|
return _bfd_final_link_relocate (howto, input_bfd, input_section,
|
5529 |
|
|
contents, rel->r_offset, value,
|
5530 |
|
|
rel->r_addend);
|
5531 |
|
|
|
5532 |
|
|
case R_ARM_GOT32:
|
5533 |
|
|
case R_ARM_GOT_PREL:
|
5534 |
|
|
/* Relocation is to the entry for this symbol in the
|
5535 |
|
|
global offset table. */
|
5536 |
|
|
if (sgot == NULL)
|
5537 |
|
|
return bfd_reloc_notsupported;
|
5538 |
|
|
|
5539 |
|
|
if (h != NULL)
|
5540 |
|
|
{
|
5541 |
|
|
bfd_vma off;
|
5542 |
|
|
bfd_boolean dyn;
|
5543 |
|
|
|
5544 |
|
|
off = h->got.offset;
|
5545 |
|
|
BFD_ASSERT (off != (bfd_vma) -1);
|
5546 |
|
|
dyn = globals->root.dynamic_sections_created;
|
5547 |
|
|
|
5548 |
|
|
if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)
|
5549 |
|
|
|| (info->shared
|
5550 |
|
|
&& SYMBOL_REFERENCES_LOCAL (info, h))
|
5551 |
|
|
|| (ELF_ST_VISIBILITY (h->other)
|
5552 |
|
|
&& h->root.type == bfd_link_hash_undefweak))
|
5553 |
|
|
{
|
5554 |
|
|
/* This is actually a static link, or it is a -Bsymbolic link
|
5555 |
|
|
and the symbol is defined locally. We must initialize this
|
5556 |
|
|
entry in the global offset table. Since the offset must
|
5557 |
|
|
always be a multiple of 4, we use the least significant bit
|
5558 |
|
|
to record whether we have initialized it already.
|
5559 |
|
|
|
5560 |
|
|
When doing a dynamic link, we create a .rel(a).got relocation
|
5561 |
|
|
entry to initialize the value. This is done in the
|
5562 |
|
|
finish_dynamic_symbol routine. */
|
5563 |
|
|
if ((off & 1) != 0)
|
5564 |
|
|
off &= ~1;
|
5565 |
|
|
else
|
5566 |
|
|
{
|
5567 |
|
|
/* If we are addressing a Thumb function, we need to
|
5568 |
|
|
adjust the address by one, so that attempts to
|
5569 |
|
|
call the function pointer will correctly
|
5570 |
|
|
interpret it as Thumb code. */
|
5571 |
|
|
if (sym_flags == STT_ARM_TFUNC)
|
5572 |
|
|
value |= 1;
|
5573 |
|
|
|
5574 |
|
|
bfd_put_32 (output_bfd, value, sgot->contents + off);
|
5575 |
|
|
h->got.offset |= 1;
|
5576 |
|
|
}
|
5577 |
|
|
}
|
5578 |
|
|
else
|
5579 |
|
|
*unresolved_reloc_p = FALSE;
|
5580 |
|
|
|
5581 |
|
|
value = sgot->output_offset + off;
|
5582 |
|
|
}
|
5583 |
|
|
else
|
5584 |
|
|
{
|
5585 |
|
|
bfd_vma off;
|
5586 |
|
|
|
5587 |
|
|
BFD_ASSERT (local_got_offsets != NULL &&
|
5588 |
|
|
local_got_offsets[r_symndx] != (bfd_vma) -1);
|
5589 |
|
|
|
5590 |
|
|
off = local_got_offsets[r_symndx];
|
5591 |
|
|
|
5592 |
|
|
/* The offset must always be a multiple of 4. We use the
|
5593 |
|
|
least significant bit to record whether we have already
|
5594 |
|
|
generated the necessary reloc. */
|
5595 |
|
|
if ((off & 1) != 0)
|
5596 |
|
|
off &= ~1;
|
5597 |
|
|
else
|
5598 |
|
|
{
|
5599 |
|
|
/* If we are addressing a Thumb function, we need to
|
5600 |
|
|
adjust the address by one, so that attempts to
|
5601 |
|
|
call the function pointer will correctly
|
5602 |
|
|
interpret it as Thumb code. */
|
5603 |
|
|
if (sym_flags == STT_ARM_TFUNC)
|
5604 |
|
|
value |= 1;
|
5605 |
|
|
|
5606 |
|
|
if (globals->use_rel)
|
5607 |
|
|
bfd_put_32 (output_bfd, value, sgot->contents + off);
|
5608 |
|
|
|
5609 |
|
|
if (info->shared)
|
5610 |
|
|
{
|
5611 |
|
|
asection * srelgot;
|
5612 |
|
|
Elf_Internal_Rela outrel;
|
5613 |
|
|
bfd_byte *loc;
|
5614 |
|
|
|
5615 |
|
|
srelgot = (bfd_get_section_by_name
|
5616 |
|
|
(dynobj, RELOC_SECTION (globals, ".got")));
|
5617 |
|
|
BFD_ASSERT (srelgot != NULL);
|
5618 |
|
|
|
5619 |
|
|
outrel.r_addend = addend + value;
|
5620 |
|
|
outrel.r_offset = (sgot->output_section->vma
|
5621 |
|
|
+ sgot->output_offset
|
5622 |
|
|
+ off);
|
5623 |
|
|
outrel.r_info = ELF32_R_INFO (0, R_ARM_RELATIVE);
|
5624 |
|
|
loc = srelgot->contents;
|
5625 |
|
|
loc += srelgot->reloc_count++ * RELOC_SIZE (globals);
|
5626 |
|
|
SWAP_RELOC_OUT (globals) (output_bfd, &outrel, loc);
|
5627 |
|
|
}
|
5628 |
|
|
|
5629 |
|
|
local_got_offsets[r_symndx] |= 1;
|
5630 |
|
|
}
|
5631 |
|
|
|
5632 |
|
|
value = sgot->output_offset + off;
|
5633 |
|
|
}
|
5634 |
|
|
if (r_type != R_ARM_GOT32)
|
5635 |
|
|
value += sgot->output_section->vma;
|
5636 |
|
|
|
5637 |
|
|
return _bfd_final_link_relocate (howto, input_bfd, input_section,
|
5638 |
|
|
contents, rel->r_offset, value,
|
5639 |
|
|
rel->r_addend);
|
5640 |
|
|
|
5641 |
|
|
case R_ARM_TLS_LDO32:
|
5642 |
|
|
value = value - dtpoff_base (info);
|
5643 |
|
|
|
5644 |
|
|
return _bfd_final_link_relocate (howto, input_bfd, input_section,
|
5645 |
|
|
contents, rel->r_offset, value,
|
5646 |
|
|
rel->r_addend);
|
5647 |
|
|
|
5648 |
|
|
case R_ARM_TLS_LDM32:
|
5649 |
|
|
{
|
5650 |
|
|
bfd_vma off;
|
5651 |
|
|
|
5652 |
|
|
if (globals->sgot == NULL)
|
5653 |
|
|
abort ();
|
5654 |
|
|
|
5655 |
|
|
off = globals->tls_ldm_got.offset;
|
5656 |
|
|
|
5657 |
|
|
if ((off & 1) != 0)
|
5658 |
|
|
off &= ~1;
|
5659 |
|
|
else
|
5660 |
|
|
{
|
5661 |
|
|
/* If we don't know the module number, create a relocation
|
5662 |
|
|
for it. */
|
5663 |
|
|
if (info->shared)
|
5664 |
|
|
{
|
5665 |
|
|
Elf_Internal_Rela outrel;
|
5666 |
|
|
bfd_byte *loc;
|
5667 |
|
|
|
5668 |
|
|
if (globals->srelgot == NULL)
|
5669 |
|
|
abort ();
|
5670 |
|
|
|
5671 |
|
|
outrel.r_addend = 0;
|
5672 |
|
|
outrel.r_offset = (globals->sgot->output_section->vma
|
5673 |
|
|
+ globals->sgot->output_offset + off);
|
5674 |
|
|
outrel.r_info = ELF32_R_INFO (0, R_ARM_TLS_DTPMOD32);
|
5675 |
|
|
|
5676 |
|
|
if (globals->use_rel)
|
5677 |
|
|
bfd_put_32 (output_bfd, outrel.r_addend,
|
5678 |
|
|
globals->sgot->contents + off);
|
5679 |
|
|
|
5680 |
|
|
loc = globals->srelgot->contents;
|
5681 |
|
|
loc += globals->srelgot->reloc_count++ * RELOC_SIZE (globals);
|
5682 |
|
|
SWAP_RELOC_OUT (globals) (output_bfd, &outrel, loc);
|
5683 |
|
|
}
|
5684 |
|
|
else
|
5685 |
|
|
bfd_put_32 (output_bfd, 1, globals->sgot->contents + off);
|
5686 |
|
|
|
5687 |
|
|
globals->tls_ldm_got.offset |= 1;
|
5688 |
|
|
}
|
5689 |
|
|
|
5690 |
|
|
value = globals->sgot->output_section->vma + globals->sgot->output_offset + off
|
5691 |
|
|
- (input_section->output_section->vma + input_section->output_offset + rel->r_offset);
|
5692 |
|
|
|
5693 |
|
|
return _bfd_final_link_relocate (howto, input_bfd, input_section,
|
5694 |
|
|
contents, rel->r_offset, value,
|
5695 |
|
|
rel->r_addend);
|
5696 |
|
|
}
|
5697 |
|
|
|
5698 |
|
|
case R_ARM_TLS_GD32:
|
5699 |
|
|
case R_ARM_TLS_IE32:
|
5700 |
|
|
{
|
5701 |
|
|
bfd_vma off;
|
5702 |
|
|
int indx;
|
5703 |
|
|
char tls_type;
|
5704 |
|
|
|
5705 |
|
|
if (globals->sgot == NULL)
|
5706 |
|
|
abort ();
|
5707 |
|
|
|
5708 |
|
|
indx = 0;
|
5709 |
|
|
if (h != NULL)
|
5710 |
|
|
{
|
5711 |
|
|
bfd_boolean dyn;
|
5712 |
|
|
dyn = globals->root.dynamic_sections_created;
|
5713 |
|
|
if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)
|
5714 |
|
|
&& (!info->shared
|
5715 |
|
|
|| !SYMBOL_REFERENCES_LOCAL (info, h)))
|
5716 |
|
|
{
|
5717 |
|
|
*unresolved_reloc_p = FALSE;
|
5718 |
|
|
indx = h->dynindx;
|
5719 |
|
|
}
|
5720 |
|
|
off = h->got.offset;
|
5721 |
|
|
tls_type = ((struct elf32_arm_link_hash_entry *) h)->tls_type;
|
5722 |
|
|
}
|
5723 |
|
|
else
|
5724 |
|
|
{
|
5725 |
|
|
if (local_got_offsets == NULL)
|
5726 |
|
|
abort ();
|
5727 |
|
|
off = local_got_offsets[r_symndx];
|
5728 |
|
|
tls_type = elf32_arm_local_got_tls_type (input_bfd)[r_symndx];
|
5729 |
|
|
}
|
5730 |
|
|
|
5731 |
|
|
if (tls_type == GOT_UNKNOWN)
|
5732 |
|
|
abort ();
|
5733 |
|
|
|
5734 |
|
|
if ((off & 1) != 0)
|
5735 |
|
|
off &= ~1;
|
5736 |
|
|
else
|
5737 |
|
|
{
|
5738 |
|
|
bfd_boolean need_relocs = FALSE;
|
5739 |
|
|
Elf_Internal_Rela outrel;
|
5740 |
|
|
bfd_byte *loc = NULL;
|
5741 |
|
|
int cur_off = off;
|
5742 |
|
|
|
5743 |
|
|
/* The GOT entries have not been initialized yet. Do it
|
5744 |
|
|
now, and emit any relocations. If both an IE GOT and a
|
5745 |
|
|
GD GOT are necessary, we emit the GD first. */
|
5746 |
|
|
|
5747 |
|
|
if ((info->shared || indx != 0)
|
5748 |
|
|
&& (h == NULL
|
5749 |
|
|
|| ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|
5750 |
|
|
|| h->root.type != bfd_link_hash_undefweak))
|
5751 |
|
|
{
|
5752 |
|
|
need_relocs = TRUE;
|
5753 |
|
|
if (globals->srelgot == NULL)
|
5754 |
|
|
abort ();
|
5755 |
|
|
loc = globals->srelgot->contents;
|
5756 |
|
|
loc += globals->srelgot->reloc_count * RELOC_SIZE (globals);
|
5757 |
|
|
}
|
5758 |
|
|
|
5759 |
|
|
if (tls_type & GOT_TLS_GD)
|
5760 |
|
|
{
|
5761 |
|
|
if (need_relocs)
|
5762 |
|
|
{
|
5763 |
|
|
outrel.r_addend = 0;
|
5764 |
|
|
outrel.r_offset = (globals->sgot->output_section->vma
|
5765 |
|
|
+ globals->sgot->output_offset
|
5766 |
|
|
+ cur_off);
|
5767 |
|
|
outrel.r_info = ELF32_R_INFO (indx, R_ARM_TLS_DTPMOD32);
|
5768 |
|
|
|
5769 |
|
|
if (globals->use_rel)
|
5770 |
|
|
bfd_put_32 (output_bfd, outrel.r_addend,
|
5771 |
|
|
globals->sgot->contents + cur_off);
|
5772 |
|
|
|
5773 |
|
|
SWAP_RELOC_OUT (globals) (output_bfd, &outrel, loc);
|
5774 |
|
|
globals->srelgot->reloc_count++;
|
5775 |
|
|
loc += RELOC_SIZE (globals);
|
5776 |
|
|
|
5777 |
|
|
if (indx == 0)
|
5778 |
|
|
bfd_put_32 (output_bfd, value - dtpoff_base (info),
|
5779 |
|
|
globals->sgot->contents + cur_off + 4);
|
5780 |
|
|
else
|
5781 |
|
|
{
|
5782 |
|
|
outrel.r_addend = 0;
|
5783 |
|
|
outrel.r_info = ELF32_R_INFO (indx,
|
5784 |
|
|
R_ARM_TLS_DTPOFF32);
|
5785 |
|
|
outrel.r_offset += 4;
|
5786 |
|
|
|
5787 |
|
|
if (globals->use_rel)
|
5788 |
|
|
bfd_put_32 (output_bfd, outrel.r_addend,
|
5789 |
|
|
globals->sgot->contents + cur_off + 4);
|
5790 |
|
|
|
5791 |
|
|
|
5792 |
|
|
SWAP_RELOC_OUT (globals) (output_bfd, &outrel, loc);
|
5793 |
|
|
globals->srelgot->reloc_count++;
|
5794 |
|
|
loc += RELOC_SIZE (globals);
|
5795 |
|
|
}
|
5796 |
|
|
}
|
5797 |
|
|
else
|
5798 |
|
|
{
|
5799 |
|
|
/* If we are not emitting relocations for a
|
5800 |
|
|
general dynamic reference, then we must be in a
|
5801 |
|
|
static link or an executable link with the
|
5802 |
|
|
symbol binding locally. Mark it as belonging
|
5803 |
|
|
to module 1, the executable. */
|
5804 |
|
|
bfd_put_32 (output_bfd, 1,
|
5805 |
|
|
globals->sgot->contents + cur_off);
|
5806 |
|
|
bfd_put_32 (output_bfd, value - dtpoff_base (info),
|
5807 |
|
|
globals->sgot->contents + cur_off + 4);
|
5808 |
|
|
}
|
5809 |
|
|
|
5810 |
|
|
cur_off += 8;
|
5811 |
|
|
}
|
5812 |
|
|
|
5813 |
|
|
if (tls_type & GOT_TLS_IE)
|
5814 |
|
|
{
|
5815 |
|
|
if (need_relocs)
|
5816 |
|
|
{
|
5817 |
|
|
if (indx == 0)
|
5818 |
|
|
outrel.r_addend = value - dtpoff_base (info);
|
5819 |
|
|
else
|
5820 |
|
|
outrel.r_addend = 0;
|
5821 |
|
|
outrel.r_offset = (globals->sgot->output_section->vma
|
5822 |
|
|
+ globals->sgot->output_offset
|
5823 |
|
|
+ cur_off);
|
5824 |
|
|
outrel.r_info = ELF32_R_INFO (indx, R_ARM_TLS_TPOFF32);
|
5825 |
|
|
|
5826 |
|
|
if (globals->use_rel)
|
5827 |
|
|
bfd_put_32 (output_bfd, outrel.r_addend,
|
5828 |
|
|
globals->sgot->contents + cur_off);
|
5829 |
|
|
|
5830 |
|
|
SWAP_RELOC_OUT (globals) (output_bfd, &outrel, loc);
|
5831 |
|
|
globals->srelgot->reloc_count++;
|
5832 |
|
|
loc += RELOC_SIZE (globals);
|
5833 |
|
|
}
|
5834 |
|
|
else
|
5835 |
|
|
bfd_put_32 (output_bfd, tpoff (info, value),
|
5836 |
|
|
globals->sgot->contents + cur_off);
|
5837 |
|
|
cur_off += 4;
|
5838 |
|
|
}
|
5839 |
|
|
|
5840 |
|
|
if (h != NULL)
|
5841 |
|
|
h->got.offset |= 1;
|
5842 |
|
|
else
|
5843 |
|
|
local_got_offsets[r_symndx] |= 1;
|
5844 |
|
|
}
|
5845 |
|
|
|
5846 |
|
|
if ((tls_type & GOT_TLS_GD) && r_type != R_ARM_TLS_GD32)
|
5847 |
|
|
off += 8;
|
5848 |
|
|
value = globals->sgot->output_section->vma + globals->sgot->output_offset + off
|
5849 |
|
|
- (input_section->output_section->vma + input_section->output_offset + rel->r_offset);
|
5850 |
|
|
|
5851 |
|
|
return _bfd_final_link_relocate (howto, input_bfd, input_section,
|
5852 |
|
|
contents, rel->r_offset, value,
|
5853 |
|
|
rel->r_addend);
|
5854 |
|
|
}
|
5855 |
|
|
|
5856 |
|
|
case R_ARM_TLS_LE32:
|
5857 |
|
|
if (info->shared)
|
5858 |
|
|
{
|
5859 |
|
|
(*_bfd_error_handler)
|
5860 |
|
|
(_("%B(%A+0x%lx): R_ARM_TLS_LE32 relocation not permitted in shared object"),
|
5861 |
|
|
input_bfd, input_section,
|
5862 |
|
|
(long) rel->r_offset, howto->name);
|
5863 |
|
|
return FALSE;
|
5864 |
|
|
}
|
5865 |
|
|
else
|
5866 |
|
|
value = tpoff (info, value);
|
5867 |
|
|
|
5868 |
|
|
return _bfd_final_link_relocate (howto, input_bfd, input_section,
|
5869 |
|
|
contents, rel->r_offset, value,
|
5870 |
|
|
rel->r_addend);
|
5871 |
|
|
|
5872 |
|
|
case R_ARM_V4BX:
|
5873 |
|
|
if (globals->fix_v4bx)
|
5874 |
|
|
{
|
5875 |
|
|
bfd_vma insn = bfd_get_32 (input_bfd, hit_data);
|
5876 |
|
|
|
5877 |
|
|
/* Ensure that we have a BX instruction. */
|
5878 |
|
|
BFD_ASSERT ((insn & 0x0ffffff0) == 0x012fff10);
|
5879 |
|
|
|
5880 |
|
|
if (globals->fix_v4bx == 2 && (insn & 0xf) != 0xf)
|
5881 |
|
|
{
|
5882 |
|
|
/* Branch to veneer. */
|
5883 |
|
|
bfd_vma glue_addr;
|
5884 |
|
|
glue_addr = elf32_arm_bx_glue (info, insn & 0xf);
|
5885 |
|
|
glue_addr -= input_section->output_section->vma
|
5886 |
|
|
+ input_section->output_offset
|
5887 |
|
|
+ rel->r_offset + 8;
|
5888 |
|
|
insn = (insn & 0xf0000000) | 0x0a000000
|
5889 |
|
|
| ((glue_addr >> 2) & 0x00ffffff);
|
5890 |
|
|
}
|
5891 |
|
|
else
|
5892 |
|
|
{
|
5893 |
|
|
/* Preserve Rm (lowest four bits) and the condition code
|
5894 |
|
|
(highest four bits). Other bits encode MOV PC,Rm. */
|
5895 |
|
|
insn = (insn & 0xf000000f) | 0x01a0f000;
|
5896 |
|
|
}
|
5897 |
|
|
|
5898 |
|
|
bfd_put_32 (input_bfd, insn, hit_data);
|
5899 |
|
|
}
|
5900 |
|
|
return bfd_reloc_ok;
|
5901 |
|
|
|
5902 |
|
|
case R_ARM_MOVW_ABS_NC:
|
5903 |
|
|
case R_ARM_MOVT_ABS:
|
5904 |
|
|
case R_ARM_MOVW_PREL_NC:
|
5905 |
|
|
case R_ARM_MOVT_PREL:
|
5906 |
|
|
/* Until we properly support segment-base-relative addressing then
|
5907 |
|
|
we assume the segment base to be zero, as for the group relocations.
|
5908 |
|
|
Thus R_ARM_MOVW_BREL_NC has the same semantics as R_ARM_MOVW_ABS_NC
|
5909 |
|
|
and R_ARM_MOVT_BREL has the same semantics as R_ARM_MOVT_ABS. */
|
5910 |
|
|
case R_ARM_MOVW_BREL_NC:
|
5911 |
|
|
case R_ARM_MOVW_BREL:
|
5912 |
|
|
case R_ARM_MOVT_BREL:
|
5913 |
|
|
{
|
5914 |
|
|
bfd_vma insn = bfd_get_32 (input_bfd, hit_data);
|
5915 |
|
|
|
5916 |
|
|
if (globals->use_rel)
|
5917 |
|
|
{
|
5918 |
|
|
addend = ((insn >> 4) & 0xf000) | (insn & 0xfff);
|
5919 |
|
|
signed_addend = (addend ^ 0x10000) - 0x10000;
|
5920 |
|
|
}
|
5921 |
|
|
|
5922 |
|
|
value += signed_addend;
|
5923 |
|
|
|
5924 |
|
|
if (r_type == R_ARM_MOVW_PREL_NC || r_type == R_ARM_MOVT_PREL)
|
5925 |
|
|
value -= (input_section->output_section->vma
|
5926 |
|
|
+ input_section->output_offset + rel->r_offset);
|
5927 |
|
|
|
5928 |
|
|
if (r_type == R_ARM_MOVW_BREL && value >= 0x10000)
|
5929 |
|
|
return bfd_reloc_overflow;
|
5930 |
|
|
|
5931 |
|
|
if (sym_flags == STT_ARM_TFUNC)
|
5932 |
|
|
value |= 1;
|
5933 |
|
|
|
5934 |
|
|
if (r_type == R_ARM_MOVT_ABS || r_type == R_ARM_MOVT_PREL
|
5935 |
|
|
|| r_type == R_ARM_MOVT_BREL)
|
5936 |
|
|
value >>= 16;
|
5937 |
|
|
|
5938 |
|
|
insn &= 0xfff0f000;
|
5939 |
|
|
insn |= value & 0xfff;
|
5940 |
|
|
insn |= (value & 0xf000) << 4;
|
5941 |
|
|
bfd_put_32 (input_bfd, insn, hit_data);
|
5942 |
|
|
}
|
5943 |
|
|
return bfd_reloc_ok;
|
5944 |
|
|
|
5945 |
|
|
case R_ARM_THM_MOVW_ABS_NC:
|
5946 |
|
|
case R_ARM_THM_MOVT_ABS:
|
5947 |
|
|
case R_ARM_THM_MOVW_PREL_NC:
|
5948 |
|
|
case R_ARM_THM_MOVT_PREL:
|
5949 |
|
|
/* Until we properly support segment-base-relative addressing then
|
5950 |
|
|
we assume the segment base to be zero, as for the above relocations.
|
5951 |
|
|
Thus R_ARM_THM_MOVW_BREL_NC has the same semantics as
|
5952 |
|
|
R_ARM_THM_MOVW_ABS_NC and R_ARM_THM_MOVT_BREL has the same semantics
|
5953 |
|
|
as R_ARM_THM_MOVT_ABS. */
|
5954 |
|
|
case R_ARM_THM_MOVW_BREL_NC:
|
5955 |
|
|
case R_ARM_THM_MOVW_BREL:
|
5956 |
|
|
case R_ARM_THM_MOVT_BREL:
|
5957 |
|
|
{
|
5958 |
|
|
bfd_vma insn;
|
5959 |
|
|
|
5960 |
|
|
insn = bfd_get_16 (input_bfd, hit_data) << 16;
|
5961 |
|
|
insn |= bfd_get_16 (input_bfd, hit_data + 2);
|
5962 |
|
|
|
5963 |
|
|
if (globals->use_rel)
|
5964 |
|
|
{
|
5965 |
|
|
addend = ((insn >> 4) & 0xf000)
|
5966 |
|
|
| ((insn >> 15) & 0x0800)
|
5967 |
|
|
| ((insn >> 4) & 0x0700)
|
5968 |
|
|
| (insn & 0x00ff);
|
5969 |
|
|
signed_addend = (addend ^ 0x10000) - 0x10000;
|
5970 |
|
|
}
|
5971 |
|
|
|
5972 |
|
|
value += signed_addend;
|
5973 |
|
|
|
5974 |
|
|
if (r_type == R_ARM_THM_MOVW_PREL_NC || r_type == R_ARM_THM_MOVT_PREL)
|
5975 |
|
|
value -= (input_section->output_section->vma
|
5976 |
|
|
+ input_section->output_offset + rel->r_offset);
|
5977 |
|
|
|
5978 |
|
|
if (r_type == R_ARM_THM_MOVW_BREL && value >= 0x10000)
|
5979 |
|
|
return bfd_reloc_overflow;
|
5980 |
|
|
|
5981 |
|
|
if (sym_flags == STT_ARM_TFUNC)
|
5982 |
|
|
value |= 1;
|
5983 |
|
|
|
5984 |
|
|
if (r_type == R_ARM_THM_MOVT_ABS || r_type == R_ARM_THM_MOVT_PREL
|
5985 |
|
|
|| r_type == R_ARM_THM_MOVT_BREL)
|
5986 |
|
|
value >>= 16;
|
5987 |
|
|
|
5988 |
|
|
insn &= 0xfbf08f00;
|
5989 |
|
|
insn |= (value & 0xf000) << 4;
|
5990 |
|
|
insn |= (value & 0x0800) << 15;
|
5991 |
|
|
insn |= (value & 0x0700) << 4;
|
5992 |
|
|
insn |= (value & 0x00ff);
|
5993 |
|
|
|
5994 |
|
|
bfd_put_16 (input_bfd, insn >> 16, hit_data);
|
5995 |
|
|
bfd_put_16 (input_bfd, insn & 0xffff, hit_data + 2);
|
5996 |
|
|
}
|
5997 |
|
|
return bfd_reloc_ok;
|
5998 |
|
|
|
5999 |
|
|
case R_ARM_ALU_PC_G0_NC:
|
6000 |
|
|
case R_ARM_ALU_PC_G1_NC:
|
6001 |
|
|
case R_ARM_ALU_PC_G0:
|
6002 |
|
|
case R_ARM_ALU_PC_G1:
|
6003 |
|
|
case R_ARM_ALU_PC_G2:
|
6004 |
|
|
case R_ARM_ALU_SB_G0_NC:
|
6005 |
|
|
case R_ARM_ALU_SB_G1_NC:
|
6006 |
|
|
case R_ARM_ALU_SB_G0:
|
6007 |
|
|
case R_ARM_ALU_SB_G1:
|
6008 |
|
|
case R_ARM_ALU_SB_G2:
|
6009 |
|
|
{
|
6010 |
|
|
bfd_vma insn = bfd_get_32 (input_bfd, hit_data);
|
6011 |
|
|
bfd_vma pc = input_section->output_section->vma
|
6012 |
|
|
+ input_section->output_offset + rel->r_offset;
|
6013 |
|
|
/* sb should be the origin of the *segment* containing the symbol.
|
6014 |
|
|
It is not clear how to obtain this OS-dependent value, so we
|
6015 |
|
|
make an arbitrary choice of zero. */
|
6016 |
|
|
bfd_vma sb = 0;
|
6017 |
|
|
bfd_vma residual;
|
6018 |
|
|
bfd_vma g_n;
|
6019 |
|
|
bfd_signed_vma signed_value;
|
6020 |
|
|
int group = 0;
|
6021 |
|
|
|
6022 |
|
|
/* Determine which group of bits to select. */
|
6023 |
|
|
switch (r_type)
|
6024 |
|
|
{
|
6025 |
|
|
case R_ARM_ALU_PC_G0_NC:
|
6026 |
|
|
case R_ARM_ALU_PC_G0:
|
6027 |
|
|
case R_ARM_ALU_SB_G0_NC:
|
6028 |
|
|
case R_ARM_ALU_SB_G0:
|
6029 |
|
|
group = 0;
|
6030 |
|
|
break;
|
6031 |
|
|
|
6032 |
|
|
case R_ARM_ALU_PC_G1_NC:
|
6033 |
|
|
case R_ARM_ALU_PC_G1:
|
6034 |
|
|
case R_ARM_ALU_SB_G1_NC:
|
6035 |
|
|
case R_ARM_ALU_SB_G1:
|
6036 |
|
|
group = 1;
|
6037 |
|
|
break;
|
6038 |
|
|
|
6039 |
|
|
case R_ARM_ALU_PC_G2:
|
6040 |
|
|
case R_ARM_ALU_SB_G2:
|
6041 |
|
|
group = 2;
|
6042 |
|
|
break;
|
6043 |
|
|
|
6044 |
|
|
default:
|
6045 |
|
|
abort();
|
6046 |
|
|
}
|
6047 |
|
|
|
6048 |
|
|
/* If REL, extract the addend from the insn. If RELA, it will
|
6049 |
|
|
have already been fetched for us. */
|
6050 |
|
|
if (globals->use_rel)
|
6051 |
|
|
{
|
6052 |
|
|
int negative;
|
6053 |
|
|
bfd_vma constant = insn & 0xff;
|
6054 |
|
|
bfd_vma rotation = (insn & 0xf00) >> 8;
|
6055 |
|
|
|
6056 |
|
|
if (rotation == 0)
|
6057 |
|
|
signed_addend = constant;
|
6058 |
|
|
else
|
6059 |
|
|
{
|
6060 |
|
|
/* Compensate for the fact that in the instruction, the
|
6061 |
|
|
rotation is stored in multiples of 2 bits. */
|
6062 |
|
|
rotation *= 2;
|
6063 |
|
|
|
6064 |
|
|
/* Rotate "constant" right by "rotation" bits. */
|
6065 |
|
|
signed_addend = (constant >> rotation) |
|
6066 |
|
|
(constant << (8 * sizeof (bfd_vma) - rotation));
|
6067 |
|
|
}
|
6068 |
|
|
|
6069 |
|
|
/* Determine if the instruction is an ADD or a SUB.
|
6070 |
|
|
(For REL, this determines the sign of the addend.) */
|
6071 |
|
|
negative = identify_add_or_sub (insn);
|
6072 |
|
|
if (negative == 0)
|
6073 |
|
|
{
|
6074 |
|
|
(*_bfd_error_handler)
|
6075 |
|
|
(_("%B(%A+0x%lx): Only ADD or SUB instructions are allowed for ALU group relocations"),
|
6076 |
|
|
input_bfd, input_section,
|
6077 |
|
|
(long) rel->r_offset, howto->name);
|
6078 |
|
|
return bfd_reloc_overflow;
|
6079 |
|
|
}
|
6080 |
|
|
|
6081 |
|
|
signed_addend *= negative;
|
6082 |
|
|
}
|
6083 |
|
|
|
6084 |
|
|
/* Compute the value (X) to go in the place. */
|
6085 |
|
|
if (r_type == R_ARM_ALU_PC_G0_NC
|
6086 |
|
|
|| r_type == R_ARM_ALU_PC_G1_NC
|
6087 |
|
|
|| r_type == R_ARM_ALU_PC_G0
|
6088 |
|
|
|| r_type == R_ARM_ALU_PC_G1
|
6089 |
|
|
|| r_type == R_ARM_ALU_PC_G2)
|
6090 |
|
|
/* PC relative. */
|
6091 |
|
|
signed_value = value - pc + signed_addend;
|
6092 |
|
|
else
|
6093 |
|
|
/* Section base relative. */
|
6094 |
|
|
signed_value = value - sb + signed_addend;
|
6095 |
|
|
|
6096 |
|
|
/* If the target symbol is a Thumb function, then set the
|
6097 |
|
|
Thumb bit in the address. */
|
6098 |
|
|
if (sym_flags == STT_ARM_TFUNC)
|
6099 |
|
|
signed_value |= 1;
|
6100 |
|
|
|
6101 |
|
|
/* Calculate the value of the relevant G_n, in encoded
|
6102 |
|
|
constant-with-rotation format. */
|
6103 |
|
|
g_n = calculate_group_reloc_mask (abs (signed_value), group,
|
6104 |
|
|
&residual);
|
6105 |
|
|
|
6106 |
|
|
/* Check for overflow if required. */
|
6107 |
|
|
if ((r_type == R_ARM_ALU_PC_G0
|
6108 |
|
|
|| r_type == R_ARM_ALU_PC_G1
|
6109 |
|
|
|| r_type == R_ARM_ALU_PC_G2
|
6110 |
|
|
|| r_type == R_ARM_ALU_SB_G0
|
6111 |
|
|
|| r_type == R_ARM_ALU_SB_G1
|
6112 |
|
|
|| r_type == R_ARM_ALU_SB_G2) && residual != 0)
|
6113 |
|
|
{
|
6114 |
|
|
(*_bfd_error_handler)
|
6115 |
|
|
(_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"),
|
6116 |
|
|
input_bfd, input_section,
|
6117 |
|
|
(long) rel->r_offset, abs (signed_value), howto->name);
|
6118 |
|
|
return bfd_reloc_overflow;
|
6119 |
|
|
}
|
6120 |
|
|
|
6121 |
|
|
/* Mask out the value and the ADD/SUB part of the opcode; take care
|
6122 |
|
|
not to destroy the S bit. */
|
6123 |
|
|
insn &= 0xff1ff000;
|
6124 |
|
|
|
6125 |
|
|
/* Set the opcode according to whether the value to go in the
|
6126 |
|
|
place is negative. */
|
6127 |
|
|
if (signed_value < 0)
|
6128 |
|
|
insn |= 1 << 22;
|
6129 |
|
|
else
|
6130 |
|
|
insn |= 1 << 23;
|
6131 |
|
|
|
6132 |
|
|
/* Encode the offset. */
|
6133 |
|
|
insn |= g_n;
|
6134 |
|
|
|
6135 |
|
|
bfd_put_32 (input_bfd, insn, hit_data);
|
6136 |
|
|
}
|
6137 |
|
|
return bfd_reloc_ok;
|
6138 |
|
|
|
6139 |
|
|
case R_ARM_LDR_PC_G0:
|
6140 |
|
|
case R_ARM_LDR_PC_G1:
|
6141 |
|
|
case R_ARM_LDR_PC_G2:
|
6142 |
|
|
case R_ARM_LDR_SB_G0:
|
6143 |
|
|
case R_ARM_LDR_SB_G1:
|
6144 |
|
|
case R_ARM_LDR_SB_G2:
|
6145 |
|
|
{
|
6146 |
|
|
bfd_vma insn = bfd_get_32 (input_bfd, hit_data);
|
6147 |
|
|
bfd_vma pc = input_section->output_section->vma
|
6148 |
|
|
+ input_section->output_offset + rel->r_offset;
|
6149 |
|
|
bfd_vma sb = 0; /* See note above. */
|
6150 |
|
|
bfd_vma residual;
|
6151 |
|
|
bfd_signed_vma signed_value;
|
6152 |
|
|
int group = 0;
|
6153 |
|
|
|
6154 |
|
|
/* Determine which groups of bits to calculate. */
|
6155 |
|
|
switch (r_type)
|
6156 |
|
|
{
|
6157 |
|
|
case R_ARM_LDR_PC_G0:
|
6158 |
|
|
case R_ARM_LDR_SB_G0:
|
6159 |
|
|
group = 0;
|
6160 |
|
|
break;
|
6161 |
|
|
|
6162 |
|
|
case R_ARM_LDR_PC_G1:
|
6163 |
|
|
case R_ARM_LDR_SB_G1:
|
6164 |
|
|
group = 1;
|
6165 |
|
|
break;
|
6166 |
|
|
|
6167 |
|
|
case R_ARM_LDR_PC_G2:
|
6168 |
|
|
case R_ARM_LDR_SB_G2:
|
6169 |
|
|
group = 2;
|
6170 |
|
|
break;
|
6171 |
|
|
|
6172 |
|
|
default:
|
6173 |
|
|
abort();
|
6174 |
|
|
}
|
6175 |
|
|
|
6176 |
|
|
/* If REL, extract the addend from the insn. If RELA, it will
|
6177 |
|
|
have already been fetched for us. */
|
6178 |
|
|
if (globals->use_rel)
|
6179 |
|
|
{
|
6180 |
|
|
int negative = (insn & (1 << 23)) ? 1 : -1;
|
6181 |
|
|
signed_addend = negative * (insn & 0xfff);
|
6182 |
|
|
}
|
6183 |
|
|
|
6184 |
|
|
/* Compute the value (X) to go in the place. */
|
6185 |
|
|
if (r_type == R_ARM_LDR_PC_G0
|
6186 |
|
|
|| r_type == R_ARM_LDR_PC_G1
|
6187 |
|
|
|| r_type == R_ARM_LDR_PC_G2)
|
6188 |
|
|
/* PC relative. */
|
6189 |
|
|
signed_value = value - pc + signed_addend;
|
6190 |
|
|
else
|
6191 |
|
|
/* Section base relative. */
|
6192 |
|
|
signed_value = value - sb + signed_addend;
|
6193 |
|
|
|
6194 |
|
|
/* Calculate the value of the relevant G_{n-1} to obtain
|
6195 |
|
|
the residual at that stage. */
|
6196 |
|
|
calculate_group_reloc_mask (abs (signed_value), group - 1, &residual);
|
6197 |
|
|
|
6198 |
|
|
/* Check for overflow. */
|
6199 |
|
|
if (residual >= 0x1000)
|
6200 |
|
|
{
|
6201 |
|
|
(*_bfd_error_handler)
|
6202 |
|
|
(_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"),
|
6203 |
|
|
input_bfd, input_section,
|
6204 |
|
|
(long) rel->r_offset, abs (signed_value), howto->name);
|
6205 |
|
|
return bfd_reloc_overflow;
|
6206 |
|
|
}
|
6207 |
|
|
|
6208 |
|
|
/* Mask out the value and U bit. */
|
6209 |
|
|
insn &= 0xff7ff000;
|
6210 |
|
|
|
6211 |
|
|
/* Set the U bit if the value to go in the place is non-negative. */
|
6212 |
|
|
if (signed_value >= 0)
|
6213 |
|
|
insn |= 1 << 23;
|
6214 |
|
|
|
6215 |
|
|
/* Encode the offset. */
|
6216 |
|
|
insn |= residual;
|
6217 |
|
|
|
6218 |
|
|
bfd_put_32 (input_bfd, insn, hit_data);
|
6219 |
|
|
}
|
6220 |
|
|
return bfd_reloc_ok;
|
6221 |
|
|
|
6222 |
|
|
case R_ARM_LDRS_PC_G0:
|
6223 |
|
|
case R_ARM_LDRS_PC_G1:
|
6224 |
|
|
case R_ARM_LDRS_PC_G2:
|
6225 |
|
|
case R_ARM_LDRS_SB_G0:
|
6226 |
|
|
case R_ARM_LDRS_SB_G1:
|
6227 |
|
|
case R_ARM_LDRS_SB_G2:
|
6228 |
|
|
{
|
6229 |
|
|
bfd_vma insn = bfd_get_32 (input_bfd, hit_data);
|
6230 |
|
|
bfd_vma pc = input_section->output_section->vma
|
6231 |
|
|
+ input_section->output_offset + rel->r_offset;
|
6232 |
|
|
bfd_vma sb = 0; /* See note above. */
|
6233 |
|
|
bfd_vma residual;
|
6234 |
|
|
bfd_signed_vma signed_value;
|
6235 |
|
|
int group = 0;
|
6236 |
|
|
|
6237 |
|
|
/* Determine which groups of bits to calculate. */
|
6238 |
|
|
switch (r_type)
|
6239 |
|
|
{
|
6240 |
|
|
case R_ARM_LDRS_PC_G0:
|
6241 |
|
|
case R_ARM_LDRS_SB_G0:
|
6242 |
|
|
group = 0;
|
6243 |
|
|
break;
|
6244 |
|
|
|
6245 |
|
|
case R_ARM_LDRS_PC_G1:
|
6246 |
|
|
case R_ARM_LDRS_SB_G1:
|
6247 |
|
|
group = 1;
|
6248 |
|
|
break;
|
6249 |
|
|
|
6250 |
|
|
case R_ARM_LDRS_PC_G2:
|
6251 |
|
|
case R_ARM_LDRS_SB_G2:
|
6252 |
|
|
group = 2;
|
6253 |
|
|
break;
|
6254 |
|
|
|
6255 |
|
|
default:
|
6256 |
|
|
abort();
|
6257 |
|
|
}
|
6258 |
|
|
|
6259 |
|
|
/* If REL, extract the addend from the insn. If RELA, it will
|
6260 |
|
|
have already been fetched for us. */
|
6261 |
|
|
if (globals->use_rel)
|
6262 |
|
|
{
|
6263 |
|
|
int negative = (insn & (1 << 23)) ? 1 : -1;
|
6264 |
|
|
signed_addend = negative * (((insn & 0xf00) >> 4) + (insn & 0xf));
|
6265 |
|
|
}
|
6266 |
|
|
|
6267 |
|
|
/* Compute the value (X) to go in the place. */
|
6268 |
|
|
if (r_type == R_ARM_LDRS_PC_G0
|
6269 |
|
|
|| r_type == R_ARM_LDRS_PC_G1
|
6270 |
|
|
|| r_type == R_ARM_LDRS_PC_G2)
|
6271 |
|
|
/* PC relative. */
|
6272 |
|
|
signed_value = value - pc + signed_addend;
|
6273 |
|
|
else
|
6274 |
|
|
/* Section base relative. */
|
6275 |
|
|
signed_value = value - sb + signed_addend;
|
6276 |
|
|
|
6277 |
|
|
/* Calculate the value of the relevant G_{n-1} to obtain
|
6278 |
|
|
the residual at that stage. */
|
6279 |
|
|
calculate_group_reloc_mask (abs (signed_value), group - 1, &residual);
|
6280 |
|
|
|
6281 |
|
|
/* Check for overflow. */
|
6282 |
|
|
if (residual >= 0x100)
|
6283 |
|
|
{
|
6284 |
|
|
(*_bfd_error_handler)
|
6285 |
|
|
(_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"),
|
6286 |
|
|
input_bfd, input_section,
|
6287 |
|
|
(long) rel->r_offset, abs (signed_value), howto->name);
|
6288 |
|
|
return bfd_reloc_overflow;
|
6289 |
|
|
}
|
6290 |
|
|
|
6291 |
|
|
/* Mask out the value and U bit. */
|
6292 |
|
|
insn &= 0xff7ff0f0;
|
6293 |
|
|
|
6294 |
|
|
/* Set the U bit if the value to go in the place is non-negative. */
|
6295 |
|
|
if (signed_value >= 0)
|
6296 |
|
|
insn |= 1 << 23;
|
6297 |
|
|
|
6298 |
|
|
/* Encode the offset. */
|
6299 |
|
|
insn |= ((residual & 0xf0) << 4) | (residual & 0xf);
|
6300 |
|
|
|
6301 |
|
|
bfd_put_32 (input_bfd, insn, hit_data);
|
6302 |
|
|
}
|
6303 |
|
|
return bfd_reloc_ok;
|
6304 |
|
|
|
6305 |
|
|
case R_ARM_LDC_PC_G0:
|
6306 |
|
|
case R_ARM_LDC_PC_G1:
|
6307 |
|
|
case R_ARM_LDC_PC_G2:
|
6308 |
|
|
case R_ARM_LDC_SB_G0:
|
6309 |
|
|
case R_ARM_LDC_SB_G1:
|
6310 |
|
|
case R_ARM_LDC_SB_G2:
|
6311 |
|
|
{
|
6312 |
|
|
bfd_vma insn = bfd_get_32 (input_bfd, hit_data);
|
6313 |
|
|
bfd_vma pc = input_section->output_section->vma
|
6314 |
|
|
+ input_section->output_offset + rel->r_offset;
|
6315 |
|
|
bfd_vma sb = 0; /* See note above. */
|
6316 |
|
|
bfd_vma residual;
|
6317 |
|
|
bfd_signed_vma signed_value;
|
6318 |
|
|
int group = 0;
|
6319 |
|
|
|
6320 |
|
|
/* Determine which groups of bits to calculate. */
|
6321 |
|
|
switch (r_type)
|
6322 |
|
|
{
|
6323 |
|
|
case R_ARM_LDC_PC_G0:
|
6324 |
|
|
case R_ARM_LDC_SB_G0:
|
6325 |
|
|
group = 0;
|
6326 |
|
|
break;
|
6327 |
|
|
|
6328 |
|
|
case R_ARM_LDC_PC_G1:
|
6329 |
|
|
case R_ARM_LDC_SB_G1:
|
6330 |
|
|
group = 1;
|
6331 |
|
|
break;
|
6332 |
|
|
|
6333 |
|
|
case R_ARM_LDC_PC_G2:
|
6334 |
|
|
case R_ARM_LDC_SB_G2:
|
6335 |
|
|
group = 2;
|
6336 |
|
|
break;
|
6337 |
|
|
|
6338 |
|
|
default:
|
6339 |
|
|
abort();
|
6340 |
|
|
}
|
6341 |
|
|
|
6342 |
|
|
/* If REL, extract the addend from the insn. If RELA, it will
|
6343 |
|
|
have already been fetched for us. */
|
6344 |
|
|
if (globals->use_rel)
|
6345 |
|
|
{
|
6346 |
|
|
int negative = (insn & (1 << 23)) ? 1 : -1;
|
6347 |
|
|
signed_addend = negative * ((insn & 0xff) << 2);
|
6348 |
|
|
}
|
6349 |
|
|
|
6350 |
|
|
/* Compute the value (X) to go in the place. */
|
6351 |
|
|
if (r_type == R_ARM_LDC_PC_G0
|
6352 |
|
|
|| r_type == R_ARM_LDC_PC_G1
|
6353 |
|
|
|| r_type == R_ARM_LDC_PC_G2)
|
6354 |
|
|
/* PC relative. */
|
6355 |
|
|
signed_value = value - pc + signed_addend;
|
6356 |
|
|
else
|
6357 |
|
|
/* Section base relative. */
|
6358 |
|
|
signed_value = value - sb + signed_addend;
|
6359 |
|
|
|
6360 |
|
|
/* Calculate the value of the relevant G_{n-1} to obtain
|
6361 |
|
|
the residual at that stage. */
|
6362 |
|
|
calculate_group_reloc_mask (abs (signed_value), group - 1, &residual);
|
6363 |
|
|
|
6364 |
|
|
/* Check for overflow. (The absolute value to go in the place must be
|
6365 |
|
|
divisible by four and, after having been divided by four, must
|
6366 |
|
|
fit in eight bits.) */
|
6367 |
|
|
if ((residual & 0x3) != 0 || residual >= 0x400)
|
6368 |
|
|
{
|
6369 |
|
|
(*_bfd_error_handler)
|
6370 |
|
|
(_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"),
|
6371 |
|
|
input_bfd, input_section,
|
6372 |
|
|
(long) rel->r_offset, abs (signed_value), howto->name);
|
6373 |
|
|
return bfd_reloc_overflow;
|
6374 |
|
|
}
|
6375 |
|
|
|
6376 |
|
|
/* Mask out the value and U bit. */
|
6377 |
|
|
insn &= 0xff7fff00;
|
6378 |
|
|
|
6379 |
|
|
/* Set the U bit if the value to go in the place is non-negative. */
|
6380 |
|
|
if (signed_value >= 0)
|
6381 |
|
|
insn |= 1 << 23;
|
6382 |
|
|
|
6383 |
|
|
/* Encode the offset. */
|
6384 |
|
|
insn |= residual >> 2;
|
6385 |
|
|
|
6386 |
|
|
bfd_put_32 (input_bfd, insn, hit_data);
|
6387 |
|
|
}
|
6388 |
|
|
return bfd_reloc_ok;
|
6389 |
|
|
|
6390 |
|
|
default:
|
6391 |
|
|
return bfd_reloc_notsupported;
|
6392 |
|
|
}
|
6393 |
|
|
}
|
6394 |
|
|
|
6395 |
|
|
/* Add INCREMENT to the reloc (of type HOWTO) at ADDRESS. */
|
6396 |
|
|
static void
|
6397 |
|
|
arm_add_to_rel (bfd * abfd,
|
6398 |
|
|
bfd_byte * address,
|
6399 |
|
|
reloc_howto_type * howto,
|
6400 |
|
|
bfd_signed_vma increment)
|
6401 |
|
|
{
|
6402 |
|
|
bfd_signed_vma addend;
|
6403 |
|
|
|
6404 |
|
|
if (howto->type == R_ARM_THM_CALL
|
6405 |
|
|
|| howto->type == R_ARM_THM_JUMP24)
|
6406 |
|
|
{
|
6407 |
|
|
int upper_insn, lower_insn;
|
6408 |
|
|
int upper, lower;
|
6409 |
|
|
|
6410 |
|
|
upper_insn = bfd_get_16 (abfd, address);
|
6411 |
|
|
lower_insn = bfd_get_16 (abfd, address + 2);
|
6412 |
|
|
upper = upper_insn & 0x7ff;
|
6413 |
|
|
lower = lower_insn & 0x7ff;
|
6414 |
|
|
|
6415 |
|
|
addend = (upper << 12) | (lower << 1);
|
6416 |
|
|
addend += increment;
|
6417 |
|
|
addend >>= 1;
|
6418 |
|
|
|
6419 |
|
|
upper_insn = (upper_insn & 0xf800) | ((addend >> 11) & 0x7ff);
|
6420 |
|
|
lower_insn = (lower_insn & 0xf800) | (addend & 0x7ff);
|
6421 |
|
|
|
6422 |
|
|
bfd_put_16 (abfd, (bfd_vma) upper_insn, address);
|
6423 |
|
|
bfd_put_16 (abfd, (bfd_vma) lower_insn, address + 2);
|
6424 |
|
|
}
|
6425 |
|
|
else
|
6426 |
|
|
{
|
6427 |
|
|
bfd_vma contents;
|
6428 |
|
|
|
6429 |
|
|
contents = bfd_get_32 (abfd, address);
|
6430 |
|
|
|
6431 |
|
|
/* Get the (signed) value from the instruction. */
|
6432 |
|
|
addend = contents & howto->src_mask;
|
6433 |
|
|
if (addend & ((howto->src_mask + 1) >> 1))
|
6434 |
|
|
{
|
6435 |
|
|
bfd_signed_vma mask;
|
6436 |
|
|
|
6437 |
|
|
mask = -1;
|
6438 |
|
|
mask &= ~ howto->src_mask;
|
6439 |
|
|
addend |= mask;
|
6440 |
|
|
}
|
6441 |
|
|
|
6442 |
|
|
/* Add in the increment, (which is a byte value). */
|
6443 |
|
|
switch (howto->type)
|
6444 |
|
|
{
|
6445 |
|
|
default:
|
6446 |
|
|
addend += increment;
|
6447 |
|
|
break;
|
6448 |
|
|
|
6449 |
|
|
case R_ARM_PC24:
|
6450 |
|
|
case R_ARM_PLT32:
|
6451 |
|
|
case R_ARM_CALL:
|
6452 |
|
|
case R_ARM_JUMP24:
|
6453 |
|
|
addend <<= howto->size;
|
6454 |
|
|
addend += increment;
|
6455 |
|
|
|
6456 |
|
|
/* Should we check for overflow here ? */
|
6457 |
|
|
|
6458 |
|
|
/* Drop any undesired bits. */
|
6459 |
|
|
addend >>= howto->rightshift;
|
6460 |
|
|
break;
|
6461 |
|
|
}
|
6462 |
|
|
|
6463 |
|
|
contents = (contents & ~ howto->dst_mask) | (addend & howto->dst_mask);
|
6464 |
|
|
|
6465 |
|
|
bfd_put_32 (abfd, contents, address);
|
6466 |
|
|
}
|
6467 |
|
|
}
|
6468 |
|
|
|
6469 |
|
|
#define IS_ARM_TLS_RELOC(R_TYPE) \
|
6470 |
|
|
((R_TYPE) == R_ARM_TLS_GD32 \
|
6471 |
|
|
|| (R_TYPE) == R_ARM_TLS_LDO32 \
|
6472 |
|
|
|| (R_TYPE) == R_ARM_TLS_LDM32 \
|
6473 |
|
|
|| (R_TYPE) == R_ARM_TLS_DTPOFF32 \
|
6474 |
|
|
|| (R_TYPE) == R_ARM_TLS_DTPMOD32 \
|
6475 |
|
|
|| (R_TYPE) == R_ARM_TLS_TPOFF32 \
|
6476 |
|
|
|| (R_TYPE) == R_ARM_TLS_LE32 \
|
6477 |
|
|
|| (R_TYPE) == R_ARM_TLS_IE32)
|
6478 |
|
|
|
6479 |
|
|
/* Relocate an ARM ELF section. */
|
6480 |
|
|
static bfd_boolean
|
6481 |
|
|
elf32_arm_relocate_section (bfd * output_bfd,
|
6482 |
|
|
struct bfd_link_info * info,
|
6483 |
|
|
bfd * input_bfd,
|
6484 |
|
|
asection * input_section,
|
6485 |
|
|
bfd_byte * contents,
|
6486 |
|
|
Elf_Internal_Rela * relocs,
|
6487 |
|
|
Elf_Internal_Sym * local_syms,
|
6488 |
|
|
asection ** local_sections)
|
6489 |
|
|
{
|
6490 |
|
|
Elf_Internal_Shdr *symtab_hdr;
|
6491 |
|
|
struct elf_link_hash_entry **sym_hashes;
|
6492 |
|
|
Elf_Internal_Rela *rel;
|
6493 |
|
|
Elf_Internal_Rela *relend;
|
6494 |
|
|
const char *name;
|
6495 |
|
|
struct elf32_arm_link_hash_table * globals;
|
6496 |
|
|
|
6497 |
|
|
globals = elf32_arm_hash_table (info);
|
6498 |
|
|
|
6499 |
|
|
symtab_hdr = & elf_symtab_hdr (input_bfd);
|
6500 |
|
|
sym_hashes = elf_sym_hashes (input_bfd);
|
6501 |
|
|
|
6502 |
|
|
rel = relocs;
|
6503 |
|
|
relend = relocs + input_section->reloc_count;
|
6504 |
|
|
for (; rel < relend; rel++)
|
6505 |
|
|
{
|
6506 |
|
|
int r_type;
|
6507 |
|
|
reloc_howto_type * howto;
|
6508 |
|
|
unsigned long r_symndx;
|
6509 |
|
|
Elf_Internal_Sym * sym;
|
6510 |
|
|
asection * sec;
|
6511 |
|
|
struct elf_link_hash_entry * h;
|
6512 |
|
|
bfd_vma relocation;
|
6513 |
|
|
bfd_reloc_status_type r;
|
6514 |
|
|
arelent bfd_reloc;
|
6515 |
|
|
char sym_type;
|
6516 |
|
|
bfd_boolean unresolved_reloc = FALSE;
|
6517 |
|
|
char *error_message = NULL;
|
6518 |
|
|
|
6519 |
|
|
r_symndx = ELF32_R_SYM (rel->r_info);
|
6520 |
|
|
r_type = ELF32_R_TYPE (rel->r_info);
|
6521 |
|
|
r_type = arm_real_reloc_type (globals, r_type);
|
6522 |
|
|
|
6523 |
|
|
if ( r_type == R_ARM_GNU_VTENTRY
|
6524 |
|
|
|| r_type == R_ARM_GNU_VTINHERIT)
|
6525 |
|
|
continue;
|
6526 |
|
|
|
6527 |
|
|
bfd_reloc.howto = elf32_arm_howto_from_type (r_type);
|
6528 |
|
|
howto = bfd_reloc.howto;
|
6529 |
|
|
|
6530 |
|
|
h = NULL;
|
6531 |
|
|
sym = NULL;
|
6532 |
|
|
sec = NULL;
|
6533 |
|
|
|
6534 |
|
|
if (r_symndx < symtab_hdr->sh_info)
|
6535 |
|
|
{
|
6536 |
|
|
sym = local_syms + r_symndx;
|
6537 |
|
|
sym_type = ELF32_ST_TYPE (sym->st_info);
|
6538 |
|
|
sec = local_sections[r_symndx];
|
6539 |
|
|
if (globals->use_rel)
|
6540 |
|
|
{
|
6541 |
|
|
relocation = (sec->output_section->vma
|
6542 |
|
|
+ sec->output_offset
|
6543 |
|
|
+ sym->st_value);
|
6544 |
|
|
if (!info->relocatable
|
6545 |
|
|
&& (sec->flags & SEC_MERGE)
|
6546 |
|
|
&& ELF_ST_TYPE (sym->st_info) == STT_SECTION)
|
6547 |
|
|
{
|
6548 |
|
|
asection *msec;
|
6549 |
|
|
bfd_vma addend, value;
|
6550 |
|
|
|
6551 |
|
|
if (howto->rightshift)
|
6552 |
|
|
{
|
6553 |
|
|
(*_bfd_error_handler)
|
6554 |
|
|
(_("%B(%A+0x%lx): %s relocation against SEC_MERGE section"),
|
6555 |
|
|
input_bfd, input_section,
|
6556 |
|
|
(long) rel->r_offset, howto->name);
|
6557 |
|
|
return FALSE;
|
6558 |
|
|
}
|
6559 |
|
|
|
6560 |
|
|
value = bfd_get_32 (input_bfd, contents + rel->r_offset);
|
6561 |
|
|
|
6562 |
|
|
/* Get the (signed) value from the instruction. */
|
6563 |
|
|
addend = value & howto->src_mask;
|
6564 |
|
|
if (addend & ((howto->src_mask + 1) >> 1))
|
6565 |
|
|
{
|
6566 |
|
|
bfd_signed_vma mask;
|
6567 |
|
|
|
6568 |
|
|
mask = -1;
|
6569 |
|
|
mask &= ~ howto->src_mask;
|
6570 |
|
|
addend |= mask;
|
6571 |
|
|
}
|
6572 |
|
|
msec = sec;
|
6573 |
|
|
addend =
|
6574 |
|
|
_bfd_elf_rel_local_sym (output_bfd, sym, &msec, addend)
|
6575 |
|
|
- relocation;
|
6576 |
|
|
addend += msec->output_section->vma + msec->output_offset;
|
6577 |
|
|
value = (value & ~ howto->dst_mask) | (addend & howto->dst_mask);
|
6578 |
|
|
bfd_put_32 (input_bfd, value, contents + rel->r_offset);
|
6579 |
|
|
}
|
6580 |
|
|
}
|
6581 |
|
|
else
|
6582 |
|
|
relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
|
6583 |
|
|
}
|
6584 |
|
|
else
|
6585 |
|
|
{
|
6586 |
|
|
bfd_boolean warned;
|
6587 |
|
|
|
6588 |
|
|
RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
|
6589 |
|
|
r_symndx, symtab_hdr, sym_hashes,
|
6590 |
|
|
h, sec, relocation,
|
6591 |
|
|
unresolved_reloc, warned);
|
6592 |
|
|
|
6593 |
|
|
sym_type = h->type;
|
6594 |
|
|
}
|
6595 |
|
|
|
6596 |
|
|
if (sec != NULL && elf_discarded_section (sec))
|
6597 |
|
|
{
|
6598 |
|
|
/* For relocs against symbols from removed linkonce sections,
|
6599 |
|
|
or sections discarded by a linker script, we just want the
|
6600 |
|
|
section contents zeroed. Avoid any special processing. */
|
6601 |
|
|
_bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
|
6602 |
|
|
rel->r_info = 0;
|
6603 |
|
|
rel->r_addend = 0;
|
6604 |
|
|
continue;
|
6605 |
|
|
}
|
6606 |
|
|
|
6607 |
|
|
if (info->relocatable)
|
6608 |
|
|
{
|
6609 |
|
|
/* This is a relocatable link. We don't have to change
|
6610 |
|
|
anything, unless the reloc is against a section symbol,
|
6611 |
|
|
in which case we have to adjust according to where the
|
6612 |
|
|
section symbol winds up in the output section. */
|
6613 |
|
|
if (sym != NULL && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
|
6614 |
|
|
{
|
6615 |
|
|
if (globals->use_rel)
|
6616 |
|
|
arm_add_to_rel (input_bfd, contents + rel->r_offset,
|
6617 |
|
|
howto, (bfd_signed_vma) sec->output_offset);
|
6618 |
|
|
else
|
6619 |
|
|
rel->r_addend += sec->output_offset;
|
6620 |
|
|
}
|
6621 |
|
|
continue;
|
6622 |
|
|
}
|
6623 |
|
|
|
6624 |
|
|
if (h != NULL)
|
6625 |
|
|
name = h->root.root.string;
|
6626 |
|
|
else
|
6627 |
|
|
{
|
6628 |
|
|
name = (bfd_elf_string_from_elf_section
|
6629 |
|
|
(input_bfd, symtab_hdr->sh_link, sym->st_name));
|
6630 |
|
|
if (name == NULL || *name == '\0')
|
6631 |
|
|
name = bfd_section_name (input_bfd, sec);
|
6632 |
|
|
}
|
6633 |
|
|
|
6634 |
|
|
if (r_symndx != 0
|
6635 |
|
|
&& r_type != R_ARM_NONE
|
6636 |
|
|
&& (h == NULL
|
6637 |
|
|
|| h->root.type == bfd_link_hash_defined
|
6638 |
|
|
|| h->root.type == bfd_link_hash_defweak)
|
6639 |
|
|
&& IS_ARM_TLS_RELOC (r_type) != (sym_type == STT_TLS))
|
6640 |
|
|
{
|
6641 |
|
|
(*_bfd_error_handler)
|
6642 |
|
|
((sym_type == STT_TLS
|
6643 |
|
|
? _("%B(%A+0x%lx): %s used with TLS symbol %s")
|
6644 |
|
|
: _("%B(%A+0x%lx): %s used with non-TLS symbol %s")),
|
6645 |
|
|
input_bfd,
|
6646 |
|
|
input_section,
|
6647 |
|
|
(long) rel->r_offset,
|
6648 |
|
|
howto->name,
|
6649 |
|
|
name);
|
6650 |
|
|
}
|
6651 |
|
|
|
6652 |
|
|
r = elf32_arm_final_link_relocate (howto, input_bfd, output_bfd,
|
6653 |
|
|
input_section, contents, rel,
|
6654 |
|
|
relocation, info, sec, name,
|
6655 |
|
|
(h ? ELF_ST_TYPE (h->type) :
|
6656 |
|
|
ELF_ST_TYPE (sym->st_info)), h,
|
6657 |
|
|
&unresolved_reloc, &error_message);
|
6658 |
|
|
|
6659 |
|
|
/* Dynamic relocs are not propagated for SEC_DEBUGGING sections
|
6660 |
|
|
because such sections are not SEC_ALLOC and thus ld.so will
|
6661 |
|
|
not process them. */
|
6662 |
|
|
if (unresolved_reloc
|
6663 |
|
|
&& !((input_section->flags & SEC_DEBUGGING) != 0
|
6664 |
|
|
&& h->def_dynamic))
|
6665 |
|
|
{
|
6666 |
|
|
(*_bfd_error_handler)
|
6667 |
|
|
(_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
|
6668 |
|
|
input_bfd,
|
6669 |
|
|
input_section,
|
6670 |
|
|
(long) rel->r_offset,
|
6671 |
|
|
howto->name,
|
6672 |
|
|
h->root.root.string);
|
6673 |
|
|
return FALSE;
|
6674 |
|
|
}
|
6675 |
|
|
|
6676 |
|
|
if (r != bfd_reloc_ok)
|
6677 |
|
|
{
|
6678 |
|
|
switch (r)
|
6679 |
|
|
{
|
6680 |
|
|
case bfd_reloc_overflow:
|
6681 |
|
|
/* If the overflowing reloc was to an undefined symbol,
|
6682 |
|
|
we have already printed one error message and there
|
6683 |
|
|
is no point complaining again. */
|
6684 |
|
|
if ((! h ||
|
6685 |
|
|
h->root.type != bfd_link_hash_undefined)
|
6686 |
|
|
&& (!((*info->callbacks->reloc_overflow)
|
6687 |
|
|
(info, (h ? &h->root : NULL), name, howto->name,
|
6688 |
|
|
(bfd_vma) 0, input_bfd, input_section,
|
6689 |
|
|
rel->r_offset))))
|
6690 |
|
|
return FALSE;
|
6691 |
|
|
break;
|
6692 |
|
|
|
6693 |
|
|
case bfd_reloc_undefined:
|
6694 |
|
|
if (!((*info->callbacks->undefined_symbol)
|
6695 |
|
|
(info, name, input_bfd, input_section,
|
6696 |
|
|
rel->r_offset, TRUE)))
|
6697 |
|
|
return FALSE;
|
6698 |
|
|
break;
|
6699 |
|
|
|
6700 |
|
|
case bfd_reloc_outofrange:
|
6701 |
|
|
error_message = _("out of range");
|
6702 |
|
|
goto common_error;
|
6703 |
|
|
|
6704 |
|
|
case bfd_reloc_notsupported:
|
6705 |
|
|
error_message = _("unsupported relocation");
|
6706 |
|
|
goto common_error;
|
6707 |
|
|
|
6708 |
|
|
case bfd_reloc_dangerous:
|
6709 |
|
|
/* error_message should already be set. */
|
6710 |
|
|
goto common_error;
|
6711 |
|
|
|
6712 |
|
|
default:
|
6713 |
|
|
error_message = _("unknown error");
|
6714 |
|
|
/* fall through */
|
6715 |
|
|
|
6716 |
|
|
common_error:
|
6717 |
|
|
BFD_ASSERT (error_message != NULL);
|
6718 |
|
|
if (!((*info->callbacks->reloc_dangerous)
|
6719 |
|
|
(info, error_message, input_bfd, input_section,
|
6720 |
|
|
rel->r_offset)))
|
6721 |
|
|
return FALSE;
|
6722 |
|
|
break;
|
6723 |
|
|
}
|
6724 |
|
|
}
|
6725 |
|
|
}
|
6726 |
|
|
|
6727 |
|
|
return TRUE;
|
6728 |
|
|
}
|
6729 |
|
|
|
6730 |
|
|
/* Set the right machine number. */
|
6731 |
|
|
|
6732 |
|
|
static bfd_boolean
|
6733 |
|
|
elf32_arm_object_p (bfd *abfd)
|
6734 |
|
|
{
|
6735 |
|
|
unsigned int mach;
|
6736 |
|
|
|
6737 |
|
|
mach = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
|
6738 |
|
|
|
6739 |
|
|
if (mach != bfd_mach_arm_unknown)
|
6740 |
|
|
bfd_default_set_arch_mach (abfd, bfd_arch_arm, mach);
|
6741 |
|
|
|
6742 |
|
|
else if (elf_elfheader (abfd)->e_flags & EF_ARM_MAVERICK_FLOAT)
|
6743 |
|
|
bfd_default_set_arch_mach (abfd, bfd_arch_arm, bfd_mach_arm_ep9312);
|
6744 |
|
|
|
6745 |
|
|
else
|
6746 |
|
|
bfd_default_set_arch_mach (abfd, bfd_arch_arm, mach);
|
6747 |
|
|
|
6748 |
|
|
return TRUE;
|
6749 |
|
|
}
|
6750 |
|
|
|
6751 |
|
|
/* Function to keep ARM specific flags in the ELF header. */
|
6752 |
|
|
|
6753 |
|
|
static bfd_boolean
|
6754 |
|
|
elf32_arm_set_private_flags (bfd *abfd, flagword flags)
|
6755 |
|
|
{
|
6756 |
|
|
if (elf_flags_init (abfd)
|
6757 |
|
|
&& elf_elfheader (abfd)->e_flags != flags)
|
6758 |
|
|
{
|
6759 |
|
|
if (EF_ARM_EABI_VERSION (flags) == EF_ARM_EABI_UNKNOWN)
|
6760 |
|
|
{
|
6761 |
|
|
if (flags & EF_ARM_INTERWORK)
|
6762 |
|
|
(*_bfd_error_handler)
|
6763 |
|
|
(_("Warning: Not setting interworking flag of %B since it has already been specified as non-interworking"),
|
6764 |
|
|
abfd);
|
6765 |
|
|
else
|
6766 |
|
|
_bfd_error_handler
|
6767 |
|
|
(_("Warning: Clearing the interworking flag of %B due to outside request"),
|
6768 |
|
|
abfd);
|
6769 |
|
|
}
|
6770 |
|
|
}
|
6771 |
|
|
else
|
6772 |
|
|
{
|
6773 |
|
|
elf_elfheader (abfd)->e_flags = flags;
|
6774 |
|
|
elf_flags_init (abfd) = TRUE;
|
6775 |
|
|
}
|
6776 |
|
|
|
6777 |
|
|
return TRUE;
|
6778 |
|
|
}
|
6779 |
|
|
|
6780 |
|
|
/* Copy backend specific data from one object module to another. */
|
6781 |
|
|
|
6782 |
|
|
static bfd_boolean
|
6783 |
|
|
elf32_arm_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
|
6784 |
|
|
{
|
6785 |
|
|
flagword in_flags;
|
6786 |
|
|
flagword out_flags;
|
6787 |
|
|
|
6788 |
|
|
if (! is_arm_elf (ibfd) || ! is_arm_elf (obfd))
|
6789 |
|
|
return TRUE;
|
6790 |
|
|
|
6791 |
|
|
in_flags = elf_elfheader (ibfd)->e_flags;
|
6792 |
|
|
out_flags = elf_elfheader (obfd)->e_flags;
|
6793 |
|
|
|
6794 |
|
|
if (elf_flags_init (obfd)
|
6795 |
|
|
&& EF_ARM_EABI_VERSION (out_flags) == EF_ARM_EABI_UNKNOWN
|
6796 |
|
|
&& in_flags != out_flags)
|
6797 |
|
|
{
|
6798 |
|
|
/* Cannot mix APCS26 and APCS32 code. */
|
6799 |
|
|
if ((in_flags & EF_ARM_APCS_26) != (out_flags & EF_ARM_APCS_26))
|
6800 |
|
|
return FALSE;
|
6801 |
|
|
|
6802 |
|
|
/* Cannot mix float APCS and non-float APCS code. */
|
6803 |
|
|
if ((in_flags & EF_ARM_APCS_FLOAT) != (out_flags & EF_ARM_APCS_FLOAT))
|
6804 |
|
|
return FALSE;
|
6805 |
|
|
|
6806 |
|
|
/* If the src and dest have different interworking flags
|
6807 |
|
|
then turn off the interworking bit. */
|
6808 |
|
|
if ((in_flags & EF_ARM_INTERWORK) != (out_flags & EF_ARM_INTERWORK))
|
6809 |
|
|
{
|
6810 |
|
|
if (out_flags & EF_ARM_INTERWORK)
|
6811 |
|
|
_bfd_error_handler
|
6812 |
|
|
(_("Warning: Clearing the interworking flag of %B because non-interworking code in %B has been linked with it"),
|
6813 |
|
|
obfd, ibfd);
|
6814 |
|
|
|
6815 |
|
|
in_flags &= ~EF_ARM_INTERWORK;
|
6816 |
|
|
}
|
6817 |
|
|
|
6818 |
|
|
/* Likewise for PIC, though don't warn for this case. */
|
6819 |
|
|
if ((in_flags & EF_ARM_PIC) != (out_flags & EF_ARM_PIC))
|
6820 |
|
|
in_flags &= ~EF_ARM_PIC;
|
6821 |
|
|
}
|
6822 |
|
|
|
6823 |
|
|
elf_elfheader (obfd)->e_flags = in_flags;
|
6824 |
|
|
elf_flags_init (obfd) = TRUE;
|
6825 |
|
|
|
6826 |
|
|
/* Also copy the EI_OSABI field. */
|
6827 |
|
|
elf_elfheader (obfd)->e_ident[EI_OSABI] =
|
6828 |
|
|
elf_elfheader (ibfd)->e_ident[EI_OSABI];
|
6829 |
|
|
|
6830 |
|
|
/* Copy object attributes. */
|
6831 |
|
|
_bfd_elf_copy_obj_attributes (ibfd, obfd);
|
6832 |
|
|
|
6833 |
|
|
return TRUE;
|
6834 |
|
|
}
|
6835 |
|
|
|
6836 |
|
|
/* Values for Tag_ABI_PCS_R9_use. */
|
6837 |
|
|
enum
|
6838 |
|
|
{
|
6839 |
|
|
AEABI_R9_V6,
|
6840 |
|
|
AEABI_R9_SB,
|
6841 |
|
|
AEABI_R9_TLS,
|
6842 |
|
|
AEABI_R9_unused
|
6843 |
|
|
};
|
6844 |
|
|
|
6845 |
|
|
/* Values for Tag_ABI_PCS_RW_data. */
|
6846 |
|
|
enum
|
6847 |
|
|
{
|
6848 |
|
|
AEABI_PCS_RW_data_absolute,
|
6849 |
|
|
AEABI_PCS_RW_data_PCrel,
|
6850 |
|
|
AEABI_PCS_RW_data_SBrel,
|
6851 |
|
|
AEABI_PCS_RW_data_unused
|
6852 |
|
|
};
|
6853 |
|
|
|
6854 |
|
|
/* Values for Tag_ABI_enum_size. */
|
6855 |
|
|
enum
|
6856 |
|
|
{
|
6857 |
|
|
AEABI_enum_unused,
|
6858 |
|
|
AEABI_enum_short,
|
6859 |
|
|
AEABI_enum_wide,
|
6860 |
|
|
AEABI_enum_forced_wide
|
6861 |
|
|
};
|
6862 |
|
|
|
6863 |
|
|
/* Determine whether an object attribute tag takes an integer, a
|
6864 |
|
|
string or both. */
|
6865 |
|
|
static int
|
6866 |
|
|
elf32_arm_obj_attrs_arg_type (int tag)
|
6867 |
|
|
{
|
6868 |
|
|
if (tag == Tag_compatibility)
|
6869 |
|
|
return 3;
|
6870 |
|
|
else if (tag == 4 || tag == 5)
|
6871 |
|
|
return 2;
|
6872 |
|
|
else if (tag < 32)
|
6873 |
|
|
return 1;
|
6874 |
|
|
else
|
6875 |
|
|
return (tag & 1) != 0 ? 2 : 1;
|
6876 |
|
|
}
|
6877 |
|
|
|
6878 |
|
|
/* Merge EABI object attributes from IBFD into OBFD. Raise an error if there
|
6879 |
|
|
are conflicting attributes. */
|
6880 |
|
|
static bfd_boolean
|
6881 |
|
|
elf32_arm_merge_eabi_attributes (bfd *ibfd, bfd *obfd)
|
6882 |
|
|
{
|
6883 |
|
|
obj_attribute *in_attr;
|
6884 |
|
|
obj_attribute *out_attr;
|
6885 |
|
|
obj_attribute_list *in_list;
|
6886 |
|
|
/* Some tags have 0 = don't care, 1 = strong requirement,
|
6887 |
|
|
2 = weak requirement. */
|
6888 |
|
|
static const int order_312[3] = {3, 1, 2};
|
6889 |
|
|
int i;
|
6890 |
|
|
|
6891 |
|
|
if (!elf_known_obj_attributes_proc (obfd)[0].i)
|
6892 |
|
|
{
|
6893 |
|
|
/* This is the first object. Copy the attributes. */
|
6894 |
|
|
_bfd_elf_copy_obj_attributes (ibfd, obfd);
|
6895 |
|
|
|
6896 |
|
|
/* Use the Tag_null value to indicate the attributes have been
|
6897 |
|
|
initialized. */
|
6898 |
|
|
elf_known_obj_attributes_proc (obfd)[0].i = 1;
|
6899 |
|
|
|
6900 |
|
|
return TRUE;
|
6901 |
|
|
}
|
6902 |
|
|
|
6903 |
|
|
in_attr = elf_known_obj_attributes_proc (ibfd);
|
6904 |
|
|
out_attr = elf_known_obj_attributes_proc (obfd);
|
6905 |
|
|
/* This needs to happen before Tag_ABI_FP_number_model is merged. */
|
6906 |
|
|
if (in_attr[Tag_ABI_VFP_args].i != out_attr[Tag_ABI_VFP_args].i)
|
6907 |
|
|
{
|
6908 |
|
|
/* Ignore mismatches if teh object doesn't use floating point. */
|
6909 |
|
|
if (out_attr[Tag_ABI_FP_number_model].i == 0)
|
6910 |
|
|
out_attr[Tag_ABI_VFP_args].i = in_attr[Tag_ABI_VFP_args].i;
|
6911 |
|
|
else if (in_attr[Tag_ABI_FP_number_model].i != 0)
|
6912 |
|
|
{
|
6913 |
|
|
_bfd_error_handler
|
6914 |
|
|
(_("ERROR: %B uses VFP register arguments, %B does not"),
|
6915 |
|
|
ibfd, obfd);
|
6916 |
|
|
return FALSE;
|
6917 |
|
|
}
|
6918 |
|
|
}
|
6919 |
|
|
|
6920 |
|
|
for (i = 4; i < NUM_KNOWN_OBJ_ATTRIBUTES; i++)
|
6921 |
|
|
{
|
6922 |
|
|
/* Merge this attribute with existing attributes. */
|
6923 |
|
|
switch (i)
|
6924 |
|
|
{
|
6925 |
|
|
case Tag_CPU_raw_name:
|
6926 |
|
|
case Tag_CPU_name:
|
6927 |
|
|
/* Use whichever has the greatest architecture requirements. We
|
6928 |
|
|
won't necessarily have both the above tags, so make sure input
|
6929 |
|
|
name is non-NULL. */
|
6930 |
|
|
if (in_attr[Tag_CPU_arch].i > out_attr[Tag_CPU_arch].i
|
6931 |
|
|
&& in_attr[i].s)
|
6932 |
|
|
out_attr[i].s = _bfd_elf_attr_strdup (obfd, in_attr[i].s);
|
6933 |
|
|
break;
|
6934 |
|
|
|
6935 |
|
|
case Tag_ABI_optimization_goals:
|
6936 |
|
|
case Tag_ABI_FP_optimization_goals:
|
6937 |
|
|
/* Use the first value seen. */
|
6938 |
|
|
break;
|
6939 |
|
|
|
6940 |
|
|
case Tag_CPU_arch:
|
6941 |
|
|
case Tag_ARM_ISA_use:
|
6942 |
|
|
case Tag_THUMB_ISA_use:
|
6943 |
|
|
case Tag_VFP_arch:
|
6944 |
|
|
case Tag_WMMX_arch:
|
6945 |
|
|
case Tag_NEON_arch:
|
6946 |
|
|
/* ??? Do NEON and WMMX conflict? */
|
6947 |
|
|
case Tag_ABI_FP_rounding:
|
6948 |
|
|
case Tag_ABI_FP_denormal:
|
6949 |
|
|
case Tag_ABI_FP_exceptions:
|
6950 |
|
|
case Tag_ABI_FP_user_exceptions:
|
6951 |
|
|
case Tag_ABI_FP_number_model:
|
6952 |
|
|
case Tag_ABI_align8_preserved:
|
6953 |
|
|
case Tag_ABI_HardFP_use:
|
6954 |
|
|
/* Use the largest value specified. */
|
6955 |
|
|
if (in_attr[i].i > out_attr[i].i)
|
6956 |
|
|
out_attr[i].i = in_attr[i].i;
|
6957 |
|
|
break;
|
6958 |
|
|
|
6959 |
|
|
case Tag_CPU_arch_profile:
|
6960 |
|
|
/* Warn if conflicting architecture profiles used. */
|
6961 |
|
|
if (out_attr[i].i && in_attr[i].i && in_attr[i].i != out_attr[i].i)
|
6962 |
|
|
{
|
6963 |
|
|
_bfd_error_handler
|
6964 |
|
|
(_("ERROR: %B: Conflicting architecture profiles %c/%c"),
|
6965 |
|
|
ibfd, in_attr[i].i, out_attr[i].i);
|
6966 |
|
|
return FALSE;
|
6967 |
|
|
}
|
6968 |
|
|
if (in_attr[i].i)
|
6969 |
|
|
out_attr[i].i = in_attr[i].i;
|
6970 |
|
|
break;
|
6971 |
|
|
case Tag_PCS_config:
|
6972 |
|
|
if (out_attr[i].i == 0)
|
6973 |
|
|
out_attr[i].i = in_attr[i].i;
|
6974 |
|
|
else if (in_attr[i].i != 0 && out_attr[i].i != 0)
|
6975 |
|
|
{
|
6976 |
|
|
/* It's sometimes ok to mix different configs, so this is only
|
6977 |
|
|
a warning. */
|
6978 |
|
|
_bfd_error_handler
|
6979 |
|
|
(_("Warning: %B: Conflicting platform configuration"), ibfd);
|
6980 |
|
|
}
|
6981 |
|
|
break;
|
6982 |
|
|
case Tag_ABI_PCS_R9_use:
|
6983 |
|
|
if (in_attr[i].i != out_attr[i].i
|
6984 |
|
|
&& out_attr[i].i != AEABI_R9_unused
|
6985 |
|
|
&& in_attr[i].i != AEABI_R9_unused)
|
6986 |
|
|
{
|
6987 |
|
|
_bfd_error_handler
|
6988 |
|
|
(_("ERROR: %B: Conflicting use of R9"), ibfd);
|
6989 |
|
|
return FALSE;
|
6990 |
|
|
}
|
6991 |
|
|
if (out_attr[i].i == AEABI_R9_unused)
|
6992 |
|
|
out_attr[i].i = in_attr[i].i;
|
6993 |
|
|
break;
|
6994 |
|
|
case Tag_ABI_PCS_RW_data:
|
6995 |
|
|
if (in_attr[i].i == AEABI_PCS_RW_data_SBrel
|
6996 |
|
|
&& out_attr[Tag_ABI_PCS_R9_use].i != AEABI_R9_SB
|
6997 |
|
|
&& out_attr[Tag_ABI_PCS_R9_use].i != AEABI_R9_unused)
|
6998 |
|
|
{
|
6999 |
|
|
_bfd_error_handler
|
7000 |
|
|
(_("ERROR: %B: SB relative addressing conflicts with use of R9"),
|
7001 |
|
|
ibfd);
|
7002 |
|
|
return FALSE;
|
7003 |
|
|
}
|
7004 |
|
|
/* Use the smallest value specified. */
|
7005 |
|
|
if (in_attr[i].i < out_attr[i].i)
|
7006 |
|
|
out_attr[i].i = in_attr[i].i;
|
7007 |
|
|
break;
|
7008 |
|
|
case Tag_ABI_PCS_RO_data:
|
7009 |
|
|
/* Use the smallest value specified. */
|
7010 |
|
|
if (in_attr[i].i < out_attr[i].i)
|
7011 |
|
|
out_attr[i].i = in_attr[i].i;
|
7012 |
|
|
break;
|
7013 |
|
|
case Tag_ABI_PCS_GOT_use:
|
7014 |
|
|
if (in_attr[i].i > 2 || out_attr[i].i > 2
|
7015 |
|
|
|| order_312[in_attr[i].i] < order_312[out_attr[i].i])
|
7016 |
|
|
out_attr[i].i = in_attr[i].i;
|
7017 |
|
|
break;
|
7018 |
|
|
case Tag_ABI_PCS_wchar_t:
|
7019 |
|
|
if (out_attr[i].i && in_attr[i].i && out_attr[i].i != in_attr[i].i)
|
7020 |
|
|
{
|
7021 |
|
|
_bfd_error_handler
|
7022 |
|
|
(_("ERROR: %B: Conflicting definitions of wchar_t"), ibfd);
|
7023 |
|
|
return FALSE;
|
7024 |
|
|
}
|
7025 |
|
|
if (in_attr[i].i)
|
7026 |
|
|
out_attr[i].i = in_attr[i].i;
|
7027 |
|
|
break;
|
7028 |
|
|
case Tag_ABI_align8_needed:
|
7029 |
|
|
/* ??? Check against Tag_ABI_align8_preserved. */
|
7030 |
|
|
if (in_attr[i].i > 2 || out_attr[i].i > 2
|
7031 |
|
|
|| order_312[in_attr[i].i] < order_312[out_attr[i].i])
|
7032 |
|
|
out_attr[i].i = in_attr[i].i;
|
7033 |
|
|
break;
|
7034 |
|
|
case Tag_ABI_enum_size:
|
7035 |
|
|
if (in_attr[i].i != AEABI_enum_unused)
|
7036 |
|
|
{
|
7037 |
|
|
if (out_attr[i].i == AEABI_enum_unused
|
7038 |
|
|
|| out_attr[i].i == AEABI_enum_forced_wide)
|
7039 |
|
|
{
|
7040 |
|
|
/* The existing object is compatible with anything.
|
7041 |
|
|
Use whatever requirements the new object has. */
|
7042 |
|
|
out_attr[i].i = in_attr[i].i;
|
7043 |
|
|
}
|
7044 |
|
|
else if (in_attr[i].i != AEABI_enum_forced_wide
|
7045 |
|
|
&& out_attr[i].i != in_attr[i].i
|
7046 |
|
|
&& !elf_arm_tdata (obfd)->no_enum_size_warning)
|
7047 |
|
|
{
|
7048 |
|
|
const char *aeabi_enum_names[] =
|
7049 |
|
|
{ "", "variable-size", "32-bit", "" };
|
7050 |
|
|
_bfd_error_handler
|
7051 |
|
|
(_("warning: %B uses %s enums yet the output is to use %s enums; use of enum values across objects may fail"),
|
7052 |
|
|
ibfd, aeabi_enum_names[in_attr[i].i],
|
7053 |
|
|
aeabi_enum_names[out_attr[i].i]);
|
7054 |
|
|
}
|
7055 |
|
|
}
|
7056 |
|
|
break;
|
7057 |
|
|
case Tag_ABI_VFP_args:
|
7058 |
|
|
/* Aready done. */
|
7059 |
|
|
break;
|
7060 |
|
|
case Tag_ABI_WMMX_args:
|
7061 |
|
|
if (in_attr[i].i != out_attr[i].i)
|
7062 |
|
|
{
|
7063 |
|
|
_bfd_error_handler
|
7064 |
|
|
(_("ERROR: %B uses iWMMXt register arguments, %B does not"),
|
7065 |
|
|
ibfd, obfd);
|
7066 |
|
|
return FALSE;
|
7067 |
|
|
}
|
7068 |
|
|
break;
|
7069 |
|
|
default: /* All known attributes should be explicitly covered. */
|
7070 |
|
|
abort ();
|
7071 |
|
|
}
|
7072 |
|
|
|
7073 |
|
|
if (in_attr[i].type && !out_attr[i].type)
|
7074 |
|
|
switch (in_attr[i].type)
|
7075 |
|
|
{
|
7076 |
|
|
case 1:
|
7077 |
|
|
if (out_attr[i].i)
|
7078 |
|
|
out_attr[i].type = 1;
|
7079 |
|
|
break;
|
7080 |
|
|
|
7081 |
|
|
case 2:
|
7082 |
|
|
if (out_attr[i].s)
|
7083 |
|
|
out_attr[i].type = 2;
|
7084 |
|
|
break;
|
7085 |
|
|
|
7086 |
|
|
default:
|
7087 |
|
|
abort ();
|
7088 |
|
|
}
|
7089 |
|
|
}
|
7090 |
|
|
|
7091 |
|
|
/* Merge Tag_compatibility attributes and any common GNU ones. */
|
7092 |
|
|
_bfd_elf_merge_object_attributes (ibfd, obfd);
|
7093 |
|
|
|
7094 |
|
|
/* Check for any attributes not known on ARM. */
|
7095 |
|
|
in_list = elf_other_obj_attributes_proc (ibfd);
|
7096 |
|
|
while (in_list && in_list->tag == Tag_compatibility)
|
7097 |
|
|
in_list = in_list->next;
|
7098 |
|
|
|
7099 |
|
|
for (; in_list; in_list = in_list->next)
|
7100 |
|
|
{
|
7101 |
|
|
if ((in_list->tag & 128) < 64)
|
7102 |
|
|
{
|
7103 |
|
|
_bfd_error_handler
|
7104 |
|
|
(_("Warning: %B: Unknown EABI object attribute %d"),
|
7105 |
|
|
ibfd, in_list->tag);
|
7106 |
|
|
break;
|
7107 |
|
|
}
|
7108 |
|
|
}
|
7109 |
|
|
return TRUE;
|
7110 |
|
|
}
|
7111 |
|
|
|
7112 |
|
|
|
7113 |
|
|
/* Return TRUE if the two EABI versions are incompatible. */
|
7114 |
|
|
|
7115 |
|
|
static bfd_boolean
|
7116 |
|
|
elf32_arm_versions_compatible (unsigned iver, unsigned over)
|
7117 |
|
|
{
|
7118 |
|
|
/* v4 and v5 are the same spec before and after it was released,
|
7119 |
|
|
so allow mixing them. */
|
7120 |
|
|
if ((iver == EF_ARM_EABI_VER4 && over == EF_ARM_EABI_VER5)
|
7121 |
|
|
|| (iver == EF_ARM_EABI_VER5 && over == EF_ARM_EABI_VER4))
|
7122 |
|
|
return TRUE;
|
7123 |
|
|
|
7124 |
|
|
return (iver == over);
|
7125 |
|
|
}
|
7126 |
|
|
|
7127 |
|
|
/* Merge backend specific data from an object file to the output
|
7128 |
|
|
object file when linking. */
|
7129 |
|
|
|
7130 |
|
|
static bfd_boolean
|
7131 |
|
|
elf32_arm_merge_private_bfd_data (bfd * ibfd, bfd * obfd)
|
7132 |
|
|
{
|
7133 |
|
|
flagword out_flags;
|
7134 |
|
|
flagword in_flags;
|
7135 |
|
|
bfd_boolean flags_compatible = TRUE;
|
7136 |
|
|
asection *sec;
|
7137 |
|
|
|
7138 |
|
|
/* Check if we have the same endianess. */
|
7139 |
|
|
if (! _bfd_generic_verify_endian_match (ibfd, obfd))
|
7140 |
|
|
return FALSE;
|
7141 |
|
|
|
7142 |
|
|
if (! is_arm_elf (ibfd) || ! is_arm_elf (obfd))
|
7143 |
|
|
return TRUE;
|
7144 |
|
|
|
7145 |
|
|
if (!elf32_arm_merge_eabi_attributes (ibfd, obfd))
|
7146 |
|
|
return FALSE;
|
7147 |
|
|
|
7148 |
|
|
/* The input BFD must have had its flags initialised. */
|
7149 |
|
|
/* The following seems bogus to me -- The flags are initialized in
|
7150 |
|
|
the assembler but I don't think an elf_flags_init field is
|
7151 |
|
|
written into the object. */
|
7152 |
|
|
/* BFD_ASSERT (elf_flags_init (ibfd)); */
|
7153 |
|
|
|
7154 |
|
|
in_flags = elf_elfheader (ibfd)->e_flags;
|
7155 |
|
|
out_flags = elf_elfheader (obfd)->e_flags;
|
7156 |
|
|
|
7157 |
|
|
if (!elf_flags_init (obfd))
|
7158 |
|
|
{
|
7159 |
|
|
/* If the input is the default architecture and had the default
|
7160 |
|
|
flags then do not bother setting the flags for the output
|
7161 |
|
|
architecture, instead allow future merges to do this. If no
|
7162 |
|
|
future merges ever set these flags then they will retain their
|
7163 |
|
|
uninitialised values, which surprise surprise, correspond
|
7164 |
|
|
to the default values. */
|
7165 |
|
|
if (bfd_get_arch_info (ibfd)->the_default
|
7166 |
|
|
&& elf_elfheader (ibfd)->e_flags == 0)
|
7167 |
|
|
return TRUE;
|
7168 |
|
|
|
7169 |
|
|
elf_flags_init (obfd) = TRUE;
|
7170 |
|
|
elf_elfheader (obfd)->e_flags = in_flags;
|
7171 |
|
|
|
7172 |
|
|
if (bfd_get_arch (obfd) == bfd_get_arch (ibfd)
|
7173 |
|
|
&& bfd_get_arch_info (obfd)->the_default)
|
7174 |
|
|
return bfd_set_arch_mach (obfd, bfd_get_arch (ibfd), bfd_get_mach (ibfd));
|
7175 |
|
|
|
7176 |
|
|
return TRUE;
|
7177 |
|
|
}
|
7178 |
|
|
|
7179 |
|
|
/* Determine what should happen if the input ARM architecture
|
7180 |
|
|
does not match the output ARM architecture. */
|
7181 |
|
|
if (! bfd_arm_merge_machines (ibfd, obfd))
|
7182 |
|
|
return FALSE;
|
7183 |
|
|
|
7184 |
|
|
/* Identical flags must be compatible. */
|
7185 |
|
|
if (in_flags == out_flags)
|
7186 |
|
|
return TRUE;
|
7187 |
|
|
|
7188 |
|
|
/* Check to see if the input BFD actually contains any sections. If
|
7189 |
|
|
not, its flags may not have been initialised either, but it
|
7190 |
|
|
cannot actually cause any incompatiblity. Do not short-circuit
|
7191 |
|
|
dynamic objects; their section list may be emptied by
|
7192 |
|
|
elf_link_add_object_symbols.
|
7193 |
|
|
|
7194 |
|
|
Also check to see if there are no code sections in the input.
|
7195 |
|
|
In this case there is no need to check for code specific flags.
|
7196 |
|
|
XXX - do we need to worry about floating-point format compatability
|
7197 |
|
|
in data sections ? */
|
7198 |
|
|
if (!(ibfd->flags & DYNAMIC))
|
7199 |
|
|
{
|
7200 |
|
|
bfd_boolean null_input_bfd = TRUE;
|
7201 |
|
|
bfd_boolean only_data_sections = TRUE;
|
7202 |
|
|
|
7203 |
|
|
for (sec = ibfd->sections; sec != NULL; sec = sec->next)
|
7204 |
|
|
{
|
7205 |
|
|
/* Ignore synthetic glue sections. */
|
7206 |
|
|
if (strcmp (sec->name, ".glue_7")
|
7207 |
|
|
&& strcmp (sec->name, ".glue_7t"))
|
7208 |
|
|
{
|
7209 |
|
|
if ((bfd_get_section_flags (ibfd, sec)
|
7210 |
|
|
& (SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS))
|
7211 |
|
|
== (SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS))
|
7212 |
|
|
only_data_sections = FALSE;
|
7213 |
|
|
|
7214 |
|
|
null_input_bfd = FALSE;
|
7215 |
|
|
break;
|
7216 |
|
|
}
|
7217 |
|
|
}
|
7218 |
|
|
|
7219 |
|
|
if (null_input_bfd || only_data_sections)
|
7220 |
|
|
return TRUE;
|
7221 |
|
|
}
|
7222 |
|
|
|
7223 |
|
|
/* Complain about various flag mismatches. */
|
7224 |
|
|
if (!elf32_arm_versions_compatible (EF_ARM_EABI_VERSION (in_flags),
|
7225 |
|
|
EF_ARM_EABI_VERSION (out_flags)))
|
7226 |
|
|
{
|
7227 |
|
|
_bfd_error_handler
|
7228 |
|
|
(_("ERROR: Source object %B has EABI version %d, but target %B has EABI version %d"),
|
7229 |
|
|
ibfd, obfd,
|
7230 |
|
|
(in_flags & EF_ARM_EABIMASK) >> 24,
|
7231 |
|
|
(out_flags & EF_ARM_EABIMASK) >> 24);
|
7232 |
|
|
return FALSE;
|
7233 |
|
|
}
|
7234 |
|
|
|
7235 |
|
|
/* Not sure what needs to be checked for EABI versions >= 1. */
|
7236 |
|
|
/* VxWorks libraries do not use these flags. */
|
7237 |
|
|
if (get_elf_backend_data (obfd) != &elf32_arm_vxworks_bed
|
7238 |
|
|
&& get_elf_backend_data (ibfd) != &elf32_arm_vxworks_bed
|
7239 |
|
|
&& EF_ARM_EABI_VERSION (in_flags) == EF_ARM_EABI_UNKNOWN)
|
7240 |
|
|
{
|
7241 |
|
|
if ((in_flags & EF_ARM_APCS_26) != (out_flags & EF_ARM_APCS_26))
|
7242 |
|
|
{
|
7243 |
|
|
_bfd_error_handler
|
7244 |
|
|
(_("ERROR: %B is compiled for APCS-%d, whereas target %B uses APCS-%d"),
|
7245 |
|
|
ibfd, obfd,
|
7246 |
|
|
in_flags & EF_ARM_APCS_26 ? 26 : 32,
|
7247 |
|
|
out_flags & EF_ARM_APCS_26 ? 26 : 32);
|
7248 |
|
|
flags_compatible = FALSE;
|
7249 |
|
|
}
|
7250 |
|
|
|
7251 |
|
|
if ((in_flags & EF_ARM_APCS_FLOAT) != (out_flags & EF_ARM_APCS_FLOAT))
|
7252 |
|
|
{
|
7253 |
|
|
if (in_flags & EF_ARM_APCS_FLOAT)
|
7254 |
|
|
_bfd_error_handler
|
7255 |
|
|
(_("ERROR: %B passes floats in float registers, whereas %B passes them in integer registers"),
|
7256 |
|
|
ibfd, obfd);
|
7257 |
|
|
else
|
7258 |
|
|
_bfd_error_handler
|
7259 |
|
|
(_("ERROR: %B passes floats in integer registers, whereas %B passes them in float registers"),
|
7260 |
|
|
ibfd, obfd);
|
7261 |
|
|
|
7262 |
|
|
flags_compatible = FALSE;
|
7263 |
|
|
}
|
7264 |
|
|
|
7265 |
|
|
if ((in_flags & EF_ARM_VFP_FLOAT) != (out_flags & EF_ARM_VFP_FLOAT))
|
7266 |
|
|
{
|
7267 |
|
|
if (in_flags & EF_ARM_VFP_FLOAT)
|
7268 |
|
|
_bfd_error_handler
|
7269 |
|
|
(_("ERROR: %B uses VFP instructions, whereas %B does not"),
|
7270 |
|
|
ibfd, obfd);
|
7271 |
|
|
else
|
7272 |
|
|
_bfd_error_handler
|
7273 |
|
|
(_("ERROR: %B uses FPA instructions, whereas %B does not"),
|
7274 |
|
|
ibfd, obfd);
|
7275 |
|
|
|
7276 |
|
|
flags_compatible = FALSE;
|
7277 |
|
|
}
|
7278 |
|
|
|
7279 |
|
|
if ((in_flags & EF_ARM_MAVERICK_FLOAT) != (out_flags & EF_ARM_MAVERICK_FLOAT))
|
7280 |
|
|
{
|
7281 |
|
|
if (in_flags & EF_ARM_MAVERICK_FLOAT)
|
7282 |
|
|
_bfd_error_handler
|
7283 |
|
|
(_("ERROR: %B uses Maverick instructions, whereas %B does not"),
|
7284 |
|
|
ibfd, obfd);
|
7285 |
|
|
else
|
7286 |
|
|
_bfd_error_handler
|
7287 |
|
|
(_("ERROR: %B does not use Maverick instructions, whereas %B does"),
|
7288 |
|
|
ibfd, obfd);
|
7289 |
|
|
|
7290 |
|
|
flags_compatible = FALSE;
|
7291 |
|
|
}
|
7292 |
|
|
|
7293 |
|
|
#ifdef EF_ARM_SOFT_FLOAT
|
7294 |
|
|
if ((in_flags & EF_ARM_SOFT_FLOAT) != (out_flags & EF_ARM_SOFT_FLOAT))
|
7295 |
|
|
{
|
7296 |
|
|
/* We can allow interworking between code that is VFP format
|
7297 |
|
|
layout, and uses either soft float or integer regs for
|
7298 |
|
|
passing floating point arguments and results. We already
|
7299 |
|
|
know that the APCS_FLOAT flags match; similarly for VFP
|
7300 |
|
|
flags. */
|
7301 |
|
|
if ((in_flags & EF_ARM_APCS_FLOAT) != 0
|
7302 |
|
|
|| (in_flags & EF_ARM_VFP_FLOAT) == 0)
|
7303 |
|
|
{
|
7304 |
|
|
if (in_flags & EF_ARM_SOFT_FLOAT)
|
7305 |
|
|
_bfd_error_handler
|
7306 |
|
|
(_("ERROR: %B uses software FP, whereas %B uses hardware FP"),
|
7307 |
|
|
ibfd, obfd);
|
7308 |
|
|
else
|
7309 |
|
|
_bfd_error_handler
|
7310 |
|
|
(_("ERROR: %B uses hardware FP, whereas %B uses software FP"),
|
7311 |
|
|
ibfd, obfd);
|
7312 |
|
|
|
7313 |
|
|
flags_compatible = FALSE;
|
7314 |
|
|
}
|
7315 |
|
|
}
|
7316 |
|
|
#endif
|
7317 |
|
|
|
7318 |
|
|
/* Interworking mismatch is only a warning. */
|
7319 |
|
|
if ((in_flags & EF_ARM_INTERWORK) != (out_flags & EF_ARM_INTERWORK))
|
7320 |
|
|
{
|
7321 |
|
|
if (in_flags & EF_ARM_INTERWORK)
|
7322 |
|
|
{
|
7323 |
|
|
_bfd_error_handler
|
7324 |
|
|
(_("Warning: %B supports interworking, whereas %B does not"),
|
7325 |
|
|
ibfd, obfd);
|
7326 |
|
|
}
|
7327 |
|
|
else
|
7328 |
|
|
{
|
7329 |
|
|
_bfd_error_handler
|
7330 |
|
|
(_("Warning: %B does not support interworking, whereas %B does"),
|
7331 |
|
|
ibfd, obfd);
|
7332 |
|
|
}
|
7333 |
|
|
}
|
7334 |
|
|
}
|
7335 |
|
|
|
7336 |
|
|
return flags_compatible;
|
7337 |
|
|
}
|
7338 |
|
|
|
7339 |
|
|
/* Display the flags field. */
|
7340 |
|
|
|
7341 |
|
|
static bfd_boolean
|
7342 |
|
|
elf32_arm_print_private_bfd_data (bfd *abfd, void * ptr)
|
7343 |
|
|
{
|
7344 |
|
|
FILE * file = (FILE *) ptr;
|
7345 |
|
|
unsigned long flags;
|
7346 |
|
|
|
7347 |
|
|
BFD_ASSERT (abfd != NULL && ptr != NULL);
|
7348 |
|
|
|
7349 |
|
|
/* Print normal ELF private data. */
|
7350 |
|
|
_bfd_elf_print_private_bfd_data (abfd, ptr);
|
7351 |
|
|
|
7352 |
|
|
flags = elf_elfheader (abfd)->e_flags;
|
7353 |
|
|
/* Ignore init flag - it may not be set, despite the flags field
|
7354 |
|
|
containing valid data. */
|
7355 |
|
|
|
7356 |
|
|
/* xgettext:c-format */
|
7357 |
|
|
fprintf (file, _("private flags = %lx:"), elf_elfheader (abfd)->e_flags);
|
7358 |
|
|
|
7359 |
|
|
switch (EF_ARM_EABI_VERSION (flags))
|
7360 |
|
|
{
|
7361 |
|
|
case EF_ARM_EABI_UNKNOWN:
|
7362 |
|
|
/* The following flag bits are GNU extensions and not part of the
|
7363 |
|
|
official ARM ELF extended ABI. Hence they are only decoded if
|
7364 |
|
|
the EABI version is not set. */
|
7365 |
|
|
if (flags & EF_ARM_INTERWORK)
|
7366 |
|
|
fprintf (file, _(" [interworking enabled]"));
|
7367 |
|
|
|
7368 |
|
|
if (flags & EF_ARM_APCS_26)
|
7369 |
|
|
fprintf (file, " [APCS-26]");
|
7370 |
|
|
else
|
7371 |
|
|
fprintf (file, " [APCS-32]");
|
7372 |
|
|
|
7373 |
|
|
if (flags & EF_ARM_VFP_FLOAT)
|
7374 |
|
|
fprintf (file, _(" [VFP float format]"));
|
7375 |
|
|
else if (flags & EF_ARM_MAVERICK_FLOAT)
|
7376 |
|
|
fprintf (file, _(" [Maverick float format]"));
|
7377 |
|
|
else
|
7378 |
|
|
fprintf (file, _(" [FPA float format]"));
|
7379 |
|
|
|
7380 |
|
|
if (flags & EF_ARM_APCS_FLOAT)
|
7381 |
|
|
fprintf (file, _(" [floats passed in float registers]"));
|
7382 |
|
|
|
7383 |
|
|
if (flags & EF_ARM_PIC)
|
7384 |
|
|
fprintf (file, _(" [position independent]"));
|
7385 |
|
|
|
7386 |
|
|
if (flags & EF_ARM_NEW_ABI)
|
7387 |
|
|
fprintf (file, _(" [new ABI]"));
|
7388 |
|
|
|
7389 |
|
|
if (flags & EF_ARM_OLD_ABI)
|
7390 |
|
|
fprintf (file, _(" [old ABI]"));
|
7391 |
|
|
|
7392 |
|
|
if (flags & EF_ARM_SOFT_FLOAT)
|
7393 |
|
|
fprintf (file, _(" [software FP]"));
|
7394 |
|
|
|
7395 |
|
|
flags &= ~(EF_ARM_INTERWORK | EF_ARM_APCS_26 | EF_ARM_APCS_FLOAT
|
7396 |
|
|
| EF_ARM_PIC | EF_ARM_NEW_ABI | EF_ARM_OLD_ABI
|
7397 |
|
|
| EF_ARM_SOFT_FLOAT | EF_ARM_VFP_FLOAT
|
7398 |
|
|
| EF_ARM_MAVERICK_FLOAT);
|
7399 |
|
|
break;
|
7400 |
|
|
|
7401 |
|
|
case EF_ARM_EABI_VER1:
|
7402 |
|
|
fprintf (file, _(" [Version1 EABI]"));
|
7403 |
|
|
|
7404 |
|
|
if (flags & EF_ARM_SYMSARESORTED)
|
7405 |
|
|
fprintf (file, _(" [sorted symbol table]"));
|
7406 |
|
|
else
|
7407 |
|
|
fprintf (file, _(" [unsorted symbol table]"));
|
7408 |
|
|
|
7409 |
|
|
flags &= ~ EF_ARM_SYMSARESORTED;
|
7410 |
|
|
break;
|
7411 |
|
|
|
7412 |
|
|
case EF_ARM_EABI_VER2:
|
7413 |
|
|
fprintf (file, _(" [Version2 EABI]"));
|
7414 |
|
|
|
7415 |
|
|
if (flags & EF_ARM_SYMSARESORTED)
|
7416 |
|
|
fprintf (file, _(" [sorted symbol table]"));
|
7417 |
|
|
else
|
7418 |
|
|
fprintf (file, _(" [unsorted symbol table]"));
|
7419 |
|
|
|
7420 |
|
|
if (flags & EF_ARM_DYNSYMSUSESEGIDX)
|
7421 |
|
|
fprintf (file, _(" [dynamic symbols use segment index]"));
|
7422 |
|
|
|
7423 |
|
|
if (flags & EF_ARM_MAPSYMSFIRST)
|
7424 |
|
|
fprintf (file, _(" [mapping symbols precede others]"));
|
7425 |
|
|
|
7426 |
|
|
flags &= ~(EF_ARM_SYMSARESORTED | EF_ARM_DYNSYMSUSESEGIDX
|
7427 |
|
|
| EF_ARM_MAPSYMSFIRST);
|
7428 |
|
|
break;
|
7429 |
|
|
|
7430 |
|
|
case EF_ARM_EABI_VER3:
|
7431 |
|
|
fprintf (file, _(" [Version3 EABI]"));
|
7432 |
|
|
break;
|
7433 |
|
|
|
7434 |
|
|
case EF_ARM_EABI_VER4:
|
7435 |
|
|
fprintf (file, _(" [Version4 EABI]"));
|
7436 |
|
|
goto eabi;
|
7437 |
|
|
|
7438 |
|
|
case EF_ARM_EABI_VER5:
|
7439 |
|
|
fprintf (file, _(" [Version5 EABI]"));
|
7440 |
|
|
eabi:
|
7441 |
|
|
if (flags & EF_ARM_BE8)
|
7442 |
|
|
fprintf (file, _(" [BE8]"));
|
7443 |
|
|
|
7444 |
|
|
if (flags & EF_ARM_LE8)
|
7445 |
|
|
fprintf (file, _(" [LE8]"));
|
7446 |
|
|
|
7447 |
|
|
flags &= ~(EF_ARM_LE8 | EF_ARM_BE8);
|
7448 |
|
|
break;
|
7449 |
|
|
|
7450 |
|
|
default:
|
7451 |
|
|
fprintf (file, _(" <EABI version unrecognised>"));
|
7452 |
|
|
break;
|
7453 |
|
|
}
|
7454 |
|
|
|
7455 |
|
|
flags &= ~ EF_ARM_EABIMASK;
|
7456 |
|
|
|
7457 |
|
|
if (flags & EF_ARM_RELEXEC)
|
7458 |
|
|
fprintf (file, _(" [relocatable executable]"));
|
7459 |
|
|
|
7460 |
|
|
if (flags & EF_ARM_HASENTRY)
|
7461 |
|
|
fprintf (file, _(" [has entry point]"));
|
7462 |
|
|
|
7463 |
|
|
flags &= ~ (EF_ARM_RELEXEC | EF_ARM_HASENTRY);
|
7464 |
|
|
|
7465 |
|
|
if (flags)
|
7466 |
|
|
fprintf (file, _("<Unrecognised flag bits set>"));
|
7467 |
|
|
|
7468 |
|
|
fputc ('\n', file);
|
7469 |
|
|
|
7470 |
|
|
return TRUE;
|
7471 |
|
|
}
|
7472 |
|
|
|
7473 |
|
|
static int
|
7474 |
|
|
elf32_arm_get_symbol_type (Elf_Internal_Sym * elf_sym, int type)
|
7475 |
|
|
{
|
7476 |
|
|
switch (ELF_ST_TYPE (elf_sym->st_info))
|
7477 |
|
|
{
|
7478 |
|
|
case STT_ARM_TFUNC:
|
7479 |
|
|
return ELF_ST_TYPE (elf_sym->st_info);
|
7480 |
|
|
|
7481 |
|
|
case STT_ARM_16BIT:
|
7482 |
|
|
/* If the symbol is not an object, return the STT_ARM_16BIT flag.
|
7483 |
|
|
This allows us to distinguish between data used by Thumb instructions
|
7484 |
|
|
and non-data (which is probably code) inside Thumb regions of an
|
7485 |
|
|
executable. */
|
7486 |
|
|
if (type != STT_OBJECT && type != STT_TLS)
|
7487 |
|
|
return ELF_ST_TYPE (elf_sym->st_info);
|
7488 |
|
|
break;
|
7489 |
|
|
|
7490 |
|
|
default:
|
7491 |
|
|
break;
|
7492 |
|
|
}
|
7493 |
|
|
|
7494 |
|
|
return type;
|
7495 |
|
|
}
|
7496 |
|
|
|
7497 |
|
|
static asection *
|
7498 |
|
|
elf32_arm_gc_mark_hook (asection *sec,
|
7499 |
|
|
struct bfd_link_info *info,
|
7500 |
|
|
Elf_Internal_Rela *rel,
|
7501 |
|
|
struct elf_link_hash_entry *h,
|
7502 |
|
|
Elf_Internal_Sym *sym)
|
7503 |
|
|
{
|
7504 |
|
|
if (h != NULL)
|
7505 |
|
|
switch (ELF32_R_TYPE (rel->r_info))
|
7506 |
|
|
{
|
7507 |
|
|
case R_ARM_GNU_VTINHERIT:
|
7508 |
|
|
case R_ARM_GNU_VTENTRY:
|
7509 |
|
|
return NULL;
|
7510 |
|
|
}
|
7511 |
|
|
|
7512 |
|
|
return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
|
7513 |
|
|
}
|
7514 |
|
|
|
7515 |
|
|
/* Update the got entry reference counts for the section being removed. */
|
7516 |
|
|
|
7517 |
|
|
static bfd_boolean
|
7518 |
|
|
elf32_arm_gc_sweep_hook (bfd * abfd,
|
7519 |
|
|
struct bfd_link_info * info,
|
7520 |
|
|
asection * sec,
|
7521 |
|
|
const Elf_Internal_Rela * relocs)
|
7522 |
|
|
{
|
7523 |
|
|
Elf_Internal_Shdr *symtab_hdr;
|
7524 |
|
|
struct elf_link_hash_entry **sym_hashes;
|
7525 |
|
|
bfd_signed_vma *local_got_refcounts;
|
7526 |
|
|
const Elf_Internal_Rela *rel, *relend;
|
7527 |
|
|
struct elf32_arm_link_hash_table * globals;
|
7528 |
|
|
|
7529 |
|
|
if (info->relocatable)
|
7530 |
|
|
return TRUE;
|
7531 |
|
|
|
7532 |
|
|
globals = elf32_arm_hash_table (info);
|
7533 |
|
|
|
7534 |
|
|
elf_section_data (sec)->local_dynrel = NULL;
|
7535 |
|
|
|
7536 |
|
|
symtab_hdr = & elf_symtab_hdr (abfd);
|
7537 |
|
|
sym_hashes = elf_sym_hashes (abfd);
|
7538 |
|
|
local_got_refcounts = elf_local_got_refcounts (abfd);
|
7539 |
|
|
|
7540 |
|
|
check_use_blx(globals);
|
7541 |
|
|
|
7542 |
|
|
relend = relocs + sec->reloc_count;
|
7543 |
|
|
for (rel = relocs; rel < relend; rel++)
|
7544 |
|
|
{
|
7545 |
|
|
unsigned long r_symndx;
|
7546 |
|
|
struct elf_link_hash_entry *h = NULL;
|
7547 |
|
|
int r_type;
|
7548 |
|
|
|
7549 |
|
|
r_symndx = ELF32_R_SYM (rel->r_info);
|
7550 |
|
|
if (r_symndx >= symtab_hdr->sh_info)
|
7551 |
|
|
{
|
7552 |
|
|
h = sym_hashes[r_symndx - symtab_hdr->sh_info];
|
7553 |
|
|
while (h->root.type == bfd_link_hash_indirect
|
7554 |
|
|
|| h->root.type == bfd_link_hash_warning)
|
7555 |
|
|
h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
7556 |
|
|
}
|
7557 |
|
|
|
7558 |
|
|
r_type = ELF32_R_TYPE (rel->r_info);
|
7559 |
|
|
r_type = arm_real_reloc_type (globals, r_type);
|
7560 |
|
|
switch (r_type)
|
7561 |
|
|
{
|
7562 |
|
|
case R_ARM_GOT32:
|
7563 |
|
|
case R_ARM_GOT_PREL:
|
7564 |
|
|
case R_ARM_TLS_GD32:
|
7565 |
|
|
case R_ARM_TLS_IE32:
|
7566 |
|
|
if (h != NULL)
|
7567 |
|
|
{
|
7568 |
|
|
if (h->got.refcount > 0)
|
7569 |
|
|
h->got.refcount -= 1;
|
7570 |
|
|
}
|
7571 |
|
|
else if (local_got_refcounts != NULL)
|
7572 |
|
|
{
|
7573 |
|
|
if (local_got_refcounts[r_symndx] > 0)
|
7574 |
|
|
local_got_refcounts[r_symndx] -= 1;
|
7575 |
|
|
}
|
7576 |
|
|
break;
|
7577 |
|
|
|
7578 |
|
|
case R_ARM_TLS_LDM32:
|
7579 |
|
|
elf32_arm_hash_table (info)->tls_ldm_got.refcount -= 1;
|
7580 |
|
|
break;
|
7581 |
|
|
|
7582 |
|
|
case R_ARM_ABS32:
|
7583 |
|
|
case R_ARM_ABS32_NOI:
|
7584 |
|
|
case R_ARM_REL32:
|
7585 |
|
|
case R_ARM_REL32_NOI:
|
7586 |
|
|
case R_ARM_PC24:
|
7587 |
|
|
case R_ARM_PLT32:
|
7588 |
|
|
case R_ARM_CALL:
|
7589 |
|
|
case R_ARM_JUMP24:
|
7590 |
|
|
case R_ARM_PREL31:
|
7591 |
|
|
case R_ARM_THM_CALL:
|
7592 |
|
|
case R_ARM_THM_JUMP24:
|
7593 |
|
|
case R_ARM_THM_JUMP19:
|
7594 |
|
|
case R_ARM_MOVW_ABS_NC:
|
7595 |
|
|
case R_ARM_MOVT_ABS:
|
7596 |
|
|
case R_ARM_MOVW_PREL_NC:
|
7597 |
|
|
case R_ARM_MOVT_PREL:
|
7598 |
|
|
case R_ARM_THM_MOVW_ABS_NC:
|
7599 |
|
|
case R_ARM_THM_MOVT_ABS:
|
7600 |
|
|
case R_ARM_THM_MOVW_PREL_NC:
|
7601 |
|
|
case R_ARM_THM_MOVT_PREL:
|
7602 |
|
|
/* Should the interworking branches be here also? */
|
7603 |
|
|
|
7604 |
|
|
if (h != NULL)
|
7605 |
|
|
{
|
7606 |
|
|
struct elf32_arm_link_hash_entry *eh;
|
7607 |
|
|
struct elf32_arm_relocs_copied **pp;
|
7608 |
|
|
struct elf32_arm_relocs_copied *p;
|
7609 |
|
|
|
7610 |
|
|
eh = (struct elf32_arm_link_hash_entry *) h;
|
7611 |
|
|
|
7612 |
|
|
if (h->plt.refcount > 0)
|
7613 |
|
|
{
|
7614 |
|
|
h->plt.refcount -= 1;
|
7615 |
|
|
if (r_type == R_ARM_THM_CALL)
|
7616 |
|
|
eh->plt_maybe_thumb_refcount--;
|
7617 |
|
|
|
7618 |
|
|
if (r_type == R_ARM_THM_JUMP24
|
7619 |
|
|
|| r_type == R_ARM_THM_JUMP19)
|
7620 |
|
|
eh->plt_thumb_refcount--;
|
7621 |
|
|
}
|
7622 |
|
|
|
7623 |
|
|
if (r_type == R_ARM_ABS32
|
7624 |
|
|
|| r_type == R_ARM_REL32
|
7625 |
|
|
|| r_type == R_ARM_ABS32_NOI
|
7626 |
|
|
|| r_type == R_ARM_REL32_NOI)
|
7627 |
|
|
{
|
7628 |
|
|
for (pp = &eh->relocs_copied; (p = *pp) != NULL;
|
7629 |
|
|
pp = &p->next)
|
7630 |
|
|
if (p->section == sec)
|
7631 |
|
|
{
|
7632 |
|
|
p->count -= 1;
|
7633 |
|
|
if (ELF32_R_TYPE (rel->r_info) == R_ARM_REL32
|
7634 |
|
|
|| ELF32_R_TYPE (rel->r_info) == R_ARM_REL32_NOI)
|
7635 |
|
|
p->pc_count -= 1;
|
7636 |
|
|
if (p->count == 0)
|
7637 |
|
|
*pp = p->next;
|
7638 |
|
|
break;
|
7639 |
|
|
}
|
7640 |
|
|
}
|
7641 |
|
|
}
|
7642 |
|
|
break;
|
7643 |
|
|
|
7644 |
|
|
default:
|
7645 |
|
|
break;
|
7646 |
|
|
}
|
7647 |
|
|
}
|
7648 |
|
|
|
7649 |
|
|
return TRUE;
|
7650 |
|
|
}
|
7651 |
|
|
|
7652 |
|
|
/* Look through the relocs for a section during the first phase. */
|
7653 |
|
|
|
7654 |
|
|
static bfd_boolean
|
7655 |
|
|
elf32_arm_check_relocs (bfd *abfd, struct bfd_link_info *info,
|
7656 |
|
|
asection *sec, const Elf_Internal_Rela *relocs)
|
7657 |
|
|
{
|
7658 |
|
|
Elf_Internal_Shdr *symtab_hdr;
|
7659 |
|
|
struct elf_link_hash_entry **sym_hashes;
|
7660 |
|
|
const Elf_Internal_Rela *rel;
|
7661 |
|
|
const Elf_Internal_Rela *rel_end;
|
7662 |
|
|
bfd *dynobj;
|
7663 |
|
|
asection *sreloc;
|
7664 |
|
|
bfd_vma *local_got_offsets;
|
7665 |
|
|
struct elf32_arm_link_hash_table *htab;
|
7666 |
|
|
|
7667 |
|
|
if (info->relocatable)
|
7668 |
|
|
return TRUE;
|
7669 |
|
|
|
7670 |
|
|
BFD_ASSERT (is_arm_elf (abfd));
|
7671 |
|
|
|
7672 |
|
|
htab = elf32_arm_hash_table (info);
|
7673 |
|
|
sreloc = NULL;
|
7674 |
|
|
|
7675 |
|
|
/* Create dynamic sections for relocatable executables so that we can
|
7676 |
|
|
copy relocations. */
|
7677 |
|
|
if (htab->root.is_relocatable_executable
|
7678 |
|
|
&& ! htab->root.dynamic_sections_created)
|
7679 |
|
|
{
|
7680 |
|
|
if (! _bfd_elf_link_create_dynamic_sections (abfd, info))
|
7681 |
|
|
return FALSE;
|
7682 |
|
|
}
|
7683 |
|
|
|
7684 |
|
|
dynobj = elf_hash_table (info)->dynobj;
|
7685 |
|
|
local_got_offsets = elf_local_got_offsets (abfd);
|
7686 |
|
|
|
7687 |
|
|
symtab_hdr = & elf_symtab_hdr (abfd);
|
7688 |
|
|
sym_hashes = elf_sym_hashes (abfd);
|
7689 |
|
|
|
7690 |
|
|
rel_end = relocs + sec->reloc_count;
|
7691 |
|
|
for (rel = relocs; rel < rel_end; rel++)
|
7692 |
|
|
{
|
7693 |
|
|
struct elf_link_hash_entry *h;
|
7694 |
|
|
struct elf32_arm_link_hash_entry *eh;
|
7695 |
|
|
unsigned long r_symndx;
|
7696 |
|
|
int r_type;
|
7697 |
|
|
|
7698 |
|
|
r_symndx = ELF32_R_SYM (rel->r_info);
|
7699 |
|
|
r_type = ELF32_R_TYPE (rel->r_info);
|
7700 |
|
|
r_type = arm_real_reloc_type (htab, r_type);
|
7701 |
|
|
|
7702 |
|
|
if (r_symndx >= NUM_SHDR_ENTRIES (symtab_hdr))
|
7703 |
|
|
{
|
7704 |
|
|
(*_bfd_error_handler) (_("%B: bad symbol index: %d"), abfd,
|
7705 |
|
|
r_symndx);
|
7706 |
|
|
return FALSE;
|
7707 |
|
|
}
|
7708 |
|
|
|
7709 |
|
|
if (r_symndx < symtab_hdr->sh_info)
|
7710 |
|
|
h = NULL;
|
7711 |
|
|
else
|
7712 |
|
|
{
|
7713 |
|
|
h = sym_hashes[r_symndx - symtab_hdr->sh_info];
|
7714 |
|
|
while (h->root.type == bfd_link_hash_indirect
|
7715 |
|
|
|| h->root.type == bfd_link_hash_warning)
|
7716 |
|
|
h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
7717 |
|
|
}
|
7718 |
|
|
|
7719 |
|
|
eh = (struct elf32_arm_link_hash_entry *) h;
|
7720 |
|
|
|
7721 |
|
|
switch (r_type)
|
7722 |
|
|
{
|
7723 |
|
|
case R_ARM_GOT32:
|
7724 |
|
|
case R_ARM_GOT_PREL:
|
7725 |
|
|
case R_ARM_TLS_GD32:
|
7726 |
|
|
case R_ARM_TLS_IE32:
|
7727 |
|
|
/* This symbol requires a global offset table entry. */
|
7728 |
|
|
{
|
7729 |
|
|
int tls_type, old_tls_type;
|
7730 |
|
|
|
7731 |
|
|
switch (r_type)
|
7732 |
|
|
{
|
7733 |
|
|
case R_ARM_TLS_GD32: tls_type = GOT_TLS_GD; break;
|
7734 |
|
|
case R_ARM_TLS_IE32: tls_type = GOT_TLS_IE; break;
|
7735 |
|
|
default: tls_type = GOT_NORMAL; break;
|
7736 |
|
|
}
|
7737 |
|
|
|
7738 |
|
|
if (h != NULL)
|
7739 |
|
|
{
|
7740 |
|
|
h->got.refcount++;
|
7741 |
|
|
old_tls_type = elf32_arm_hash_entry (h)->tls_type;
|
7742 |
|
|
}
|
7743 |
|
|
else
|
7744 |
|
|
{
|
7745 |
|
|
bfd_signed_vma *local_got_refcounts;
|
7746 |
|
|
|
7747 |
|
|
/* This is a global offset table entry for a local symbol. */
|
7748 |
|
|
local_got_refcounts = elf_local_got_refcounts (abfd);
|
7749 |
|
|
if (local_got_refcounts == NULL)
|
7750 |
|
|
{
|
7751 |
|
|
bfd_size_type size;
|
7752 |
|
|
|
7753 |
|
|
size = symtab_hdr->sh_info;
|
7754 |
|
|
size *= (sizeof (bfd_signed_vma) + sizeof(char));
|
7755 |
|
|
local_got_refcounts = bfd_zalloc (abfd, size);
|
7756 |
|
|
if (local_got_refcounts == NULL)
|
7757 |
|
|
return FALSE;
|
7758 |
|
|
elf_local_got_refcounts (abfd) = local_got_refcounts;
|
7759 |
|
|
elf32_arm_local_got_tls_type (abfd)
|
7760 |
|
|
= (char *) (local_got_refcounts + symtab_hdr->sh_info);
|
7761 |
|
|
}
|
7762 |
|
|
local_got_refcounts[r_symndx] += 1;
|
7763 |
|
|
old_tls_type = elf32_arm_local_got_tls_type (abfd) [r_symndx];
|
7764 |
|
|
}
|
7765 |
|
|
|
7766 |
|
|
/* We will already have issued an error message if there is a
|
7767 |
|
|
TLS / non-TLS mismatch, based on the symbol type. We don't
|
7768 |
|
|
support any linker relaxations. So just combine any TLS
|
7769 |
|
|
types needed. */
|
7770 |
|
|
if (old_tls_type != GOT_UNKNOWN && old_tls_type != GOT_NORMAL
|
7771 |
|
|
&& tls_type != GOT_NORMAL)
|
7772 |
|
|
tls_type |= old_tls_type;
|
7773 |
|
|
|
7774 |
|
|
if (old_tls_type != tls_type)
|
7775 |
|
|
{
|
7776 |
|
|
if (h != NULL)
|
7777 |
|
|
elf32_arm_hash_entry (h)->tls_type = tls_type;
|
7778 |
|
|
else
|
7779 |
|
|
elf32_arm_local_got_tls_type (abfd) [r_symndx] = tls_type;
|
7780 |
|
|
}
|
7781 |
|
|
}
|
7782 |
|
|
/* Fall through */
|
7783 |
|
|
|
7784 |
|
|
case R_ARM_TLS_LDM32:
|
7785 |
|
|
if (r_type == R_ARM_TLS_LDM32)
|
7786 |
|
|
htab->tls_ldm_got.refcount++;
|
7787 |
|
|
/* Fall through */
|
7788 |
|
|
|
7789 |
|
|
case R_ARM_GOTOFF32:
|
7790 |
|
|
case R_ARM_GOTPC:
|
7791 |
|
|
if (htab->sgot == NULL)
|
7792 |
|
|
{
|
7793 |
|
|
if (htab->root.dynobj == NULL)
|
7794 |
|
|
htab->root.dynobj = abfd;
|
7795 |
|
|
if (!create_got_section (htab->root.dynobj, info))
|
7796 |
|
|
return FALSE;
|
7797 |
|
|
}
|
7798 |
|
|
break;
|
7799 |
|
|
|
7800 |
|
|
case R_ARM_ABS12:
|
7801 |
|
|
/* VxWorks uses dynamic R_ARM_ABS12 relocations for
|
7802 |
|
|
ldr __GOTT_INDEX__ offsets. */
|
7803 |
|
|
if (!htab->vxworks_p)
|
7804 |
|
|
break;
|
7805 |
|
|
/* Fall through */
|
7806 |
|
|
|
7807 |
|
|
case R_ARM_ABS32:
|
7808 |
|
|
case R_ARM_ABS32_NOI:
|
7809 |
|
|
case R_ARM_REL32:
|
7810 |
|
|
case R_ARM_REL32_NOI:
|
7811 |
|
|
case R_ARM_PC24:
|
7812 |
|
|
case R_ARM_PLT32:
|
7813 |
|
|
case R_ARM_CALL:
|
7814 |
|
|
case R_ARM_JUMP24:
|
7815 |
|
|
case R_ARM_PREL31:
|
7816 |
|
|
case R_ARM_THM_CALL:
|
7817 |
|
|
case R_ARM_THM_JUMP24:
|
7818 |
|
|
case R_ARM_THM_JUMP19:
|
7819 |
|
|
case R_ARM_MOVW_ABS_NC:
|
7820 |
|
|
case R_ARM_MOVT_ABS:
|
7821 |
|
|
case R_ARM_MOVW_PREL_NC:
|
7822 |
|
|
case R_ARM_MOVT_PREL:
|
7823 |
|
|
case R_ARM_THM_MOVW_ABS_NC:
|
7824 |
|
|
case R_ARM_THM_MOVT_ABS:
|
7825 |
|
|
case R_ARM_THM_MOVW_PREL_NC:
|
7826 |
|
|
case R_ARM_THM_MOVT_PREL:
|
7827 |
|
|
/* Should the interworking branches be listed here? */
|
7828 |
|
|
if (h != NULL)
|
7829 |
|
|
{
|
7830 |
|
|
/* If this reloc is in a read-only section, we might
|
7831 |
|
|
need a copy reloc. We can't check reliably at this
|
7832 |
|
|
stage whether the section is read-only, as input
|
7833 |
|
|
sections have not yet been mapped to output sections.
|
7834 |
|
|
Tentatively set the flag for now, and correct in
|
7835 |
|
|
adjust_dynamic_symbol. */
|
7836 |
|
|
if (!info->shared)
|
7837 |
|
|
h->non_got_ref = 1;
|
7838 |
|
|
|
7839 |
|
|
/* We may need a .plt entry if the function this reloc
|
7840 |
|
|
refers to is in a different object. We can't tell for
|
7841 |
|
|
sure yet, because something later might force the
|
7842 |
|
|
symbol local. */
|
7843 |
|
|
if (r_type != R_ARM_ABS32
|
7844 |
|
|
&& r_type != R_ARM_REL32
|
7845 |
|
|
&& r_type != R_ARM_ABS32_NOI
|
7846 |
|
|
&& r_type != R_ARM_REL32_NOI
|
7847 |
|
|
&& r_type != R_ARM_ABS12)
|
7848 |
|
|
h->needs_plt = 1;
|
7849 |
|
|
|
7850 |
|
|
/* If we create a PLT entry, this relocation will reference
|
7851 |
|
|
it, even if it's an ABS32 relocation. */
|
7852 |
|
|
h->plt.refcount += 1;
|
7853 |
|
|
|
7854 |
|
|
/* It's too early to use htab->use_blx here, so we have to
|
7855 |
|
|
record possible blx references separately from
|
7856 |
|
|
relocs that definitely need a thumb stub. */
|
7857 |
|
|
|
7858 |
|
|
if (r_type == R_ARM_THM_CALL)
|
7859 |
|
|
eh->plt_maybe_thumb_refcount += 1;
|
7860 |
|
|
|
7861 |
|
|
if (r_type == R_ARM_THM_JUMP24
|
7862 |
|
|
|| r_type == R_ARM_THM_JUMP19)
|
7863 |
|
|
eh->plt_thumb_refcount += 1;
|
7864 |
|
|
}
|
7865 |
|
|
|
7866 |
|
|
/* If we are creating a shared library or relocatable executable,
|
7867 |
|
|
and this is a reloc against a global symbol, or a non PC
|
7868 |
|
|
relative reloc against a local symbol, then we need to copy
|
7869 |
|
|
the reloc into the shared library. However, if we are linking
|
7870 |
|
|
with -Bsymbolic, we do not need to copy a reloc against a
|
7871 |
|
|
global symbol which is defined in an object we are
|
7872 |
|
|
including in the link (i.e., DEF_REGULAR is set). At
|
7873 |
|
|
this point we have not seen all the input files, so it is
|
7874 |
|
|
possible that DEF_REGULAR is not set now but will be set
|
7875 |
|
|
later (it is never cleared). We account for that
|
7876 |
|
|
possibility below by storing information in the
|
7877 |
|
|
relocs_copied field of the hash table entry. */
|
7878 |
|
|
if ((info->shared || htab->root.is_relocatable_executable)
|
7879 |
|
|
&& (sec->flags & SEC_ALLOC) != 0
|
7880 |
|
|
&& ((r_type == R_ARM_ABS32 || r_type == R_ARM_ABS32_NOI)
|
7881 |
|
|
|| (h != NULL && ! h->needs_plt
|
7882 |
|
|
&& (! info->symbolic || ! h->def_regular))))
|
7883 |
|
|
{
|
7884 |
|
|
struct elf32_arm_relocs_copied *p, **head;
|
7885 |
|
|
|
7886 |
|
|
/* When creating a shared object, we must copy these
|
7887 |
|
|
reloc types into the output file. We create a reloc
|
7888 |
|
|
section in dynobj and make room for this reloc. */
|
7889 |
|
|
if (sreloc == NULL)
|
7890 |
|
|
{
|
7891 |
|
|
const char * name;
|
7892 |
|
|
|
7893 |
|
|
name = (bfd_elf_string_from_elf_section
|
7894 |
|
|
(abfd,
|
7895 |
|
|
elf_elfheader (abfd)->e_shstrndx,
|
7896 |
|
|
elf_section_data (sec)->rel_hdr.sh_name));
|
7897 |
|
|
if (name == NULL)
|
7898 |
|
|
return FALSE;
|
7899 |
|
|
|
7900 |
|
|
BFD_ASSERT (reloc_section_p (htab, name, sec));
|
7901 |
|
|
|
7902 |
|
|
sreloc = bfd_get_section_by_name (dynobj, name);
|
7903 |
|
|
if (sreloc == NULL)
|
7904 |
|
|
{
|
7905 |
|
|
flagword flags;
|
7906 |
|
|
|
7907 |
|
|
flags = (SEC_HAS_CONTENTS | SEC_READONLY
|
7908 |
|
|
| SEC_IN_MEMORY | SEC_LINKER_CREATED);
|
7909 |
|
|
if ((sec->flags & SEC_ALLOC) != 0
|
7910 |
|
|
/* BPABI objects never have dynamic
|
7911 |
|
|
relocations mapped. */
|
7912 |
|
|
&& !htab->symbian_p)
|
7913 |
|
|
flags |= SEC_ALLOC | SEC_LOAD;
|
7914 |
|
|
sreloc = bfd_make_section_with_flags (dynobj,
|
7915 |
|
|
name,
|
7916 |
|
|
flags);
|
7917 |
|
|
if (sreloc == NULL
|
7918 |
|
|
|| ! bfd_set_section_alignment (dynobj, sreloc, 2))
|
7919 |
|
|
return FALSE;
|
7920 |
|
|
}
|
7921 |
|
|
|
7922 |
|
|
elf_section_data (sec)->sreloc = sreloc;
|
7923 |
|
|
}
|
7924 |
|
|
|
7925 |
|
|
/* If this is a global symbol, we count the number of
|
7926 |
|
|
relocations we need for this symbol. */
|
7927 |
|
|
if (h != NULL)
|
7928 |
|
|
{
|
7929 |
|
|
head = &((struct elf32_arm_link_hash_entry *) h)->relocs_copied;
|
7930 |
|
|
}
|
7931 |
|
|
else
|
7932 |
|
|
{
|
7933 |
|
|
/* Track dynamic relocs needed for local syms too.
|
7934 |
|
|
We really need local syms available to do this
|
7935 |
|
|
easily. Oh well. */
|
7936 |
|
|
|
7937 |
|
|
asection *s;
|
7938 |
|
|
void *vpp;
|
7939 |
|
|
|
7940 |
|
|
s = bfd_section_from_r_symndx (abfd, &htab->sym_sec,
|
7941 |
|
|
sec, r_symndx);
|
7942 |
|
|
if (s == NULL)
|
7943 |
|
|
return FALSE;
|
7944 |
|
|
|
7945 |
|
|
vpp = &elf_section_data (s)->local_dynrel;
|
7946 |
|
|
head = (struct elf32_arm_relocs_copied **) vpp;
|
7947 |
|
|
}
|
7948 |
|
|
|
7949 |
|
|
p = *head;
|
7950 |
|
|
if (p == NULL || p->section != sec)
|
7951 |
|
|
{
|
7952 |
|
|
bfd_size_type amt = sizeof *p;
|
7953 |
|
|
|
7954 |
|
|
p = bfd_alloc (htab->root.dynobj, amt);
|
7955 |
|
|
if (p == NULL)
|
7956 |
|
|
return FALSE;
|
7957 |
|
|
p->next = *head;
|
7958 |
|
|
*head = p;
|
7959 |
|
|
p->section = sec;
|
7960 |
|
|
p->count = 0;
|
7961 |
|
|
p->pc_count = 0;
|
7962 |
|
|
}
|
7963 |
|
|
|
7964 |
|
|
if (r_type == R_ARM_REL32 || r_type == R_ARM_REL32_NOI)
|
7965 |
|
|
p->pc_count += 1;
|
7966 |
|
|
p->count += 1;
|
7967 |
|
|
}
|
7968 |
|
|
break;
|
7969 |
|
|
|
7970 |
|
|
/* This relocation describes the C++ object vtable hierarchy.
|
7971 |
|
|
Reconstruct it for later use during GC. */
|
7972 |
|
|
case R_ARM_GNU_VTINHERIT:
|
7973 |
|
|
if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
|
7974 |
|
|
return FALSE;
|
7975 |
|
|
break;
|
7976 |
|
|
|
7977 |
|
|
/* This relocation describes which C++ vtable entries are actually
|
7978 |
|
|
used. Record for later use during GC. */
|
7979 |
|
|
case R_ARM_GNU_VTENTRY:
|
7980 |
|
|
BFD_ASSERT (h != NULL);
|
7981 |
|
|
if (h != NULL
|
7982 |
|
|
&& !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset))
|
7983 |
|
|
return FALSE;
|
7984 |
|
|
break;
|
7985 |
|
|
}
|
7986 |
|
|
}
|
7987 |
|
|
|
7988 |
|
|
return TRUE;
|
7989 |
|
|
}
|
7990 |
|
|
|
7991 |
|
|
/* Unwinding tables are not referenced directly. This pass marks them as
|
7992 |
|
|
required if the corresponding code section is marked. */
|
7993 |
|
|
|
7994 |
|
|
static bfd_boolean
|
7995 |
|
|
elf32_arm_gc_mark_extra_sections(struct bfd_link_info *info,
|
7996 |
|
|
elf_gc_mark_hook_fn gc_mark_hook)
|
7997 |
|
|
{
|
7998 |
|
|
bfd *sub;
|
7999 |
|
|
Elf_Internal_Shdr **elf_shdrp;
|
8000 |
|
|
bfd_boolean again;
|
8001 |
|
|
|
8002 |
|
|
/* Marking EH data may cause additional code sections to be marked,
|
8003 |
|
|
requiring multiple passes. */
|
8004 |
|
|
again = TRUE;
|
8005 |
|
|
while (again)
|
8006 |
|
|
{
|
8007 |
|
|
again = FALSE;
|
8008 |
|
|
for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
|
8009 |
|
|
{
|
8010 |
|
|
asection *o;
|
8011 |
|
|
|
8012 |
|
|
if (! is_arm_elf (sub))
|
8013 |
|
|
continue;
|
8014 |
|
|
|
8015 |
|
|
elf_shdrp = elf_elfsections (sub);
|
8016 |
|
|
for (o = sub->sections; o != NULL; o = o->next)
|
8017 |
|
|
{
|
8018 |
|
|
Elf_Internal_Shdr *hdr;
|
8019 |
|
|
|
8020 |
|
|
hdr = &elf_section_data (o)->this_hdr;
|
8021 |
|
|
if (hdr->sh_type == SHT_ARM_EXIDX && hdr->sh_link
|
8022 |
|
|
&& !o->gc_mark
|
8023 |
|
|
&& elf_shdrp[hdr->sh_link]->bfd_section->gc_mark)
|
8024 |
|
|
{
|
8025 |
|
|
again = TRUE;
|
8026 |
|
|
if (!_bfd_elf_gc_mark (info, o, gc_mark_hook))
|
8027 |
|
|
return FALSE;
|
8028 |
|
|
}
|
8029 |
|
|
}
|
8030 |
|
|
}
|
8031 |
|
|
}
|
8032 |
|
|
|
8033 |
|
|
return TRUE;
|
8034 |
|
|
}
|
8035 |
|
|
|
8036 |
|
|
/* Treat mapping symbols as special target symbols. */
|
8037 |
|
|
|
8038 |
|
|
static bfd_boolean
|
8039 |
|
|
elf32_arm_is_target_special_symbol (bfd * abfd ATTRIBUTE_UNUSED, asymbol * sym)
|
8040 |
|
|
{
|
8041 |
|
|
return bfd_is_arm_special_symbol_name (sym->name,
|
8042 |
|
|
BFD_ARM_SPECIAL_SYM_TYPE_ANY);
|
8043 |
|
|
}
|
8044 |
|
|
|
8045 |
|
|
/* This is a copy of elf_find_function() from elf.c except that
|
8046 |
|
|
ARM mapping symbols are ignored when looking for function names
|
8047 |
|
|
and STT_ARM_TFUNC is considered to a function type. */
|
8048 |
|
|
|
8049 |
|
|
static bfd_boolean
|
8050 |
|
|
arm_elf_find_function (bfd * abfd ATTRIBUTE_UNUSED,
|
8051 |
|
|
asection * section,
|
8052 |
|
|
asymbol ** symbols,
|
8053 |
|
|
bfd_vma offset,
|
8054 |
|
|
const char ** filename_ptr,
|
8055 |
|
|
const char ** functionname_ptr)
|
8056 |
|
|
{
|
8057 |
|
|
const char * filename = NULL;
|
8058 |
|
|
asymbol * func = NULL;
|
8059 |
|
|
bfd_vma low_func = 0;
|
8060 |
|
|
asymbol ** p;
|
8061 |
|
|
|
8062 |
|
|
for (p = symbols; *p != NULL; p++)
|
8063 |
|
|
{
|
8064 |
|
|
elf_symbol_type *q;
|
8065 |
|
|
|
8066 |
|
|
q = (elf_symbol_type *) *p;
|
8067 |
|
|
|
8068 |
|
|
switch (ELF_ST_TYPE (q->internal_elf_sym.st_info))
|
8069 |
|
|
{
|
8070 |
|
|
default:
|
8071 |
|
|
break;
|
8072 |
|
|
case STT_FILE:
|
8073 |
|
|
filename = bfd_asymbol_name (&q->symbol);
|
8074 |
|
|
break;
|
8075 |
|
|
case STT_FUNC:
|
8076 |
|
|
case STT_ARM_TFUNC:
|
8077 |
|
|
case STT_NOTYPE:
|
8078 |
|
|
/* Skip mapping symbols. */
|
8079 |
|
|
if ((q->symbol.flags & BSF_LOCAL)
|
8080 |
|
|
&& bfd_is_arm_special_symbol_name (q->symbol.name,
|
8081 |
|
|
BFD_ARM_SPECIAL_SYM_TYPE_ANY))
|
8082 |
|
|
continue;
|
8083 |
|
|
/* Fall through. */
|
8084 |
|
|
if (bfd_get_section (&q->symbol) == section
|
8085 |
|
|
&& q->symbol.value >= low_func
|
8086 |
|
|
&& q->symbol.value <= offset)
|
8087 |
|
|
{
|
8088 |
|
|
func = (asymbol *) q;
|
8089 |
|
|
low_func = q->symbol.value;
|
8090 |
|
|
}
|
8091 |
|
|
break;
|
8092 |
|
|
}
|
8093 |
|
|
}
|
8094 |
|
|
|
8095 |
|
|
if (func == NULL)
|
8096 |
|
|
return FALSE;
|
8097 |
|
|
|
8098 |
|
|
if (filename_ptr)
|
8099 |
|
|
*filename_ptr = filename;
|
8100 |
|
|
if (functionname_ptr)
|
8101 |
|
|
*functionname_ptr = bfd_asymbol_name (func);
|
8102 |
|
|
|
8103 |
|
|
return TRUE;
|
8104 |
|
|
}
|
8105 |
|
|
|
8106 |
|
|
|
8107 |
|
|
/* Find the nearest line to a particular section and offset, for error
|
8108 |
|
|
reporting. This code is a duplicate of the code in elf.c, except
|
8109 |
|
|
that it uses arm_elf_find_function. */
|
8110 |
|
|
|
8111 |
|
|
static bfd_boolean
|
8112 |
|
|
elf32_arm_find_nearest_line (bfd * abfd,
|
8113 |
|
|
asection * section,
|
8114 |
|
|
asymbol ** symbols,
|
8115 |
|
|
bfd_vma offset,
|
8116 |
|
|
const char ** filename_ptr,
|
8117 |
|
|
const char ** functionname_ptr,
|
8118 |
|
|
unsigned int * line_ptr)
|
8119 |
|
|
{
|
8120 |
|
|
bfd_boolean found = FALSE;
|
8121 |
|
|
|
8122 |
|
|
/* We skip _bfd_dwarf1_find_nearest_line since no known ARM toolchain uses it. */
|
8123 |
|
|
|
8124 |
|
|
if (_bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset,
|
8125 |
|
|
filename_ptr, functionname_ptr,
|
8126 |
|
|
line_ptr, 0,
|
8127 |
|
|
& elf_tdata (abfd)->dwarf2_find_line_info))
|
8128 |
|
|
{
|
8129 |
|
|
if (!*functionname_ptr)
|
8130 |
|
|
arm_elf_find_function (abfd, section, symbols, offset,
|
8131 |
|
|
*filename_ptr ? NULL : filename_ptr,
|
8132 |
|
|
functionname_ptr);
|
8133 |
|
|
|
8134 |
|
|
return TRUE;
|
8135 |
|
|
}
|
8136 |
|
|
|
8137 |
|
|
if (! _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset,
|
8138 |
|
|
& found, filename_ptr,
|
8139 |
|
|
functionname_ptr, line_ptr,
|
8140 |
|
|
& elf_tdata (abfd)->line_info))
|
8141 |
|
|
return FALSE;
|
8142 |
|
|
|
8143 |
|
|
if (found && (*functionname_ptr || *line_ptr))
|
8144 |
|
|
return TRUE;
|
8145 |
|
|
|
8146 |
|
|
if (symbols == NULL)
|
8147 |
|
|
return FALSE;
|
8148 |
|
|
|
8149 |
|
|
if (! arm_elf_find_function (abfd, section, symbols, offset,
|
8150 |
|
|
filename_ptr, functionname_ptr))
|
8151 |
|
|
return FALSE;
|
8152 |
|
|
|
8153 |
|
|
*line_ptr = 0;
|
8154 |
|
|
return TRUE;
|
8155 |
|
|
}
|
8156 |
|
|
|
8157 |
|
|
static bfd_boolean
|
8158 |
|
|
elf32_arm_find_inliner_info (bfd * abfd,
|
8159 |
|
|
const char ** filename_ptr,
|
8160 |
|
|
const char ** functionname_ptr,
|
8161 |
|
|
unsigned int * line_ptr)
|
8162 |
|
|
{
|
8163 |
|
|
bfd_boolean found;
|
8164 |
|
|
found = _bfd_dwarf2_find_inliner_info (abfd, filename_ptr,
|
8165 |
|
|
functionname_ptr, line_ptr,
|
8166 |
|
|
& elf_tdata (abfd)->dwarf2_find_line_info);
|
8167 |
|
|
return found;
|
8168 |
|
|
}
|
8169 |
|
|
|
8170 |
|
|
/* Adjust a symbol defined by a dynamic object and referenced by a
|
8171 |
|
|
regular object. The current definition is in some section of the
|
8172 |
|
|
dynamic object, but we're not including those sections. We have to
|
8173 |
|
|
change the definition to something the rest of the link can
|
8174 |
|
|
understand. */
|
8175 |
|
|
|
8176 |
|
|
static bfd_boolean
|
8177 |
|
|
elf32_arm_adjust_dynamic_symbol (struct bfd_link_info * info,
|
8178 |
|
|
struct elf_link_hash_entry * h)
|
8179 |
|
|
{
|
8180 |
|
|
bfd * dynobj;
|
8181 |
|
|
asection * s;
|
8182 |
|
|
struct elf32_arm_link_hash_entry * eh;
|
8183 |
|
|
struct elf32_arm_link_hash_table *globals;
|
8184 |
|
|
|
8185 |
|
|
globals = elf32_arm_hash_table (info);
|
8186 |
|
|
dynobj = elf_hash_table (info)->dynobj;
|
8187 |
|
|
|
8188 |
|
|
/* Make sure we know what is going on here. */
|
8189 |
|
|
BFD_ASSERT (dynobj != NULL
|
8190 |
|
|
&& (h->needs_plt
|
8191 |
|
|
|| h->u.weakdef != NULL
|
8192 |
|
|
|| (h->def_dynamic
|
8193 |
|
|
&& h->ref_regular
|
8194 |
|
|
&& !h->def_regular)));
|
8195 |
|
|
|
8196 |
|
|
eh = (struct elf32_arm_link_hash_entry *) h;
|
8197 |
|
|
|
8198 |
|
|
/* If this is a function, put it in the procedure linkage table. We
|
8199 |
|
|
will fill in the contents of the procedure linkage table later,
|
8200 |
|
|
when we know the address of the .got section. */
|
8201 |
|
|
if (h->type == STT_FUNC || h->type == STT_ARM_TFUNC
|
8202 |
|
|
|| h->needs_plt)
|
8203 |
|
|
{
|
8204 |
|
|
if (h->plt.refcount <= 0
|
8205 |
|
|
|| SYMBOL_CALLS_LOCAL (info, h)
|
8206 |
|
|
|| (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
|
8207 |
|
|
&& h->root.type == bfd_link_hash_undefweak))
|
8208 |
|
|
{
|
8209 |
|
|
/* This case can occur if we saw a PLT32 reloc in an input
|
8210 |
|
|
file, but the symbol was never referred to by a dynamic
|
8211 |
|
|
object, or if all references were garbage collected. In
|
8212 |
|
|
such a case, we don't actually need to build a procedure
|
8213 |
|
|
linkage table, and we can just do a PC24 reloc instead. */
|
8214 |
|
|
h->plt.offset = (bfd_vma) -1;
|
8215 |
|
|
eh->plt_thumb_refcount = 0;
|
8216 |
|
|
eh->plt_maybe_thumb_refcount = 0;
|
8217 |
|
|
h->needs_plt = 0;
|
8218 |
|
|
}
|
8219 |
|
|
|
8220 |
|
|
return TRUE;
|
8221 |
|
|
}
|
8222 |
|
|
else
|
8223 |
|
|
{
|
8224 |
|
|
/* It's possible that we incorrectly decided a .plt reloc was
|
8225 |
|
|
needed for an R_ARM_PC24 or similar reloc to a non-function sym
|
8226 |
|
|
in check_relocs. We can't decide accurately between function
|
8227 |
|
|
and non-function syms in check-relocs; Objects loaded later in
|
8228 |
|
|
the link may change h->type. So fix it now. */
|
8229 |
|
|
h->plt.offset = (bfd_vma) -1;
|
8230 |
|
|
eh->plt_thumb_refcount = 0;
|
8231 |
|
|
eh->plt_maybe_thumb_refcount = 0;
|
8232 |
|
|
}
|
8233 |
|
|
|
8234 |
|
|
/* If this is a weak symbol, and there is a real definition, the
|
8235 |
|
|
processor independent code will have arranged for us to see the
|
8236 |
|
|
real definition first, and we can just use the same value. */
|
8237 |
|
|
if (h->u.weakdef != NULL)
|
8238 |
|
|
{
|
8239 |
|
|
BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined
|
8240 |
|
|
|| h->u.weakdef->root.type == bfd_link_hash_defweak);
|
8241 |
|
|
h->root.u.def.section = h->u.weakdef->root.u.def.section;
|
8242 |
|
|
h->root.u.def.value = h->u.weakdef->root.u.def.value;
|
8243 |
|
|
return TRUE;
|
8244 |
|
|
}
|
8245 |
|
|
|
8246 |
|
|
/* If there are no non-GOT references, we do not need a copy
|
8247 |
|
|
relocation. */
|
8248 |
|
|
if (!h->non_got_ref)
|
8249 |
|
|
return TRUE;
|
8250 |
|
|
|
8251 |
|
|
/* This is a reference to a symbol defined by a dynamic object which
|
8252 |
|
|
is not a function. */
|
8253 |
|
|
|
8254 |
|
|
/* If we are creating a shared library, we must presume that the
|
8255 |
|
|
only references to the symbol are via the global offset table.
|
8256 |
|
|
For such cases we need not do anything here; the relocations will
|
8257 |
|
|
be handled correctly by relocate_section. Relocatable executables
|
8258 |
|
|
can reference data in shared objects directly, so we don't need to
|
8259 |
|
|
do anything here. */
|
8260 |
|
|
if (info->shared || globals->root.is_relocatable_executable)
|
8261 |
|
|
return TRUE;
|
8262 |
|
|
|
8263 |
|
|
if (h->size == 0)
|
8264 |
|
|
{
|
8265 |
|
|
(*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
|
8266 |
|
|
h->root.root.string);
|
8267 |
|
|
return TRUE;
|
8268 |
|
|
}
|
8269 |
|
|
|
8270 |
|
|
/* We must allocate the symbol in our .dynbss section, which will
|
8271 |
|
|
become part of the .bss section of the executable. There will be
|
8272 |
|
|
an entry for this symbol in the .dynsym section. The dynamic
|
8273 |
|
|
object will contain position independent code, so all references
|
8274 |
|
|
from the dynamic object to this symbol will go through the global
|
8275 |
|
|
offset table. The dynamic linker will use the .dynsym entry to
|
8276 |
|
|
determine the address it must put in the global offset table, so
|
8277 |
|
|
both the dynamic object and the regular object will refer to the
|
8278 |
|
|
same memory location for the variable. */
|
8279 |
|
|
s = bfd_get_section_by_name (dynobj, ".dynbss");
|
8280 |
|
|
BFD_ASSERT (s != NULL);
|
8281 |
|
|
|
8282 |
|
|
/* We must generate a R_ARM_COPY reloc to tell the dynamic linker to
|
8283 |
|
|
copy the initial value out of the dynamic object and into the
|
8284 |
|
|
runtime process image. We need to remember the offset into the
|
8285 |
|
|
.rel(a).bss section we are going to use. */
|
8286 |
|
|
if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
|
8287 |
|
|
{
|
8288 |
|
|
asection *srel;
|
8289 |
|
|
|
8290 |
|
|
srel = bfd_get_section_by_name (dynobj, RELOC_SECTION (globals, ".bss"));
|
8291 |
|
|
BFD_ASSERT (srel != NULL);
|
8292 |
|
|
srel->size += RELOC_SIZE (globals);
|
8293 |
|
|
h->needs_copy = 1;
|
8294 |
|
|
}
|
8295 |
|
|
|
8296 |
|
|
return _bfd_elf_adjust_dynamic_copy (h, s);
|
8297 |
|
|
}
|
8298 |
|
|
|
8299 |
|
|
/* Allocate space in .plt, .got and associated reloc sections for
|
8300 |
|
|
dynamic relocs. */
|
8301 |
|
|
|
8302 |
|
|
static bfd_boolean
|
8303 |
|
|
allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
|
8304 |
|
|
{
|
8305 |
|
|
struct bfd_link_info *info;
|
8306 |
|
|
struct elf32_arm_link_hash_table *htab;
|
8307 |
|
|
struct elf32_arm_link_hash_entry *eh;
|
8308 |
|
|
struct elf32_arm_relocs_copied *p;
|
8309 |
|
|
bfd_signed_vma thumb_refs;
|
8310 |
|
|
|
8311 |
|
|
eh = (struct elf32_arm_link_hash_entry *) h;
|
8312 |
|
|
|
8313 |
|
|
if (h->root.type == bfd_link_hash_indirect)
|
8314 |
|
|
return TRUE;
|
8315 |
|
|
|
8316 |
|
|
if (h->root.type == bfd_link_hash_warning)
|
8317 |
|
|
/* When warning symbols are created, they **replace** the "real"
|
8318 |
|
|
entry in the hash table, thus we never get to see the real
|
8319 |
|
|
symbol in a hash traversal. So look at it now. */
|
8320 |
|
|
h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
8321 |
|
|
|
8322 |
|
|
info = (struct bfd_link_info *) inf;
|
8323 |
|
|
htab = elf32_arm_hash_table (info);
|
8324 |
|
|
|
8325 |
|
|
if (htab->root.dynamic_sections_created
|
8326 |
|
|
&& h->plt.refcount > 0)
|
8327 |
|
|
{
|
8328 |
|
|
/* Make sure this symbol is output as a dynamic symbol.
|
8329 |
|
|
Undefined weak syms won't yet be marked as dynamic. */
|
8330 |
|
|
if (h->dynindx == -1
|
8331 |
|
|
&& !h->forced_local)
|
8332 |
|
|
{
|
8333 |
|
|
if (! bfd_elf_link_record_dynamic_symbol (info, h))
|
8334 |
|
|
return FALSE;
|
8335 |
|
|
}
|
8336 |
|
|
|
8337 |
|
|
if (info->shared
|
8338 |
|
|
|| WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, 0, h))
|
8339 |
|
|
{
|
8340 |
|
|
asection *s = htab->splt;
|
8341 |
|
|
|
8342 |
|
|
/* If this is the first .plt entry, make room for the special
|
8343 |
|
|
first entry. */
|
8344 |
|
|
if (s->size == 0)
|
8345 |
|
|
s->size += htab->plt_header_size;
|
8346 |
|
|
|
8347 |
|
|
h->plt.offset = s->size;
|
8348 |
|
|
|
8349 |
|
|
/* If we will insert a Thumb trampoline before this PLT, leave room
|
8350 |
|
|
for it. */
|
8351 |
|
|
thumb_refs = eh->plt_thumb_refcount;
|
8352 |
|
|
if (!htab->use_blx)
|
8353 |
|
|
thumb_refs += eh->plt_maybe_thumb_refcount;
|
8354 |
|
|
|
8355 |
|
|
if (thumb_refs > 0)
|
8356 |
|
|
{
|
8357 |
|
|
h->plt.offset += PLT_THUMB_STUB_SIZE;
|
8358 |
|
|
s->size += PLT_THUMB_STUB_SIZE;
|
8359 |
|
|
}
|
8360 |
|
|
|
8361 |
|
|
/* If this symbol is not defined in a regular file, and we are
|
8362 |
|
|
not generating a shared library, then set the symbol to this
|
8363 |
|
|
location in the .plt. This is required to make function
|
8364 |
|
|
pointers compare as equal between the normal executable and
|
8365 |
|
|
the shared library. */
|
8366 |
|
|
if (! info->shared
|
8367 |
|
|
&& !h->def_regular)
|
8368 |
|
|
{
|
8369 |
|
|
h->root.u.def.section = s;
|
8370 |
|
|
h->root.u.def.value = h->plt.offset;
|
8371 |
|
|
|
8372 |
|
|
/* Make sure the function is not marked as Thumb, in case
|
8373 |
|
|
it is the target of an ABS32 relocation, which will
|
8374 |
|
|
point to the PLT entry. */
|
8375 |
|
|
if (ELF_ST_TYPE (h->type) == STT_ARM_TFUNC)
|
8376 |
|
|
h->type = ELF_ST_INFO (ELF_ST_BIND (h->type), STT_FUNC);
|
8377 |
|
|
}
|
8378 |
|
|
|
8379 |
|
|
/* Make room for this entry. */
|
8380 |
|
|
s->size += htab->plt_entry_size;
|
8381 |
|
|
|
8382 |
|
|
if (!htab->symbian_p)
|
8383 |
|
|
{
|
8384 |
|
|
/* We also need to make an entry in the .got.plt section, which
|
8385 |
|
|
will be placed in the .got section by the linker script. */
|
8386 |
|
|
eh->plt_got_offset = htab->sgotplt->size;
|
8387 |
|
|
htab->sgotplt->size += 4;
|
8388 |
|
|
}
|
8389 |
|
|
|
8390 |
|
|
/* We also need to make an entry in the .rel(a).plt section. */
|
8391 |
|
|
htab->srelplt->size += RELOC_SIZE (htab);
|
8392 |
|
|
|
8393 |
|
|
/* VxWorks executables have a second set of relocations for
|
8394 |
|
|
each PLT entry. They go in a separate relocation section,
|
8395 |
|
|
which is processed by the kernel loader. */
|
8396 |
|
|
if (htab->vxworks_p && !info->shared)
|
8397 |
|
|
{
|
8398 |
|
|
/* There is a relocation for the initial PLT entry:
|
8399 |
|
|
an R_ARM_32 relocation for _GLOBAL_OFFSET_TABLE_. */
|
8400 |
|
|
if (h->plt.offset == htab->plt_header_size)
|
8401 |
|
|
htab->srelplt2->size += RELOC_SIZE (htab);
|
8402 |
|
|
|
8403 |
|
|
/* There are two extra relocations for each subsequent
|
8404 |
|
|
PLT entry: an R_ARM_32 relocation for the GOT entry,
|
8405 |
|
|
and an R_ARM_32 relocation for the PLT entry. */
|
8406 |
|
|
htab->srelplt2->size += RELOC_SIZE (htab) * 2;
|
8407 |
|
|
}
|
8408 |
|
|
}
|
8409 |
|
|
else
|
8410 |
|
|
{
|
8411 |
|
|
h->plt.offset = (bfd_vma) -1;
|
8412 |
|
|
h->needs_plt = 0;
|
8413 |
|
|
}
|
8414 |
|
|
}
|
8415 |
|
|
else
|
8416 |
|
|
{
|
8417 |
|
|
h->plt.offset = (bfd_vma) -1;
|
8418 |
|
|
h->needs_plt = 0;
|
8419 |
|
|
}
|
8420 |
|
|
|
8421 |
|
|
if (h->got.refcount > 0)
|
8422 |
|
|
{
|
8423 |
|
|
asection *s;
|
8424 |
|
|
bfd_boolean dyn;
|
8425 |
|
|
int tls_type = elf32_arm_hash_entry (h)->tls_type;
|
8426 |
|
|
int indx;
|
8427 |
|
|
|
8428 |
|
|
/* Make sure this symbol is output as a dynamic symbol.
|
8429 |
|
|
Undefined weak syms won't yet be marked as dynamic. */
|
8430 |
|
|
if (h->dynindx == -1
|
8431 |
|
|
&& !h->forced_local)
|
8432 |
|
|
{
|
8433 |
|
|
if (! bfd_elf_link_record_dynamic_symbol (info, h))
|
8434 |
|
|
return FALSE;
|
8435 |
|
|
}
|
8436 |
|
|
|
8437 |
|
|
if (!htab->symbian_p)
|
8438 |
|
|
{
|
8439 |
|
|
s = htab->sgot;
|
8440 |
|
|
h->got.offset = s->size;
|
8441 |
|
|
|
8442 |
|
|
if (tls_type == GOT_UNKNOWN)
|
8443 |
|
|
abort ();
|
8444 |
|
|
|
8445 |
|
|
if (tls_type == GOT_NORMAL)
|
8446 |
|
|
/* Non-TLS symbols need one GOT slot. */
|
8447 |
|
|
s->size += 4;
|
8448 |
|
|
else
|
8449 |
|
|
{
|
8450 |
|
|
if (tls_type & GOT_TLS_GD)
|
8451 |
|
|
/* R_ARM_TLS_GD32 needs 2 consecutive GOT slots. */
|
8452 |
|
|
s->size += 8;
|
8453 |
|
|
if (tls_type & GOT_TLS_IE)
|
8454 |
|
|
/* R_ARM_TLS_IE32 needs one GOT slot. */
|
8455 |
|
|
s->size += 4;
|
8456 |
|
|
}
|
8457 |
|
|
|
8458 |
|
|
dyn = htab->root.dynamic_sections_created;
|
8459 |
|
|
|
8460 |
|
|
indx = 0;
|
8461 |
|
|
if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)
|
8462 |
|
|
&& (!info->shared
|
8463 |
|
|
|| !SYMBOL_REFERENCES_LOCAL (info, h)))
|
8464 |
|
|
indx = h->dynindx;
|
8465 |
|
|
|
8466 |
|
|
if (tls_type != GOT_NORMAL
|
8467 |
|
|
&& (info->shared || indx != 0)
|
8468 |
|
|
&& (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|
8469 |
|
|
|| h->root.type != bfd_link_hash_undefweak))
|
8470 |
|
|
{
|
8471 |
|
|
if (tls_type & GOT_TLS_IE)
|
8472 |
|
|
htab->srelgot->size += RELOC_SIZE (htab);
|
8473 |
|
|
|
8474 |
|
|
if (tls_type & GOT_TLS_GD)
|
8475 |
|
|
htab->srelgot->size += RELOC_SIZE (htab);
|
8476 |
|
|
|
8477 |
|
|
if ((tls_type & GOT_TLS_GD) && indx != 0)
|
8478 |
|
|
htab->srelgot->size += RELOC_SIZE (htab);
|
8479 |
|
|
}
|
8480 |
|
|
else if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|
8481 |
|
|
|| h->root.type != bfd_link_hash_undefweak)
|
8482 |
|
|
&& (info->shared
|
8483 |
|
|
|| WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h)))
|
8484 |
|
|
htab->srelgot->size += RELOC_SIZE (htab);
|
8485 |
|
|
}
|
8486 |
|
|
}
|
8487 |
|
|
else
|
8488 |
|
|
h->got.offset = (bfd_vma) -1;
|
8489 |
|
|
|
8490 |
|
|
/* Allocate stubs for exported Thumb functions on v4t. */
|
8491 |
|
|
if (!htab->use_blx && h->dynindx != -1
|
8492 |
|
|
&& h->def_regular
|
8493 |
|
|
&& ELF_ST_TYPE (h->type) == STT_ARM_TFUNC
|
8494 |
|
|
&& ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
|
8495 |
|
|
{
|
8496 |
|
|
struct elf_link_hash_entry * th;
|
8497 |
|
|
struct bfd_link_hash_entry * bh;
|
8498 |
|
|
struct elf_link_hash_entry * myh;
|
8499 |
|
|
char name[1024];
|
8500 |
|
|
asection *s;
|
8501 |
|
|
bh = NULL;
|
8502 |
|
|
/* Create a new symbol to regist the real location of the function. */
|
8503 |
|
|
s = h->root.u.def.section;
|
8504 |
|
|
sprintf(name, "__real_%s", h->root.root.string);
|
8505 |
|
|
_bfd_generic_link_add_one_symbol (info, s->owner,
|
8506 |
|
|
name, BSF_GLOBAL, s,
|
8507 |
|
|
h->root.u.def.value,
|
8508 |
|
|
NULL, TRUE, FALSE, &bh);
|
8509 |
|
|
|
8510 |
|
|
myh = (struct elf_link_hash_entry *) bh;
|
8511 |
|
|
myh->type = ELF_ST_INFO (STB_LOCAL, STT_ARM_TFUNC);
|
8512 |
|
|
myh->forced_local = 1;
|
8513 |
|
|
eh->export_glue = myh;
|
8514 |
|
|
th = record_arm_to_thumb_glue (info, h);
|
8515 |
|
|
/* Point the symbol at the stub. */
|
8516 |
|
|
h->type = ELF_ST_INFO (ELF_ST_BIND (h->type), STT_FUNC);
|
8517 |
|
|
h->root.u.def.section = th->root.u.def.section;
|
8518 |
|
|
h->root.u.def.value = th->root.u.def.value & ~1;
|
8519 |
|
|
}
|
8520 |
|
|
|
8521 |
|
|
if (eh->relocs_copied == NULL)
|
8522 |
|
|
return TRUE;
|
8523 |
|
|
|
8524 |
|
|
/* In the shared -Bsymbolic case, discard space allocated for
|
8525 |
|
|
dynamic pc-relative relocs against symbols which turn out to be
|
8526 |
|
|
defined in regular objects. For the normal shared case, discard
|
8527 |
|
|
space for pc-relative relocs that have become local due to symbol
|
8528 |
|
|
visibility changes. */
|
8529 |
|
|
|
8530 |
|
|
if (info->shared || htab->root.is_relocatable_executable)
|
8531 |
|
|
{
|
8532 |
|
|
/* The only relocs that use pc_count are R_ARM_REL32 and
|
8533 |
|
|
R_ARM_REL32_NOI, which will appear on something like
|
8534 |
|
|
".long foo - .". We want calls to protected symbols to resolve
|
8535 |
|
|
directly to the function rather than going via the plt. If people
|
8536 |
|
|
want function pointer comparisons to work as expected then they
|
8537 |
|
|
should avoid writing assembly like ".long foo - .". */
|
8538 |
|
|
if (SYMBOL_CALLS_LOCAL (info, h))
|
8539 |
|
|
{
|
8540 |
|
|
struct elf32_arm_relocs_copied **pp;
|
8541 |
|
|
|
8542 |
|
|
for (pp = &eh->relocs_copied; (p = *pp) != NULL; )
|
8543 |
|
|
{
|
8544 |
|
|
p->count -= p->pc_count;
|
8545 |
|
|
p->pc_count = 0;
|
8546 |
|
|
if (p->count == 0)
|
8547 |
|
|
*pp = p->next;
|
8548 |
|
|
else
|
8549 |
|
|
pp = &p->next;
|
8550 |
|
|
}
|
8551 |
|
|
}
|
8552 |
|
|
|
8553 |
|
|
/* Also discard relocs on undefined weak syms with non-default
|
8554 |
|
|
visibility. */
|
8555 |
|
|
if (eh->relocs_copied != NULL
|
8556 |
|
|
&& h->root.type == bfd_link_hash_undefweak)
|
8557 |
|
|
{
|
8558 |
|
|
if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
|
8559 |
|
|
eh->relocs_copied = NULL;
|
8560 |
|
|
|
8561 |
|
|
/* Make sure undefined weak symbols are output as a dynamic
|
8562 |
|
|
symbol in PIEs. */
|
8563 |
|
|
else if (h->dynindx == -1
|
8564 |
|
|
&& !h->forced_local)
|
8565 |
|
|
{
|
8566 |
|
|
if (! bfd_elf_link_record_dynamic_symbol (info, h))
|
8567 |
|
|
return FALSE;
|
8568 |
|
|
}
|
8569 |
|
|
}
|
8570 |
|
|
|
8571 |
|
|
else if (htab->root.is_relocatable_executable && h->dynindx == -1
|
8572 |
|
|
&& h->root.type == bfd_link_hash_new)
|
8573 |
|
|
{
|
8574 |
|
|
/* Output absolute symbols so that we can create relocations
|
8575 |
|
|
against them. For normal symbols we output a relocation
|
8576 |
|
|
against the section that contains them. */
|
8577 |
|
|
if (! bfd_elf_link_record_dynamic_symbol (info, h))
|
8578 |
|
|
return FALSE;
|
8579 |
|
|
}
|
8580 |
|
|
|
8581 |
|
|
}
|
8582 |
|
|
else
|
8583 |
|
|
{
|
8584 |
|
|
/* For the non-shared case, discard space for relocs against
|
8585 |
|
|
symbols which turn out to need copy relocs or are not
|
8586 |
|
|
dynamic. */
|
8587 |
|
|
|
8588 |
|
|
if (!h->non_got_ref
|
8589 |
|
|
&& ((h->def_dynamic
|
8590 |
|
|
&& !h->def_regular)
|
8591 |
|
|
|| (htab->root.dynamic_sections_created
|
8592 |
|
|
&& (h->root.type == bfd_link_hash_undefweak
|
8593 |
|
|
|| h->root.type == bfd_link_hash_undefined))))
|
8594 |
|
|
{
|
8595 |
|
|
/* Make sure this symbol is output as a dynamic symbol.
|
8596 |
|
|
Undefined weak syms won't yet be marked as dynamic. */
|
8597 |
|
|
if (h->dynindx == -1
|
8598 |
|
|
&& !h->forced_local)
|
8599 |
|
|
{
|
8600 |
|
|
if (! bfd_elf_link_record_dynamic_symbol (info, h))
|
8601 |
|
|
return FALSE;
|
8602 |
|
|
}
|
8603 |
|
|
|
8604 |
|
|
/* If that succeeded, we know we'll be keeping all the
|
8605 |
|
|
relocs. */
|
8606 |
|
|
if (h->dynindx != -1)
|
8607 |
|
|
goto keep;
|
8608 |
|
|
}
|
8609 |
|
|
|
8610 |
|
|
eh->relocs_copied = NULL;
|
8611 |
|
|
|
8612 |
|
|
keep: ;
|
8613 |
|
|
}
|
8614 |
|
|
|
8615 |
|
|
/* Finally, allocate space. */
|
8616 |
|
|
for (p = eh->relocs_copied; p != NULL; p = p->next)
|
8617 |
|
|
{
|
8618 |
|
|
asection *sreloc = elf_section_data (p->section)->sreloc;
|
8619 |
|
|
sreloc->size += p->count * RELOC_SIZE (htab);
|
8620 |
|
|
}
|
8621 |
|
|
|
8622 |
|
|
return TRUE;
|
8623 |
|
|
}
|
8624 |
|
|
|
8625 |
|
|
/* Find any dynamic relocs that apply to read-only sections. */
|
8626 |
|
|
|
8627 |
|
|
static bfd_boolean
|
8628 |
|
|
elf32_arm_readonly_dynrelocs (struct elf_link_hash_entry *h, PTR inf)
|
8629 |
|
|
{
|
8630 |
|
|
struct elf32_arm_link_hash_entry *eh;
|
8631 |
|
|
struct elf32_arm_relocs_copied *p;
|
8632 |
|
|
|
8633 |
|
|
if (h->root.type == bfd_link_hash_warning)
|
8634 |
|
|
h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
8635 |
|
|
|
8636 |
|
|
eh = (struct elf32_arm_link_hash_entry *) h;
|
8637 |
|
|
for (p = eh->relocs_copied; p != NULL; p = p->next)
|
8638 |
|
|
{
|
8639 |
|
|
asection *s = p->section;
|
8640 |
|
|
|
8641 |
|
|
if (s != NULL && (s->flags & SEC_READONLY) != 0)
|
8642 |
|
|
{
|
8643 |
|
|
struct bfd_link_info *info = (struct bfd_link_info *) inf;
|
8644 |
|
|
|
8645 |
|
|
info->flags |= DF_TEXTREL;
|
8646 |
|
|
|
8647 |
|
|
/* Not an error, just cut short the traversal. */
|
8648 |
|
|
return FALSE;
|
8649 |
|
|
}
|
8650 |
|
|
}
|
8651 |
|
|
return TRUE;
|
8652 |
|
|
}
|
8653 |
|
|
|
8654 |
|
|
void
|
8655 |
|
|
bfd_elf32_arm_set_byteswap_code (struct bfd_link_info *info,
|
8656 |
|
|
int byteswap_code)
|
8657 |
|
|
{
|
8658 |
|
|
struct elf32_arm_link_hash_table *globals;
|
8659 |
|
|
|
8660 |
|
|
globals = elf32_arm_hash_table (info);
|
8661 |
|
|
globals->byteswap_code = byteswap_code;
|
8662 |
|
|
}
|
8663 |
|
|
|
8664 |
|
|
/* Set the sizes of the dynamic sections. */
|
8665 |
|
|
|
8666 |
|
|
static bfd_boolean
|
8667 |
|
|
elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED,
|
8668 |
|
|
struct bfd_link_info * info)
|
8669 |
|
|
{
|
8670 |
|
|
bfd * dynobj;
|
8671 |
|
|
asection * s;
|
8672 |
|
|
bfd_boolean plt;
|
8673 |
|
|
bfd_boolean relocs;
|
8674 |
|
|
bfd *ibfd;
|
8675 |
|
|
struct elf32_arm_link_hash_table *htab;
|
8676 |
|
|
|
8677 |
|
|
htab = elf32_arm_hash_table (info);
|
8678 |
|
|
dynobj = elf_hash_table (info)->dynobj;
|
8679 |
|
|
BFD_ASSERT (dynobj != NULL);
|
8680 |
|
|
check_use_blx (htab);
|
8681 |
|
|
|
8682 |
|
|
if (elf_hash_table (info)->dynamic_sections_created)
|
8683 |
|
|
{
|
8684 |
|
|
/* Set the contents of the .interp section to the interpreter. */
|
8685 |
|
|
if (info->executable)
|
8686 |
|
|
{
|
8687 |
|
|
s = bfd_get_section_by_name (dynobj, ".interp");
|
8688 |
|
|
BFD_ASSERT (s != NULL);
|
8689 |
|
|
s->size = sizeof ELF_DYNAMIC_INTERPRETER;
|
8690 |
|
|
s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
|
8691 |
|
|
}
|
8692 |
|
|
}
|
8693 |
|
|
|
8694 |
|
|
/* Set up .got offsets for local syms, and space for local dynamic
|
8695 |
|
|
relocs. */
|
8696 |
|
|
for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
|
8697 |
|
|
{
|
8698 |
|
|
bfd_signed_vma *local_got;
|
8699 |
|
|
bfd_signed_vma *end_local_got;
|
8700 |
|
|
char *local_tls_type;
|
8701 |
|
|
bfd_size_type locsymcount;
|
8702 |
|
|
Elf_Internal_Shdr *symtab_hdr;
|
8703 |
|
|
asection *srel;
|
8704 |
|
|
|
8705 |
|
|
if (! is_arm_elf (ibfd))
|
8706 |
|
|
continue;
|
8707 |
|
|
|
8708 |
|
|
for (s = ibfd->sections; s != NULL; s = s->next)
|
8709 |
|
|
{
|
8710 |
|
|
struct elf32_arm_relocs_copied *p;
|
8711 |
|
|
|
8712 |
|
|
for (p = elf_section_data (s)->local_dynrel; p != NULL; p = p->next)
|
8713 |
|
|
{
|
8714 |
|
|
if (!bfd_is_abs_section (p->section)
|
8715 |
|
|
&& bfd_is_abs_section (p->section->output_section))
|
8716 |
|
|
{
|
8717 |
|
|
/* Input section has been discarded, either because
|
8718 |
|
|
it is a copy of a linkonce section or due to
|
8719 |
|
|
linker script /DISCARD/, so we'll be discarding
|
8720 |
|
|
the relocs too. */
|
8721 |
|
|
}
|
8722 |
|
|
else if (p->count != 0)
|
8723 |
|
|
{
|
8724 |
|
|
srel = elf_section_data (p->section)->sreloc;
|
8725 |
|
|
srel->size += p->count * RELOC_SIZE (htab);
|
8726 |
|
|
if ((p->section->output_section->flags & SEC_READONLY) != 0)
|
8727 |
|
|
info->flags |= DF_TEXTREL;
|
8728 |
|
|
}
|
8729 |
|
|
}
|
8730 |
|
|
}
|
8731 |
|
|
|
8732 |
|
|
local_got = elf_local_got_refcounts (ibfd);
|
8733 |
|
|
if (!local_got)
|
8734 |
|
|
continue;
|
8735 |
|
|
|
8736 |
|
|
symtab_hdr = & elf_symtab_hdr (ibfd);
|
8737 |
|
|
locsymcount = symtab_hdr->sh_info;
|
8738 |
|
|
end_local_got = local_got + locsymcount;
|
8739 |
|
|
local_tls_type = elf32_arm_local_got_tls_type (ibfd);
|
8740 |
|
|
s = htab->sgot;
|
8741 |
|
|
srel = htab->srelgot;
|
8742 |
|
|
for (; local_got < end_local_got; ++local_got, ++local_tls_type)
|
8743 |
|
|
{
|
8744 |
|
|
if (*local_got > 0)
|
8745 |
|
|
{
|
8746 |
|
|
*local_got = s->size;
|
8747 |
|
|
if (*local_tls_type & GOT_TLS_GD)
|
8748 |
|
|
/* TLS_GD relocs need an 8-byte structure in the GOT. */
|
8749 |
|
|
s->size += 8;
|
8750 |
|
|
if (*local_tls_type & GOT_TLS_IE)
|
8751 |
|
|
s->size += 4;
|
8752 |
|
|
if (*local_tls_type == GOT_NORMAL)
|
8753 |
|
|
s->size += 4;
|
8754 |
|
|
|
8755 |
|
|
if (info->shared || *local_tls_type == GOT_TLS_GD)
|
8756 |
|
|
srel->size += RELOC_SIZE (htab);
|
8757 |
|
|
}
|
8758 |
|
|
else
|
8759 |
|
|
*local_got = (bfd_vma) -1;
|
8760 |
|
|
}
|
8761 |
|
|
}
|
8762 |
|
|
|
8763 |
|
|
if (htab->tls_ldm_got.refcount > 0)
|
8764 |
|
|
{
|
8765 |
|
|
/* Allocate two GOT entries and one dynamic relocation (if necessary)
|
8766 |
|
|
for R_ARM_TLS_LDM32 relocations. */
|
8767 |
|
|
htab->tls_ldm_got.offset = htab->sgot->size;
|
8768 |
|
|
htab->sgot->size += 8;
|
8769 |
|
|
if (info->shared)
|
8770 |
|
|
htab->srelgot->size += RELOC_SIZE (htab);
|
8771 |
|
|
}
|
8772 |
|
|
else
|
8773 |
|
|
htab->tls_ldm_got.offset = -1;
|
8774 |
|
|
|
8775 |
|
|
/* Allocate global sym .plt and .got entries, and space for global
|
8776 |
|
|
sym dynamic relocs. */
|
8777 |
|
|
elf_link_hash_traverse (& htab->root, allocate_dynrelocs, info);
|
8778 |
|
|
|
8779 |
|
|
/* Here we rummage through the found bfds to collect glue information. */
|
8780 |
|
|
for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
|
8781 |
|
|
{
|
8782 |
|
|
if (! is_arm_elf (ibfd))
|
8783 |
|
|
continue;
|
8784 |
|
|
|
8785 |
|
|
/* Initialise mapping tables for code/data. */
|
8786 |
|
|
bfd_elf32_arm_init_maps (ibfd);
|
8787 |
|
|
|
8788 |
|
|
if (!bfd_elf32_arm_process_before_allocation (ibfd, info)
|
8789 |
|
|
|| !bfd_elf32_arm_vfp11_erratum_scan (ibfd, info))
|
8790 |
|
|
/* xgettext:c-format */
|
8791 |
|
|
_bfd_error_handler (_("Errors encountered processing file %s"),
|
8792 |
|
|
ibfd->filename);
|
8793 |
|
|
}
|
8794 |
|
|
|
8795 |
|
|
/* The check_relocs and adjust_dynamic_symbol entry points have
|
8796 |
|
|
determined the sizes of the various dynamic sections. Allocate
|
8797 |
|
|
memory for them. */
|
8798 |
|
|
plt = FALSE;
|
8799 |
|
|
relocs = FALSE;
|
8800 |
|
|
for (s = dynobj->sections; s != NULL; s = s->next)
|
8801 |
|
|
{
|
8802 |
|
|
const char * name;
|
8803 |
|
|
|
8804 |
|
|
if ((s->flags & SEC_LINKER_CREATED) == 0)
|
8805 |
|
|
continue;
|
8806 |
|
|
|
8807 |
|
|
/* It's OK to base decisions on the section name, because none
|
8808 |
|
|
of the dynobj section names depend upon the input files. */
|
8809 |
|
|
name = bfd_get_section_name (dynobj, s);
|
8810 |
|
|
|
8811 |
|
|
if (strcmp (name, ".plt") == 0)
|
8812 |
|
|
{
|
8813 |
|
|
/* Remember whether there is a PLT. */
|
8814 |
|
|
plt = s->size != 0;
|
8815 |
|
|
}
|
8816 |
|
|
else if (CONST_STRNEQ (name, ".rel"))
|
8817 |
|
|
{
|
8818 |
|
|
if (s->size != 0)
|
8819 |
|
|
{
|
8820 |
|
|
/* Remember whether there are any reloc sections other
|
8821 |
|
|
than .rel(a).plt and .rela.plt.unloaded. */
|
8822 |
|
|
if (s != htab->srelplt && s != htab->srelplt2)
|
8823 |
|
|
relocs = TRUE;
|
8824 |
|
|
|
8825 |
|
|
/* We use the reloc_count field as a counter if we need
|
8826 |
|
|
to copy relocs into the output file. */
|
8827 |
|
|
s->reloc_count = 0;
|
8828 |
|
|
}
|
8829 |
|
|
}
|
8830 |
|
|
else if (! CONST_STRNEQ (name, ".got")
|
8831 |
|
|
&& strcmp (name, ".dynbss") != 0)
|
8832 |
|
|
{
|
8833 |
|
|
/* It's not one of our sections, so don't allocate space. */
|
8834 |
|
|
continue;
|
8835 |
|
|
}
|
8836 |
|
|
|
8837 |
|
|
if (s->size == 0)
|
8838 |
|
|
{
|
8839 |
|
|
/* If we don't need this section, strip it from the
|
8840 |
|
|
output file. This is mostly to handle .rel(a).bss and
|
8841 |
|
|
.rel(a).plt. We must create both sections in
|
8842 |
|
|
create_dynamic_sections, because they must be created
|
8843 |
|
|
before the linker maps input sections to output
|
8844 |
|
|
sections. The linker does that before
|
8845 |
|
|
adjust_dynamic_symbol is called, and it is that
|
8846 |
|
|
function which decides whether anything needs to go
|
8847 |
|
|
into these sections. */
|
8848 |
|
|
s->flags |= SEC_EXCLUDE;
|
8849 |
|
|
continue;
|
8850 |
|
|
}
|
8851 |
|
|
|
8852 |
|
|
if ((s->flags & SEC_HAS_CONTENTS) == 0)
|
8853 |
|
|
continue;
|
8854 |
|
|
|
8855 |
|
|
/* Allocate memory for the section contents. */
|
8856 |
|
|
s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size);
|
8857 |
|
|
if (s->contents == NULL)
|
8858 |
|
|
return FALSE;
|
8859 |
|
|
}
|
8860 |
|
|
|
8861 |
|
|
if (elf_hash_table (info)->dynamic_sections_created)
|
8862 |
|
|
{
|
8863 |
|
|
/* Add some entries to the .dynamic section. We fill in the
|
8864 |
|
|
values later, in elf32_arm_finish_dynamic_sections, but we
|
8865 |
|
|
must add the entries now so that we get the correct size for
|
8866 |
|
|
the .dynamic section. The DT_DEBUG entry is filled in by the
|
8867 |
|
|
dynamic linker and used by the debugger. */
|
8868 |
|
|
#define add_dynamic_entry(TAG, VAL) \
|
8869 |
|
|
_bfd_elf_add_dynamic_entry (info, TAG, VAL)
|
8870 |
|
|
|
8871 |
|
|
if (info->executable)
|
8872 |
|
|
{
|
8873 |
|
|
if (!add_dynamic_entry (DT_DEBUG, 0))
|
8874 |
|
|
return FALSE;
|
8875 |
|
|
}
|
8876 |
|
|
|
8877 |
|
|
if (plt)
|
8878 |
|
|
{
|
8879 |
|
|
if ( !add_dynamic_entry (DT_PLTGOT, 0)
|
8880 |
|
|
|| !add_dynamic_entry (DT_PLTRELSZ, 0)
|
8881 |
|
|
|| !add_dynamic_entry (DT_PLTREL,
|
8882 |
|
|
htab->use_rel ? DT_REL : DT_RELA)
|
8883 |
|
|
|| !add_dynamic_entry (DT_JMPREL, 0))
|
8884 |
|
|
return FALSE;
|
8885 |
|
|
}
|
8886 |
|
|
|
8887 |
|
|
if (relocs)
|
8888 |
|
|
{
|
8889 |
|
|
if (htab->use_rel)
|
8890 |
|
|
{
|
8891 |
|
|
if (!add_dynamic_entry (DT_REL, 0)
|
8892 |
|
|
|| !add_dynamic_entry (DT_RELSZ, 0)
|
8893 |
|
|
|| !add_dynamic_entry (DT_RELENT, RELOC_SIZE (htab)))
|
8894 |
|
|
return FALSE;
|
8895 |
|
|
}
|
8896 |
|
|
else
|
8897 |
|
|
{
|
8898 |
|
|
if (!add_dynamic_entry (DT_RELA, 0)
|
8899 |
|
|
|| !add_dynamic_entry (DT_RELASZ, 0)
|
8900 |
|
|
|| !add_dynamic_entry (DT_RELAENT, RELOC_SIZE (htab)))
|
8901 |
|
|
return FALSE;
|
8902 |
|
|
}
|
8903 |
|
|
}
|
8904 |
|
|
|
8905 |
|
|
/* If any dynamic relocs apply to a read-only section,
|
8906 |
|
|
then we need a DT_TEXTREL entry. */
|
8907 |
|
|
if ((info->flags & DF_TEXTREL) == 0)
|
8908 |
|
|
elf_link_hash_traverse (&htab->root, elf32_arm_readonly_dynrelocs,
|
8909 |
|
|
(PTR) info);
|
8910 |
|
|
|
8911 |
|
|
if ((info->flags & DF_TEXTREL) != 0)
|
8912 |
|
|
{
|
8913 |
|
|
if (!add_dynamic_entry (DT_TEXTREL, 0))
|
8914 |
|
|
return FALSE;
|
8915 |
|
|
}
|
8916 |
|
|
if (htab->vxworks_p
|
8917 |
|
|
&& !elf_vxworks_add_dynamic_entries (output_bfd, info))
|
8918 |
|
|
return FALSE;
|
8919 |
|
|
}
|
8920 |
|
|
#undef add_dynamic_entry
|
8921 |
|
|
|
8922 |
|
|
return TRUE;
|
8923 |
|
|
}
|
8924 |
|
|
|
8925 |
|
|
/* Finish up dynamic symbol handling. We set the contents of various
|
8926 |
|
|
dynamic sections here. */
|
8927 |
|
|
|
8928 |
|
|
static bfd_boolean
|
8929 |
|
|
elf32_arm_finish_dynamic_symbol (bfd * output_bfd, struct bfd_link_info * info,
|
8930 |
|
|
struct elf_link_hash_entry * h, Elf_Internal_Sym * sym)
|
8931 |
|
|
{
|
8932 |
|
|
bfd * dynobj;
|
8933 |
|
|
struct elf32_arm_link_hash_table *htab;
|
8934 |
|
|
struct elf32_arm_link_hash_entry *eh;
|
8935 |
|
|
|
8936 |
|
|
dynobj = elf_hash_table (info)->dynobj;
|
8937 |
|
|
htab = elf32_arm_hash_table (info);
|
8938 |
|
|
eh = (struct elf32_arm_link_hash_entry *) h;
|
8939 |
|
|
|
8940 |
|
|
if (h->plt.offset != (bfd_vma) -1)
|
8941 |
|
|
{
|
8942 |
|
|
asection * splt;
|
8943 |
|
|
asection * srel;
|
8944 |
|
|
bfd_byte *loc;
|
8945 |
|
|
bfd_vma plt_index;
|
8946 |
|
|
Elf_Internal_Rela rel;
|
8947 |
|
|
|
8948 |
|
|
/* This symbol has an entry in the procedure linkage table. Set
|
8949 |
|
|
it up. */
|
8950 |
|
|
|
8951 |
|
|
BFD_ASSERT (h->dynindx != -1);
|
8952 |
|
|
|
8953 |
|
|
splt = bfd_get_section_by_name (dynobj, ".plt");
|
8954 |
|
|
srel = bfd_get_section_by_name (dynobj, RELOC_SECTION (htab, ".plt"));
|
8955 |
|
|
BFD_ASSERT (splt != NULL && srel != NULL);
|
8956 |
|
|
|
8957 |
|
|
/* Fill in the entry in the procedure linkage table. */
|
8958 |
|
|
if (htab->symbian_p)
|
8959 |
|
|
{
|
8960 |
|
|
put_arm_insn (htab, output_bfd,
|
8961 |
|
|
elf32_arm_symbian_plt_entry[0],
|
8962 |
|
|
splt->contents + h->plt.offset);
|
8963 |
|
|
bfd_put_32 (output_bfd,
|
8964 |
|
|
elf32_arm_symbian_plt_entry[1],
|
8965 |
|
|
splt->contents + h->plt.offset + 4);
|
8966 |
|
|
|
8967 |
|
|
/* Fill in the entry in the .rel.plt section. */
|
8968 |
|
|
rel.r_offset = (splt->output_section->vma
|
8969 |
|
|
+ splt->output_offset
|
8970 |
|
|
+ h->plt.offset + 4);
|
8971 |
|
|
rel.r_info = ELF32_R_INFO (h->dynindx, R_ARM_GLOB_DAT);
|
8972 |
|
|
|
8973 |
|
|
/* Get the index in the procedure linkage table which
|
8974 |
|
|
corresponds to this symbol. This is the index of this symbol
|
8975 |
|
|
in all the symbols for which we are making plt entries. The
|
8976 |
|
|
first entry in the procedure linkage table is reserved. */
|
8977 |
|
|
plt_index = ((h->plt.offset - htab->plt_header_size)
|
8978 |
|
|
/ htab->plt_entry_size);
|
8979 |
|
|
}
|
8980 |
|
|
else
|
8981 |
|
|
{
|
8982 |
|
|
bfd_vma got_offset, got_address, plt_address;
|
8983 |
|
|
bfd_vma got_displacement;
|
8984 |
|
|
asection * sgot;
|
8985 |
|
|
bfd_byte * ptr;
|
8986 |
|
|
|
8987 |
|
|
sgot = bfd_get_section_by_name (dynobj, ".got.plt");
|
8988 |
|
|
BFD_ASSERT (sgot != NULL);
|
8989 |
|
|
|
8990 |
|
|
/* Get the offset into the .got.plt table of the entry that
|
8991 |
|
|
corresponds to this function. */
|
8992 |
|
|
got_offset = eh->plt_got_offset;
|
8993 |
|
|
|
8994 |
|
|
/* Get the index in the procedure linkage table which
|
8995 |
|
|
corresponds to this symbol. This is the index of this symbol
|
8996 |
|
|
in all the symbols for which we are making plt entries. The
|
8997 |
|
|
first three entries in .got.plt are reserved; after that
|
8998 |
|
|
symbols appear in the same order as in .plt. */
|
8999 |
|
|
plt_index = (got_offset - 12) / 4;
|
9000 |
|
|
|
9001 |
|
|
/* Calculate the address of the GOT entry. */
|
9002 |
|
|
got_address = (sgot->output_section->vma
|
9003 |
|
|
+ sgot->output_offset
|
9004 |
|
|
+ got_offset);
|
9005 |
|
|
|
9006 |
|
|
/* ...and the address of the PLT entry. */
|
9007 |
|
|
plt_address = (splt->output_section->vma
|
9008 |
|
|
+ splt->output_offset
|
9009 |
|
|
+ h->plt.offset);
|
9010 |
|
|
|
9011 |
|
|
ptr = htab->splt->contents + h->plt.offset;
|
9012 |
|
|
if (htab->vxworks_p && info->shared)
|
9013 |
|
|
{
|
9014 |
|
|
unsigned int i;
|
9015 |
|
|
bfd_vma val;
|
9016 |
|
|
|
9017 |
|
|
for (i = 0; i != htab->plt_entry_size / 4; i++, ptr += 4)
|
9018 |
|
|
{
|
9019 |
|
|
val = elf32_arm_vxworks_shared_plt_entry[i];
|
9020 |
|
|
if (i == 2)
|
9021 |
|
|
val |= got_address - sgot->output_section->vma;
|
9022 |
|
|
if (i == 5)
|
9023 |
|
|
val |= plt_index * RELOC_SIZE (htab);
|
9024 |
|
|
if (i == 2 || i == 5)
|
9025 |
|
|
bfd_put_32 (output_bfd, val, ptr);
|
9026 |
|
|
else
|
9027 |
|
|
put_arm_insn (htab, output_bfd, val, ptr);
|
9028 |
|
|
}
|
9029 |
|
|
}
|
9030 |
|
|
else if (htab->vxworks_p)
|
9031 |
|
|
{
|
9032 |
|
|
unsigned int i;
|
9033 |
|
|
bfd_vma val;
|
9034 |
|
|
|
9035 |
|
|
for (i = 0; i != htab->plt_entry_size / 4; i++, ptr += 4)
|
9036 |
|
|
{
|
9037 |
|
|
val = elf32_arm_vxworks_exec_plt_entry[i];
|
9038 |
|
|
if (i == 2)
|
9039 |
|
|
val |= got_address;
|
9040 |
|
|
if (i == 4)
|
9041 |
|
|
val |= 0xffffff & -((h->plt.offset + i * 4 + 8) >> 2);
|
9042 |
|
|
if (i == 5)
|
9043 |
|
|
val |= plt_index * RELOC_SIZE (htab);
|
9044 |
|
|
if (i == 2 || i == 5)
|
9045 |
|
|
bfd_put_32 (output_bfd, val, ptr);
|
9046 |
|
|
else
|
9047 |
|
|
put_arm_insn (htab, output_bfd, val, ptr);
|
9048 |
|
|
}
|
9049 |
|
|
|
9050 |
|
|
loc = (htab->srelplt2->contents
|
9051 |
|
|
+ (plt_index * 2 + 1) * RELOC_SIZE (htab));
|
9052 |
|
|
|
9053 |
|
|
/* Create the .rela.plt.unloaded R_ARM_ABS32 relocation
|
9054 |
|
|
referencing the GOT for this PLT entry. */
|
9055 |
|
|
rel.r_offset = plt_address + 8;
|
9056 |
|
|
rel.r_info = ELF32_R_INFO (htab->root.hgot->indx, R_ARM_ABS32);
|
9057 |
|
|
rel.r_addend = got_offset;
|
9058 |
|
|
SWAP_RELOC_OUT (htab) (output_bfd, &rel, loc);
|
9059 |
|
|
loc += RELOC_SIZE (htab);
|
9060 |
|
|
|
9061 |
|
|
/* Create the R_ARM_ABS32 relocation referencing the
|
9062 |
|
|
beginning of the PLT for this GOT entry. */
|
9063 |
|
|
rel.r_offset = got_address;
|
9064 |
|
|
rel.r_info = ELF32_R_INFO (htab->root.hplt->indx, R_ARM_ABS32);
|
9065 |
|
|
rel.r_addend = 0;
|
9066 |
|
|
SWAP_RELOC_OUT (htab) (output_bfd, &rel, loc);
|
9067 |
|
|
}
|
9068 |
|
|
else
|
9069 |
|
|
{
|
9070 |
|
|
bfd_signed_vma thumb_refs;
|
9071 |
|
|
/* Calculate the displacement between the PLT slot and the
|
9072 |
|
|
entry in the GOT. The eight-byte offset accounts for the
|
9073 |
|
|
value produced by adding to pc in the first instruction
|
9074 |
|
|
of the PLT stub. */
|
9075 |
|
|
got_displacement = got_address - (plt_address + 8);
|
9076 |
|
|
|
9077 |
|
|
BFD_ASSERT ((got_displacement & 0xf0000000) == 0);
|
9078 |
|
|
|
9079 |
|
|
thumb_refs = eh->plt_thumb_refcount;
|
9080 |
|
|
if (!htab->use_blx)
|
9081 |
|
|
thumb_refs += eh->plt_maybe_thumb_refcount;
|
9082 |
|
|
|
9083 |
|
|
if (thumb_refs > 0)
|
9084 |
|
|
{
|
9085 |
|
|
put_thumb_insn (htab, output_bfd,
|
9086 |
|
|
elf32_arm_plt_thumb_stub[0], ptr - 4);
|
9087 |
|
|
put_thumb_insn (htab, output_bfd,
|
9088 |
|
|
elf32_arm_plt_thumb_stub[1], ptr - 2);
|
9089 |
|
|
}
|
9090 |
|
|
|
9091 |
|
|
put_arm_insn (htab, output_bfd,
|
9092 |
|
|
elf32_arm_plt_entry[0]
|
9093 |
|
|
| ((got_displacement & 0x0ff00000) >> 20),
|
9094 |
|
|
ptr + 0);
|
9095 |
|
|
put_arm_insn (htab, output_bfd,
|
9096 |
|
|
elf32_arm_plt_entry[1]
|
9097 |
|
|
| ((got_displacement & 0x000ff000) >> 12),
|
9098 |
|
|
ptr+ 4);
|
9099 |
|
|
put_arm_insn (htab, output_bfd,
|
9100 |
|
|
elf32_arm_plt_entry[2]
|
9101 |
|
|
| (got_displacement & 0x00000fff),
|
9102 |
|
|
ptr + 8);
|
9103 |
|
|
#ifdef FOUR_WORD_PLT
|
9104 |
|
|
bfd_put_32 (output_bfd, elf32_arm_plt_entry[3], ptr + 12);
|
9105 |
|
|
#endif
|
9106 |
|
|
}
|
9107 |
|
|
|
9108 |
|
|
/* Fill in the entry in the global offset table. */
|
9109 |
|
|
bfd_put_32 (output_bfd,
|
9110 |
|
|
(splt->output_section->vma
|
9111 |
|
|
+ splt->output_offset),
|
9112 |
|
|
sgot->contents + got_offset);
|
9113 |
|
|
|
9114 |
|
|
/* Fill in the entry in the .rel(a).plt section. */
|
9115 |
|
|
rel.r_addend = 0;
|
9116 |
|
|
rel.r_offset = got_address;
|
9117 |
|
|
rel.r_info = ELF32_R_INFO (h->dynindx, R_ARM_JUMP_SLOT);
|
9118 |
|
|
}
|
9119 |
|
|
|
9120 |
|
|
loc = srel->contents + plt_index * RELOC_SIZE (htab);
|
9121 |
|
|
SWAP_RELOC_OUT (htab) (output_bfd, &rel, loc);
|
9122 |
|
|
|
9123 |
|
|
if (!h->def_regular)
|
9124 |
|
|
{
|
9125 |
|
|
/* Mark the symbol as undefined, rather than as defined in
|
9126 |
|
|
the .plt section. Leave the value alone. */
|
9127 |
|
|
sym->st_shndx = SHN_UNDEF;
|
9128 |
|
|
/* If the symbol is weak, we do need to clear the value.
|
9129 |
|
|
Otherwise, the PLT entry would provide a definition for
|
9130 |
|
|
the symbol even if the symbol wasn't defined anywhere,
|
9131 |
|
|
and so the symbol would never be NULL. */
|
9132 |
|
|
if (!h->ref_regular_nonweak)
|
9133 |
|
|
sym->st_value = 0;
|
9134 |
|
|
}
|
9135 |
|
|
}
|
9136 |
|
|
|
9137 |
|
|
if (h->got.offset != (bfd_vma) -1
|
9138 |
|
|
&& (elf32_arm_hash_entry (h)->tls_type & GOT_TLS_GD) == 0
|
9139 |
|
|
&& (elf32_arm_hash_entry (h)->tls_type & GOT_TLS_IE) == 0)
|
9140 |
|
|
{
|
9141 |
|
|
asection * sgot;
|
9142 |
|
|
asection * srel;
|
9143 |
|
|
Elf_Internal_Rela rel;
|
9144 |
|
|
bfd_byte *loc;
|
9145 |
|
|
bfd_vma offset;
|
9146 |
|
|
|
9147 |
|
|
/* This symbol has an entry in the global offset table. Set it
|
9148 |
|
|
up. */
|
9149 |
|
|
sgot = bfd_get_section_by_name (dynobj, ".got");
|
9150 |
|
|
srel = bfd_get_section_by_name (dynobj, RELOC_SECTION (htab, ".got"));
|
9151 |
|
|
BFD_ASSERT (sgot != NULL && srel != NULL);
|
9152 |
|
|
|
9153 |
|
|
offset = (h->got.offset & ~(bfd_vma) 1);
|
9154 |
|
|
rel.r_addend = 0;
|
9155 |
|
|
rel.r_offset = (sgot->output_section->vma
|
9156 |
|
|
+ sgot->output_offset
|
9157 |
|
|
+ offset);
|
9158 |
|
|
|
9159 |
|
|
/* If this is a static link, or it is a -Bsymbolic link and the
|
9160 |
|
|
symbol is defined locally or was forced to be local because
|
9161 |
|
|
of a version file, we just want to emit a RELATIVE reloc.
|
9162 |
|
|
The entry in the global offset table will already have been
|
9163 |
|
|
initialized in the relocate_section function. */
|
9164 |
|
|
if (info->shared
|
9165 |
|
|
&& SYMBOL_REFERENCES_LOCAL (info, h))
|
9166 |
|
|
{
|
9167 |
|
|
BFD_ASSERT((h->got.offset & 1) != 0);
|
9168 |
|
|
rel.r_info = ELF32_R_INFO (0, R_ARM_RELATIVE);
|
9169 |
|
|
if (!htab->use_rel)
|
9170 |
|
|
{
|
9171 |
|
|
rel.r_addend = bfd_get_32 (output_bfd, sgot->contents + offset);
|
9172 |
|
|
bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + offset);
|
9173 |
|
|
}
|
9174 |
|
|
}
|
9175 |
|
|
else
|
9176 |
|
|
{
|
9177 |
|
|
BFD_ASSERT((h->got.offset & 1) == 0);
|
9178 |
|
|
bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + offset);
|
9179 |
|
|
rel.r_info = ELF32_R_INFO (h->dynindx, R_ARM_GLOB_DAT);
|
9180 |
|
|
}
|
9181 |
|
|
|
9182 |
|
|
loc = srel->contents + srel->reloc_count++ * RELOC_SIZE (htab);
|
9183 |
|
|
SWAP_RELOC_OUT (htab) (output_bfd, &rel, loc);
|
9184 |
|
|
}
|
9185 |
|
|
|
9186 |
|
|
if (h->needs_copy)
|
9187 |
|
|
{
|
9188 |
|
|
asection * s;
|
9189 |
|
|
Elf_Internal_Rela rel;
|
9190 |
|
|
bfd_byte *loc;
|
9191 |
|
|
|
9192 |
|
|
/* This symbol needs a copy reloc. Set it up. */
|
9193 |
|
|
BFD_ASSERT (h->dynindx != -1
|
9194 |
|
|
&& (h->root.type == bfd_link_hash_defined
|
9195 |
|
|
|| h->root.type == bfd_link_hash_defweak));
|
9196 |
|
|
|
9197 |
|
|
s = bfd_get_section_by_name (h->root.u.def.section->owner,
|
9198 |
|
|
RELOC_SECTION (htab, ".bss"));
|
9199 |
|
|
BFD_ASSERT (s != NULL);
|
9200 |
|
|
|
9201 |
|
|
rel.r_addend = 0;
|
9202 |
|
|
rel.r_offset = (h->root.u.def.value
|
9203 |
|
|
+ h->root.u.def.section->output_section->vma
|
9204 |
|
|
+ h->root.u.def.section->output_offset);
|
9205 |
|
|
rel.r_info = ELF32_R_INFO (h->dynindx, R_ARM_COPY);
|
9206 |
|
|
loc = s->contents + s->reloc_count++ * RELOC_SIZE (htab);
|
9207 |
|
|
SWAP_RELOC_OUT (htab) (output_bfd, &rel, loc);
|
9208 |
|
|
}
|
9209 |
|
|
|
9210 |
|
|
/* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. On VxWorks,
|
9211 |
|
|
the _GLOBAL_OFFSET_TABLE_ symbol is not absolute: it is relative
|
9212 |
|
|
to the ".got" section. */
|
9213 |
|
|
if (strcmp (h->root.root.string, "_DYNAMIC") == 0
|
9214 |
|
|
|| (!htab->vxworks_p && h == htab->root.hgot))
|
9215 |
|
|
sym->st_shndx = SHN_ABS;
|
9216 |
|
|
|
9217 |
|
|
return TRUE;
|
9218 |
|
|
}
|
9219 |
|
|
|
9220 |
|
|
/* Finish up the dynamic sections. */
|
9221 |
|
|
|
9222 |
|
|
static bfd_boolean
|
9223 |
|
|
elf32_arm_finish_dynamic_sections (bfd * output_bfd, struct bfd_link_info * info)
|
9224 |
|
|
{
|
9225 |
|
|
bfd * dynobj;
|
9226 |
|
|
asection * sgot;
|
9227 |
|
|
asection * sdyn;
|
9228 |
|
|
|
9229 |
|
|
dynobj = elf_hash_table (info)->dynobj;
|
9230 |
|
|
|
9231 |
|
|
sgot = bfd_get_section_by_name (dynobj, ".got.plt");
|
9232 |
|
|
BFD_ASSERT (elf32_arm_hash_table (info)->symbian_p || sgot != NULL);
|
9233 |
|
|
sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
|
9234 |
|
|
|
9235 |
|
|
if (elf_hash_table (info)->dynamic_sections_created)
|
9236 |
|
|
{
|
9237 |
|
|
asection *splt;
|
9238 |
|
|
Elf32_External_Dyn *dyncon, *dynconend;
|
9239 |
|
|
struct elf32_arm_link_hash_table *htab;
|
9240 |
|
|
|
9241 |
|
|
htab = elf32_arm_hash_table (info);
|
9242 |
|
|
splt = bfd_get_section_by_name (dynobj, ".plt");
|
9243 |
|
|
BFD_ASSERT (splt != NULL && sdyn != NULL);
|
9244 |
|
|
|
9245 |
|
|
dyncon = (Elf32_External_Dyn *) sdyn->contents;
|
9246 |
|
|
dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size);
|
9247 |
|
|
|
9248 |
|
|
for (; dyncon < dynconend; dyncon++)
|
9249 |
|
|
{
|
9250 |
|
|
Elf_Internal_Dyn dyn;
|
9251 |
|
|
const char * name;
|
9252 |
|
|
asection * s;
|
9253 |
|
|
|
9254 |
|
|
bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
|
9255 |
|
|
|
9256 |
|
|
switch (dyn.d_tag)
|
9257 |
|
|
{
|
9258 |
|
|
unsigned int type;
|
9259 |
|
|
|
9260 |
|
|
default:
|
9261 |
|
|
if (htab->vxworks_p
|
9262 |
|
|
&& elf_vxworks_finish_dynamic_entry (output_bfd, &dyn))
|
9263 |
|
|
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
|
9264 |
|
|
break;
|
9265 |
|
|
|
9266 |
|
|
case DT_HASH:
|
9267 |
|
|
name = ".hash";
|
9268 |
|
|
goto get_vma_if_bpabi;
|
9269 |
|
|
case DT_STRTAB:
|
9270 |
|
|
name = ".dynstr";
|
9271 |
|
|
goto get_vma_if_bpabi;
|
9272 |
|
|
case DT_SYMTAB:
|
9273 |
|
|
name = ".dynsym";
|
9274 |
|
|
goto get_vma_if_bpabi;
|
9275 |
|
|
case DT_VERSYM:
|
9276 |
|
|
name = ".gnu.version";
|
9277 |
|
|
goto get_vma_if_bpabi;
|
9278 |
|
|
case DT_VERDEF:
|
9279 |
|
|
name = ".gnu.version_d";
|
9280 |
|
|
goto get_vma_if_bpabi;
|
9281 |
|
|
case DT_VERNEED:
|
9282 |
|
|
name = ".gnu.version_r";
|
9283 |
|
|
goto get_vma_if_bpabi;
|
9284 |
|
|
|
9285 |
|
|
case DT_PLTGOT:
|
9286 |
|
|
name = ".got";
|
9287 |
|
|
goto get_vma;
|
9288 |
|
|
case DT_JMPREL:
|
9289 |
|
|
name = RELOC_SECTION (htab, ".plt");
|
9290 |
|
|
get_vma:
|
9291 |
|
|
s = bfd_get_section_by_name (output_bfd, name);
|
9292 |
|
|
BFD_ASSERT (s != NULL);
|
9293 |
|
|
if (!htab->symbian_p)
|
9294 |
|
|
dyn.d_un.d_ptr = s->vma;
|
9295 |
|
|
else
|
9296 |
|
|
/* In the BPABI, tags in the PT_DYNAMIC section point
|
9297 |
|
|
at the file offset, not the memory address, for the
|
9298 |
|
|
convenience of the post linker. */
|
9299 |
|
|
dyn.d_un.d_ptr = s->filepos;
|
9300 |
|
|
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
|
9301 |
|
|
break;
|
9302 |
|
|
|
9303 |
|
|
get_vma_if_bpabi:
|
9304 |
|
|
if (htab->symbian_p)
|
9305 |
|
|
goto get_vma;
|
9306 |
|
|
break;
|
9307 |
|
|
|
9308 |
|
|
case DT_PLTRELSZ:
|
9309 |
|
|
s = bfd_get_section_by_name (output_bfd,
|
9310 |
|
|
RELOC_SECTION (htab, ".plt"));
|
9311 |
|
|
BFD_ASSERT (s != NULL);
|
9312 |
|
|
dyn.d_un.d_val = s->size;
|
9313 |
|
|
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
|
9314 |
|
|
break;
|
9315 |
|
|
|
9316 |
|
|
case DT_RELSZ:
|
9317 |
|
|
case DT_RELASZ:
|
9318 |
|
|
if (!htab->symbian_p)
|
9319 |
|
|
{
|
9320 |
|
|
/* My reading of the SVR4 ABI indicates that the
|
9321 |
|
|
procedure linkage table relocs (DT_JMPREL) should be
|
9322 |
|
|
included in the overall relocs (DT_REL). This is
|
9323 |
|
|
what Solaris does. However, UnixWare can not handle
|
9324 |
|
|
that case. Therefore, we override the DT_RELSZ entry
|
9325 |
|
|
here to make it not include the JMPREL relocs. Since
|
9326 |
|
|
the linker script arranges for .rel(a).plt to follow all
|
9327 |
|
|
other relocation sections, we don't have to worry
|
9328 |
|
|
about changing the DT_REL entry. */
|
9329 |
|
|
s = bfd_get_section_by_name (output_bfd,
|
9330 |
|
|
RELOC_SECTION (htab, ".plt"));
|
9331 |
|
|
if (s != NULL)
|
9332 |
|
|
dyn.d_un.d_val -= s->size;
|
9333 |
|
|
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
|
9334 |
|
|
break;
|
9335 |
|
|
}
|
9336 |
|
|
/* Fall through */
|
9337 |
|
|
|
9338 |
|
|
case DT_REL:
|
9339 |
|
|
case DT_RELA:
|
9340 |
|
|
/* In the BPABI, the DT_REL tag must point at the file
|
9341 |
|
|
offset, not the VMA, of the first relocation
|
9342 |
|
|
section. So, we use code similar to that in
|
9343 |
|
|
elflink.c, but do not check for SHF_ALLOC on the
|
9344 |
|
|
relcoation section, since relocations sections are
|
9345 |
|
|
never allocated under the BPABI. The comments above
|
9346 |
|
|
about Unixware notwithstanding, we include all of the
|
9347 |
|
|
relocations here. */
|
9348 |
|
|
if (htab->symbian_p)
|
9349 |
|
|
{
|
9350 |
|
|
unsigned int i;
|
9351 |
|
|
type = ((dyn.d_tag == DT_REL || dyn.d_tag == DT_RELSZ)
|
9352 |
|
|
? SHT_REL : SHT_RELA);
|
9353 |
|
|
dyn.d_un.d_val = 0;
|
9354 |
|
|
for (i = 1; i < elf_numsections (output_bfd); i++)
|
9355 |
|
|
{
|
9356 |
|
|
Elf_Internal_Shdr *hdr
|
9357 |
|
|
= elf_elfsections (output_bfd)[i];
|
9358 |
|
|
if (hdr->sh_type == type)
|
9359 |
|
|
{
|
9360 |
|
|
if (dyn.d_tag == DT_RELSZ
|
9361 |
|
|
|| dyn.d_tag == DT_RELASZ)
|
9362 |
|
|
dyn.d_un.d_val += hdr->sh_size;
|
9363 |
|
|
else if ((ufile_ptr) hdr->sh_offset
|
9364 |
|
|
<= dyn.d_un.d_val - 1)
|
9365 |
|
|
dyn.d_un.d_val = hdr->sh_offset;
|
9366 |
|
|
}
|
9367 |
|
|
}
|
9368 |
|
|
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
|
9369 |
|
|
}
|
9370 |
|
|
break;
|
9371 |
|
|
|
9372 |
|
|
/* Set the bottom bit of DT_INIT/FINI if the
|
9373 |
|
|
corresponding function is Thumb. */
|
9374 |
|
|
case DT_INIT:
|
9375 |
|
|
name = info->init_function;
|
9376 |
|
|
goto get_sym;
|
9377 |
|
|
case DT_FINI:
|
9378 |
|
|
name = info->fini_function;
|
9379 |
|
|
get_sym:
|
9380 |
|
|
/* If it wasn't set by elf_bfd_final_link
|
9381 |
|
|
then there is nothing to adjust. */
|
9382 |
|
|
if (dyn.d_un.d_val != 0)
|
9383 |
|
|
{
|
9384 |
|
|
struct elf_link_hash_entry * eh;
|
9385 |
|
|
|
9386 |
|
|
eh = elf_link_hash_lookup (elf_hash_table (info), name,
|
9387 |
|
|
FALSE, FALSE, TRUE);
|
9388 |
|
|
if (eh != (struct elf_link_hash_entry *) NULL
|
9389 |
|
|
&& ELF_ST_TYPE (eh->type) == STT_ARM_TFUNC)
|
9390 |
|
|
{
|
9391 |
|
|
dyn.d_un.d_val |= 1;
|
9392 |
|
|
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
|
9393 |
|
|
}
|
9394 |
|
|
}
|
9395 |
|
|
break;
|
9396 |
|
|
}
|
9397 |
|
|
}
|
9398 |
|
|
|
9399 |
|
|
/* Fill in the first entry in the procedure linkage table. */
|
9400 |
|
|
if (splt->size > 0 && elf32_arm_hash_table (info)->plt_header_size)
|
9401 |
|
|
{
|
9402 |
|
|
const bfd_vma *plt0_entry;
|
9403 |
|
|
bfd_vma got_address, plt_address, got_displacement;
|
9404 |
|
|
|
9405 |
|
|
/* Calculate the addresses of the GOT and PLT. */
|
9406 |
|
|
got_address = sgot->output_section->vma + sgot->output_offset;
|
9407 |
|
|
plt_address = splt->output_section->vma + splt->output_offset;
|
9408 |
|
|
|
9409 |
|
|
if (htab->vxworks_p)
|
9410 |
|
|
{
|
9411 |
|
|
/* The VxWorks GOT is relocated by the dynamic linker.
|
9412 |
|
|
Therefore, we must emit relocations rather than simply
|
9413 |
|
|
computing the values now. */
|
9414 |
|
|
Elf_Internal_Rela rel;
|
9415 |
|
|
|
9416 |
|
|
plt0_entry = elf32_arm_vxworks_exec_plt0_entry;
|
9417 |
|
|
put_arm_insn (htab, output_bfd, plt0_entry[0],
|
9418 |
|
|
splt->contents + 0);
|
9419 |
|
|
put_arm_insn (htab, output_bfd, plt0_entry[1],
|
9420 |
|
|
splt->contents + 4);
|
9421 |
|
|
put_arm_insn (htab, output_bfd, plt0_entry[2],
|
9422 |
|
|
splt->contents + 8);
|
9423 |
|
|
bfd_put_32 (output_bfd, got_address, splt->contents + 12);
|
9424 |
|
|
|
9425 |
|
|
/* Generate a relocation for _GLOBAL_OFFSET_TABLE_. */
|
9426 |
|
|
rel.r_offset = plt_address + 12;
|
9427 |
|
|
rel.r_info = ELF32_R_INFO (htab->root.hgot->indx, R_ARM_ABS32);
|
9428 |
|
|
rel.r_addend = 0;
|
9429 |
|
|
SWAP_RELOC_OUT (htab) (output_bfd, &rel,
|
9430 |
|
|
htab->srelplt2->contents);
|
9431 |
|
|
}
|
9432 |
|
|
else
|
9433 |
|
|
{
|
9434 |
|
|
got_displacement = got_address - (plt_address + 16);
|
9435 |
|
|
|
9436 |
|
|
plt0_entry = elf32_arm_plt0_entry;
|
9437 |
|
|
put_arm_insn (htab, output_bfd, plt0_entry[0],
|
9438 |
|
|
splt->contents + 0);
|
9439 |
|
|
put_arm_insn (htab, output_bfd, plt0_entry[1],
|
9440 |
|
|
splt->contents + 4);
|
9441 |
|
|
put_arm_insn (htab, output_bfd, plt0_entry[2],
|
9442 |
|
|
splt->contents + 8);
|
9443 |
|
|
put_arm_insn (htab, output_bfd, plt0_entry[3],
|
9444 |
|
|
splt->contents + 12);
|
9445 |
|
|
|
9446 |
|
|
#ifdef FOUR_WORD_PLT
|
9447 |
|
|
/* The displacement value goes in the otherwise-unused
|
9448 |
|
|
last word of the second entry. */
|
9449 |
|
|
bfd_put_32 (output_bfd, got_displacement, splt->contents + 28);
|
9450 |
|
|
#else
|
9451 |
|
|
bfd_put_32 (output_bfd, got_displacement, splt->contents + 16);
|
9452 |
|
|
#endif
|
9453 |
|
|
}
|
9454 |
|
|
}
|
9455 |
|
|
|
9456 |
|
|
/* UnixWare sets the entsize of .plt to 4, although that doesn't
|
9457 |
|
|
really seem like the right value. */
|
9458 |
|
|
if (splt->output_section->owner == output_bfd)
|
9459 |
|
|
elf_section_data (splt->output_section)->this_hdr.sh_entsize = 4;
|
9460 |
|
|
|
9461 |
|
|
if (htab->vxworks_p && !info->shared && htab->splt->size > 0)
|
9462 |
|
|
{
|
9463 |
|
|
/* Correct the .rel(a).plt.unloaded relocations. They will have
|
9464 |
|
|
incorrect symbol indexes. */
|
9465 |
|
|
int num_plts;
|
9466 |
|
|
unsigned char *p;
|
9467 |
|
|
|
9468 |
|
|
num_plts = ((htab->splt->size - htab->plt_header_size)
|
9469 |
|
|
/ htab->plt_entry_size);
|
9470 |
|
|
p = htab->srelplt2->contents + RELOC_SIZE (htab);
|
9471 |
|
|
|
9472 |
|
|
for (; num_plts; num_plts--)
|
9473 |
|
|
{
|
9474 |
|
|
Elf_Internal_Rela rel;
|
9475 |
|
|
|
9476 |
|
|
SWAP_RELOC_IN (htab) (output_bfd, p, &rel);
|
9477 |
|
|
rel.r_info = ELF32_R_INFO (htab->root.hgot->indx, R_ARM_ABS32);
|
9478 |
|
|
SWAP_RELOC_OUT (htab) (output_bfd, &rel, p);
|
9479 |
|
|
p += RELOC_SIZE (htab);
|
9480 |
|
|
|
9481 |
|
|
SWAP_RELOC_IN (htab) (output_bfd, p, &rel);
|
9482 |
|
|
rel.r_info = ELF32_R_INFO (htab->root.hplt->indx, R_ARM_ABS32);
|
9483 |
|
|
SWAP_RELOC_OUT (htab) (output_bfd, &rel, p);
|
9484 |
|
|
p += RELOC_SIZE (htab);
|
9485 |
|
|
}
|
9486 |
|
|
}
|
9487 |
|
|
}
|
9488 |
|
|
|
9489 |
|
|
/* Fill in the first three entries in the global offset table. */
|
9490 |
|
|
if (sgot)
|
9491 |
|
|
{
|
9492 |
|
|
if (sgot->size > 0)
|
9493 |
|
|
{
|
9494 |
|
|
if (sdyn == NULL)
|
9495 |
|
|
bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents);
|
9496 |
|
|
else
|
9497 |
|
|
bfd_put_32 (output_bfd,
|
9498 |
|
|
sdyn->output_section->vma + sdyn->output_offset,
|
9499 |
|
|
sgot->contents);
|
9500 |
|
|
bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + 4);
|
9501 |
|
|
bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + 8);
|
9502 |
|
|
}
|
9503 |
|
|
|
9504 |
|
|
elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
|
9505 |
|
|
}
|
9506 |
|
|
|
9507 |
|
|
return TRUE;
|
9508 |
|
|
}
|
9509 |
|
|
|
9510 |
|
|
static void
|
9511 |
|
|
elf32_arm_post_process_headers (bfd * abfd, struct bfd_link_info * link_info ATTRIBUTE_UNUSED)
|
9512 |
|
|
{
|
9513 |
|
|
Elf_Internal_Ehdr * i_ehdrp; /* ELF file header, internal form. */
|
9514 |
|
|
struct elf32_arm_link_hash_table *globals;
|
9515 |
|
|
|
9516 |
|
|
i_ehdrp = elf_elfheader (abfd);
|
9517 |
|
|
|
9518 |
|
|
if (EF_ARM_EABI_VERSION (i_ehdrp->e_flags) == EF_ARM_EABI_UNKNOWN)
|
9519 |
|
|
i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_ARM;
|
9520 |
|
|
else
|
9521 |
|
|
i_ehdrp->e_ident[EI_OSABI] = 0;
|
9522 |
|
|
i_ehdrp->e_ident[EI_ABIVERSION] = ARM_ELF_ABI_VERSION;
|
9523 |
|
|
|
9524 |
|
|
if (link_info)
|
9525 |
|
|
{
|
9526 |
|
|
globals = elf32_arm_hash_table (link_info);
|
9527 |
|
|
if (globals->byteswap_code)
|
9528 |
|
|
i_ehdrp->e_flags |= EF_ARM_BE8;
|
9529 |
|
|
}
|
9530 |
|
|
}
|
9531 |
|
|
|
9532 |
|
|
static enum elf_reloc_type_class
|
9533 |
|
|
elf32_arm_reloc_type_class (const Elf_Internal_Rela *rela)
|
9534 |
|
|
{
|
9535 |
|
|
switch ((int) ELF32_R_TYPE (rela->r_info))
|
9536 |
|
|
{
|
9537 |
|
|
case R_ARM_RELATIVE:
|
9538 |
|
|
return reloc_class_relative;
|
9539 |
|
|
case R_ARM_JUMP_SLOT:
|
9540 |
|
|
return reloc_class_plt;
|
9541 |
|
|
case R_ARM_COPY:
|
9542 |
|
|
return reloc_class_copy;
|
9543 |
|
|
default:
|
9544 |
|
|
return reloc_class_normal;
|
9545 |
|
|
}
|
9546 |
|
|
}
|
9547 |
|
|
|
9548 |
|
|
/* Set the right machine number for an Arm ELF file. */
|
9549 |
|
|
|
9550 |
|
|
static bfd_boolean
|
9551 |
|
|
elf32_arm_section_flags (flagword *flags, const Elf_Internal_Shdr *hdr)
|
9552 |
|
|
{
|
9553 |
|
|
if (hdr->sh_type == SHT_NOTE)
|
9554 |
|
|
*flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_SAME_CONTENTS;
|
9555 |
|
|
|
9556 |
|
|
return TRUE;
|
9557 |
|
|
}
|
9558 |
|
|
|
9559 |
|
|
static void
|
9560 |
|
|
elf32_arm_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED)
|
9561 |
|
|
{
|
9562 |
|
|
bfd_arm_update_notes (abfd, ARM_NOTE_SECTION);
|
9563 |
|
|
}
|
9564 |
|
|
|
9565 |
|
|
/* Return TRUE if this is an unwinding table entry. */
|
9566 |
|
|
|
9567 |
|
|
static bfd_boolean
|
9568 |
|
|
is_arm_elf_unwind_section_name (bfd * abfd ATTRIBUTE_UNUSED, const char * name)
|
9569 |
|
|
{
|
9570 |
|
|
return (CONST_STRNEQ (name, ELF_STRING_ARM_unwind)
|
9571 |
|
|
|| CONST_STRNEQ (name, ELF_STRING_ARM_unwind_once));
|
9572 |
|
|
}
|
9573 |
|
|
|
9574 |
|
|
|
9575 |
|
|
/* Set the type and flags for an ARM section. We do this by
|
9576 |
|
|
the section name, which is a hack, but ought to work. */
|
9577 |
|
|
|
9578 |
|
|
static bfd_boolean
|
9579 |
|
|
elf32_arm_fake_sections (bfd * abfd, Elf_Internal_Shdr * hdr, asection * sec)
|
9580 |
|
|
{
|
9581 |
|
|
const char * name;
|
9582 |
|
|
|
9583 |
|
|
name = bfd_get_section_name (abfd, sec);
|
9584 |
|
|
|
9585 |
|
|
if (is_arm_elf_unwind_section_name (abfd, name))
|
9586 |
|
|
{
|
9587 |
|
|
hdr->sh_type = SHT_ARM_EXIDX;
|
9588 |
|
|
hdr->sh_flags |= SHF_LINK_ORDER;
|
9589 |
|
|
}
|
9590 |
|
|
return TRUE;
|
9591 |
|
|
}
|
9592 |
|
|
|
9593 |
|
|
/* Handle an ARM specific section when reading an object file. This is
|
9594 |
|
|
called when bfd_section_from_shdr finds a section with an unknown
|
9595 |
|
|
type. */
|
9596 |
|
|
|
9597 |
|
|
static bfd_boolean
|
9598 |
|
|
elf32_arm_section_from_shdr (bfd *abfd,
|
9599 |
|
|
Elf_Internal_Shdr * hdr,
|
9600 |
|
|
const char *name,
|
9601 |
|
|
int shindex)
|
9602 |
|
|
{
|
9603 |
|
|
/* There ought to be a place to keep ELF backend specific flags, but
|
9604 |
|
|
at the moment there isn't one. We just keep track of the
|
9605 |
|
|
sections by their name, instead. Fortunately, the ABI gives
|
9606 |
|
|
names for all the ARM specific sections, so we will probably get
|
9607 |
|
|
away with this. */
|
9608 |
|
|
switch (hdr->sh_type)
|
9609 |
|
|
{
|
9610 |
|
|
case SHT_ARM_EXIDX:
|
9611 |
|
|
case SHT_ARM_PREEMPTMAP:
|
9612 |
|
|
case SHT_ARM_ATTRIBUTES:
|
9613 |
|
|
break;
|
9614 |
|
|
|
9615 |
|
|
default:
|
9616 |
|
|
return FALSE;
|
9617 |
|
|
}
|
9618 |
|
|
|
9619 |
|
|
if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
|
9620 |
|
|
return FALSE;
|
9621 |
|
|
|
9622 |
|
|
return TRUE;
|
9623 |
|
|
}
|
9624 |
|
|
|
9625 |
|
|
/* A structure used to record a list of sections, independently
|
9626 |
|
|
of the next and prev fields in the asection structure. */
|
9627 |
|
|
typedef struct section_list
|
9628 |
|
|
{
|
9629 |
|
|
asection * sec;
|
9630 |
|
|
struct section_list * next;
|
9631 |
|
|
struct section_list * prev;
|
9632 |
|
|
}
|
9633 |
|
|
section_list;
|
9634 |
|
|
|
9635 |
|
|
/* Unfortunately we need to keep a list of sections for which
|
9636 |
|
|
an _arm_elf_section_data structure has been allocated. This
|
9637 |
|
|
is because it is possible for functions like elf32_arm_write_section
|
9638 |
|
|
to be called on a section which has had an elf_data_structure
|
9639 |
|
|
allocated for it (and so the used_by_bfd field is valid) but
|
9640 |
|
|
for which the ARM extended version of this structure - the
|
9641 |
|
|
_arm_elf_section_data structure - has not been allocated. */
|
9642 |
|
|
static section_list * sections_with_arm_elf_section_data = NULL;
|
9643 |
|
|
|
9644 |
|
|
static void
|
9645 |
|
|
record_section_with_arm_elf_section_data (asection * sec)
|
9646 |
|
|
{
|
9647 |
|
|
struct section_list * entry;
|
9648 |
|
|
|
9649 |
|
|
entry = bfd_malloc (sizeof (* entry));
|
9650 |
|
|
if (entry == NULL)
|
9651 |
|
|
return;
|
9652 |
|
|
entry->sec = sec;
|
9653 |
|
|
entry->next = sections_with_arm_elf_section_data;
|
9654 |
|
|
entry->prev = NULL;
|
9655 |
|
|
if (entry->next != NULL)
|
9656 |
|
|
entry->next->prev = entry;
|
9657 |
|
|
sections_with_arm_elf_section_data = entry;
|
9658 |
|
|
}
|
9659 |
|
|
|
9660 |
|
|
static struct section_list *
|
9661 |
|
|
find_arm_elf_section_entry (asection * sec)
|
9662 |
|
|
{
|
9663 |
|
|
struct section_list * entry;
|
9664 |
|
|
static struct section_list * last_entry = NULL;
|
9665 |
|
|
|
9666 |
|
|
/* This is a short cut for the typical case where the sections are added
|
9667 |
|
|
to the sections_with_arm_elf_section_data list in forward order and
|
9668 |
|
|
then looked up here in backwards order. This makes a real difference
|
9669 |
|
|
to the ld-srec/sec64k.exp linker test. */
|
9670 |
|
|
entry = sections_with_arm_elf_section_data;
|
9671 |
|
|
if (last_entry != NULL)
|
9672 |
|
|
{
|
9673 |
|
|
if (last_entry->sec == sec)
|
9674 |
|
|
entry = last_entry;
|
9675 |
|
|
else if (last_entry->next != NULL
|
9676 |
|
|
&& last_entry->next->sec == sec)
|
9677 |
|
|
entry = last_entry->next;
|
9678 |
|
|
}
|
9679 |
|
|
|
9680 |
|
|
for (; entry; entry = entry->next)
|
9681 |
|
|
if (entry->sec == sec)
|
9682 |
|
|
break;
|
9683 |
|
|
|
9684 |
|
|
if (entry)
|
9685 |
|
|
/* Record the entry prior to this one - it is the entry we are most
|
9686 |
|
|
likely to want to locate next time. Also this way if we have been
|
9687 |
|
|
called from unrecord_section_with_arm_elf_section_data() we will not
|
9688 |
|
|
be caching a pointer that is about to be freed. */
|
9689 |
|
|
last_entry = entry->prev;
|
9690 |
|
|
|
9691 |
|
|
return entry;
|
9692 |
|
|
}
|
9693 |
|
|
|
9694 |
|
|
static _arm_elf_section_data *
|
9695 |
|
|
get_arm_elf_section_data (asection * sec)
|
9696 |
|
|
{
|
9697 |
|
|
struct section_list * entry;
|
9698 |
|
|
|
9699 |
|
|
entry = find_arm_elf_section_entry (sec);
|
9700 |
|
|
|
9701 |
|
|
if (entry)
|
9702 |
|
|
return elf32_arm_section_data (entry->sec);
|
9703 |
|
|
else
|
9704 |
|
|
return NULL;
|
9705 |
|
|
}
|
9706 |
|
|
|
9707 |
|
|
static void
|
9708 |
|
|
unrecord_section_with_arm_elf_section_data (asection * sec)
|
9709 |
|
|
{
|
9710 |
|
|
struct section_list * entry;
|
9711 |
|
|
|
9712 |
|
|
entry = find_arm_elf_section_entry (sec);
|
9713 |
|
|
|
9714 |
|
|
if (entry)
|
9715 |
|
|
{
|
9716 |
|
|
if (entry->prev != NULL)
|
9717 |
|
|
entry->prev->next = entry->next;
|
9718 |
|
|
if (entry->next != NULL)
|
9719 |
|
|
entry->next->prev = entry->prev;
|
9720 |
|
|
if (entry == sections_with_arm_elf_section_data)
|
9721 |
|
|
sections_with_arm_elf_section_data = entry->next;
|
9722 |
|
|
free (entry);
|
9723 |
|
|
}
|
9724 |
|
|
}
|
9725 |
|
|
|
9726 |
|
|
|
9727 |
|
|
typedef struct
|
9728 |
|
|
{
|
9729 |
|
|
void *finfo;
|
9730 |
|
|
struct bfd_link_info *info;
|
9731 |
|
|
asection *sec;
|
9732 |
|
|
int sec_shndx;
|
9733 |
|
|
bfd_boolean (*func) (void *, const char *, Elf_Internal_Sym *,
|
9734 |
|
|
asection *, struct elf_link_hash_entry *);
|
9735 |
|
|
} output_arch_syminfo;
|
9736 |
|
|
|
9737 |
|
|
enum map_symbol_type
|
9738 |
|
|
{
|
9739 |
|
|
ARM_MAP_ARM,
|
9740 |
|
|
ARM_MAP_THUMB,
|
9741 |
|
|
ARM_MAP_DATA
|
9742 |
|
|
};
|
9743 |
|
|
|
9744 |
|
|
|
9745 |
|
|
/* Output a single PLT mapping symbol. */
|
9746 |
|
|
|
9747 |
|
|
static bfd_boolean
|
9748 |
|
|
elf32_arm_ouput_plt_map_sym (output_arch_syminfo *osi,
|
9749 |
|
|
enum map_symbol_type type,
|
9750 |
|
|
bfd_vma offset)
|
9751 |
|
|
{
|
9752 |
|
|
static const char *names[3] = {"$a", "$t", "$d"};
|
9753 |
|
|
struct elf32_arm_link_hash_table *htab;
|
9754 |
|
|
Elf_Internal_Sym sym;
|
9755 |
|
|
|
9756 |
|
|
htab = elf32_arm_hash_table (osi->info);
|
9757 |
|
|
sym.st_value = osi->sec->output_section->vma
|
9758 |
|
|
+ osi->sec->output_offset
|
9759 |
|
|
+ offset;
|
9760 |
|
|
sym.st_size = 0;
|
9761 |
|
|
sym.st_other = 0;
|
9762 |
|
|
sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_NOTYPE);
|
9763 |
|
|
sym.st_shndx = osi->sec_shndx;
|
9764 |
|
|
if (!osi->func (osi->finfo, names[type], &sym, osi->sec, NULL))
|
9765 |
|
|
return FALSE;
|
9766 |
|
|
return TRUE;
|
9767 |
|
|
}
|
9768 |
|
|
|
9769 |
|
|
|
9770 |
|
|
/* Output mapping symbols for PLT entries associated with H. */
|
9771 |
|
|
|
9772 |
|
|
static bfd_boolean
|
9773 |
|
|
elf32_arm_output_plt_map (struct elf_link_hash_entry *h, void *inf)
|
9774 |
|
|
{
|
9775 |
|
|
output_arch_syminfo *osi = (output_arch_syminfo *) inf;
|
9776 |
|
|
struct elf32_arm_link_hash_table *htab;
|
9777 |
|
|
struct elf32_arm_link_hash_entry *eh;
|
9778 |
|
|
bfd_vma addr;
|
9779 |
|
|
|
9780 |
|
|
htab = elf32_arm_hash_table (osi->info);
|
9781 |
|
|
|
9782 |
|
|
if (h->root.type == bfd_link_hash_indirect)
|
9783 |
|
|
return TRUE;
|
9784 |
|
|
|
9785 |
|
|
if (h->root.type == bfd_link_hash_warning)
|
9786 |
|
|
/* When warning symbols are created, they **replace** the "real"
|
9787 |
|
|
entry in the hash table, thus we never get to see the real
|
9788 |
|
|
symbol in a hash traversal. So look at it now. */
|
9789 |
|
|
h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
9790 |
|
|
|
9791 |
|
|
if (h->plt.offset == (bfd_vma) -1)
|
9792 |
|
|
return TRUE;
|
9793 |
|
|
|
9794 |
|
|
eh = (struct elf32_arm_link_hash_entry *) h;
|
9795 |
|
|
addr = h->plt.offset;
|
9796 |
|
|
if (htab->symbian_p)
|
9797 |
|
|
{
|
9798 |
|
|
if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_ARM, addr))
|
9799 |
|
|
return FALSE;
|
9800 |
|
|
if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_DATA, addr + 4))
|
9801 |
|
|
return FALSE;
|
9802 |
|
|
}
|
9803 |
|
|
else if (htab->vxworks_p)
|
9804 |
|
|
{
|
9805 |
|
|
if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_ARM, addr))
|
9806 |
|
|
return FALSE;
|
9807 |
|
|
if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_DATA, addr + 8))
|
9808 |
|
|
return FALSE;
|
9809 |
|
|
if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_ARM, addr + 12))
|
9810 |
|
|
return FALSE;
|
9811 |
|
|
if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_DATA, addr + 20))
|
9812 |
|
|
return FALSE;
|
9813 |
|
|
}
|
9814 |
|
|
else
|
9815 |
|
|
{
|
9816 |
|
|
bfd_signed_vma thumb_refs;
|
9817 |
|
|
|
9818 |
|
|
thumb_refs = eh->plt_thumb_refcount;
|
9819 |
|
|
if (!htab->use_blx)
|
9820 |
|
|
thumb_refs += eh->plt_maybe_thumb_refcount;
|
9821 |
|
|
|
9822 |
|
|
if (thumb_refs > 0)
|
9823 |
|
|
{
|
9824 |
|
|
if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_THUMB, addr - 4))
|
9825 |
|
|
return FALSE;
|
9826 |
|
|
}
|
9827 |
|
|
#ifdef FOUR_WORD_PLT
|
9828 |
|
|
if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_ARM, addr))
|
9829 |
|
|
return FALSE;
|
9830 |
|
|
if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_DATA, addr + 12))
|
9831 |
|
|
return FALSE;
|
9832 |
|
|
#else
|
9833 |
|
|
/* A three-word PLT with no Thumb thunk contains only Arm code,
|
9834 |
|
|
so only need to output a mapping symbol for the first PLT entry and
|
9835 |
|
|
entries with thumb thunks. */
|
9836 |
|
|
if (thumb_refs > 0 || addr == 20)
|
9837 |
|
|
{
|
9838 |
|
|
if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_ARM, addr))
|
9839 |
|
|
return FALSE;
|
9840 |
|
|
}
|
9841 |
|
|
#endif
|
9842 |
|
|
}
|
9843 |
|
|
|
9844 |
|
|
return TRUE;
|
9845 |
|
|
}
|
9846 |
|
|
|
9847 |
|
|
|
9848 |
|
|
/* Output mapping symbols for linker generated sections. */
|
9849 |
|
|
|
9850 |
|
|
static bfd_boolean
|
9851 |
|
|
elf32_arm_output_arch_local_syms (bfd *output_bfd,
|
9852 |
|
|
struct bfd_link_info *info,
|
9853 |
|
|
void *finfo, bfd_boolean (*func) (void *, const char *,
|
9854 |
|
|
Elf_Internal_Sym *,
|
9855 |
|
|
asection *,
|
9856 |
|
|
struct elf_link_hash_entry *))
|
9857 |
|
|
{
|
9858 |
|
|
output_arch_syminfo osi;
|
9859 |
|
|
struct elf32_arm_link_hash_table *htab;
|
9860 |
|
|
bfd_vma offset;
|
9861 |
|
|
bfd_size_type size;
|
9862 |
|
|
|
9863 |
|
|
htab = elf32_arm_hash_table (info);
|
9864 |
|
|
check_use_blx(htab);
|
9865 |
|
|
|
9866 |
|
|
osi.finfo = finfo;
|
9867 |
|
|
osi.info = info;
|
9868 |
|
|
osi.func = func;
|
9869 |
|
|
|
9870 |
|
|
/* ARM->Thumb glue. */
|
9871 |
|
|
if (htab->arm_glue_size > 0)
|
9872 |
|
|
{
|
9873 |
|
|
osi.sec = bfd_get_section_by_name (htab->bfd_of_glue_owner,
|
9874 |
|
|
ARM2THUMB_GLUE_SECTION_NAME);
|
9875 |
|
|
|
9876 |
|
|
osi.sec_shndx = _bfd_elf_section_from_bfd_section
|
9877 |
|
|
(output_bfd, osi.sec->output_section);
|
9878 |
|
|
if (info->shared || htab->root.is_relocatable_executable
|
9879 |
|
|
|| htab->pic_veneer)
|
9880 |
|
|
size = ARM2THUMB_PIC_GLUE_SIZE;
|
9881 |
|
|
else if (htab->use_blx)
|
9882 |
|
|
size = ARM2THUMB_V5_STATIC_GLUE_SIZE;
|
9883 |
|
|
else
|
9884 |
|
|
size = ARM2THUMB_STATIC_GLUE_SIZE;
|
9885 |
|
|
|
9886 |
|
|
for (offset = 0; offset < htab->arm_glue_size; offset += size)
|
9887 |
|
|
{
|
9888 |
|
|
elf32_arm_ouput_plt_map_sym (&osi, ARM_MAP_ARM, offset);
|
9889 |
|
|
elf32_arm_ouput_plt_map_sym (&osi, ARM_MAP_DATA, offset + size - 4);
|
9890 |
|
|
}
|
9891 |
|
|
}
|
9892 |
|
|
|
9893 |
|
|
/* Thumb->ARM glue. */
|
9894 |
|
|
if (htab->thumb_glue_size > 0)
|
9895 |
|
|
{
|
9896 |
|
|
osi.sec = bfd_get_section_by_name (htab->bfd_of_glue_owner,
|
9897 |
|
|
THUMB2ARM_GLUE_SECTION_NAME);
|
9898 |
|
|
|
9899 |
|
|
osi.sec_shndx = _bfd_elf_section_from_bfd_section
|
9900 |
|
|
(output_bfd, osi.sec->output_section);
|
9901 |
|
|
size = THUMB2ARM_GLUE_SIZE;
|
9902 |
|
|
|
9903 |
|
|
for (offset = 0; offset < htab->thumb_glue_size; offset += size)
|
9904 |
|
|
{
|
9905 |
|
|
elf32_arm_ouput_plt_map_sym (&osi, ARM_MAP_THUMB, offset);
|
9906 |
|
|
elf32_arm_ouput_plt_map_sym (&osi, ARM_MAP_ARM, offset + 4);
|
9907 |
|
|
}
|
9908 |
|
|
}
|
9909 |
|
|
|
9910 |
|
|
/* ARMv4 BX veneers. */
|
9911 |
|
|
if (htab->bx_glue_size > 0)
|
9912 |
|
|
{
|
9913 |
|
|
osi.sec = bfd_get_section_by_name (htab->bfd_of_glue_owner,
|
9914 |
|
|
ARM_BX_GLUE_SECTION_NAME);
|
9915 |
|
|
|
9916 |
|
|
osi.sec_shndx = _bfd_elf_section_from_bfd_section
|
9917 |
|
|
(output_bfd, osi.sec->output_section);
|
9918 |
|
|
|
9919 |
|
|
elf32_arm_ouput_plt_map_sym (&osi, ARM_MAP_ARM, 0);
|
9920 |
|
|
}
|
9921 |
|
|
|
9922 |
|
|
/* Finally, output mapping symbols for the PLT. */
|
9923 |
|
|
if (!htab->splt || htab->splt->size == 0)
|
9924 |
|
|
return TRUE;
|
9925 |
|
|
|
9926 |
|
|
osi.sec_shndx = _bfd_elf_section_from_bfd_section (output_bfd,
|
9927 |
|
|
htab->splt->output_section);
|
9928 |
|
|
osi.sec = htab->splt;
|
9929 |
|
|
/* Output mapping symbols for the plt header. SymbianOS does not have a
|
9930 |
|
|
plt header. */
|
9931 |
|
|
if (htab->vxworks_p)
|
9932 |
|
|
{
|
9933 |
|
|
/* VxWorks shared libraries have no PLT header. */
|
9934 |
|
|
if (!info->shared)
|
9935 |
|
|
{
|
9936 |
|
|
if (!elf32_arm_ouput_plt_map_sym (&osi, ARM_MAP_ARM, 0))
|
9937 |
|
|
return FALSE;
|
9938 |
|
|
if (!elf32_arm_ouput_plt_map_sym (&osi, ARM_MAP_DATA, 12))
|
9939 |
|
|
return FALSE;
|
9940 |
|
|
}
|
9941 |
|
|
}
|
9942 |
|
|
else if (!htab->symbian_p)
|
9943 |
|
|
{
|
9944 |
|
|
if (!elf32_arm_ouput_plt_map_sym (&osi, ARM_MAP_ARM, 0))
|
9945 |
|
|
return FALSE;
|
9946 |
|
|
#ifndef FOUR_WORD_PLT
|
9947 |
|
|
if (!elf32_arm_ouput_plt_map_sym (&osi, ARM_MAP_DATA, 16))
|
9948 |
|
|
return FALSE;
|
9949 |
|
|
#endif
|
9950 |
|
|
}
|
9951 |
|
|
|
9952 |
|
|
elf_link_hash_traverse (&htab->root, elf32_arm_output_plt_map, (void *) &osi);
|
9953 |
|
|
return TRUE;
|
9954 |
|
|
}
|
9955 |
|
|
|
9956 |
|
|
/* Allocate target specific section data. */
|
9957 |
|
|
|
9958 |
|
|
static bfd_boolean
|
9959 |
|
|
elf32_arm_new_section_hook (bfd *abfd, asection *sec)
|
9960 |
|
|
{
|
9961 |
|
|
if (!sec->used_by_bfd)
|
9962 |
|
|
{
|
9963 |
|
|
_arm_elf_section_data *sdata;
|
9964 |
|
|
bfd_size_type amt = sizeof (*sdata);
|
9965 |
|
|
|
9966 |
|
|
sdata = bfd_zalloc (abfd, amt);
|
9967 |
|
|
if (sdata == NULL)
|
9968 |
|
|
return FALSE;
|
9969 |
|
|
sec->used_by_bfd = sdata;
|
9970 |
|
|
}
|
9971 |
|
|
|
9972 |
|
|
record_section_with_arm_elf_section_data (sec);
|
9973 |
|
|
|
9974 |
|
|
return _bfd_elf_new_section_hook (abfd, sec);
|
9975 |
|
|
}
|
9976 |
|
|
|
9977 |
|
|
|
9978 |
|
|
/* Used to order a list of mapping symbols by address. */
|
9979 |
|
|
|
9980 |
|
|
static int
|
9981 |
|
|
elf32_arm_compare_mapping (const void * a, const void * b)
|
9982 |
|
|
{
|
9983 |
|
|
const elf32_arm_section_map *amap = (const elf32_arm_section_map *) a;
|
9984 |
|
|
const elf32_arm_section_map *bmap = (const elf32_arm_section_map *) b;
|
9985 |
|
|
|
9986 |
|
|
if (amap->vma > bmap->vma)
|
9987 |
|
|
return 1;
|
9988 |
|
|
else if (amap->vma < bmap->vma)
|
9989 |
|
|
return -1;
|
9990 |
|
|
else if (amap->type > bmap->type)
|
9991 |
|
|
/* Ensure results do not depend on the host qsort for objects with
|
9992 |
|
|
multiple mapping symbols at the same address by sorting on type
|
9993 |
|
|
after vma. */
|
9994 |
|
|
return 1;
|
9995 |
|
|
else if (amap->type < bmap->type)
|
9996 |
|
|
return -1;
|
9997 |
|
|
else
|
9998 |
|
|
return 0;
|
9999 |
|
|
}
|
10000 |
|
|
|
10001 |
|
|
|
10002 |
|
|
/* Do code byteswapping. Return FALSE afterwards so that the section is
|
10003 |
|
|
written out as normal. */
|
10004 |
|
|
|
10005 |
|
|
static bfd_boolean
|
10006 |
|
|
elf32_arm_write_section (bfd *output_bfd,
|
10007 |
|
|
struct bfd_link_info *link_info, asection *sec,
|
10008 |
|
|
bfd_byte *contents)
|
10009 |
|
|
{
|
10010 |
|
|
int mapcount, errcount;
|
10011 |
|
|
_arm_elf_section_data *arm_data;
|
10012 |
|
|
struct elf32_arm_link_hash_table *globals = elf32_arm_hash_table (link_info);
|
10013 |
|
|
elf32_arm_section_map *map;
|
10014 |
|
|
elf32_vfp11_erratum_list *errnode;
|
10015 |
|
|
bfd_vma ptr;
|
10016 |
|
|
bfd_vma end;
|
10017 |
|
|
bfd_vma offset = sec->output_section->vma + sec->output_offset;
|
10018 |
|
|
bfd_byte tmp;
|
10019 |
|
|
int i;
|
10020 |
|
|
|
10021 |
|
|
/* If this section has not been allocated an _arm_elf_section_data
|
10022 |
|
|
structure then we cannot record anything. */
|
10023 |
|
|
arm_data = get_arm_elf_section_data (sec);
|
10024 |
|
|
if (arm_data == NULL)
|
10025 |
|
|
return FALSE;
|
10026 |
|
|
|
10027 |
|
|
mapcount = arm_data->mapcount;
|
10028 |
|
|
map = arm_data->map;
|
10029 |
|
|
errcount = arm_data->erratumcount;
|
10030 |
|
|
|
10031 |
|
|
if (errcount != 0)
|
10032 |
|
|
{
|
10033 |
|
|
unsigned int endianflip = bfd_big_endian (output_bfd) ? 3 : 0;
|
10034 |
|
|
|
10035 |
|
|
for (errnode = arm_data->erratumlist; errnode != 0;
|
10036 |
|
|
errnode = errnode->next)
|
10037 |
|
|
{
|
10038 |
|
|
bfd_vma index = errnode->vma - offset;
|
10039 |
|
|
|
10040 |
|
|
switch (errnode->type)
|
10041 |
|
|
{
|
10042 |
|
|
case VFP11_ERRATUM_BRANCH_TO_ARM_VENEER:
|
10043 |
|
|
{
|
10044 |
|
|
bfd_vma branch_to_veneer;
|
10045 |
|
|
/* Original condition code of instruction, plus bit mask for
|
10046 |
|
|
ARM B instruction. */
|
10047 |
|
|
unsigned int insn = (errnode->u.b.vfp_insn & 0xf0000000)
|
10048 |
|
|
| 0x0a000000;
|
10049 |
|
|
|
10050 |
|
|
/* The instruction is before the label. */
|
10051 |
|
|
index -= 4;
|
10052 |
|
|
|
10053 |
|
|
/* Above offset included in -4 below. */
|
10054 |
|
|
branch_to_veneer = errnode->u.b.veneer->vma
|
10055 |
|
|
- errnode->vma - 4;
|
10056 |
|
|
|
10057 |
|
|
if ((signed) branch_to_veneer < -(1 << 25)
|
10058 |
|
|
|| (signed) branch_to_veneer >= (1 << 25))
|
10059 |
|
|
(*_bfd_error_handler) (_("%B: error: VFP11 veneer out of "
|
10060 |
|
|
"range"), output_bfd);
|
10061 |
|
|
|
10062 |
|
|
insn |= (branch_to_veneer >> 2) & 0xffffff;
|
10063 |
|
|
contents[endianflip ^ index] = insn & 0xff;
|
10064 |
|
|
contents[endianflip ^ (index + 1)] = (insn >> 8) & 0xff;
|
10065 |
|
|
contents[endianflip ^ (index + 2)] = (insn >> 16) & 0xff;
|
10066 |
|
|
contents[endianflip ^ (index + 3)] = (insn >> 24) & 0xff;
|
10067 |
|
|
}
|
10068 |
|
|
break;
|
10069 |
|
|
|
10070 |
|
|
case VFP11_ERRATUM_ARM_VENEER:
|
10071 |
|
|
{
|
10072 |
|
|
bfd_vma branch_from_veneer;
|
10073 |
|
|
unsigned int insn;
|
10074 |
|
|
|
10075 |
|
|
/* Take size of veneer into account. */
|
10076 |
|
|
branch_from_veneer = errnode->u.v.branch->vma
|
10077 |
|
|
- errnode->vma - 12;
|
10078 |
|
|
|
10079 |
|
|
if ((signed) branch_from_veneer < -(1 << 25)
|
10080 |
|
|
|| (signed) branch_from_veneer >= (1 << 25))
|
10081 |
|
|
(*_bfd_error_handler) (_("%B: error: VFP11 veneer out of "
|
10082 |
|
|
"range"), output_bfd);
|
10083 |
|
|
|
10084 |
|
|
/* Original instruction. */
|
10085 |
|
|
insn = errnode->u.v.branch->u.b.vfp_insn;
|
10086 |
|
|
contents[endianflip ^ index] = insn & 0xff;
|
10087 |
|
|
contents[endianflip ^ (index + 1)] = (insn >> 8) & 0xff;
|
10088 |
|
|
contents[endianflip ^ (index + 2)] = (insn >> 16) & 0xff;
|
10089 |
|
|
contents[endianflip ^ (index + 3)] = (insn >> 24) & 0xff;
|
10090 |
|
|
|
10091 |
|
|
/* Branch back to insn after original insn. */
|
10092 |
|
|
insn = 0xea000000 | ((branch_from_veneer >> 2) & 0xffffff);
|
10093 |
|
|
contents[endianflip ^ (index + 4)] = insn & 0xff;
|
10094 |
|
|
contents[endianflip ^ (index + 5)] = (insn >> 8) & 0xff;
|
10095 |
|
|
contents[endianflip ^ (index + 6)] = (insn >> 16) & 0xff;
|
10096 |
|
|
contents[endianflip ^ (index + 7)] = (insn >> 24) & 0xff;
|
10097 |
|
|
}
|
10098 |
|
|
break;
|
10099 |
|
|
|
10100 |
|
|
default:
|
10101 |
|
|
abort ();
|
10102 |
|
|
}
|
10103 |
|
|
}
|
10104 |
|
|
}
|
10105 |
|
|
|
10106 |
|
|
if (mapcount == 0)
|
10107 |
|
|
return FALSE;
|
10108 |
|
|
|
10109 |
|
|
if (globals->byteswap_code)
|
10110 |
|
|
{
|
10111 |
|
|
qsort (map, mapcount, sizeof (* map), elf32_arm_compare_mapping);
|
10112 |
|
|
|
10113 |
|
|
ptr = map[0].vma;
|
10114 |
|
|
for (i = 0; i < mapcount; i++)
|
10115 |
|
|
{
|
10116 |
|
|
if (i == mapcount - 1)
|
10117 |
|
|
end = sec->size;
|
10118 |
|
|
else
|
10119 |
|
|
end = map[i + 1].vma;
|
10120 |
|
|
|
10121 |
|
|
switch (map[i].type)
|
10122 |
|
|
{
|
10123 |
|
|
case 'a':
|
10124 |
|
|
/* Byte swap code words. */
|
10125 |
|
|
while (ptr + 3 < end)
|
10126 |
|
|
{
|
10127 |
|
|
tmp = contents[ptr];
|
10128 |
|
|
contents[ptr] = contents[ptr + 3];
|
10129 |
|
|
contents[ptr + 3] = tmp;
|
10130 |
|
|
tmp = contents[ptr + 1];
|
10131 |
|
|
contents[ptr + 1] = contents[ptr + 2];
|
10132 |
|
|
contents[ptr + 2] = tmp;
|
10133 |
|
|
ptr += 4;
|
10134 |
|
|
}
|
10135 |
|
|
break;
|
10136 |
|
|
|
10137 |
|
|
case 't':
|
10138 |
|
|
/* Byte swap code halfwords. */
|
10139 |
|
|
while (ptr + 1 < end)
|
10140 |
|
|
{
|
10141 |
|
|
tmp = contents[ptr];
|
10142 |
|
|
contents[ptr] = contents[ptr + 1];
|
10143 |
|
|
contents[ptr + 1] = tmp;
|
10144 |
|
|
ptr += 2;
|
10145 |
|
|
}
|
10146 |
|
|
break;
|
10147 |
|
|
|
10148 |
|
|
case 'd':
|
10149 |
|
|
/* Leave data alone. */
|
10150 |
|
|
break;
|
10151 |
|
|
}
|
10152 |
|
|
ptr = end;
|
10153 |
|
|
}
|
10154 |
|
|
}
|
10155 |
|
|
|
10156 |
|
|
free (map);
|
10157 |
|
|
arm_data->mapcount = 0;
|
10158 |
|
|
arm_data->mapsize = 0;
|
10159 |
|
|
arm_data->map = NULL;
|
10160 |
|
|
unrecord_section_with_arm_elf_section_data (sec);
|
10161 |
|
|
|
10162 |
|
|
return FALSE;
|
10163 |
|
|
}
|
10164 |
|
|
|
10165 |
|
|
static void
|
10166 |
|
|
unrecord_section_via_map_over_sections (bfd * abfd ATTRIBUTE_UNUSED,
|
10167 |
|
|
asection * sec,
|
10168 |
|
|
void * ignore ATTRIBUTE_UNUSED)
|
10169 |
|
|
{
|
10170 |
|
|
unrecord_section_with_arm_elf_section_data (sec);
|
10171 |
|
|
}
|
10172 |
|
|
|
10173 |
|
|
static bfd_boolean
|
10174 |
|
|
elf32_arm_close_and_cleanup (bfd * abfd)
|
10175 |
|
|
{
|
10176 |
|
|
if (abfd->sections)
|
10177 |
|
|
bfd_map_over_sections (abfd,
|
10178 |
|
|
unrecord_section_via_map_over_sections,
|
10179 |
|
|
NULL);
|
10180 |
|
|
|
10181 |
|
|
return _bfd_elf_close_and_cleanup (abfd);
|
10182 |
|
|
}
|
10183 |
|
|
|
10184 |
|
|
static bfd_boolean
|
10185 |
|
|
elf32_arm_bfd_free_cached_info (bfd * abfd)
|
10186 |
|
|
{
|
10187 |
|
|
if (abfd->sections)
|
10188 |
|
|
bfd_map_over_sections (abfd,
|
10189 |
|
|
unrecord_section_via_map_over_sections,
|
10190 |
|
|
NULL);
|
10191 |
|
|
|
10192 |
|
|
return _bfd_free_cached_info (abfd);
|
10193 |
|
|
}
|
10194 |
|
|
|
10195 |
|
|
/* Display STT_ARM_TFUNC symbols as functions. */
|
10196 |
|
|
|
10197 |
|
|
static void
|
10198 |
|
|
elf32_arm_symbol_processing (bfd *abfd ATTRIBUTE_UNUSED,
|
10199 |
|
|
asymbol *asym)
|
10200 |
|
|
{
|
10201 |
|
|
elf_symbol_type *elfsym = (elf_symbol_type *) asym;
|
10202 |
|
|
|
10203 |
|
|
if (ELF_ST_TYPE (elfsym->internal_elf_sym.st_info) == STT_ARM_TFUNC)
|
10204 |
|
|
elfsym->symbol.flags |= BSF_FUNCTION;
|
10205 |
|
|
}
|
10206 |
|
|
|
10207 |
|
|
|
10208 |
|
|
/* Mangle thumb function symbols as we read them in. */
|
10209 |
|
|
|
10210 |
|
|
static bfd_boolean
|
10211 |
|
|
elf32_arm_swap_symbol_in (bfd * abfd,
|
10212 |
|
|
const void *psrc,
|
10213 |
|
|
const void *pshn,
|
10214 |
|
|
Elf_Internal_Sym *dst)
|
10215 |
|
|
{
|
10216 |
|
|
if (!bfd_elf32_swap_symbol_in (abfd, psrc, pshn, dst))
|
10217 |
|
|
return FALSE;
|
10218 |
|
|
|
10219 |
|
|
/* New EABI objects mark thumb function symbols by setting the low bit of
|
10220 |
|
|
the address. Turn these into STT_ARM_TFUNC. */
|
10221 |
|
|
if (ELF_ST_TYPE (dst->st_info) == STT_FUNC
|
10222 |
|
|
&& (dst->st_value & 1))
|
10223 |
|
|
{
|
10224 |
|
|
dst->st_info = ELF_ST_INFO (ELF_ST_BIND (dst->st_info), STT_ARM_TFUNC);
|
10225 |
|
|
dst->st_value &= ~(bfd_vma) 1;
|
10226 |
|
|
}
|
10227 |
|
|
return TRUE;
|
10228 |
|
|
}
|
10229 |
|
|
|
10230 |
|
|
|
10231 |
|
|
/* Mangle thumb function symbols as we write them out. */
|
10232 |
|
|
|
10233 |
|
|
static void
|
10234 |
|
|
elf32_arm_swap_symbol_out (bfd *abfd,
|
10235 |
|
|
const Elf_Internal_Sym *src,
|
10236 |
|
|
void *cdst,
|
10237 |
|
|
void *shndx)
|
10238 |
|
|
{
|
10239 |
|
|
Elf_Internal_Sym newsym;
|
10240 |
|
|
|
10241 |
|
|
/* We convert STT_ARM_TFUNC symbols into STT_FUNC with the low bit
|
10242 |
|
|
of the address set, as per the new EABI. We do this unconditionally
|
10243 |
|
|
because objcopy does not set the elf header flags until after
|
10244 |
|
|
it writes out the symbol table. */
|
10245 |
|
|
if (ELF_ST_TYPE (src->st_info) == STT_ARM_TFUNC)
|
10246 |
|
|
{
|
10247 |
|
|
newsym = *src;
|
10248 |
|
|
newsym.st_info = ELF_ST_INFO (ELF_ST_BIND (src->st_info), STT_FUNC);
|
10249 |
|
|
if (newsym.st_shndx != SHN_UNDEF)
|
10250 |
|
|
{
|
10251 |
|
|
/* Do this only for defined symbols. At link type, the static
|
10252 |
|
|
linker will simulate the work of dynamic linker of resolving
|
10253 |
|
|
symbols and will carry over the thumbness of found symbols to
|
10254 |
|
|
the output symbol table. It's not clear how it happens, but
|
10255 |
|
|
the thumbness of undefined symbols can well be different at
|
10256 |
|
|
runtime, and writing '1' for them will be confusing for users
|
10257 |
|
|
and possibly for dynamic linker itself.
|
10258 |
|
|
*/
|
10259 |
|
|
newsym.st_value |= 1;
|
10260 |
|
|
}
|
10261 |
|
|
|
10262 |
|
|
src = &newsym;
|
10263 |
|
|
}
|
10264 |
|
|
bfd_elf32_swap_symbol_out (abfd, src, cdst, shndx);
|
10265 |
|
|
}
|
10266 |
|
|
|
10267 |
|
|
/* Add the PT_ARM_EXIDX program header. */
|
10268 |
|
|
|
10269 |
|
|
static bfd_boolean
|
10270 |
|
|
elf32_arm_modify_segment_map (bfd *abfd,
|
10271 |
|
|
struct bfd_link_info *info ATTRIBUTE_UNUSED)
|
10272 |
|
|
{
|
10273 |
|
|
struct elf_segment_map *m;
|
10274 |
|
|
asection *sec;
|
10275 |
|
|
|
10276 |
|
|
sec = bfd_get_section_by_name (abfd, ".ARM.exidx");
|
10277 |
|
|
if (sec != NULL && (sec->flags & SEC_LOAD) != 0)
|
10278 |
|
|
{
|
10279 |
|
|
/* If there is already a PT_ARM_EXIDX header, then we do not
|
10280 |
|
|
want to add another one. This situation arises when running
|
10281 |
|
|
"strip"; the input binary already has the header. */
|
10282 |
|
|
m = elf_tdata (abfd)->segment_map;
|
10283 |
|
|
while (m && m->p_type != PT_ARM_EXIDX)
|
10284 |
|
|
m = m->next;
|
10285 |
|
|
if (!m)
|
10286 |
|
|
{
|
10287 |
|
|
m = bfd_zalloc (abfd, sizeof (struct elf_segment_map));
|
10288 |
|
|
if (m == NULL)
|
10289 |
|
|
return FALSE;
|
10290 |
|
|
m->p_type = PT_ARM_EXIDX;
|
10291 |
|
|
m->count = 1;
|
10292 |
|
|
m->sections[0] = sec;
|
10293 |
|
|
|
10294 |
|
|
m->next = elf_tdata (abfd)->segment_map;
|
10295 |
|
|
elf_tdata (abfd)->segment_map = m;
|
10296 |
|
|
}
|
10297 |
|
|
}
|
10298 |
|
|
|
10299 |
|
|
return TRUE;
|
10300 |
|
|
}
|
10301 |
|
|
|
10302 |
|
|
/* We may add a PT_ARM_EXIDX program header. */
|
10303 |
|
|
|
10304 |
|
|
static int
|
10305 |
|
|
elf32_arm_additional_program_headers (bfd *abfd,
|
10306 |
|
|
struct bfd_link_info *info ATTRIBUTE_UNUSED)
|
10307 |
|
|
{
|
10308 |
|
|
asection *sec;
|
10309 |
|
|
|
10310 |
|
|
sec = bfd_get_section_by_name (abfd, ".ARM.exidx");
|
10311 |
|
|
if (sec != NULL && (sec->flags & SEC_LOAD) != 0)
|
10312 |
|
|
return 1;
|
10313 |
|
|
else
|
10314 |
|
|
return 0;
|
10315 |
|
|
}
|
10316 |
|
|
|
10317 |
|
|
/* We have two function types: STT_FUNC and STT_ARM_TFUNC. */
|
10318 |
|
|
static bfd_boolean
|
10319 |
|
|
elf32_arm_is_function_type (unsigned int type)
|
10320 |
|
|
{
|
10321 |
|
|
return (type == STT_FUNC) || (type == STT_ARM_TFUNC);
|
10322 |
|
|
}
|
10323 |
|
|
|
10324 |
|
|
/* We use this to override swap_symbol_in and swap_symbol_out. */
|
10325 |
|
|
const struct elf_size_info elf32_arm_size_info = {
|
10326 |
|
|
sizeof (Elf32_External_Ehdr),
|
10327 |
|
|
sizeof (Elf32_External_Phdr),
|
10328 |
|
|
sizeof (Elf32_External_Shdr),
|
10329 |
|
|
sizeof (Elf32_External_Rel),
|
10330 |
|
|
sizeof (Elf32_External_Rela),
|
10331 |
|
|
sizeof (Elf32_External_Sym),
|
10332 |
|
|
sizeof (Elf32_External_Dyn),
|
10333 |
|
|
sizeof (Elf_External_Note),
|
10334 |
|
|
4,
|
10335 |
|
|
1,
|
10336 |
|
|
32, 2,
|
10337 |
|
|
ELFCLASS32, EV_CURRENT,
|
10338 |
|
|
bfd_elf32_write_out_phdrs,
|
10339 |
|
|
bfd_elf32_write_shdrs_and_ehdr,
|
10340 |
|
|
bfd_elf32_checksum_contents,
|
10341 |
|
|
bfd_elf32_write_relocs,
|
10342 |
|
|
elf32_arm_swap_symbol_in,
|
10343 |
|
|
elf32_arm_swap_symbol_out,
|
10344 |
|
|
bfd_elf32_slurp_reloc_table,
|
10345 |
|
|
bfd_elf32_slurp_symbol_table,
|
10346 |
|
|
bfd_elf32_swap_dyn_in,
|
10347 |
|
|
bfd_elf32_swap_dyn_out,
|
10348 |
|
|
bfd_elf32_swap_reloc_in,
|
10349 |
|
|
bfd_elf32_swap_reloc_out,
|
10350 |
|
|
bfd_elf32_swap_reloca_in,
|
10351 |
|
|
bfd_elf32_swap_reloca_out
|
10352 |
|
|
};
|
10353 |
|
|
|
10354 |
|
|
#define ELF_ARCH bfd_arch_arm
|
10355 |
|
|
#define ELF_MACHINE_CODE EM_ARM
|
10356 |
|
|
#ifdef __QNXTARGET__
|
10357 |
|
|
#define ELF_MAXPAGESIZE 0x1000
|
10358 |
|
|
#else
|
10359 |
|
|
#define ELF_MAXPAGESIZE 0x8000
|
10360 |
|
|
#endif
|
10361 |
|
|
#define ELF_MINPAGESIZE 0x1000
|
10362 |
|
|
#define ELF_COMMONPAGESIZE 0x1000
|
10363 |
|
|
|
10364 |
|
|
#define bfd_elf32_mkobject elf32_arm_mkobject
|
10365 |
|
|
|
10366 |
|
|
#define bfd_elf32_bfd_copy_private_bfd_data elf32_arm_copy_private_bfd_data
|
10367 |
|
|
#define bfd_elf32_bfd_merge_private_bfd_data elf32_arm_merge_private_bfd_data
|
10368 |
|
|
#define bfd_elf32_bfd_set_private_flags elf32_arm_set_private_flags
|
10369 |
|
|
#define bfd_elf32_bfd_print_private_bfd_data elf32_arm_print_private_bfd_data
|
10370 |
|
|
#define bfd_elf32_bfd_link_hash_table_create elf32_arm_link_hash_table_create
|
10371 |
|
|
#define bfd_elf32_bfd_reloc_type_lookup elf32_arm_reloc_type_lookup
|
10372 |
|
|
#define bfd_elf32_bfd_reloc_name_lookup elf32_arm_reloc_name_lookup
|
10373 |
|
|
#define bfd_elf32_find_nearest_line elf32_arm_find_nearest_line
|
10374 |
|
|
#define bfd_elf32_find_inliner_info elf32_arm_find_inliner_info
|
10375 |
|
|
#define bfd_elf32_new_section_hook elf32_arm_new_section_hook
|
10376 |
|
|
#define bfd_elf32_bfd_is_target_special_symbol elf32_arm_is_target_special_symbol
|
10377 |
|
|
#define bfd_elf32_close_and_cleanup elf32_arm_close_and_cleanup
|
10378 |
|
|
#define bfd_elf32_bfd_free_cached_info elf32_arm_bfd_free_cached_info
|
10379 |
|
|
|
10380 |
|
|
#define elf_backend_get_symbol_type elf32_arm_get_symbol_type
|
10381 |
|
|
#define elf_backend_gc_mark_hook elf32_arm_gc_mark_hook
|
10382 |
|
|
#define elf_backend_gc_mark_extra_sections elf32_arm_gc_mark_extra_sections
|
10383 |
|
|
#define elf_backend_gc_sweep_hook elf32_arm_gc_sweep_hook
|
10384 |
|
|
#define elf_backend_check_relocs elf32_arm_check_relocs
|
10385 |
|
|
#define elf_backend_relocate_section elf32_arm_relocate_section
|
10386 |
|
|
#define elf_backend_write_section elf32_arm_write_section
|
10387 |
|
|
#define elf_backend_adjust_dynamic_symbol elf32_arm_adjust_dynamic_symbol
|
10388 |
|
|
#define elf_backend_create_dynamic_sections elf32_arm_create_dynamic_sections
|
10389 |
|
|
#define elf_backend_finish_dynamic_symbol elf32_arm_finish_dynamic_symbol
|
10390 |
|
|
#define elf_backend_finish_dynamic_sections elf32_arm_finish_dynamic_sections
|
10391 |
|
|
#define elf_backend_size_dynamic_sections elf32_arm_size_dynamic_sections
|
10392 |
|
|
#define elf_backend_init_index_section _bfd_elf_init_2_index_sections
|
10393 |
|
|
#define elf_backend_post_process_headers elf32_arm_post_process_headers
|
10394 |
|
|
#define elf_backend_reloc_type_class elf32_arm_reloc_type_class
|
10395 |
|
|
#define elf_backend_object_p elf32_arm_object_p
|
10396 |
|
|
#define elf_backend_section_flags elf32_arm_section_flags
|
10397 |
|
|
#define elf_backend_fake_sections elf32_arm_fake_sections
|
10398 |
|
|
#define elf_backend_section_from_shdr elf32_arm_section_from_shdr
|
10399 |
|
|
#define elf_backend_final_write_processing elf32_arm_final_write_processing
|
10400 |
|
|
#define elf_backend_copy_indirect_symbol elf32_arm_copy_indirect_symbol
|
10401 |
|
|
#define elf_backend_symbol_processing elf32_arm_symbol_processing
|
10402 |
|
|
#define elf_backend_size_info elf32_arm_size_info
|
10403 |
|
|
#define elf_backend_modify_segment_map elf32_arm_modify_segment_map
|
10404 |
|
|
#define elf_backend_additional_program_headers \
|
10405 |
|
|
elf32_arm_additional_program_headers
|
10406 |
|
|
#define elf_backend_output_arch_local_syms \
|
10407 |
|
|
elf32_arm_output_arch_local_syms
|
10408 |
|
|
#define elf_backend_begin_write_processing \
|
10409 |
|
|
elf32_arm_begin_write_processing
|
10410 |
|
|
#define elf_backend_is_function_type elf32_arm_is_function_type
|
10411 |
|
|
|
10412 |
|
|
#define elf_backend_can_refcount 1
|
10413 |
|
|
#define elf_backend_can_gc_sections 1
|
10414 |
|
|
#define elf_backend_plt_readonly 1
|
10415 |
|
|
#define elf_backend_want_got_plt 1
|
10416 |
|
|
#define elf_backend_want_plt_sym 0
|
10417 |
|
|
#define elf_backend_may_use_rel_p 1
|
10418 |
|
|
#define elf_backend_may_use_rela_p 0
|
10419 |
|
|
#define elf_backend_default_use_rela_p 0
|
10420 |
|
|
|
10421 |
|
|
#define elf_backend_got_header_size 12
|
10422 |
|
|
|
10423 |
|
|
#undef elf_backend_obj_attrs_vendor
|
10424 |
|
|
#define elf_backend_obj_attrs_vendor "aeabi"
|
10425 |
|
|
#undef elf_backend_obj_attrs_section
|
10426 |
|
|
#define elf_backend_obj_attrs_section ".ARM.attributes"
|
10427 |
|
|
#undef elf_backend_obj_attrs_arg_type
|
10428 |
|
|
#define elf_backend_obj_attrs_arg_type elf32_arm_obj_attrs_arg_type
|
10429 |
|
|
#undef elf_backend_obj_attrs_section_type
|
10430 |
|
|
#define elf_backend_obj_attrs_section_type SHT_ARM_ATTRIBUTES
|
10431 |
|
|
|
10432 |
|
|
#include "elf32-target.h"
|
10433 |
|
|
|
10434 |
|
|
/* VxWorks Targets */
|
10435 |
|
|
|
10436 |
|
|
#undef TARGET_LITTLE_SYM
|
10437 |
|
|
#define TARGET_LITTLE_SYM bfd_elf32_littlearm_vxworks_vec
|
10438 |
|
|
#undef TARGET_LITTLE_NAME
|
10439 |
|
|
#define TARGET_LITTLE_NAME "elf32-littlearm-vxworks"
|
10440 |
|
|
#undef TARGET_BIG_SYM
|
10441 |
|
|
#define TARGET_BIG_SYM bfd_elf32_bigarm_vxworks_vec
|
10442 |
|
|
#undef TARGET_BIG_NAME
|
10443 |
|
|
#define TARGET_BIG_NAME "elf32-bigarm-vxworks"
|
10444 |
|
|
|
10445 |
|
|
/* Like elf32_arm_link_hash_table_create -- but overrides
|
10446 |
|
|
appropriately for VxWorks. */
|
10447 |
|
|
static struct bfd_link_hash_table *
|
10448 |
|
|
elf32_arm_vxworks_link_hash_table_create (bfd *abfd)
|
10449 |
|
|
{
|
10450 |
|
|
struct bfd_link_hash_table *ret;
|
10451 |
|
|
|
10452 |
|
|
ret = elf32_arm_link_hash_table_create (abfd);
|
10453 |
|
|
if (ret)
|
10454 |
|
|
{
|
10455 |
|
|
struct elf32_arm_link_hash_table *htab
|
10456 |
|
|
= (struct elf32_arm_link_hash_table *) ret;
|
10457 |
|
|
htab->use_rel = 0;
|
10458 |
|
|
htab->vxworks_p = 1;
|
10459 |
|
|
}
|
10460 |
|
|
return ret;
|
10461 |
|
|
}
|
10462 |
|
|
|
10463 |
|
|
static void
|
10464 |
|
|
elf32_arm_vxworks_final_write_processing (bfd *abfd, bfd_boolean linker)
|
10465 |
|
|
{
|
10466 |
|
|
elf32_arm_final_write_processing (abfd, linker);
|
10467 |
|
|
elf_vxworks_final_write_processing (abfd, linker);
|
10468 |
|
|
}
|
10469 |
|
|
|
10470 |
|
|
#undef elf32_bed
|
10471 |
|
|
#define elf32_bed elf32_arm_vxworks_bed
|
10472 |
|
|
|
10473 |
|
|
#undef bfd_elf32_bfd_link_hash_table_create
|
10474 |
|
|
#define bfd_elf32_bfd_link_hash_table_create \
|
10475 |
|
|
elf32_arm_vxworks_link_hash_table_create
|
10476 |
|
|
#undef elf_backend_add_symbol_hook
|
10477 |
|
|
#define elf_backend_add_symbol_hook \
|
10478 |
|
|
elf_vxworks_add_symbol_hook
|
10479 |
|
|
#undef elf_backend_final_write_processing
|
10480 |
|
|
#define elf_backend_final_write_processing \
|
10481 |
|
|
elf32_arm_vxworks_final_write_processing
|
10482 |
|
|
#undef elf_backend_emit_relocs
|
10483 |
|
|
#define elf_backend_emit_relocs \
|
10484 |
|
|
elf_vxworks_emit_relocs
|
10485 |
|
|
|
10486 |
|
|
#undef elf_backend_may_use_rel_p
|
10487 |
|
|
#define elf_backend_may_use_rel_p 0
|
10488 |
|
|
#undef elf_backend_may_use_rela_p
|
10489 |
|
|
#define elf_backend_may_use_rela_p 1
|
10490 |
|
|
#undef elf_backend_default_use_rela_p
|
10491 |
|
|
#define elf_backend_default_use_rela_p 1
|
10492 |
|
|
#undef elf_backend_want_plt_sym
|
10493 |
|
|
#define elf_backend_want_plt_sym 1
|
10494 |
|
|
#undef ELF_MAXPAGESIZE
|
10495 |
|
|
#define ELF_MAXPAGESIZE 0x1000
|
10496 |
|
|
|
10497 |
|
|
#include "elf32-target.h"
|
10498 |
|
|
|
10499 |
|
|
|
10500 |
|
|
/* Symbian OS Targets */
|
10501 |
|
|
|
10502 |
|
|
#undef TARGET_LITTLE_SYM
|
10503 |
|
|
#define TARGET_LITTLE_SYM bfd_elf32_littlearm_symbian_vec
|
10504 |
|
|
#undef TARGET_LITTLE_NAME
|
10505 |
|
|
#define TARGET_LITTLE_NAME "elf32-littlearm-symbian"
|
10506 |
|
|
#undef TARGET_BIG_SYM
|
10507 |
|
|
#define TARGET_BIG_SYM bfd_elf32_bigarm_symbian_vec
|
10508 |
|
|
#undef TARGET_BIG_NAME
|
10509 |
|
|
#define TARGET_BIG_NAME "elf32-bigarm-symbian"
|
10510 |
|
|
|
10511 |
|
|
/* Like elf32_arm_link_hash_table_create -- but overrides
|
10512 |
|
|
appropriately for Symbian OS. */
|
10513 |
|
|
static struct bfd_link_hash_table *
|
10514 |
|
|
elf32_arm_symbian_link_hash_table_create (bfd *abfd)
|
10515 |
|
|
{
|
10516 |
|
|
struct bfd_link_hash_table *ret;
|
10517 |
|
|
|
10518 |
|
|
ret = elf32_arm_link_hash_table_create (abfd);
|
10519 |
|
|
if (ret)
|
10520 |
|
|
{
|
10521 |
|
|
struct elf32_arm_link_hash_table *htab
|
10522 |
|
|
= (struct elf32_arm_link_hash_table *)ret;
|
10523 |
|
|
/* There is no PLT header for Symbian OS. */
|
10524 |
|
|
htab->plt_header_size = 0;
|
10525 |
|
|
/* The PLT entries are each three instructions. */
|
10526 |
|
|
htab->plt_entry_size = 4 * NUM_ELEM (elf32_arm_symbian_plt_entry);
|
10527 |
|
|
htab->symbian_p = 1;
|
10528 |
|
|
/* Symbian uses armv5t or above, so use_blx is always true. */
|
10529 |
|
|
htab->use_blx = 1;
|
10530 |
|
|
htab->root.is_relocatable_executable = 1;
|
10531 |
|
|
}
|
10532 |
|
|
return ret;
|
10533 |
|
|
}
|
10534 |
|
|
|
10535 |
|
|
static const struct bfd_elf_special_section
|
10536 |
|
|
elf32_arm_symbian_special_sections[] =
|
10537 |
|
|
{
|
10538 |
|
|
/* In a BPABI executable, the dynamic linking sections do not go in
|
10539 |
|
|
the loadable read-only segment. The post-linker may wish to
|
10540 |
|
|
refer to these sections, but they are not part of the final
|
10541 |
|
|
program image. */
|
10542 |
|
|
{ STRING_COMMA_LEN (".dynamic"), 0, SHT_DYNAMIC, 0 },
|
10543 |
|
|
{ STRING_COMMA_LEN (".dynstr"), 0, SHT_STRTAB, 0 },
|
10544 |
|
|
{ STRING_COMMA_LEN (".dynsym"), 0, SHT_DYNSYM, 0 },
|
10545 |
|
|
{ STRING_COMMA_LEN (".got"), 0, SHT_PROGBITS, 0 },
|
10546 |
|
|
{ STRING_COMMA_LEN (".hash"), 0, SHT_HASH, 0 },
|
10547 |
|
|
/* These sections do not need to be writable as the SymbianOS
|
10548 |
|
|
postlinker will arrange things so that no dynamic relocation is
|
10549 |
|
|
required. */
|
10550 |
|
|
{ STRING_COMMA_LEN (".init_array"), 0, SHT_INIT_ARRAY, SHF_ALLOC },
|
10551 |
|
|
{ STRING_COMMA_LEN (".fini_array"), 0, SHT_FINI_ARRAY, SHF_ALLOC },
|
10552 |
|
|
{ STRING_COMMA_LEN (".preinit_array"), 0, SHT_PREINIT_ARRAY, SHF_ALLOC },
|
10553 |
|
|
{ NULL, 0, 0, 0, 0 }
|
10554 |
|
|
};
|
10555 |
|
|
|
10556 |
|
|
static void
|
10557 |
|
|
elf32_arm_symbian_begin_write_processing (bfd *abfd,
|
10558 |
|
|
struct bfd_link_info *link_info)
|
10559 |
|
|
{
|
10560 |
|
|
/* BPABI objects are never loaded directly by an OS kernel; they are
|
10561 |
|
|
processed by a postlinker first, into an OS-specific format. If
|
10562 |
|
|
the D_PAGED bit is set on the file, BFD will align segments on
|
10563 |
|
|
page boundaries, so that an OS can directly map the file. With
|
10564 |
|
|
BPABI objects, that just results in wasted space. In addition,
|
10565 |
|
|
because we clear the D_PAGED bit, map_sections_to_segments will
|
10566 |
|
|
recognize that the program headers should not be mapped into any
|
10567 |
|
|
loadable segment. */
|
10568 |
|
|
abfd->flags &= ~D_PAGED;
|
10569 |
|
|
elf32_arm_begin_write_processing(abfd, link_info);
|
10570 |
|
|
}
|
10571 |
|
|
|
10572 |
|
|
static bfd_boolean
|
10573 |
|
|
elf32_arm_symbian_modify_segment_map (bfd *abfd,
|
10574 |
|
|
struct bfd_link_info *info)
|
10575 |
|
|
{
|
10576 |
|
|
struct elf_segment_map *m;
|
10577 |
|
|
asection *dynsec;
|
10578 |
|
|
|
10579 |
|
|
/* BPABI shared libraries and executables should have a PT_DYNAMIC
|
10580 |
|
|
segment. However, because the .dynamic section is not marked
|
10581 |
|
|
with SEC_LOAD, the generic ELF code will not create such a
|
10582 |
|
|
segment. */
|
10583 |
|
|
dynsec = bfd_get_section_by_name (abfd, ".dynamic");
|
10584 |
|
|
if (dynsec)
|
10585 |
|
|
{
|
10586 |
|
|
for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
|
10587 |
|
|
if (m->p_type == PT_DYNAMIC)
|
10588 |
|
|
break;
|
10589 |
|
|
|
10590 |
|
|
if (m == NULL)
|
10591 |
|
|
{
|
10592 |
|
|
m = _bfd_elf_make_dynamic_segment (abfd, dynsec);
|
10593 |
|
|
m->next = elf_tdata (abfd)->segment_map;
|
10594 |
|
|
elf_tdata (abfd)->segment_map = m;
|
10595 |
|
|
}
|
10596 |
|
|
}
|
10597 |
|
|
|
10598 |
|
|
/* Also call the generic arm routine. */
|
10599 |
|
|
return elf32_arm_modify_segment_map (abfd, info);
|
10600 |
|
|
}
|
10601 |
|
|
|
10602 |
|
|
#undef elf32_bed
|
10603 |
|
|
#define elf32_bed elf32_arm_symbian_bed
|
10604 |
|
|
|
10605 |
|
|
/* The dynamic sections are not allocated on SymbianOS; the postlinker
|
10606 |
|
|
will process them and then discard them. */
|
10607 |
|
|
#undef ELF_DYNAMIC_SEC_FLAGS
|
10608 |
|
|
#define ELF_DYNAMIC_SEC_FLAGS \
|
10609 |
|
|
(SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED)
|
10610 |
|
|
|
10611 |
|
|
#undef bfd_elf32_bfd_link_hash_table_create
|
10612 |
|
|
#define bfd_elf32_bfd_link_hash_table_create \
|
10613 |
|
|
elf32_arm_symbian_link_hash_table_create
|
10614 |
|
|
#undef elf_backend_add_symbol_hook
|
10615 |
|
|
|
10616 |
|
|
#undef elf_backend_special_sections
|
10617 |
|
|
#define elf_backend_special_sections elf32_arm_symbian_special_sections
|
10618 |
|
|
|
10619 |
|
|
#undef elf_backend_begin_write_processing
|
10620 |
|
|
#define elf_backend_begin_write_processing \
|
10621 |
|
|
elf32_arm_symbian_begin_write_processing
|
10622 |
|
|
#undef elf_backend_final_write_processing
|
10623 |
|
|
#define elf_backend_final_write_processing \
|
10624 |
|
|
elf32_arm_final_write_processing
|
10625 |
|
|
#undef elf_backend_emit_relocs
|
10626 |
|
|
|
10627 |
|
|
#undef elf_backend_modify_segment_map
|
10628 |
|
|
#define elf_backend_modify_segment_map elf32_arm_symbian_modify_segment_map
|
10629 |
|
|
|
10630 |
|
|
/* There is no .got section for BPABI objects, and hence no header. */
|
10631 |
|
|
#undef elf_backend_got_header_size
|
10632 |
|
|
#define elf_backend_got_header_size 0
|
10633 |
|
|
|
10634 |
|
|
/* Similarly, there is no .got.plt section. */
|
10635 |
|
|
#undef elf_backend_want_got_plt
|
10636 |
|
|
#define elf_backend_want_got_plt 0
|
10637 |
|
|
|
10638 |
|
|
#undef elf_backend_may_use_rel_p
|
10639 |
|
|
#define elf_backend_may_use_rel_p 1
|
10640 |
|
|
#undef elf_backend_may_use_rela_p
|
10641 |
|
|
#define elf_backend_may_use_rela_p 0
|
10642 |
|
|
#undef elf_backend_default_use_rela_p
|
10643 |
|
|
#define elf_backend_default_use_rela_p 0
|
10644 |
|
|
#undef elf_backend_want_plt_sym
|
10645 |
|
|
#define elf_backend_want_plt_sym 0
|
10646 |
|
|
#undef ELF_MAXPAGESIZE
|
10647 |
|
|
#define ELF_MAXPAGESIZE 0x8000
|
10648 |
|
|
|
10649 |
|
|
#include "elf32-target.h"
|