Commit | Line | Data |
---|---|---|
252b5132 | 1 | /* 32-bit ELF support for ARM |
d7f735da | 2 | Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 |
d1f161ea | 3 | Free Software Foundation, Inc. |
252b5132 RH |
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 2 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 | |
3e110533 | 19 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ |
252b5132 | 20 | |
7f266840 DJ |
21 | #include "bfd.h" |
22 | #include "sysdep.h" | |
00a97672 | 23 | #include "libiberty.h" |
7f266840 DJ |
24 | #include "libbfd.h" |
25 | #include "elf-bfd.h" | |
00a97672 | 26 | #include "elf-vxworks.h" |
ee065d83 | 27 | #include "elf/arm.h" |
7f266840 DJ |
28 | |
29 | #ifndef NUM_ELEM | |
30 | #define NUM_ELEM(a) (sizeof (a) / (sizeof (a)[0])) | |
31 | #endif | |
32 | ||
00a97672 RS |
33 | /* Return the relocation section associated with NAME. HTAB is the |
34 | bfd's elf32_arm_link_hash_entry. */ | |
35 | #define RELOC_SECTION(HTAB, NAME) \ | |
36 | ((HTAB)->use_rel ? ".rel" NAME : ".rela" NAME) | |
37 | ||
38 | /* Return size of a relocation entry. HTAB is the bfd's | |
39 | elf32_arm_link_hash_entry. */ | |
40 | #define RELOC_SIZE(HTAB) \ | |
41 | ((HTAB)->use_rel \ | |
42 | ? sizeof (Elf32_External_Rel) \ | |
43 | : sizeof (Elf32_External_Rela)) | |
44 | ||
45 | /* Return function to swap relocations in. HTAB is the bfd's | |
46 | elf32_arm_link_hash_entry. */ | |
47 | #define SWAP_RELOC_IN(HTAB) \ | |
48 | ((HTAB)->use_rel \ | |
49 | ? bfd_elf32_swap_reloc_in \ | |
50 | : bfd_elf32_swap_reloca_in) | |
51 | ||
52 | /* Return function to swap relocations out. HTAB is the bfd's | |
53 | elf32_arm_link_hash_entry. */ | |
54 | #define SWAP_RELOC_OUT(HTAB) \ | |
55 | ((HTAB)->use_rel \ | |
56 | ? bfd_elf32_swap_reloc_out \ | |
57 | : bfd_elf32_swap_reloca_out) | |
58 | ||
7f266840 DJ |
59 | #define elf_info_to_howto 0 |
60 | #define elf_info_to_howto_rel elf32_arm_info_to_howto | |
61 | ||
62 | #define ARM_ELF_ABI_VERSION 0 | |
63 | #define ARM_ELF_OS_ABI_VERSION ELFOSABI_ARM | |
64 | ||
24718e3b | 65 | static struct elf_backend_data elf32_arm_vxworks_bed; |
00a97672 | 66 | |
7f266840 DJ |
67 | /* Note: code such as elf32_arm_reloc_type_lookup expect to use e.g. |
68 | R_ARM_PC24 as an index into this, and find the R_ARM_PC24 HOWTO | |
69 | in that slot. */ | |
70 | ||
c19d1205 | 71 | static reloc_howto_type elf32_arm_howto_table_1[] = |
7f266840 DJ |
72 | { |
73 | /* No relocation */ | |
74 | HOWTO (R_ARM_NONE, /* type */ | |
75 | 0, /* rightshift */ | |
76 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
77 | 0, /* bitsize */ | |
78 | FALSE, /* pc_relative */ | |
79 | 0, /* bitpos */ | |
80 | complain_overflow_dont,/* complain_on_overflow */ | |
81 | bfd_elf_generic_reloc, /* special_function */ | |
82 | "R_ARM_NONE", /* name */ | |
83 | FALSE, /* partial_inplace */ | |
84 | 0, /* src_mask */ | |
85 | 0, /* dst_mask */ | |
86 | FALSE), /* pcrel_offset */ | |
87 | ||
88 | HOWTO (R_ARM_PC24, /* type */ | |
89 | 2, /* rightshift */ | |
90 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
91 | 24, /* bitsize */ | |
92 | TRUE, /* pc_relative */ | |
93 | 0, /* bitpos */ | |
94 | complain_overflow_signed,/* complain_on_overflow */ | |
95 | bfd_elf_generic_reloc, /* special_function */ | |
96 | "R_ARM_PC24", /* name */ | |
97 | FALSE, /* partial_inplace */ | |
98 | 0x00ffffff, /* src_mask */ | |
99 | 0x00ffffff, /* dst_mask */ | |
100 | TRUE), /* pcrel_offset */ | |
101 | ||
102 | /* 32 bit absolute */ | |
103 | HOWTO (R_ARM_ABS32, /* type */ | |
104 | 0, /* rightshift */ | |
105 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
106 | 32, /* bitsize */ | |
107 | FALSE, /* pc_relative */ | |
108 | 0, /* bitpos */ | |
109 | complain_overflow_bitfield,/* complain_on_overflow */ | |
110 | bfd_elf_generic_reloc, /* special_function */ | |
111 | "R_ARM_ABS32", /* name */ | |
112 | FALSE, /* partial_inplace */ | |
113 | 0xffffffff, /* src_mask */ | |
114 | 0xffffffff, /* dst_mask */ | |
115 | FALSE), /* pcrel_offset */ | |
116 | ||
117 | /* standard 32bit pc-relative reloc */ | |
118 | HOWTO (R_ARM_REL32, /* type */ | |
119 | 0, /* rightshift */ | |
120 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
121 | 32, /* bitsize */ | |
122 | TRUE, /* pc_relative */ | |
123 | 0, /* bitpos */ | |
124 | complain_overflow_bitfield,/* complain_on_overflow */ | |
125 | bfd_elf_generic_reloc, /* special_function */ | |
126 | "R_ARM_REL32", /* name */ | |
127 | FALSE, /* partial_inplace */ | |
128 | 0xffffffff, /* src_mask */ | |
129 | 0xffffffff, /* dst_mask */ | |
130 | TRUE), /* pcrel_offset */ | |
131 | ||
c19d1205 | 132 | /* 8 bit absolute - R_ARM_LDR_PC_G0 in AAELF */ |
4962c51a | 133 | HOWTO (R_ARM_LDR_PC_G0, /* type */ |
7f266840 DJ |
134 | 0, /* rightshift */ |
135 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
4962c51a MS |
136 | 32, /* bitsize */ |
137 | TRUE, /* pc_relative */ | |
7f266840 | 138 | 0, /* bitpos */ |
4962c51a | 139 | complain_overflow_dont,/* complain_on_overflow */ |
7f266840 | 140 | bfd_elf_generic_reloc, /* special_function */ |
4962c51a | 141 | "R_ARM_LDR_PC_G0", /* name */ |
7f266840 | 142 | FALSE, /* partial_inplace */ |
4962c51a MS |
143 | 0xffffffff, /* src_mask */ |
144 | 0xffffffff, /* dst_mask */ | |
145 | TRUE), /* pcrel_offset */ | |
7f266840 DJ |
146 | |
147 | /* 16 bit absolute */ | |
148 | HOWTO (R_ARM_ABS16, /* type */ | |
149 | 0, /* rightshift */ | |
150 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
151 | 16, /* bitsize */ | |
152 | FALSE, /* pc_relative */ | |
153 | 0, /* bitpos */ | |
154 | complain_overflow_bitfield,/* complain_on_overflow */ | |
155 | bfd_elf_generic_reloc, /* special_function */ | |
156 | "R_ARM_ABS16", /* name */ | |
157 | FALSE, /* partial_inplace */ | |
158 | 0x0000ffff, /* src_mask */ | |
159 | 0x0000ffff, /* dst_mask */ | |
160 | FALSE), /* pcrel_offset */ | |
161 | ||
162 | /* 12 bit absolute */ | |
163 | HOWTO (R_ARM_ABS12, /* type */ | |
164 | 0, /* rightshift */ | |
165 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
166 | 12, /* bitsize */ | |
167 | FALSE, /* pc_relative */ | |
168 | 0, /* bitpos */ | |
169 | complain_overflow_bitfield,/* complain_on_overflow */ | |
170 | bfd_elf_generic_reloc, /* special_function */ | |
171 | "R_ARM_ABS12", /* name */ | |
172 | FALSE, /* partial_inplace */ | |
00a97672 RS |
173 | 0x00000fff, /* src_mask */ |
174 | 0x00000fff, /* dst_mask */ | |
7f266840 DJ |
175 | FALSE), /* pcrel_offset */ |
176 | ||
177 | HOWTO (R_ARM_THM_ABS5, /* type */ | |
178 | 6, /* rightshift */ | |
179 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
180 | 5, /* bitsize */ | |
181 | FALSE, /* pc_relative */ | |
182 | 0, /* bitpos */ | |
183 | complain_overflow_bitfield,/* complain_on_overflow */ | |
184 | bfd_elf_generic_reloc, /* special_function */ | |
185 | "R_ARM_THM_ABS5", /* name */ | |
186 | FALSE, /* partial_inplace */ | |
187 | 0x000007e0, /* src_mask */ | |
188 | 0x000007e0, /* dst_mask */ | |
189 | FALSE), /* pcrel_offset */ | |
190 | ||
191 | /* 8 bit absolute */ | |
192 | HOWTO (R_ARM_ABS8, /* type */ | |
193 | 0, /* rightshift */ | |
194 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
195 | 8, /* bitsize */ | |
196 | FALSE, /* pc_relative */ | |
197 | 0, /* bitpos */ | |
198 | complain_overflow_bitfield,/* complain_on_overflow */ | |
199 | bfd_elf_generic_reloc, /* special_function */ | |
200 | "R_ARM_ABS8", /* name */ | |
201 | FALSE, /* partial_inplace */ | |
202 | 0x000000ff, /* src_mask */ | |
203 | 0x000000ff, /* dst_mask */ | |
204 | FALSE), /* pcrel_offset */ | |
205 | ||
206 | HOWTO (R_ARM_SBREL32, /* type */ | |
207 | 0, /* rightshift */ | |
208 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
209 | 32, /* bitsize */ | |
210 | FALSE, /* pc_relative */ | |
211 | 0, /* bitpos */ | |
212 | complain_overflow_dont,/* complain_on_overflow */ | |
213 | bfd_elf_generic_reloc, /* special_function */ | |
214 | "R_ARM_SBREL32", /* name */ | |
215 | FALSE, /* partial_inplace */ | |
216 | 0xffffffff, /* src_mask */ | |
217 | 0xffffffff, /* dst_mask */ | |
218 | FALSE), /* pcrel_offset */ | |
219 | ||
c19d1205 | 220 | HOWTO (R_ARM_THM_CALL, /* type */ |
7f266840 DJ |
221 | 1, /* rightshift */ |
222 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
e95de063 | 223 | 25, /* bitsize */ |
7f266840 DJ |
224 | TRUE, /* pc_relative */ |
225 | 0, /* bitpos */ | |
226 | complain_overflow_signed,/* complain_on_overflow */ | |
227 | bfd_elf_generic_reloc, /* special_function */ | |
c19d1205 | 228 | "R_ARM_THM_CALL", /* name */ |
7f266840 DJ |
229 | FALSE, /* partial_inplace */ |
230 | 0x07ff07ff, /* src_mask */ | |
231 | 0x07ff07ff, /* dst_mask */ | |
232 | TRUE), /* pcrel_offset */ | |
233 | ||
234 | HOWTO (R_ARM_THM_PC8, /* type */ | |
235 | 1, /* rightshift */ | |
236 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
237 | 8, /* bitsize */ | |
238 | TRUE, /* pc_relative */ | |
239 | 0, /* bitpos */ | |
240 | complain_overflow_signed,/* complain_on_overflow */ | |
241 | bfd_elf_generic_reloc, /* special_function */ | |
242 | "R_ARM_THM_PC8", /* name */ | |
243 | FALSE, /* partial_inplace */ | |
244 | 0x000000ff, /* src_mask */ | |
245 | 0x000000ff, /* dst_mask */ | |
246 | TRUE), /* pcrel_offset */ | |
247 | ||
c19d1205 | 248 | HOWTO (R_ARM_BREL_ADJ, /* type */ |
7f266840 DJ |
249 | 1, /* rightshift */ |
250 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
c19d1205 ZW |
251 | 32, /* bitsize */ |
252 | FALSE, /* pc_relative */ | |
7f266840 DJ |
253 | 0, /* bitpos */ |
254 | complain_overflow_signed,/* complain_on_overflow */ | |
255 | bfd_elf_generic_reloc, /* special_function */ | |
c19d1205 | 256 | "R_ARM_BREL_ADJ", /* name */ |
7f266840 | 257 | FALSE, /* partial_inplace */ |
c19d1205 ZW |
258 | 0xffffffff, /* src_mask */ |
259 | 0xffffffff, /* dst_mask */ | |
260 | FALSE), /* pcrel_offset */ | |
7f266840 DJ |
261 | |
262 | HOWTO (R_ARM_SWI24, /* type */ | |
263 | 0, /* rightshift */ | |
264 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
265 | 0, /* bitsize */ | |
266 | FALSE, /* pc_relative */ | |
267 | 0, /* bitpos */ | |
268 | complain_overflow_signed,/* complain_on_overflow */ | |
269 | bfd_elf_generic_reloc, /* special_function */ | |
270 | "R_ARM_SWI24", /* name */ | |
271 | FALSE, /* partial_inplace */ | |
272 | 0x00000000, /* src_mask */ | |
273 | 0x00000000, /* dst_mask */ | |
274 | FALSE), /* pcrel_offset */ | |
275 | ||
276 | HOWTO (R_ARM_THM_SWI8, /* type */ | |
277 | 0, /* rightshift */ | |
278 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
279 | 0, /* bitsize */ | |
280 | FALSE, /* pc_relative */ | |
281 | 0, /* bitpos */ | |
282 | complain_overflow_signed,/* complain_on_overflow */ | |
283 | bfd_elf_generic_reloc, /* special_function */ | |
284 | "R_ARM_SWI8", /* name */ | |
285 | FALSE, /* partial_inplace */ | |
286 | 0x00000000, /* src_mask */ | |
287 | 0x00000000, /* dst_mask */ | |
288 | FALSE), /* pcrel_offset */ | |
289 | ||
290 | /* BLX instruction for the ARM. */ | |
291 | HOWTO (R_ARM_XPC25, /* type */ | |
292 | 2, /* rightshift */ | |
293 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
294 | 25, /* bitsize */ | |
295 | TRUE, /* pc_relative */ | |
296 | 0, /* bitpos */ | |
297 | complain_overflow_signed,/* complain_on_overflow */ | |
298 | bfd_elf_generic_reloc, /* special_function */ | |
299 | "R_ARM_XPC25", /* name */ | |
300 | FALSE, /* partial_inplace */ | |
301 | 0x00ffffff, /* src_mask */ | |
302 | 0x00ffffff, /* dst_mask */ | |
303 | TRUE), /* pcrel_offset */ | |
304 | ||
305 | /* BLX instruction for the Thumb. */ | |
306 | HOWTO (R_ARM_THM_XPC22, /* type */ | |
307 | 2, /* rightshift */ | |
308 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
309 | 22, /* bitsize */ | |
310 | TRUE, /* pc_relative */ | |
311 | 0, /* bitpos */ | |
312 | complain_overflow_signed,/* complain_on_overflow */ | |
313 | bfd_elf_generic_reloc, /* special_function */ | |
314 | "R_ARM_THM_XPC22", /* name */ | |
315 | FALSE, /* partial_inplace */ | |
316 | 0x07ff07ff, /* src_mask */ | |
317 | 0x07ff07ff, /* dst_mask */ | |
318 | TRUE), /* pcrel_offset */ | |
319 | ||
ba93b8ac | 320 | /* Dynamic TLS relocations. */ |
7f266840 | 321 | |
ba93b8ac DJ |
322 | HOWTO (R_ARM_TLS_DTPMOD32, /* type */ |
323 | 0, /* rightshift */ | |
324 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
325 | 32, /* bitsize */ | |
326 | FALSE, /* pc_relative */ | |
327 | 0, /* bitpos */ | |
328 | complain_overflow_bitfield,/* complain_on_overflow */ | |
329 | bfd_elf_generic_reloc, /* special_function */ | |
330 | "R_ARM_TLS_DTPMOD32", /* name */ | |
331 | TRUE, /* partial_inplace */ | |
332 | 0xffffffff, /* src_mask */ | |
333 | 0xffffffff, /* dst_mask */ | |
334 | FALSE), /* pcrel_offset */ | |
7f266840 | 335 | |
ba93b8ac DJ |
336 | HOWTO (R_ARM_TLS_DTPOFF32, /* type */ |
337 | 0, /* rightshift */ | |
338 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
339 | 32, /* bitsize */ | |
340 | FALSE, /* pc_relative */ | |
341 | 0, /* bitpos */ | |
342 | complain_overflow_bitfield,/* complain_on_overflow */ | |
343 | bfd_elf_generic_reloc, /* special_function */ | |
344 | "R_ARM_TLS_DTPOFF32", /* name */ | |
345 | TRUE, /* partial_inplace */ | |
346 | 0xffffffff, /* src_mask */ | |
347 | 0xffffffff, /* dst_mask */ | |
348 | FALSE), /* pcrel_offset */ | |
7f266840 | 349 | |
ba93b8ac DJ |
350 | HOWTO (R_ARM_TLS_TPOFF32, /* type */ |
351 | 0, /* rightshift */ | |
352 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
353 | 32, /* bitsize */ | |
354 | FALSE, /* pc_relative */ | |
355 | 0, /* bitpos */ | |
356 | complain_overflow_bitfield,/* complain_on_overflow */ | |
357 | bfd_elf_generic_reloc, /* special_function */ | |
358 | "R_ARM_TLS_TPOFF32", /* name */ | |
359 | TRUE, /* partial_inplace */ | |
360 | 0xffffffff, /* src_mask */ | |
361 | 0xffffffff, /* dst_mask */ | |
362 | FALSE), /* pcrel_offset */ | |
7f266840 DJ |
363 | |
364 | /* Relocs used in ARM Linux */ | |
365 | ||
366 | HOWTO (R_ARM_COPY, /* type */ | |
367 | 0, /* rightshift */ | |
368 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
369 | 32, /* bitsize */ | |
370 | FALSE, /* pc_relative */ | |
371 | 0, /* bitpos */ | |
372 | complain_overflow_bitfield,/* complain_on_overflow */ | |
373 | bfd_elf_generic_reloc, /* special_function */ | |
374 | "R_ARM_COPY", /* name */ | |
375 | TRUE, /* partial_inplace */ | |
376 | 0xffffffff, /* src_mask */ | |
377 | 0xffffffff, /* dst_mask */ | |
378 | FALSE), /* pcrel_offset */ | |
379 | ||
380 | HOWTO (R_ARM_GLOB_DAT, /* type */ | |
381 | 0, /* rightshift */ | |
382 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
383 | 32, /* bitsize */ | |
384 | FALSE, /* pc_relative */ | |
385 | 0, /* bitpos */ | |
386 | complain_overflow_bitfield,/* complain_on_overflow */ | |
387 | bfd_elf_generic_reloc, /* special_function */ | |
388 | "R_ARM_GLOB_DAT", /* name */ | |
389 | TRUE, /* partial_inplace */ | |
390 | 0xffffffff, /* src_mask */ | |
391 | 0xffffffff, /* dst_mask */ | |
392 | FALSE), /* pcrel_offset */ | |
393 | ||
394 | HOWTO (R_ARM_JUMP_SLOT, /* type */ | |
395 | 0, /* rightshift */ | |
396 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
397 | 32, /* bitsize */ | |
398 | FALSE, /* pc_relative */ | |
399 | 0, /* bitpos */ | |
400 | complain_overflow_bitfield,/* complain_on_overflow */ | |
401 | bfd_elf_generic_reloc, /* special_function */ | |
402 | "R_ARM_JUMP_SLOT", /* name */ | |
403 | TRUE, /* partial_inplace */ | |
404 | 0xffffffff, /* src_mask */ | |
405 | 0xffffffff, /* dst_mask */ | |
406 | FALSE), /* pcrel_offset */ | |
407 | ||
408 | HOWTO (R_ARM_RELATIVE, /* type */ | |
409 | 0, /* rightshift */ | |
410 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
411 | 32, /* bitsize */ | |
412 | FALSE, /* pc_relative */ | |
413 | 0, /* bitpos */ | |
414 | complain_overflow_bitfield,/* complain_on_overflow */ | |
415 | bfd_elf_generic_reloc, /* special_function */ | |
416 | "R_ARM_RELATIVE", /* name */ | |
417 | TRUE, /* partial_inplace */ | |
418 | 0xffffffff, /* src_mask */ | |
419 | 0xffffffff, /* dst_mask */ | |
420 | FALSE), /* pcrel_offset */ | |
421 | ||
c19d1205 | 422 | HOWTO (R_ARM_GOTOFF32, /* type */ |
7f266840 DJ |
423 | 0, /* rightshift */ |
424 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
425 | 32, /* bitsize */ | |
426 | FALSE, /* pc_relative */ | |
427 | 0, /* bitpos */ | |
428 | complain_overflow_bitfield,/* complain_on_overflow */ | |
429 | bfd_elf_generic_reloc, /* special_function */ | |
c19d1205 | 430 | "R_ARM_GOTOFF32", /* name */ |
7f266840 DJ |
431 | TRUE, /* partial_inplace */ |
432 | 0xffffffff, /* src_mask */ | |
433 | 0xffffffff, /* dst_mask */ | |
434 | FALSE), /* pcrel_offset */ | |
435 | ||
436 | HOWTO (R_ARM_GOTPC, /* type */ | |
437 | 0, /* rightshift */ | |
438 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
439 | 32, /* bitsize */ | |
440 | TRUE, /* pc_relative */ | |
441 | 0, /* bitpos */ | |
442 | complain_overflow_bitfield,/* complain_on_overflow */ | |
443 | bfd_elf_generic_reloc, /* special_function */ | |
444 | "R_ARM_GOTPC", /* name */ | |
445 | TRUE, /* partial_inplace */ | |
446 | 0xffffffff, /* src_mask */ | |
447 | 0xffffffff, /* dst_mask */ | |
448 | TRUE), /* pcrel_offset */ | |
449 | ||
450 | HOWTO (R_ARM_GOT32, /* type */ | |
451 | 0, /* rightshift */ | |
452 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
453 | 32, /* bitsize */ | |
454 | FALSE, /* pc_relative */ | |
455 | 0, /* bitpos */ | |
456 | complain_overflow_bitfield,/* complain_on_overflow */ | |
457 | bfd_elf_generic_reloc, /* special_function */ | |
458 | "R_ARM_GOT32", /* name */ | |
459 | TRUE, /* partial_inplace */ | |
460 | 0xffffffff, /* src_mask */ | |
461 | 0xffffffff, /* dst_mask */ | |
462 | FALSE), /* pcrel_offset */ | |
463 | ||
464 | HOWTO (R_ARM_PLT32, /* type */ | |
465 | 2, /* rightshift */ | |
466 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
ce490eda | 467 | 24, /* bitsize */ |
7f266840 DJ |
468 | TRUE, /* pc_relative */ |
469 | 0, /* bitpos */ | |
470 | complain_overflow_bitfield,/* complain_on_overflow */ | |
471 | bfd_elf_generic_reloc, /* special_function */ | |
472 | "R_ARM_PLT32", /* name */ | |
ce490eda | 473 | FALSE, /* partial_inplace */ |
7f266840 DJ |
474 | 0x00ffffff, /* src_mask */ |
475 | 0x00ffffff, /* dst_mask */ | |
476 | TRUE), /* pcrel_offset */ | |
477 | ||
478 | HOWTO (R_ARM_CALL, /* type */ | |
479 | 2, /* rightshift */ | |
480 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
481 | 24, /* bitsize */ | |
482 | TRUE, /* pc_relative */ | |
483 | 0, /* bitpos */ | |
484 | complain_overflow_signed,/* complain_on_overflow */ | |
485 | bfd_elf_generic_reloc, /* special_function */ | |
486 | "R_ARM_CALL", /* name */ | |
487 | FALSE, /* partial_inplace */ | |
488 | 0x00ffffff, /* src_mask */ | |
489 | 0x00ffffff, /* dst_mask */ | |
490 | TRUE), /* pcrel_offset */ | |
491 | ||
492 | HOWTO (R_ARM_JUMP24, /* type */ | |
493 | 2, /* rightshift */ | |
494 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
495 | 24, /* bitsize */ | |
496 | TRUE, /* pc_relative */ | |
497 | 0, /* bitpos */ | |
498 | complain_overflow_signed,/* complain_on_overflow */ | |
499 | bfd_elf_generic_reloc, /* special_function */ | |
500 | "R_ARM_JUMP24", /* name */ | |
501 | FALSE, /* partial_inplace */ | |
502 | 0x00ffffff, /* src_mask */ | |
503 | 0x00ffffff, /* dst_mask */ | |
504 | TRUE), /* pcrel_offset */ | |
505 | ||
c19d1205 ZW |
506 | HOWTO (R_ARM_THM_JUMP24, /* type */ |
507 | 1, /* rightshift */ | |
508 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
509 | 24, /* bitsize */ | |
510 | TRUE, /* pc_relative */ | |
7f266840 | 511 | 0, /* bitpos */ |
c19d1205 | 512 | complain_overflow_signed,/* complain_on_overflow */ |
7f266840 | 513 | bfd_elf_generic_reloc, /* special_function */ |
c19d1205 | 514 | "R_ARM_THM_JUMP24", /* name */ |
7f266840 | 515 | FALSE, /* partial_inplace */ |
c19d1205 ZW |
516 | 0x07ff2fff, /* src_mask */ |
517 | 0x07ff2fff, /* dst_mask */ | |
518 | TRUE), /* pcrel_offset */ | |
7f266840 | 519 | |
c19d1205 | 520 | HOWTO (R_ARM_BASE_ABS, /* type */ |
7f266840 | 521 | 0, /* rightshift */ |
c19d1205 ZW |
522 | 2, /* size (0 = byte, 1 = short, 2 = long) */ |
523 | 32, /* bitsize */ | |
7f266840 DJ |
524 | FALSE, /* pc_relative */ |
525 | 0, /* bitpos */ | |
526 | complain_overflow_dont,/* complain_on_overflow */ | |
527 | bfd_elf_generic_reloc, /* special_function */ | |
c19d1205 | 528 | "R_ARM_BASE_ABS", /* name */ |
7f266840 | 529 | FALSE, /* partial_inplace */ |
c19d1205 ZW |
530 | 0xffffffff, /* src_mask */ |
531 | 0xffffffff, /* dst_mask */ | |
7f266840 DJ |
532 | FALSE), /* pcrel_offset */ |
533 | ||
534 | HOWTO (R_ARM_ALU_PCREL7_0, /* type */ | |
535 | 0, /* rightshift */ | |
536 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
537 | 12, /* bitsize */ | |
538 | TRUE, /* pc_relative */ | |
539 | 0, /* bitpos */ | |
540 | complain_overflow_dont,/* complain_on_overflow */ | |
541 | bfd_elf_generic_reloc, /* special_function */ | |
542 | "R_ARM_ALU_PCREL_7_0", /* name */ | |
543 | FALSE, /* partial_inplace */ | |
544 | 0x00000fff, /* src_mask */ | |
545 | 0x00000fff, /* dst_mask */ | |
546 | TRUE), /* pcrel_offset */ | |
547 | ||
548 | HOWTO (R_ARM_ALU_PCREL15_8, /* type */ | |
549 | 0, /* rightshift */ | |
550 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
551 | 12, /* bitsize */ | |
552 | TRUE, /* pc_relative */ | |
553 | 8, /* bitpos */ | |
554 | complain_overflow_dont,/* complain_on_overflow */ | |
555 | bfd_elf_generic_reloc, /* special_function */ | |
556 | "R_ARM_ALU_PCREL_15_8",/* name */ | |
557 | FALSE, /* partial_inplace */ | |
558 | 0x00000fff, /* src_mask */ | |
559 | 0x00000fff, /* dst_mask */ | |
560 | TRUE), /* pcrel_offset */ | |
561 | ||
562 | HOWTO (R_ARM_ALU_PCREL23_15, /* type */ | |
563 | 0, /* rightshift */ | |
564 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
565 | 12, /* bitsize */ | |
566 | TRUE, /* pc_relative */ | |
567 | 16, /* bitpos */ | |
568 | complain_overflow_dont,/* complain_on_overflow */ | |
569 | bfd_elf_generic_reloc, /* special_function */ | |
570 | "R_ARM_ALU_PCREL_23_15",/* name */ | |
571 | FALSE, /* partial_inplace */ | |
572 | 0x00000fff, /* src_mask */ | |
573 | 0x00000fff, /* dst_mask */ | |
574 | TRUE), /* pcrel_offset */ | |
575 | ||
576 | HOWTO (R_ARM_LDR_SBREL_11_0, /* type */ | |
577 | 0, /* rightshift */ | |
578 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
579 | 12, /* bitsize */ | |
580 | FALSE, /* pc_relative */ | |
581 | 0, /* bitpos */ | |
582 | complain_overflow_dont,/* complain_on_overflow */ | |
583 | bfd_elf_generic_reloc, /* special_function */ | |
584 | "R_ARM_LDR_SBREL_11_0",/* name */ | |
585 | FALSE, /* partial_inplace */ | |
586 | 0x00000fff, /* src_mask */ | |
587 | 0x00000fff, /* dst_mask */ | |
588 | FALSE), /* pcrel_offset */ | |
589 | ||
590 | HOWTO (R_ARM_ALU_SBREL_19_12, /* type */ | |
591 | 0, /* rightshift */ | |
592 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
593 | 8, /* bitsize */ | |
594 | FALSE, /* pc_relative */ | |
595 | 12, /* bitpos */ | |
596 | complain_overflow_dont,/* complain_on_overflow */ | |
597 | bfd_elf_generic_reloc, /* special_function */ | |
598 | "R_ARM_ALU_SBREL_19_12",/* name */ | |
599 | FALSE, /* partial_inplace */ | |
600 | 0x000ff000, /* src_mask */ | |
601 | 0x000ff000, /* dst_mask */ | |
602 | FALSE), /* pcrel_offset */ | |
603 | ||
604 | HOWTO (R_ARM_ALU_SBREL_27_20, /* type */ | |
605 | 0, /* rightshift */ | |
606 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
607 | 8, /* bitsize */ | |
608 | FALSE, /* pc_relative */ | |
609 | 20, /* bitpos */ | |
610 | complain_overflow_dont,/* complain_on_overflow */ | |
611 | bfd_elf_generic_reloc, /* special_function */ | |
612 | "R_ARM_ALU_SBREL_27_20",/* name */ | |
613 | FALSE, /* partial_inplace */ | |
614 | 0x0ff00000, /* src_mask */ | |
615 | 0x0ff00000, /* dst_mask */ | |
616 | FALSE), /* pcrel_offset */ | |
617 | ||
618 | HOWTO (R_ARM_TARGET1, /* type */ | |
619 | 0, /* rightshift */ | |
620 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
621 | 32, /* bitsize */ | |
622 | FALSE, /* pc_relative */ | |
623 | 0, /* bitpos */ | |
624 | complain_overflow_dont,/* complain_on_overflow */ | |
625 | bfd_elf_generic_reloc, /* special_function */ | |
626 | "R_ARM_TARGET1", /* name */ | |
627 | FALSE, /* partial_inplace */ | |
628 | 0xffffffff, /* src_mask */ | |
629 | 0xffffffff, /* dst_mask */ | |
630 | FALSE), /* pcrel_offset */ | |
631 | ||
632 | HOWTO (R_ARM_ROSEGREL32, /* type */ | |
633 | 0, /* rightshift */ | |
634 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
635 | 32, /* bitsize */ | |
636 | FALSE, /* pc_relative */ | |
637 | 0, /* bitpos */ | |
638 | complain_overflow_dont,/* complain_on_overflow */ | |
639 | bfd_elf_generic_reloc, /* special_function */ | |
640 | "R_ARM_ROSEGREL32", /* name */ | |
641 | FALSE, /* partial_inplace */ | |
642 | 0xffffffff, /* src_mask */ | |
643 | 0xffffffff, /* dst_mask */ | |
644 | FALSE), /* pcrel_offset */ | |
645 | ||
646 | HOWTO (R_ARM_V4BX, /* type */ | |
647 | 0, /* rightshift */ | |
648 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
649 | 32, /* bitsize */ | |
650 | FALSE, /* pc_relative */ | |
651 | 0, /* bitpos */ | |
652 | complain_overflow_dont,/* complain_on_overflow */ | |
653 | bfd_elf_generic_reloc, /* special_function */ | |
654 | "R_ARM_V4BX", /* name */ | |
655 | FALSE, /* partial_inplace */ | |
656 | 0xffffffff, /* src_mask */ | |
657 | 0xffffffff, /* dst_mask */ | |
658 | FALSE), /* pcrel_offset */ | |
659 | ||
660 | HOWTO (R_ARM_TARGET2, /* type */ | |
661 | 0, /* rightshift */ | |
662 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
663 | 32, /* bitsize */ | |
664 | FALSE, /* pc_relative */ | |
665 | 0, /* bitpos */ | |
666 | complain_overflow_signed,/* complain_on_overflow */ | |
667 | bfd_elf_generic_reloc, /* special_function */ | |
668 | "R_ARM_TARGET2", /* name */ | |
669 | FALSE, /* partial_inplace */ | |
670 | 0xffffffff, /* src_mask */ | |
671 | 0xffffffff, /* dst_mask */ | |
672 | TRUE), /* pcrel_offset */ | |
673 | ||
674 | HOWTO (R_ARM_PREL31, /* type */ | |
675 | 0, /* rightshift */ | |
676 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
677 | 31, /* bitsize */ | |
678 | TRUE, /* pc_relative */ | |
679 | 0, /* bitpos */ | |
680 | complain_overflow_signed,/* complain_on_overflow */ | |
681 | bfd_elf_generic_reloc, /* special_function */ | |
682 | "R_ARM_PREL31", /* name */ | |
683 | FALSE, /* partial_inplace */ | |
684 | 0x7fffffff, /* src_mask */ | |
685 | 0x7fffffff, /* dst_mask */ | |
686 | TRUE), /* pcrel_offset */ | |
c19d1205 ZW |
687 | |
688 | HOWTO (R_ARM_MOVW_ABS_NC, /* type */ | |
689 | 0, /* rightshift */ | |
690 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
691 | 16, /* bitsize */ | |
692 | FALSE, /* pc_relative */ | |
693 | 0, /* bitpos */ | |
694 | complain_overflow_dont,/* complain_on_overflow */ | |
695 | bfd_elf_generic_reloc, /* special_function */ | |
696 | "R_ARM_MOVW_ABS_NC", /* name */ | |
697 | FALSE, /* partial_inplace */ | |
698 | 0x0000ffff, /* src_mask */ | |
699 | 0x0000ffff, /* dst_mask */ | |
700 | FALSE), /* pcrel_offset */ | |
701 | ||
702 | HOWTO (R_ARM_MOVT_ABS, /* type */ | |
703 | 0, /* rightshift */ | |
704 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
705 | 16, /* bitsize */ | |
706 | FALSE, /* pc_relative */ | |
707 | 0, /* bitpos */ | |
708 | complain_overflow_bitfield,/* complain_on_overflow */ | |
709 | bfd_elf_generic_reloc, /* special_function */ | |
710 | "R_ARM_MOVT_ABS", /* name */ | |
711 | FALSE, /* partial_inplace */ | |
712 | 0x0000ffff, /* src_mask */ | |
713 | 0x0000ffff, /* dst_mask */ | |
714 | FALSE), /* pcrel_offset */ | |
715 | ||
716 | HOWTO (R_ARM_MOVW_PREL_NC, /* type */ | |
717 | 0, /* rightshift */ | |
718 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
719 | 16, /* bitsize */ | |
720 | TRUE, /* pc_relative */ | |
721 | 0, /* bitpos */ | |
722 | complain_overflow_dont,/* complain_on_overflow */ | |
723 | bfd_elf_generic_reloc, /* special_function */ | |
724 | "R_ARM_MOVW_PREL_NC", /* name */ | |
725 | FALSE, /* partial_inplace */ | |
726 | 0x0000ffff, /* src_mask */ | |
727 | 0x0000ffff, /* dst_mask */ | |
728 | TRUE), /* pcrel_offset */ | |
729 | ||
730 | HOWTO (R_ARM_MOVT_PREL, /* type */ | |
731 | 0, /* rightshift */ | |
732 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
733 | 16, /* bitsize */ | |
734 | TRUE, /* pc_relative */ | |
735 | 0, /* bitpos */ | |
736 | complain_overflow_bitfield,/* complain_on_overflow */ | |
737 | bfd_elf_generic_reloc, /* special_function */ | |
738 | "R_ARM_MOVT_PREL", /* name */ | |
739 | FALSE, /* partial_inplace */ | |
740 | 0x0000ffff, /* src_mask */ | |
741 | 0x0000ffff, /* dst_mask */ | |
742 | TRUE), /* pcrel_offset */ | |
743 | ||
744 | HOWTO (R_ARM_THM_MOVW_ABS_NC, /* type */ | |
745 | 0, /* rightshift */ | |
746 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
747 | 16, /* bitsize */ | |
748 | FALSE, /* pc_relative */ | |
749 | 0, /* bitpos */ | |
750 | complain_overflow_dont,/* complain_on_overflow */ | |
751 | bfd_elf_generic_reloc, /* special_function */ | |
752 | "R_ARM_THM_MOVW_ABS_NC",/* name */ | |
753 | FALSE, /* partial_inplace */ | |
754 | 0x040f70ff, /* src_mask */ | |
755 | 0x040f70ff, /* dst_mask */ | |
756 | FALSE), /* pcrel_offset */ | |
757 | ||
758 | HOWTO (R_ARM_THM_MOVT_ABS, /* type */ | |
759 | 0, /* rightshift */ | |
760 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
761 | 16, /* bitsize */ | |
762 | FALSE, /* pc_relative */ | |
763 | 0, /* bitpos */ | |
764 | complain_overflow_bitfield,/* complain_on_overflow */ | |
765 | bfd_elf_generic_reloc, /* special_function */ | |
766 | "R_ARM_THM_MOVT_ABS", /* name */ | |
767 | FALSE, /* partial_inplace */ | |
768 | 0x040f70ff, /* src_mask */ | |
769 | 0x040f70ff, /* dst_mask */ | |
770 | FALSE), /* pcrel_offset */ | |
771 | ||
772 | HOWTO (R_ARM_THM_MOVW_PREL_NC,/* type */ | |
773 | 0, /* rightshift */ | |
774 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
775 | 16, /* bitsize */ | |
776 | TRUE, /* pc_relative */ | |
777 | 0, /* bitpos */ | |
778 | complain_overflow_dont,/* complain_on_overflow */ | |
779 | bfd_elf_generic_reloc, /* special_function */ | |
780 | "R_ARM_THM_MOVW_PREL_NC",/* name */ | |
781 | FALSE, /* partial_inplace */ | |
782 | 0x040f70ff, /* src_mask */ | |
783 | 0x040f70ff, /* dst_mask */ | |
784 | TRUE), /* pcrel_offset */ | |
785 | ||
786 | HOWTO (R_ARM_THM_MOVT_PREL, /* type */ | |
787 | 0, /* rightshift */ | |
788 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
789 | 16, /* bitsize */ | |
790 | TRUE, /* pc_relative */ | |
791 | 0, /* bitpos */ | |
792 | complain_overflow_bitfield,/* complain_on_overflow */ | |
793 | bfd_elf_generic_reloc, /* special_function */ | |
794 | "R_ARM_THM_MOVT_PREL", /* name */ | |
795 | FALSE, /* partial_inplace */ | |
796 | 0x040f70ff, /* src_mask */ | |
797 | 0x040f70ff, /* dst_mask */ | |
798 | TRUE), /* pcrel_offset */ | |
799 | ||
800 | HOWTO (R_ARM_THM_JUMP19, /* type */ | |
801 | 1, /* rightshift */ | |
802 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
803 | 19, /* bitsize */ | |
804 | TRUE, /* pc_relative */ | |
805 | 0, /* bitpos */ | |
806 | complain_overflow_signed,/* complain_on_overflow */ | |
807 | bfd_elf_generic_reloc, /* special_function */ | |
808 | "R_ARM_THM_JUMP19", /* name */ | |
809 | FALSE, /* partial_inplace */ | |
810 | 0x043f2fff, /* src_mask */ | |
811 | 0x043f2fff, /* dst_mask */ | |
812 | TRUE), /* pcrel_offset */ | |
813 | ||
814 | HOWTO (R_ARM_THM_JUMP6, /* type */ | |
815 | 1, /* rightshift */ | |
816 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
817 | 6, /* bitsize */ | |
818 | TRUE, /* pc_relative */ | |
819 | 0, /* bitpos */ | |
820 | complain_overflow_unsigned,/* complain_on_overflow */ | |
821 | bfd_elf_generic_reloc, /* special_function */ | |
822 | "R_ARM_THM_JUMP6", /* name */ | |
823 | FALSE, /* partial_inplace */ | |
824 | 0x02f8, /* src_mask */ | |
825 | 0x02f8, /* dst_mask */ | |
826 | TRUE), /* pcrel_offset */ | |
827 | ||
828 | /* These are declared as 13-bit signed relocations because we can | |
829 | address -4095 .. 4095(base) by altering ADDW to SUBW or vice | |
830 | versa. */ | |
831 | HOWTO (R_ARM_THM_ALU_PREL_11_0,/* type */ | |
832 | 0, /* rightshift */ | |
833 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
834 | 13, /* bitsize */ | |
835 | TRUE, /* pc_relative */ | |
836 | 0, /* bitpos */ | |
2cab6cc3 | 837 | complain_overflow_dont,/* complain_on_overflow */ |
c19d1205 ZW |
838 | bfd_elf_generic_reloc, /* special_function */ |
839 | "R_ARM_THM_ALU_PREL_11_0",/* name */ | |
840 | FALSE, /* partial_inplace */ | |
2cab6cc3 MS |
841 | 0xffffffff, /* src_mask */ |
842 | 0xffffffff, /* dst_mask */ | |
c19d1205 ZW |
843 | TRUE), /* pcrel_offset */ |
844 | ||
845 | HOWTO (R_ARM_THM_PC12, /* type */ | |
846 | 0, /* rightshift */ | |
847 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
848 | 13, /* bitsize */ | |
849 | TRUE, /* pc_relative */ | |
850 | 0, /* bitpos */ | |
2cab6cc3 | 851 | complain_overflow_dont,/* complain_on_overflow */ |
c19d1205 ZW |
852 | bfd_elf_generic_reloc, /* special_function */ |
853 | "R_ARM_THM_PC12", /* name */ | |
854 | FALSE, /* partial_inplace */ | |
2cab6cc3 MS |
855 | 0xffffffff, /* src_mask */ |
856 | 0xffffffff, /* dst_mask */ | |
c19d1205 ZW |
857 | TRUE), /* pcrel_offset */ |
858 | ||
859 | HOWTO (R_ARM_ABS32_NOI, /* type */ | |
860 | 0, /* rightshift */ | |
861 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
862 | 32, /* bitsize */ | |
863 | FALSE, /* pc_relative */ | |
864 | 0, /* bitpos */ | |
865 | complain_overflow_dont,/* complain_on_overflow */ | |
866 | bfd_elf_generic_reloc, /* special_function */ | |
867 | "R_ARM_ABS32_NOI", /* name */ | |
868 | FALSE, /* partial_inplace */ | |
869 | 0xffffffff, /* src_mask */ | |
870 | 0xffffffff, /* dst_mask */ | |
871 | FALSE), /* pcrel_offset */ | |
872 | ||
873 | HOWTO (R_ARM_REL32_NOI, /* type */ | |
874 | 0, /* rightshift */ | |
875 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
876 | 32, /* bitsize */ | |
877 | TRUE, /* pc_relative */ | |
878 | 0, /* bitpos */ | |
879 | complain_overflow_dont,/* complain_on_overflow */ | |
880 | bfd_elf_generic_reloc, /* special_function */ | |
881 | "R_ARM_REL32_NOI", /* name */ | |
882 | FALSE, /* partial_inplace */ | |
883 | 0xffffffff, /* src_mask */ | |
884 | 0xffffffff, /* dst_mask */ | |
885 | FALSE), /* pcrel_offset */ | |
7f266840 | 886 | |
4962c51a MS |
887 | /* Group relocations. */ |
888 | ||
889 | HOWTO (R_ARM_ALU_PC_G0_NC, /* type */ | |
890 | 0, /* rightshift */ | |
891 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
892 | 32, /* bitsize */ | |
893 | TRUE, /* pc_relative */ | |
894 | 0, /* bitpos */ | |
895 | complain_overflow_dont,/* complain_on_overflow */ | |
896 | bfd_elf_generic_reloc, /* special_function */ | |
897 | "R_ARM_ALU_PC_G0_NC", /* name */ | |
898 | FALSE, /* partial_inplace */ | |
899 | 0xffffffff, /* src_mask */ | |
900 | 0xffffffff, /* dst_mask */ | |
901 | TRUE), /* pcrel_offset */ | |
902 | ||
903 | HOWTO (R_ARM_ALU_PC_G0, /* type */ | |
904 | 0, /* rightshift */ | |
905 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
906 | 32, /* bitsize */ | |
907 | TRUE, /* pc_relative */ | |
908 | 0, /* bitpos */ | |
909 | complain_overflow_dont,/* complain_on_overflow */ | |
910 | bfd_elf_generic_reloc, /* special_function */ | |
911 | "R_ARM_ALU_PC_G0", /* name */ | |
912 | FALSE, /* partial_inplace */ | |
913 | 0xffffffff, /* src_mask */ | |
914 | 0xffffffff, /* dst_mask */ | |
915 | TRUE), /* pcrel_offset */ | |
916 | ||
917 | HOWTO (R_ARM_ALU_PC_G1_NC, /* type */ | |
918 | 0, /* rightshift */ | |
919 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
920 | 32, /* bitsize */ | |
921 | TRUE, /* pc_relative */ | |
922 | 0, /* bitpos */ | |
923 | complain_overflow_dont,/* complain_on_overflow */ | |
924 | bfd_elf_generic_reloc, /* special_function */ | |
925 | "R_ARM_ALU_PC_G1_NC", /* name */ | |
926 | FALSE, /* partial_inplace */ | |
927 | 0xffffffff, /* src_mask */ | |
928 | 0xffffffff, /* dst_mask */ | |
929 | TRUE), /* pcrel_offset */ | |
930 | ||
931 | HOWTO (R_ARM_ALU_PC_G1, /* type */ | |
932 | 0, /* rightshift */ | |
933 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
934 | 32, /* bitsize */ | |
935 | TRUE, /* pc_relative */ | |
936 | 0, /* bitpos */ | |
937 | complain_overflow_dont,/* complain_on_overflow */ | |
938 | bfd_elf_generic_reloc, /* special_function */ | |
939 | "R_ARM_ALU_PC_G1", /* name */ | |
940 | FALSE, /* partial_inplace */ | |
941 | 0xffffffff, /* src_mask */ | |
942 | 0xffffffff, /* dst_mask */ | |
943 | TRUE), /* pcrel_offset */ | |
944 | ||
945 | HOWTO (R_ARM_ALU_PC_G2, /* type */ | |
946 | 0, /* rightshift */ | |
947 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
948 | 32, /* bitsize */ | |
949 | TRUE, /* pc_relative */ | |
950 | 0, /* bitpos */ | |
951 | complain_overflow_dont,/* complain_on_overflow */ | |
952 | bfd_elf_generic_reloc, /* special_function */ | |
953 | "R_ARM_ALU_PC_G2", /* name */ | |
954 | FALSE, /* partial_inplace */ | |
955 | 0xffffffff, /* src_mask */ | |
956 | 0xffffffff, /* dst_mask */ | |
957 | TRUE), /* pcrel_offset */ | |
958 | ||
959 | HOWTO (R_ARM_LDR_PC_G1, /* type */ | |
960 | 0, /* rightshift */ | |
961 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
962 | 32, /* bitsize */ | |
963 | TRUE, /* pc_relative */ | |
964 | 0, /* bitpos */ | |
965 | complain_overflow_dont,/* complain_on_overflow */ | |
966 | bfd_elf_generic_reloc, /* special_function */ | |
967 | "R_ARM_LDR_PC_G1", /* name */ | |
968 | FALSE, /* partial_inplace */ | |
969 | 0xffffffff, /* src_mask */ | |
970 | 0xffffffff, /* dst_mask */ | |
971 | TRUE), /* pcrel_offset */ | |
972 | ||
973 | HOWTO (R_ARM_LDR_PC_G2, /* type */ | |
974 | 0, /* rightshift */ | |
975 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
976 | 32, /* bitsize */ | |
977 | TRUE, /* pc_relative */ | |
978 | 0, /* bitpos */ | |
979 | complain_overflow_dont,/* complain_on_overflow */ | |
980 | bfd_elf_generic_reloc, /* special_function */ | |
981 | "R_ARM_LDR_PC_G2", /* name */ | |
982 | FALSE, /* partial_inplace */ | |
983 | 0xffffffff, /* src_mask */ | |
984 | 0xffffffff, /* dst_mask */ | |
985 | TRUE), /* pcrel_offset */ | |
986 | ||
987 | HOWTO (R_ARM_LDRS_PC_G0, /* type */ | |
988 | 0, /* rightshift */ | |
989 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
990 | 32, /* bitsize */ | |
991 | TRUE, /* pc_relative */ | |
992 | 0, /* bitpos */ | |
993 | complain_overflow_dont,/* complain_on_overflow */ | |
994 | bfd_elf_generic_reloc, /* special_function */ | |
995 | "R_ARM_LDRS_PC_G0", /* name */ | |
996 | FALSE, /* partial_inplace */ | |
997 | 0xffffffff, /* src_mask */ | |
998 | 0xffffffff, /* dst_mask */ | |
999 | TRUE), /* pcrel_offset */ | |
1000 | ||
1001 | HOWTO (R_ARM_LDRS_PC_G1, /* type */ | |
1002 | 0, /* rightshift */ | |
1003 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1004 | 32, /* bitsize */ | |
1005 | TRUE, /* pc_relative */ | |
1006 | 0, /* bitpos */ | |
1007 | complain_overflow_dont,/* complain_on_overflow */ | |
1008 | bfd_elf_generic_reloc, /* special_function */ | |
1009 | "R_ARM_LDRS_PC_G1", /* name */ | |
1010 | FALSE, /* partial_inplace */ | |
1011 | 0xffffffff, /* src_mask */ | |
1012 | 0xffffffff, /* dst_mask */ | |
1013 | TRUE), /* pcrel_offset */ | |
1014 | ||
1015 | HOWTO (R_ARM_LDRS_PC_G2, /* type */ | |
1016 | 0, /* rightshift */ | |
1017 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1018 | 32, /* bitsize */ | |
1019 | TRUE, /* pc_relative */ | |
1020 | 0, /* bitpos */ | |
1021 | complain_overflow_dont,/* complain_on_overflow */ | |
1022 | bfd_elf_generic_reloc, /* special_function */ | |
1023 | "R_ARM_LDRS_PC_G2", /* name */ | |
1024 | FALSE, /* partial_inplace */ | |
1025 | 0xffffffff, /* src_mask */ | |
1026 | 0xffffffff, /* dst_mask */ | |
1027 | TRUE), /* pcrel_offset */ | |
1028 | ||
1029 | HOWTO (R_ARM_LDC_PC_G0, /* type */ | |
1030 | 0, /* rightshift */ | |
1031 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1032 | 32, /* bitsize */ | |
1033 | TRUE, /* pc_relative */ | |
1034 | 0, /* bitpos */ | |
1035 | complain_overflow_dont,/* complain_on_overflow */ | |
1036 | bfd_elf_generic_reloc, /* special_function */ | |
1037 | "R_ARM_LDC_PC_G0", /* name */ | |
1038 | FALSE, /* partial_inplace */ | |
1039 | 0xffffffff, /* src_mask */ | |
1040 | 0xffffffff, /* dst_mask */ | |
1041 | TRUE), /* pcrel_offset */ | |
1042 | ||
1043 | HOWTO (R_ARM_LDC_PC_G1, /* type */ | |
1044 | 0, /* rightshift */ | |
1045 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1046 | 32, /* bitsize */ | |
1047 | TRUE, /* pc_relative */ | |
1048 | 0, /* bitpos */ | |
1049 | complain_overflow_dont,/* complain_on_overflow */ | |
1050 | bfd_elf_generic_reloc, /* special_function */ | |
1051 | "R_ARM_LDC_PC_G1", /* name */ | |
1052 | FALSE, /* partial_inplace */ | |
1053 | 0xffffffff, /* src_mask */ | |
1054 | 0xffffffff, /* dst_mask */ | |
1055 | TRUE), /* pcrel_offset */ | |
1056 | ||
1057 | HOWTO (R_ARM_LDC_PC_G2, /* type */ | |
1058 | 0, /* rightshift */ | |
1059 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1060 | 32, /* bitsize */ | |
1061 | TRUE, /* pc_relative */ | |
1062 | 0, /* bitpos */ | |
1063 | complain_overflow_dont,/* complain_on_overflow */ | |
1064 | bfd_elf_generic_reloc, /* special_function */ | |
1065 | "R_ARM_LDC_PC_G2", /* name */ | |
1066 | FALSE, /* partial_inplace */ | |
1067 | 0xffffffff, /* src_mask */ | |
1068 | 0xffffffff, /* dst_mask */ | |
1069 | TRUE), /* pcrel_offset */ | |
1070 | ||
1071 | HOWTO (R_ARM_ALU_SB_G0_NC, /* type */ | |
1072 | 0, /* rightshift */ | |
1073 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1074 | 32, /* bitsize */ | |
1075 | TRUE, /* pc_relative */ | |
1076 | 0, /* bitpos */ | |
1077 | complain_overflow_dont,/* complain_on_overflow */ | |
1078 | bfd_elf_generic_reloc, /* special_function */ | |
1079 | "R_ARM_ALU_SB_G0_NC", /* name */ | |
1080 | FALSE, /* partial_inplace */ | |
1081 | 0xffffffff, /* src_mask */ | |
1082 | 0xffffffff, /* dst_mask */ | |
1083 | TRUE), /* pcrel_offset */ | |
1084 | ||
1085 | HOWTO (R_ARM_ALU_SB_G0, /* type */ | |
1086 | 0, /* rightshift */ | |
1087 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1088 | 32, /* bitsize */ | |
1089 | TRUE, /* pc_relative */ | |
1090 | 0, /* bitpos */ | |
1091 | complain_overflow_dont,/* complain_on_overflow */ | |
1092 | bfd_elf_generic_reloc, /* special_function */ | |
1093 | "R_ARM_ALU_SB_G0", /* name */ | |
1094 | FALSE, /* partial_inplace */ | |
1095 | 0xffffffff, /* src_mask */ | |
1096 | 0xffffffff, /* dst_mask */ | |
1097 | TRUE), /* pcrel_offset */ | |
1098 | ||
1099 | HOWTO (R_ARM_ALU_SB_G1_NC, /* type */ | |
1100 | 0, /* rightshift */ | |
1101 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1102 | 32, /* bitsize */ | |
1103 | TRUE, /* pc_relative */ | |
1104 | 0, /* bitpos */ | |
1105 | complain_overflow_dont,/* complain_on_overflow */ | |
1106 | bfd_elf_generic_reloc, /* special_function */ | |
1107 | "R_ARM_ALU_SB_G1_NC", /* name */ | |
1108 | FALSE, /* partial_inplace */ | |
1109 | 0xffffffff, /* src_mask */ | |
1110 | 0xffffffff, /* dst_mask */ | |
1111 | TRUE), /* pcrel_offset */ | |
1112 | ||
1113 | HOWTO (R_ARM_ALU_SB_G1, /* type */ | |
1114 | 0, /* rightshift */ | |
1115 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1116 | 32, /* bitsize */ | |
1117 | TRUE, /* pc_relative */ | |
1118 | 0, /* bitpos */ | |
1119 | complain_overflow_dont,/* complain_on_overflow */ | |
1120 | bfd_elf_generic_reloc, /* special_function */ | |
1121 | "R_ARM_ALU_SB_G1", /* name */ | |
1122 | FALSE, /* partial_inplace */ | |
1123 | 0xffffffff, /* src_mask */ | |
1124 | 0xffffffff, /* dst_mask */ | |
1125 | TRUE), /* pcrel_offset */ | |
1126 | ||
1127 | HOWTO (R_ARM_ALU_SB_G2, /* type */ | |
1128 | 0, /* rightshift */ | |
1129 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1130 | 32, /* bitsize */ | |
1131 | TRUE, /* pc_relative */ | |
1132 | 0, /* bitpos */ | |
1133 | complain_overflow_dont,/* complain_on_overflow */ | |
1134 | bfd_elf_generic_reloc, /* special_function */ | |
1135 | "R_ARM_ALU_SB_G2", /* name */ | |
1136 | FALSE, /* partial_inplace */ | |
1137 | 0xffffffff, /* src_mask */ | |
1138 | 0xffffffff, /* dst_mask */ | |
1139 | TRUE), /* pcrel_offset */ | |
1140 | ||
1141 | HOWTO (R_ARM_LDR_SB_G0, /* type */ | |
1142 | 0, /* rightshift */ | |
1143 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1144 | 32, /* bitsize */ | |
1145 | TRUE, /* pc_relative */ | |
1146 | 0, /* bitpos */ | |
1147 | complain_overflow_dont,/* complain_on_overflow */ | |
1148 | bfd_elf_generic_reloc, /* special_function */ | |
1149 | "R_ARM_LDR_SB_G0", /* name */ | |
1150 | FALSE, /* partial_inplace */ | |
1151 | 0xffffffff, /* src_mask */ | |
1152 | 0xffffffff, /* dst_mask */ | |
1153 | TRUE), /* pcrel_offset */ | |
1154 | ||
1155 | HOWTO (R_ARM_LDR_SB_G1, /* type */ | |
1156 | 0, /* rightshift */ | |
1157 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1158 | 32, /* bitsize */ | |
1159 | TRUE, /* pc_relative */ | |
1160 | 0, /* bitpos */ | |
1161 | complain_overflow_dont,/* complain_on_overflow */ | |
1162 | bfd_elf_generic_reloc, /* special_function */ | |
1163 | "R_ARM_LDR_SB_G1", /* name */ | |
1164 | FALSE, /* partial_inplace */ | |
1165 | 0xffffffff, /* src_mask */ | |
1166 | 0xffffffff, /* dst_mask */ | |
1167 | TRUE), /* pcrel_offset */ | |
1168 | ||
1169 | HOWTO (R_ARM_LDR_SB_G2, /* type */ | |
1170 | 0, /* rightshift */ | |
1171 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1172 | 32, /* bitsize */ | |
1173 | TRUE, /* pc_relative */ | |
1174 | 0, /* bitpos */ | |
1175 | complain_overflow_dont,/* complain_on_overflow */ | |
1176 | bfd_elf_generic_reloc, /* special_function */ | |
1177 | "R_ARM_LDR_SB_G2", /* name */ | |
1178 | FALSE, /* partial_inplace */ | |
1179 | 0xffffffff, /* src_mask */ | |
1180 | 0xffffffff, /* dst_mask */ | |
1181 | TRUE), /* pcrel_offset */ | |
1182 | ||
1183 | HOWTO (R_ARM_LDRS_SB_G0, /* type */ | |
1184 | 0, /* rightshift */ | |
1185 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1186 | 32, /* bitsize */ | |
1187 | TRUE, /* pc_relative */ | |
1188 | 0, /* bitpos */ | |
1189 | complain_overflow_dont,/* complain_on_overflow */ | |
1190 | bfd_elf_generic_reloc, /* special_function */ | |
1191 | "R_ARM_LDRS_SB_G0", /* name */ | |
1192 | FALSE, /* partial_inplace */ | |
1193 | 0xffffffff, /* src_mask */ | |
1194 | 0xffffffff, /* dst_mask */ | |
1195 | TRUE), /* pcrel_offset */ | |
1196 | ||
1197 | HOWTO (R_ARM_LDRS_SB_G1, /* type */ | |
1198 | 0, /* rightshift */ | |
1199 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1200 | 32, /* bitsize */ | |
1201 | TRUE, /* pc_relative */ | |
1202 | 0, /* bitpos */ | |
1203 | complain_overflow_dont,/* complain_on_overflow */ | |
1204 | bfd_elf_generic_reloc, /* special_function */ | |
1205 | "R_ARM_LDRS_SB_G1", /* name */ | |
1206 | FALSE, /* partial_inplace */ | |
1207 | 0xffffffff, /* src_mask */ | |
1208 | 0xffffffff, /* dst_mask */ | |
1209 | TRUE), /* pcrel_offset */ | |
1210 | ||
1211 | HOWTO (R_ARM_LDRS_SB_G2, /* type */ | |
1212 | 0, /* rightshift */ | |
1213 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1214 | 32, /* bitsize */ | |
1215 | TRUE, /* pc_relative */ | |
1216 | 0, /* bitpos */ | |
1217 | complain_overflow_dont,/* complain_on_overflow */ | |
1218 | bfd_elf_generic_reloc, /* special_function */ | |
1219 | "R_ARM_LDRS_SB_G2", /* name */ | |
1220 | FALSE, /* partial_inplace */ | |
1221 | 0xffffffff, /* src_mask */ | |
1222 | 0xffffffff, /* dst_mask */ | |
1223 | TRUE), /* pcrel_offset */ | |
1224 | ||
1225 | HOWTO (R_ARM_LDC_SB_G0, /* type */ | |
1226 | 0, /* rightshift */ | |
1227 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1228 | 32, /* bitsize */ | |
1229 | TRUE, /* pc_relative */ | |
1230 | 0, /* bitpos */ | |
1231 | complain_overflow_dont,/* complain_on_overflow */ | |
1232 | bfd_elf_generic_reloc, /* special_function */ | |
1233 | "R_ARM_LDC_SB_G0", /* name */ | |
1234 | FALSE, /* partial_inplace */ | |
1235 | 0xffffffff, /* src_mask */ | |
1236 | 0xffffffff, /* dst_mask */ | |
1237 | TRUE), /* pcrel_offset */ | |
1238 | ||
1239 | HOWTO (R_ARM_LDC_SB_G1, /* type */ | |
1240 | 0, /* rightshift */ | |
1241 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1242 | 32, /* bitsize */ | |
1243 | TRUE, /* pc_relative */ | |
1244 | 0, /* bitpos */ | |
1245 | complain_overflow_dont,/* complain_on_overflow */ | |
1246 | bfd_elf_generic_reloc, /* special_function */ | |
1247 | "R_ARM_LDC_SB_G1", /* name */ | |
1248 | FALSE, /* partial_inplace */ | |
1249 | 0xffffffff, /* src_mask */ | |
1250 | 0xffffffff, /* dst_mask */ | |
1251 | TRUE), /* pcrel_offset */ | |
1252 | ||
1253 | HOWTO (R_ARM_LDC_SB_G2, /* type */ | |
1254 | 0, /* rightshift */ | |
1255 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1256 | 32, /* bitsize */ | |
1257 | TRUE, /* pc_relative */ | |
1258 | 0, /* bitpos */ | |
1259 | complain_overflow_dont,/* complain_on_overflow */ | |
1260 | bfd_elf_generic_reloc, /* special_function */ | |
1261 | "R_ARM_LDC_SB_G2", /* name */ | |
1262 | FALSE, /* partial_inplace */ | |
1263 | 0xffffffff, /* src_mask */ | |
1264 | 0xffffffff, /* dst_mask */ | |
1265 | TRUE), /* pcrel_offset */ | |
1266 | ||
1267 | /* End of group relocations. */ | |
c19d1205 | 1268 | |
c19d1205 ZW |
1269 | HOWTO (R_ARM_MOVW_BREL_NC, /* type */ |
1270 | 0, /* rightshift */ | |
1271 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1272 | 16, /* bitsize */ | |
1273 | FALSE, /* pc_relative */ | |
1274 | 0, /* bitpos */ | |
1275 | complain_overflow_dont,/* complain_on_overflow */ | |
1276 | bfd_elf_generic_reloc, /* special_function */ | |
1277 | "R_ARM_MOVW_BREL_NC", /* name */ | |
1278 | FALSE, /* partial_inplace */ | |
1279 | 0x0000ffff, /* src_mask */ | |
1280 | 0x0000ffff, /* dst_mask */ | |
1281 | FALSE), /* pcrel_offset */ | |
1282 | ||
1283 | HOWTO (R_ARM_MOVT_BREL, /* type */ | |
1284 | 0, /* rightshift */ | |
1285 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1286 | 16, /* bitsize */ | |
1287 | FALSE, /* pc_relative */ | |
1288 | 0, /* bitpos */ | |
1289 | complain_overflow_bitfield,/* complain_on_overflow */ | |
1290 | bfd_elf_generic_reloc, /* special_function */ | |
1291 | "R_ARM_MOVT_BREL", /* name */ | |
1292 | FALSE, /* partial_inplace */ | |
1293 | 0x0000ffff, /* src_mask */ | |
1294 | 0x0000ffff, /* dst_mask */ | |
1295 | FALSE), /* pcrel_offset */ | |
1296 | ||
1297 | HOWTO (R_ARM_MOVW_BREL, /* type */ | |
1298 | 0, /* rightshift */ | |
1299 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1300 | 16, /* bitsize */ | |
1301 | FALSE, /* pc_relative */ | |
1302 | 0, /* bitpos */ | |
1303 | complain_overflow_dont,/* complain_on_overflow */ | |
1304 | bfd_elf_generic_reloc, /* special_function */ | |
1305 | "R_ARM_MOVW_BREL", /* name */ | |
1306 | FALSE, /* partial_inplace */ | |
1307 | 0x0000ffff, /* src_mask */ | |
1308 | 0x0000ffff, /* dst_mask */ | |
1309 | FALSE), /* pcrel_offset */ | |
1310 | ||
1311 | HOWTO (R_ARM_THM_MOVW_BREL_NC,/* type */ | |
1312 | 0, /* rightshift */ | |
1313 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1314 | 16, /* bitsize */ | |
1315 | FALSE, /* pc_relative */ | |
1316 | 0, /* bitpos */ | |
1317 | complain_overflow_dont,/* complain_on_overflow */ | |
1318 | bfd_elf_generic_reloc, /* special_function */ | |
1319 | "R_ARM_THM_MOVW_BREL_NC",/* name */ | |
1320 | FALSE, /* partial_inplace */ | |
1321 | 0x040f70ff, /* src_mask */ | |
1322 | 0x040f70ff, /* dst_mask */ | |
1323 | FALSE), /* pcrel_offset */ | |
1324 | ||
1325 | HOWTO (R_ARM_THM_MOVT_BREL, /* type */ | |
1326 | 0, /* rightshift */ | |
1327 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1328 | 16, /* bitsize */ | |
1329 | FALSE, /* pc_relative */ | |
1330 | 0, /* bitpos */ | |
1331 | complain_overflow_bitfield,/* complain_on_overflow */ | |
1332 | bfd_elf_generic_reloc, /* special_function */ | |
1333 | "R_ARM_THM_MOVT_BREL", /* name */ | |
1334 | FALSE, /* partial_inplace */ | |
1335 | 0x040f70ff, /* src_mask */ | |
1336 | 0x040f70ff, /* dst_mask */ | |
1337 | FALSE), /* pcrel_offset */ | |
1338 | ||
1339 | HOWTO (R_ARM_THM_MOVW_BREL, /* type */ | |
1340 | 0, /* rightshift */ | |
1341 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1342 | 16, /* bitsize */ | |
1343 | FALSE, /* pc_relative */ | |
1344 | 0, /* bitpos */ | |
1345 | complain_overflow_dont,/* complain_on_overflow */ | |
1346 | bfd_elf_generic_reloc, /* special_function */ | |
1347 | "R_ARM_THM_MOVW_BREL", /* name */ | |
1348 | FALSE, /* partial_inplace */ | |
1349 | 0x040f70ff, /* src_mask */ | |
1350 | 0x040f70ff, /* dst_mask */ | |
1351 | FALSE), /* pcrel_offset */ | |
1352 | ||
1353 | EMPTY_HOWTO (90), /* unallocated */ | |
1354 | EMPTY_HOWTO (91), | |
1355 | EMPTY_HOWTO (92), | |
1356 | EMPTY_HOWTO (93), | |
1357 | ||
1358 | HOWTO (R_ARM_PLT32_ABS, /* type */ | |
1359 | 0, /* rightshift */ | |
1360 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1361 | 32, /* bitsize */ | |
1362 | FALSE, /* pc_relative */ | |
1363 | 0, /* bitpos */ | |
1364 | complain_overflow_dont,/* complain_on_overflow */ | |
1365 | bfd_elf_generic_reloc, /* special_function */ | |
1366 | "R_ARM_PLT32_ABS", /* name */ | |
1367 | FALSE, /* partial_inplace */ | |
1368 | 0xffffffff, /* src_mask */ | |
1369 | 0xffffffff, /* dst_mask */ | |
1370 | FALSE), /* pcrel_offset */ | |
1371 | ||
1372 | HOWTO (R_ARM_GOT_ABS, /* type */ | |
1373 | 0, /* rightshift */ | |
1374 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1375 | 32, /* bitsize */ | |
1376 | FALSE, /* pc_relative */ | |
1377 | 0, /* bitpos */ | |
1378 | complain_overflow_dont,/* complain_on_overflow */ | |
1379 | bfd_elf_generic_reloc, /* special_function */ | |
1380 | "R_ARM_GOT_ABS", /* name */ | |
1381 | FALSE, /* partial_inplace */ | |
1382 | 0xffffffff, /* src_mask */ | |
1383 | 0xffffffff, /* dst_mask */ | |
1384 | FALSE), /* pcrel_offset */ | |
1385 | ||
1386 | HOWTO (R_ARM_GOT_PREL, /* type */ | |
1387 | 0, /* rightshift */ | |
1388 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1389 | 32, /* bitsize */ | |
1390 | TRUE, /* pc_relative */ | |
1391 | 0, /* bitpos */ | |
1392 | complain_overflow_dont, /* complain_on_overflow */ | |
1393 | bfd_elf_generic_reloc, /* special_function */ | |
1394 | "R_ARM_GOT_PREL", /* name */ | |
1395 | FALSE, /* partial_inplace */ | |
1396 | 0xffffffff, /* src_mask */ | |
1397 | 0xffffffff, /* dst_mask */ | |
1398 | TRUE), /* pcrel_offset */ | |
1399 | ||
1400 | HOWTO (R_ARM_GOT_BREL12, /* type */ | |
1401 | 0, /* rightshift */ | |
1402 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1403 | 12, /* bitsize */ | |
1404 | FALSE, /* pc_relative */ | |
1405 | 0, /* bitpos */ | |
1406 | complain_overflow_bitfield,/* complain_on_overflow */ | |
1407 | bfd_elf_generic_reloc, /* special_function */ | |
1408 | "R_ARM_GOT_BREL12", /* name */ | |
1409 | FALSE, /* partial_inplace */ | |
1410 | 0x00000fff, /* src_mask */ | |
1411 | 0x00000fff, /* dst_mask */ | |
1412 | FALSE), /* pcrel_offset */ | |
1413 | ||
1414 | HOWTO (R_ARM_GOTOFF12, /* type */ | |
1415 | 0, /* rightshift */ | |
1416 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1417 | 12, /* bitsize */ | |
1418 | FALSE, /* pc_relative */ | |
1419 | 0, /* bitpos */ | |
1420 | complain_overflow_bitfield,/* complain_on_overflow */ | |
1421 | bfd_elf_generic_reloc, /* special_function */ | |
1422 | "R_ARM_GOTOFF12", /* name */ | |
1423 | FALSE, /* partial_inplace */ | |
1424 | 0x00000fff, /* src_mask */ | |
1425 | 0x00000fff, /* dst_mask */ | |
1426 | FALSE), /* pcrel_offset */ | |
1427 | ||
1428 | EMPTY_HOWTO (R_ARM_GOTRELAX), /* reserved for future GOT-load optimizations */ | |
1429 | ||
1430 | /* GNU extension to record C++ vtable member usage */ | |
1431 | HOWTO (R_ARM_GNU_VTENTRY, /* type */ | |
ba93b8ac DJ |
1432 | 0, /* rightshift */ |
1433 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
c19d1205 | 1434 | 0, /* bitsize */ |
ba93b8ac DJ |
1435 | FALSE, /* pc_relative */ |
1436 | 0, /* bitpos */ | |
c19d1205 ZW |
1437 | complain_overflow_dont, /* complain_on_overflow */ |
1438 | _bfd_elf_rel_vtable_reloc_fn, /* special_function */ | |
1439 | "R_ARM_GNU_VTENTRY", /* name */ | |
1440 | FALSE, /* partial_inplace */ | |
1441 | 0, /* src_mask */ | |
1442 | 0, /* dst_mask */ | |
1443 | FALSE), /* pcrel_offset */ | |
1444 | ||
1445 | /* GNU extension to record C++ vtable hierarchy */ | |
1446 | HOWTO (R_ARM_GNU_VTINHERIT, /* type */ | |
1447 | 0, /* rightshift */ | |
1448 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1449 | 0, /* bitsize */ | |
1450 | FALSE, /* pc_relative */ | |
1451 | 0, /* bitpos */ | |
1452 | complain_overflow_dont, /* complain_on_overflow */ | |
1453 | NULL, /* special_function */ | |
1454 | "R_ARM_GNU_VTINHERIT", /* name */ | |
1455 | FALSE, /* partial_inplace */ | |
1456 | 0, /* src_mask */ | |
1457 | 0, /* dst_mask */ | |
1458 | FALSE), /* pcrel_offset */ | |
1459 | ||
1460 | HOWTO (R_ARM_THM_JUMP11, /* type */ | |
1461 | 1, /* rightshift */ | |
1462 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
1463 | 11, /* bitsize */ | |
1464 | TRUE, /* pc_relative */ | |
1465 | 0, /* bitpos */ | |
1466 | complain_overflow_signed, /* complain_on_overflow */ | |
1467 | bfd_elf_generic_reloc, /* special_function */ | |
1468 | "R_ARM_THM_JUMP11", /* name */ | |
1469 | FALSE, /* partial_inplace */ | |
1470 | 0x000007ff, /* src_mask */ | |
1471 | 0x000007ff, /* dst_mask */ | |
1472 | TRUE), /* pcrel_offset */ | |
1473 | ||
1474 | HOWTO (R_ARM_THM_JUMP8, /* type */ | |
1475 | 1, /* rightshift */ | |
1476 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
1477 | 8, /* bitsize */ | |
1478 | TRUE, /* pc_relative */ | |
1479 | 0, /* bitpos */ | |
1480 | complain_overflow_signed, /* complain_on_overflow */ | |
1481 | bfd_elf_generic_reloc, /* special_function */ | |
1482 | "R_ARM_THM_JUMP8", /* name */ | |
1483 | FALSE, /* partial_inplace */ | |
1484 | 0x000000ff, /* src_mask */ | |
1485 | 0x000000ff, /* dst_mask */ | |
1486 | TRUE), /* pcrel_offset */ | |
ba93b8ac | 1487 | |
c19d1205 ZW |
1488 | /* TLS relocations */ |
1489 | HOWTO (R_ARM_TLS_GD32, /* type */ | |
ba93b8ac DJ |
1490 | 0, /* rightshift */ |
1491 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1492 | 32, /* bitsize */ | |
1493 | FALSE, /* pc_relative */ | |
1494 | 0, /* bitpos */ | |
1495 | complain_overflow_bitfield,/* complain_on_overflow */ | |
c19d1205 ZW |
1496 | NULL, /* special_function */ |
1497 | "R_ARM_TLS_GD32", /* name */ | |
ba93b8ac DJ |
1498 | TRUE, /* partial_inplace */ |
1499 | 0xffffffff, /* src_mask */ | |
1500 | 0xffffffff, /* dst_mask */ | |
c19d1205 | 1501 | FALSE), /* pcrel_offset */ |
ba93b8ac | 1502 | |
ba93b8ac DJ |
1503 | HOWTO (R_ARM_TLS_LDM32, /* type */ |
1504 | 0, /* rightshift */ | |
1505 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1506 | 32, /* bitsize */ | |
1507 | FALSE, /* pc_relative */ | |
1508 | 0, /* bitpos */ | |
1509 | complain_overflow_bitfield,/* complain_on_overflow */ | |
1510 | bfd_elf_generic_reloc, /* special_function */ | |
1511 | "R_ARM_TLS_LDM32", /* name */ | |
1512 | TRUE, /* partial_inplace */ | |
1513 | 0xffffffff, /* src_mask */ | |
1514 | 0xffffffff, /* dst_mask */ | |
c19d1205 | 1515 | FALSE), /* pcrel_offset */ |
ba93b8ac | 1516 | |
c19d1205 | 1517 | HOWTO (R_ARM_TLS_LDO32, /* type */ |
ba93b8ac DJ |
1518 | 0, /* rightshift */ |
1519 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1520 | 32, /* bitsize */ | |
1521 | FALSE, /* pc_relative */ | |
1522 | 0, /* bitpos */ | |
1523 | complain_overflow_bitfield,/* complain_on_overflow */ | |
1524 | bfd_elf_generic_reloc, /* special_function */ | |
c19d1205 | 1525 | "R_ARM_TLS_LDO32", /* name */ |
ba93b8ac DJ |
1526 | TRUE, /* partial_inplace */ |
1527 | 0xffffffff, /* src_mask */ | |
1528 | 0xffffffff, /* dst_mask */ | |
c19d1205 | 1529 | FALSE), /* pcrel_offset */ |
ba93b8ac | 1530 | |
ba93b8ac DJ |
1531 | HOWTO (R_ARM_TLS_IE32, /* type */ |
1532 | 0, /* rightshift */ | |
1533 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1534 | 32, /* bitsize */ | |
1535 | FALSE, /* pc_relative */ | |
1536 | 0, /* bitpos */ | |
1537 | complain_overflow_bitfield,/* complain_on_overflow */ | |
1538 | NULL, /* special_function */ | |
1539 | "R_ARM_TLS_IE32", /* name */ | |
1540 | TRUE, /* partial_inplace */ | |
1541 | 0xffffffff, /* src_mask */ | |
1542 | 0xffffffff, /* dst_mask */ | |
c19d1205 | 1543 | FALSE), /* pcrel_offset */ |
7f266840 | 1544 | |
c19d1205 | 1545 | HOWTO (R_ARM_TLS_LE32, /* type */ |
7f266840 DJ |
1546 | 0, /* rightshift */ |
1547 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
c19d1205 | 1548 | 32, /* bitsize */ |
7f266840 DJ |
1549 | FALSE, /* pc_relative */ |
1550 | 0, /* bitpos */ | |
c19d1205 ZW |
1551 | complain_overflow_bitfield,/* complain_on_overflow */ |
1552 | bfd_elf_generic_reloc, /* special_function */ | |
1553 | "R_ARM_TLS_LE32", /* name */ | |
1554 | TRUE, /* partial_inplace */ | |
1555 | 0xffffffff, /* src_mask */ | |
1556 | 0xffffffff, /* dst_mask */ | |
1557 | FALSE), /* pcrel_offset */ | |
7f266840 | 1558 | |
c19d1205 ZW |
1559 | HOWTO (R_ARM_TLS_LDO12, /* type */ |
1560 | 0, /* rightshift */ | |
1561 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1562 | 12, /* bitsize */ | |
1563 | FALSE, /* pc_relative */ | |
7f266840 | 1564 | 0, /* bitpos */ |
c19d1205 | 1565 | complain_overflow_bitfield,/* complain_on_overflow */ |
7f266840 | 1566 | bfd_elf_generic_reloc, /* special_function */ |
c19d1205 | 1567 | "R_ARM_TLS_LDO12", /* name */ |
7f266840 | 1568 | FALSE, /* partial_inplace */ |
c19d1205 ZW |
1569 | 0x00000fff, /* src_mask */ |
1570 | 0x00000fff, /* dst_mask */ | |
1571 | FALSE), /* pcrel_offset */ | |
7f266840 | 1572 | |
c19d1205 ZW |
1573 | HOWTO (R_ARM_TLS_LE12, /* type */ |
1574 | 0, /* rightshift */ | |
1575 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1576 | 12, /* bitsize */ | |
1577 | FALSE, /* pc_relative */ | |
7f266840 | 1578 | 0, /* bitpos */ |
c19d1205 | 1579 | complain_overflow_bitfield,/* complain_on_overflow */ |
7f266840 | 1580 | bfd_elf_generic_reloc, /* special_function */ |
c19d1205 | 1581 | "R_ARM_TLS_LE12", /* name */ |
7f266840 | 1582 | FALSE, /* partial_inplace */ |
c19d1205 ZW |
1583 | 0x00000fff, /* src_mask */ |
1584 | 0x00000fff, /* dst_mask */ | |
1585 | FALSE), /* pcrel_offset */ | |
7f266840 | 1586 | |
c19d1205 | 1587 | HOWTO (R_ARM_TLS_IE12GP, /* type */ |
7f266840 DJ |
1588 | 0, /* rightshift */ |
1589 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
c19d1205 ZW |
1590 | 12, /* bitsize */ |
1591 | FALSE, /* pc_relative */ | |
7f266840 | 1592 | 0, /* bitpos */ |
c19d1205 | 1593 | complain_overflow_bitfield,/* complain_on_overflow */ |
7f266840 | 1594 | bfd_elf_generic_reloc, /* special_function */ |
c19d1205 | 1595 | "R_ARM_TLS_IE12GP", /* name */ |
7f266840 | 1596 | FALSE, /* partial_inplace */ |
c19d1205 ZW |
1597 | 0x00000fff, /* src_mask */ |
1598 | 0x00000fff, /* dst_mask */ | |
1599 | FALSE), /* pcrel_offset */ | |
1600 | }; | |
1601 | ||
1602 | /* 112-127 private relocations | |
1603 | 128 R_ARM_ME_TOO, obsolete | |
1604 | 129-255 unallocated in AAELF. | |
7f266840 | 1605 | |
c19d1205 ZW |
1606 | 249-255 extended, currently unused, relocations: */ |
1607 | ||
4962c51a | 1608 | static reloc_howto_type elf32_arm_howto_table_2[4] = |
7f266840 DJ |
1609 | { |
1610 | HOWTO (R_ARM_RREL32, /* type */ | |
1611 | 0, /* rightshift */ | |
1612 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
1613 | 0, /* bitsize */ | |
1614 | FALSE, /* pc_relative */ | |
1615 | 0, /* bitpos */ | |
1616 | complain_overflow_dont,/* complain_on_overflow */ | |
1617 | bfd_elf_generic_reloc, /* special_function */ | |
1618 | "R_ARM_RREL32", /* name */ | |
1619 | FALSE, /* partial_inplace */ | |
1620 | 0, /* src_mask */ | |
1621 | 0, /* dst_mask */ | |
1622 | FALSE), /* pcrel_offset */ | |
1623 | ||
1624 | HOWTO (R_ARM_RABS32, /* type */ | |
1625 | 0, /* rightshift */ | |
1626 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
1627 | 0, /* bitsize */ | |
1628 | FALSE, /* pc_relative */ | |
1629 | 0, /* bitpos */ | |
1630 | complain_overflow_dont,/* complain_on_overflow */ | |
1631 | bfd_elf_generic_reloc, /* special_function */ | |
1632 | "R_ARM_RABS32", /* name */ | |
1633 | FALSE, /* partial_inplace */ | |
1634 | 0, /* src_mask */ | |
1635 | 0, /* dst_mask */ | |
1636 | FALSE), /* pcrel_offset */ | |
1637 | ||
1638 | HOWTO (R_ARM_RPC24, /* type */ | |
1639 | 0, /* rightshift */ | |
1640 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
1641 | 0, /* bitsize */ | |
1642 | FALSE, /* pc_relative */ | |
1643 | 0, /* bitpos */ | |
1644 | complain_overflow_dont,/* complain_on_overflow */ | |
1645 | bfd_elf_generic_reloc, /* special_function */ | |
1646 | "R_ARM_RPC24", /* name */ | |
1647 | FALSE, /* partial_inplace */ | |
1648 | 0, /* src_mask */ | |
1649 | 0, /* dst_mask */ | |
1650 | FALSE), /* pcrel_offset */ | |
1651 | ||
1652 | HOWTO (R_ARM_RBASE, /* type */ | |
1653 | 0, /* rightshift */ | |
1654 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
1655 | 0, /* bitsize */ | |
1656 | FALSE, /* pc_relative */ | |
1657 | 0, /* bitpos */ | |
1658 | complain_overflow_dont,/* complain_on_overflow */ | |
1659 | bfd_elf_generic_reloc, /* special_function */ | |
1660 | "R_ARM_RBASE", /* name */ | |
1661 | FALSE, /* partial_inplace */ | |
1662 | 0, /* src_mask */ | |
1663 | 0, /* dst_mask */ | |
1664 | FALSE) /* pcrel_offset */ | |
1665 | }; | |
1666 | ||
1667 | static reloc_howto_type * | |
1668 | elf32_arm_howto_from_type (unsigned int r_type) | |
1669 | { | |
c19d1205 ZW |
1670 | if (r_type < NUM_ELEM (elf32_arm_howto_table_1)) |
1671 | return &elf32_arm_howto_table_1[r_type]; | |
ba93b8ac | 1672 | |
c19d1205 ZW |
1673 | if (r_type >= R_ARM_RREL32 |
1674 | && r_type < R_ARM_RREL32 + NUM_ELEM (elf32_arm_howto_table_2)) | |
4962c51a | 1675 | return &elf32_arm_howto_table_2[r_type - R_ARM_RREL32]; |
7f266840 | 1676 | |
c19d1205 | 1677 | return NULL; |
7f266840 DJ |
1678 | } |
1679 | ||
1680 | static void | |
1681 | elf32_arm_info_to_howto (bfd * abfd ATTRIBUTE_UNUSED, arelent * bfd_reloc, | |
1682 | Elf_Internal_Rela * elf_reloc) | |
1683 | { | |
1684 | unsigned int r_type; | |
1685 | ||
1686 | r_type = ELF32_R_TYPE (elf_reloc->r_info); | |
1687 | bfd_reloc->howto = elf32_arm_howto_from_type (r_type); | |
1688 | } | |
1689 | ||
1690 | struct elf32_arm_reloc_map | |
1691 | { | |
1692 | bfd_reloc_code_real_type bfd_reloc_val; | |
1693 | unsigned char elf_reloc_val; | |
1694 | }; | |
1695 | ||
1696 | /* All entries in this list must also be present in elf32_arm_howto_table. */ | |
1697 | static const struct elf32_arm_reloc_map elf32_arm_reloc_map[] = | |
1698 | { | |
1699 | {BFD_RELOC_NONE, R_ARM_NONE}, | |
1700 | {BFD_RELOC_ARM_PCREL_BRANCH, R_ARM_PC24}, | |
39b41c9c PB |
1701 | {BFD_RELOC_ARM_PCREL_CALL, R_ARM_CALL}, |
1702 | {BFD_RELOC_ARM_PCREL_JUMP, R_ARM_JUMP24}, | |
7f266840 DJ |
1703 | {BFD_RELOC_ARM_PCREL_BLX, R_ARM_XPC25}, |
1704 | {BFD_RELOC_THUMB_PCREL_BLX, R_ARM_THM_XPC22}, | |
1705 | {BFD_RELOC_32, R_ARM_ABS32}, | |
1706 | {BFD_RELOC_32_PCREL, R_ARM_REL32}, | |
1707 | {BFD_RELOC_8, R_ARM_ABS8}, | |
1708 | {BFD_RELOC_16, R_ARM_ABS16}, | |
1709 | {BFD_RELOC_ARM_OFFSET_IMM, R_ARM_ABS12}, | |
1710 | {BFD_RELOC_ARM_THUMB_OFFSET, R_ARM_THM_ABS5}, | |
c19d1205 ZW |
1711 | {BFD_RELOC_THUMB_PCREL_BRANCH25, R_ARM_THM_JUMP24}, |
1712 | {BFD_RELOC_THUMB_PCREL_BRANCH23, R_ARM_THM_CALL}, | |
1713 | {BFD_RELOC_THUMB_PCREL_BRANCH12, R_ARM_THM_JUMP11}, | |
1714 | {BFD_RELOC_THUMB_PCREL_BRANCH20, R_ARM_THM_JUMP19}, | |
1715 | {BFD_RELOC_THUMB_PCREL_BRANCH9, R_ARM_THM_JUMP8}, | |
1716 | {BFD_RELOC_THUMB_PCREL_BRANCH7, R_ARM_THM_JUMP6}, | |
7f266840 DJ |
1717 | {BFD_RELOC_ARM_GLOB_DAT, R_ARM_GLOB_DAT}, |
1718 | {BFD_RELOC_ARM_JUMP_SLOT, R_ARM_JUMP_SLOT}, | |
1719 | {BFD_RELOC_ARM_RELATIVE, R_ARM_RELATIVE}, | |
c19d1205 | 1720 | {BFD_RELOC_ARM_GOTOFF, R_ARM_GOTOFF32}, |
7f266840 DJ |
1721 | {BFD_RELOC_ARM_GOTPC, R_ARM_GOTPC}, |
1722 | {BFD_RELOC_ARM_GOT32, R_ARM_GOT32}, | |
1723 | {BFD_RELOC_ARM_PLT32, R_ARM_PLT32}, | |
1724 | {BFD_RELOC_ARM_TARGET1, R_ARM_TARGET1}, | |
1725 | {BFD_RELOC_ARM_ROSEGREL32, R_ARM_ROSEGREL32}, | |
1726 | {BFD_RELOC_ARM_SBREL32, R_ARM_SBREL32}, | |
1727 | {BFD_RELOC_ARM_PREL31, R_ARM_PREL31}, | |
ba93b8ac DJ |
1728 | {BFD_RELOC_ARM_TARGET2, R_ARM_TARGET2}, |
1729 | {BFD_RELOC_ARM_PLT32, R_ARM_PLT32}, | |
1730 | {BFD_RELOC_ARM_TLS_GD32, R_ARM_TLS_GD32}, | |
1731 | {BFD_RELOC_ARM_TLS_LDO32, R_ARM_TLS_LDO32}, | |
1732 | {BFD_RELOC_ARM_TLS_LDM32, R_ARM_TLS_LDM32}, | |
1733 | {BFD_RELOC_ARM_TLS_DTPMOD32, R_ARM_TLS_DTPMOD32}, | |
1734 | {BFD_RELOC_ARM_TLS_DTPOFF32, R_ARM_TLS_DTPOFF32}, | |
1735 | {BFD_RELOC_ARM_TLS_TPOFF32, R_ARM_TLS_TPOFF32}, | |
1736 | {BFD_RELOC_ARM_TLS_IE32, R_ARM_TLS_IE32}, | |
1737 | {BFD_RELOC_ARM_TLS_LE32, R_ARM_TLS_LE32}, | |
c19d1205 ZW |
1738 | {BFD_RELOC_VTABLE_INHERIT, R_ARM_GNU_VTINHERIT}, |
1739 | {BFD_RELOC_VTABLE_ENTRY, R_ARM_GNU_VTENTRY}, | |
b6895b4f PB |
1740 | {BFD_RELOC_ARM_MOVW, R_ARM_MOVW_ABS_NC}, |
1741 | {BFD_RELOC_ARM_MOVT, R_ARM_MOVT_ABS}, | |
1742 | {BFD_RELOC_ARM_MOVW_PCREL, R_ARM_MOVW_PREL_NC}, | |
1743 | {BFD_RELOC_ARM_MOVT_PCREL, R_ARM_MOVT_PREL}, | |
1744 | {BFD_RELOC_ARM_THUMB_MOVW, R_ARM_THM_MOVW_ABS_NC}, | |
1745 | {BFD_RELOC_ARM_THUMB_MOVT, R_ARM_THM_MOVT_ABS}, | |
1746 | {BFD_RELOC_ARM_THUMB_MOVW_PCREL, R_ARM_THM_MOVW_PREL_NC}, | |
1747 | {BFD_RELOC_ARM_THUMB_MOVT_PCREL, R_ARM_THM_MOVT_PREL}, | |
4962c51a MS |
1748 | {BFD_RELOC_ARM_ALU_PC_G0_NC, R_ARM_ALU_PC_G0_NC}, |
1749 | {BFD_RELOC_ARM_ALU_PC_G0, R_ARM_ALU_PC_G0}, | |
1750 | {BFD_RELOC_ARM_ALU_PC_G1_NC, R_ARM_ALU_PC_G1_NC}, | |
1751 | {BFD_RELOC_ARM_ALU_PC_G1, R_ARM_ALU_PC_G1}, | |
1752 | {BFD_RELOC_ARM_ALU_PC_G2, R_ARM_ALU_PC_G2}, | |
1753 | {BFD_RELOC_ARM_LDR_PC_G0, R_ARM_LDR_PC_G0}, | |
1754 | {BFD_RELOC_ARM_LDR_PC_G1, R_ARM_LDR_PC_G1}, | |
1755 | {BFD_RELOC_ARM_LDR_PC_G2, R_ARM_LDR_PC_G2}, | |
1756 | {BFD_RELOC_ARM_LDRS_PC_G0, R_ARM_LDRS_PC_G0}, | |
1757 | {BFD_RELOC_ARM_LDRS_PC_G1, R_ARM_LDRS_PC_G1}, | |
1758 | {BFD_RELOC_ARM_LDRS_PC_G2, R_ARM_LDRS_PC_G2}, | |
1759 | {BFD_RELOC_ARM_LDC_PC_G0, R_ARM_LDC_PC_G0}, | |
1760 | {BFD_RELOC_ARM_LDC_PC_G1, R_ARM_LDC_PC_G1}, | |
1761 | {BFD_RELOC_ARM_LDC_PC_G2, R_ARM_LDC_PC_G2}, | |
1762 | {BFD_RELOC_ARM_ALU_SB_G0_NC, R_ARM_ALU_SB_G0_NC}, | |
1763 | {BFD_RELOC_ARM_ALU_SB_G0, R_ARM_ALU_SB_G0}, | |
1764 | {BFD_RELOC_ARM_ALU_SB_G1_NC, R_ARM_ALU_SB_G1_NC}, | |
1765 | {BFD_RELOC_ARM_ALU_SB_G1, R_ARM_ALU_SB_G1}, | |
1766 | {BFD_RELOC_ARM_ALU_SB_G2, R_ARM_ALU_SB_G2}, | |
1767 | {BFD_RELOC_ARM_LDR_SB_G0, R_ARM_LDR_SB_G0}, | |
1768 | {BFD_RELOC_ARM_LDR_SB_G1, R_ARM_LDR_SB_G1}, | |
1769 | {BFD_RELOC_ARM_LDR_SB_G2, R_ARM_LDR_SB_G2}, | |
1770 | {BFD_RELOC_ARM_LDRS_SB_G0, R_ARM_LDRS_SB_G0}, | |
1771 | {BFD_RELOC_ARM_LDRS_SB_G1, R_ARM_LDRS_SB_G1}, | |
1772 | {BFD_RELOC_ARM_LDRS_SB_G2, R_ARM_LDRS_SB_G2}, | |
1773 | {BFD_RELOC_ARM_LDC_SB_G0, R_ARM_LDC_SB_G0}, | |
1774 | {BFD_RELOC_ARM_LDC_SB_G1, R_ARM_LDC_SB_G1}, | |
1775 | {BFD_RELOC_ARM_LDC_SB_G2, R_ARM_LDC_SB_G2} | |
7f266840 DJ |
1776 | }; |
1777 | ||
1778 | static reloc_howto_type * | |
f1c71a59 ZW |
1779 | elf32_arm_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, |
1780 | bfd_reloc_code_real_type code) | |
7f266840 DJ |
1781 | { |
1782 | unsigned int i; | |
c19d1205 ZW |
1783 | for (i = 0; i < NUM_ELEM (elf32_arm_reloc_map); i ++) |
1784 | if (elf32_arm_reloc_map[i].bfd_reloc_val == code) | |
1785 | return elf32_arm_howto_from_type (elf32_arm_reloc_map[i].elf_reloc_val); | |
7f266840 | 1786 | |
c19d1205 | 1787 | return NULL; |
7f266840 DJ |
1788 | } |
1789 | ||
1790 | /* Support for core dump NOTE sections */ | |
1791 | static bfd_boolean | |
f1c71a59 | 1792 | elf32_arm_nabi_grok_prstatus (bfd *abfd, Elf_Internal_Note *note) |
7f266840 DJ |
1793 | { |
1794 | int offset; | |
1795 | size_t size; | |
1796 | ||
1797 | switch (note->descsz) | |
1798 | { | |
1799 | default: | |
1800 | return FALSE; | |
1801 | ||
1802 | case 148: /* Linux/ARM 32-bit*/ | |
1803 | /* pr_cursig */ | |
1804 | elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12); | |
1805 | ||
1806 | /* pr_pid */ | |
1807 | elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24); | |
1808 | ||
1809 | /* pr_reg */ | |
1810 | offset = 72; | |
1811 | size = 72; | |
1812 | ||
1813 | break; | |
1814 | } | |
1815 | ||
1816 | /* Make a ".reg/999" section. */ | |
1817 | return _bfd_elfcore_make_pseudosection (abfd, ".reg", | |
1818 | size, note->descpos + offset); | |
1819 | } | |
1820 | ||
1821 | static bfd_boolean | |
f1c71a59 | 1822 | elf32_arm_nabi_grok_psinfo (bfd *abfd, Elf_Internal_Note *note) |
7f266840 DJ |
1823 | { |
1824 | switch (note->descsz) | |
1825 | { | |
1826 | default: | |
1827 | return FALSE; | |
1828 | ||
1829 | case 124: /* Linux/ARM elf_prpsinfo */ | |
1830 | elf_tdata (abfd)->core_program | |
1831 | = _bfd_elfcore_strndup (abfd, note->descdata + 28, 16); | |
1832 | elf_tdata (abfd)->core_command | |
1833 | = _bfd_elfcore_strndup (abfd, note->descdata + 44, 80); | |
1834 | } | |
1835 | ||
1836 | /* Note that for some reason, a spurious space is tacked | |
1837 | onto the end of the args in some (at least one anyway) | |
1838 | implementations, so strip it off if it exists. */ | |
1839 | ||
1840 | { | |
1841 | char *command = elf_tdata (abfd)->core_command; | |
1842 | int n = strlen (command); | |
1843 | ||
1844 | if (0 < n && command[n - 1] == ' ') | |
1845 | command[n - 1] = '\0'; | |
1846 | } | |
1847 | ||
1848 | return TRUE; | |
1849 | } | |
1850 | ||
1851 | #define TARGET_LITTLE_SYM bfd_elf32_littlearm_vec | |
1852 | #define TARGET_LITTLE_NAME "elf32-littlearm" | |
1853 | #define TARGET_BIG_SYM bfd_elf32_bigarm_vec | |
1854 | #define TARGET_BIG_NAME "elf32-bigarm" | |
1855 | ||
1856 | #define elf_backend_grok_prstatus elf32_arm_nabi_grok_prstatus | |
1857 | #define elf_backend_grok_psinfo elf32_arm_nabi_grok_psinfo | |
1858 | ||
252b5132 RH |
1859 | typedef unsigned long int insn32; |
1860 | typedef unsigned short int insn16; | |
1861 | ||
3a4a14e9 PB |
1862 | /* In lieu of proper flags, assume all EABIv4 or later objects are |
1863 | interworkable. */ | |
57e8b36a | 1864 | #define INTERWORK_FLAG(abfd) \ |
3a4a14e9 | 1865 | (EF_ARM_EABI_VERSION (elf_elfheader (abfd)->e_flags) >= EF_ARM_EABI_VER4 \ |
85a84e7a | 1866 | || (elf_elfheader (abfd)->e_flags & EF_ARM_INTERWORK)) |
9b485d32 | 1867 | |
252b5132 RH |
1868 | /* The linker script knows the section names for placement. |
1869 | The entry_names are used to do simple name mangling on the stubs. | |
1870 | Given a function name, and its type, the stub can be found. The | |
9b485d32 | 1871 | name can be changed. The only requirement is the %s be present. */ |
252b5132 RH |
1872 | #define THUMB2ARM_GLUE_SECTION_NAME ".glue_7t" |
1873 | #define THUMB2ARM_GLUE_ENTRY_NAME "__%s_from_thumb" | |
1874 | ||
1875 | #define ARM2THUMB_GLUE_SECTION_NAME ".glue_7" | |
1876 | #define ARM2THUMB_GLUE_ENTRY_NAME "__%s_from_arm" | |
1877 | ||
1878 | /* The name of the dynamic interpreter. This is put in the .interp | |
1879 | section. */ | |
1880 | #define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1" | |
1881 | ||
5e681ec4 PB |
1882 | #ifdef FOUR_WORD_PLT |
1883 | ||
252b5132 RH |
1884 | /* The first entry in a procedure linkage table looks like |
1885 | this. It is set up so that any shared library function that is | |
59f2c4e7 | 1886 | called before the relocation has been set up calls the dynamic |
9b485d32 | 1887 | linker first. */ |
e5a52504 | 1888 | static const bfd_vma elf32_arm_plt0_entry [] = |
5e681ec4 PB |
1889 | { |
1890 | 0xe52de004, /* str lr, [sp, #-4]! */ | |
1891 | 0xe59fe010, /* ldr lr, [pc, #16] */ | |
1892 | 0xe08fe00e, /* add lr, pc, lr */ | |
1893 | 0xe5bef008, /* ldr pc, [lr, #8]! */ | |
1894 | }; | |
1895 | ||
1896 | /* Subsequent entries in a procedure linkage table look like | |
1897 | this. */ | |
e5a52504 | 1898 | static const bfd_vma elf32_arm_plt_entry [] = |
5e681ec4 PB |
1899 | { |
1900 | 0xe28fc600, /* add ip, pc, #NN */ | |
1901 | 0xe28cca00, /* add ip, ip, #NN */ | |
1902 | 0xe5bcf000, /* ldr pc, [ip, #NN]! */ | |
1903 | 0x00000000, /* unused */ | |
1904 | }; | |
1905 | ||
1906 | #else | |
1907 | ||
5e681ec4 PB |
1908 | /* The first entry in a procedure linkage table looks like |
1909 | this. It is set up so that any shared library function that is | |
1910 | called before the relocation has been set up calls the dynamic | |
1911 | linker first. */ | |
e5a52504 | 1912 | static const bfd_vma elf32_arm_plt0_entry [] = |
917583ad | 1913 | { |
5e681ec4 PB |
1914 | 0xe52de004, /* str lr, [sp, #-4]! */ |
1915 | 0xe59fe004, /* ldr lr, [pc, #4] */ | |
1916 | 0xe08fe00e, /* add lr, pc, lr */ | |
1917 | 0xe5bef008, /* ldr pc, [lr, #8]! */ | |
1918 | 0x00000000, /* &GOT[0] - . */ | |
917583ad | 1919 | }; |
252b5132 RH |
1920 | |
1921 | /* Subsequent entries in a procedure linkage table look like | |
1922 | this. */ | |
e5a52504 | 1923 | static const bfd_vma elf32_arm_plt_entry [] = |
5e681ec4 PB |
1924 | { |
1925 | 0xe28fc600, /* add ip, pc, #0xNN00000 */ | |
1926 | 0xe28cca00, /* add ip, ip, #0xNN000 */ | |
1927 | 0xe5bcf000, /* ldr pc, [ip, #0xNNN]! */ | |
1928 | }; | |
1929 | ||
1930 | #endif | |
252b5132 | 1931 | |
00a97672 RS |
1932 | /* The format of the first entry in the procedure linkage table |
1933 | for a VxWorks executable. */ | |
1934 | static const bfd_vma elf32_arm_vxworks_exec_plt0_entry[] = | |
1935 | { | |
1936 | 0xe52dc008, /* str ip,[sp,#-8]! */ | |
1937 | 0xe59fc000, /* ldr ip,[pc] */ | |
1938 | 0xe59cf008, /* ldr pc,[ip,#8] */ | |
1939 | 0x00000000, /* .long _GLOBAL_OFFSET_TABLE_ */ | |
1940 | }; | |
1941 | ||
1942 | /* The format of subsequent entries in a VxWorks executable. */ | |
1943 | static const bfd_vma elf32_arm_vxworks_exec_plt_entry[] = | |
1944 | { | |
1945 | 0xe59fc000, /* ldr ip,[pc] */ | |
1946 | 0xe59cf000, /* ldr pc,[ip] */ | |
1947 | 0x00000000, /* .long @got */ | |
1948 | 0xe59fc000, /* ldr ip,[pc] */ | |
1949 | 0xea000000, /* b _PLT */ | |
1950 | 0x00000000, /* .long @pltindex*sizeof(Elf32_Rela) */ | |
1951 | }; | |
1952 | ||
1953 | /* The format of entries in a VxWorks shared library. */ | |
1954 | static const bfd_vma elf32_arm_vxworks_shared_plt_entry[] = | |
1955 | { | |
1956 | 0xe59fc000, /* ldr ip,[pc] */ | |
1957 | 0xe79cf009, /* ldr pc,[ip,r9] */ | |
1958 | 0x00000000, /* .long @got */ | |
1959 | 0xe59fc000, /* ldr ip,[pc] */ | |
1960 | 0xe599f008, /* ldr pc,[r9,#8] */ | |
1961 | 0x00000000, /* .long @pltindex*sizeof(Elf32_Rela) */ | |
1962 | }; | |
1963 | ||
b7693d02 DJ |
1964 | /* An initial stub used if the PLT entry is referenced from Thumb code. */ |
1965 | #define PLT_THUMB_STUB_SIZE 4 | |
1966 | static const bfd_vma elf32_arm_plt_thumb_stub [] = | |
1967 | { | |
1968 | 0x4778, /* bx pc */ | |
1969 | 0x46c0 /* nop */ | |
1970 | }; | |
1971 | ||
e5a52504 MM |
1972 | /* The entries in a PLT when using a DLL-based target with multiple |
1973 | address spaces. */ | |
1974 | static const bfd_vma elf32_arm_symbian_plt_entry [] = | |
1975 | { | |
83a358aa | 1976 | 0xe51ff004, /* ldr pc, [pc, #-4] */ |
e5a52504 MM |
1977 | 0x00000000, /* dcd R_ARM_GLOB_DAT(X) */ |
1978 | }; | |
1979 | ||
e489d0ae PB |
1980 | /* Used to build a map of a section. This is required for mixed-endian |
1981 | code/data. */ | |
1982 | ||
1983 | typedef struct elf32_elf_section_map | |
1984 | { | |
1985 | bfd_vma vma; | |
1986 | char type; | |
1987 | } | |
1988 | elf32_arm_section_map; | |
1989 | ||
8e3de13a | 1990 | typedef struct _arm_elf_section_data |
e489d0ae PB |
1991 | { |
1992 | struct bfd_elf_section_data elf; | |
8e3de13a | 1993 | unsigned int mapcount; |
e489d0ae | 1994 | elf32_arm_section_map *map; |
8e3de13a NC |
1995 | } |
1996 | _arm_elf_section_data; | |
e489d0ae PB |
1997 | |
1998 | #define elf32_arm_section_data(sec) \ | |
8e3de13a | 1999 | ((_arm_elf_section_data *) elf_section_data (sec)) |
e489d0ae | 2000 | |
ba93b8ac DJ |
2001 | /* The size of the thread control block. */ |
2002 | #define TCB_SIZE 8 | |
2003 | ||
ee065d83 PB |
2004 | #define NUM_KNOWN_ATTRIBUTES 32 |
2005 | ||
2006 | typedef struct aeabi_attribute | |
2007 | { | |
2008 | int type; | |
2009 | unsigned int i; | |
2010 | char *s; | |
2011 | } aeabi_attribute; | |
2012 | ||
2013 | typedef struct aeabi_attribute_list | |
2014 | { | |
2015 | struct aeabi_attribute_list *next; | |
2016 | int tag; | |
2017 | aeabi_attribute attr; | |
2018 | } aeabi_attribute_list; | |
2019 | ||
ba93b8ac DJ |
2020 | struct elf32_arm_obj_tdata |
2021 | { | |
2022 | struct elf_obj_tdata root; | |
2023 | ||
2024 | /* tls_type for each local got entry. */ | |
2025 | char *local_got_tls_type; | |
ee065d83 PB |
2026 | |
2027 | aeabi_attribute known_eabi_attributes[NUM_KNOWN_ATTRIBUTES]; | |
2028 | aeabi_attribute_list *other_eabi_attributes; | |
ba93b8ac DJ |
2029 | }; |
2030 | ||
2031 | #define elf32_arm_tdata(abfd) \ | |
2032 | ((struct elf32_arm_obj_tdata *) (abfd)->tdata.any) | |
2033 | ||
2034 | #define elf32_arm_local_got_tls_type(abfd) \ | |
2035 | (elf32_arm_tdata (abfd)->local_got_tls_type) | |
2036 | ||
2037 | static bfd_boolean | |
2038 | elf32_arm_mkobject (bfd *abfd) | |
2039 | { | |
ba93b8ac | 2040 | if (abfd->tdata.any == NULL) |
62d7a5f6 AM |
2041 | { |
2042 | bfd_size_type amt = sizeof (struct elf32_arm_obj_tdata); | |
2043 | abfd->tdata.any = bfd_zalloc (abfd, amt); | |
2044 | if (abfd->tdata.any == NULL) | |
2045 | return FALSE; | |
2046 | } | |
2047 | return bfd_elf_mkobject (abfd); | |
ba93b8ac DJ |
2048 | } |
2049 | ||
252b5132 RH |
2050 | /* The ARM linker needs to keep track of the number of relocs that it |
2051 | decides to copy in check_relocs for each symbol. This is so that | |
2052 | it can discard PC relative relocs if it doesn't need them when | |
2053 | linking with -Bsymbolic. We store the information in a field | |
2054 | extending the regular ELF linker hash table. */ | |
2055 | ||
ba93b8ac DJ |
2056 | /* This structure keeps track of the number of relocs we have copied |
2057 | for a given symbol. */ | |
5e681ec4 | 2058 | struct elf32_arm_relocs_copied |
917583ad NC |
2059 | { |
2060 | /* Next section. */ | |
5e681ec4 | 2061 | struct elf32_arm_relocs_copied * next; |
917583ad NC |
2062 | /* A section in dynobj. */ |
2063 | asection * section; | |
2064 | /* Number of relocs copied in this section. */ | |
2065 | bfd_size_type count; | |
ba93b8ac DJ |
2066 | /* Number of PC-relative relocs copied in this section. */ |
2067 | bfd_size_type pc_count; | |
917583ad | 2068 | }; |
252b5132 | 2069 | |
ba93b8ac DJ |
2070 | #define elf32_arm_hash_entry(ent) ((struct elf32_arm_link_hash_entry *)(ent)) |
2071 | ||
ba96a88f | 2072 | /* Arm ELF linker hash entry. */ |
252b5132 | 2073 | struct elf32_arm_link_hash_entry |
917583ad NC |
2074 | { |
2075 | struct elf_link_hash_entry root; | |
252b5132 | 2076 | |
917583ad | 2077 | /* Number of PC relative relocs copied for this symbol. */ |
5e681ec4 | 2078 | struct elf32_arm_relocs_copied * relocs_copied; |
b7693d02 DJ |
2079 | |
2080 | /* We reference count Thumb references to a PLT entry separately, | |
2081 | so that we can emit the Thumb trampoline only if needed. */ | |
2082 | bfd_signed_vma plt_thumb_refcount; | |
2083 | ||
2084 | /* Since PLT entries have variable size if the Thumb prologue is | |
2085 | used, we need to record the index into .got.plt instead of | |
2086 | recomputing it from the PLT offset. */ | |
2087 | bfd_signed_vma plt_got_offset; | |
ba93b8ac DJ |
2088 | |
2089 | #define GOT_UNKNOWN 0 | |
2090 | #define GOT_NORMAL 1 | |
2091 | #define GOT_TLS_GD 2 | |
2092 | #define GOT_TLS_IE 4 | |
2093 | unsigned char tls_type; | |
a4fd1a8e PB |
2094 | |
2095 | /* The symbol marking the real symbol location for exported thumb | |
2096 | symbols with Arm stubs. */ | |
2097 | struct elf_link_hash_entry *export_glue; | |
917583ad | 2098 | }; |
252b5132 | 2099 | |
252b5132 | 2100 | /* Traverse an arm ELF linker hash table. */ |
252b5132 RH |
2101 | #define elf32_arm_link_hash_traverse(table, func, info) \ |
2102 | (elf_link_hash_traverse \ | |
2103 | (&(table)->root, \ | |
b7693d02 | 2104 | (bfd_boolean (*) (struct elf_link_hash_entry *, void *)) (func), \ |
252b5132 RH |
2105 | (info))) |
2106 | ||
2107 | /* Get the ARM elf linker hash table from a link_info structure. */ | |
2108 | #define elf32_arm_hash_table(info) \ | |
2109 | ((struct elf32_arm_link_hash_table *) ((info)->hash)) | |
2110 | ||
9b485d32 | 2111 | /* ARM ELF linker hash table. */ |
252b5132 | 2112 | struct elf32_arm_link_hash_table |
917583ad NC |
2113 | { |
2114 | /* The main hash table. */ | |
2115 | struct elf_link_hash_table root; | |
252b5132 | 2116 | |
4cc11e76 | 2117 | /* The size in bytes of the section containing the Thumb-to-ARM glue. */ |
dc810e39 | 2118 | bfd_size_type thumb_glue_size; |
252b5132 | 2119 | |
4cc11e76 | 2120 | /* The size in bytes of the section containing the ARM-to-Thumb glue. */ |
dc810e39 | 2121 | bfd_size_type arm_glue_size; |
252b5132 | 2122 | |
4cc11e76 | 2123 | /* An arbitrary input BFD chosen to hold the glue sections. */ |
917583ad | 2124 | bfd * bfd_of_glue_owner; |
ba96a88f | 2125 | |
e489d0ae PB |
2126 | /* Nonzero to output a BE8 image. */ |
2127 | int byteswap_code; | |
2128 | ||
9c504268 | 2129 | /* Zero if R_ARM_TARGET1 means R_ARM_ABS32. |
87bc043a | 2130 | Nonzero if R_ARM_TARGET1 means R_ARM_REL32. */ |
9c504268 PB |
2131 | int target1_is_rel; |
2132 | ||
eb043451 PB |
2133 | /* The relocation to use for R_ARM_TARGET2 relocations. */ |
2134 | int target2_reloc; | |
2135 | ||
319850b4 JB |
2136 | /* Nonzero to fix BX instructions for ARMv4 targets. */ |
2137 | int fix_v4bx; | |
2138 | ||
33bfe774 JB |
2139 | /* Nonzero if the ARM/Thumb BLX instructions are available for use. */ |
2140 | int use_blx; | |
2141 | ||
e5a52504 MM |
2142 | /* The number of bytes in the initial entry in the PLT. */ |
2143 | bfd_size_type plt_header_size; | |
2144 | ||
2145 | /* The number of bytes in the subsequent PLT etries. */ | |
2146 | bfd_size_type plt_entry_size; | |
2147 | ||
00a97672 RS |
2148 | /* True if the target system is VxWorks. */ |
2149 | int vxworks_p; | |
2150 | ||
e5a52504 MM |
2151 | /* True if the target system is Symbian OS. */ |
2152 | int symbian_p; | |
2153 | ||
4e7fd91e PB |
2154 | /* True if the target uses REL relocations. */ |
2155 | int use_rel; | |
2156 | ||
5e681ec4 PB |
2157 | /* Short-cuts to get to dynamic linker sections. */ |
2158 | asection *sgot; | |
2159 | asection *sgotplt; | |
2160 | asection *srelgot; | |
2161 | asection *splt; | |
2162 | asection *srelplt; | |
2163 | asection *sdynbss; | |
2164 | asection *srelbss; | |
2165 | ||
00a97672 RS |
2166 | /* The (unloaded but important) VxWorks .rela.plt.unloaded section. */ |
2167 | asection *srelplt2; | |
2168 | ||
ba93b8ac DJ |
2169 | /* Data for R_ARM_TLS_LDM32 relocations. */ |
2170 | union { | |
2171 | bfd_signed_vma refcount; | |
2172 | bfd_vma offset; | |
2173 | } tls_ldm_got; | |
2174 | ||
5e681ec4 PB |
2175 | /* Small local sym to section mapping cache. */ |
2176 | struct sym_sec_cache sym_sec; | |
b7693d02 DJ |
2177 | |
2178 | /* For convenience in allocate_dynrelocs. */ | |
2179 | bfd * obfd; | |
917583ad | 2180 | }; |
252b5132 | 2181 | |
780a67af NC |
2182 | /* Create an entry in an ARM ELF linker hash table. */ |
2183 | ||
2184 | static struct bfd_hash_entry * | |
57e8b36a NC |
2185 | elf32_arm_link_hash_newfunc (struct bfd_hash_entry * entry, |
2186 | struct bfd_hash_table * table, | |
2187 | const char * string) | |
780a67af NC |
2188 | { |
2189 | struct elf32_arm_link_hash_entry * ret = | |
2190 | (struct elf32_arm_link_hash_entry *) entry; | |
2191 | ||
2192 | /* Allocate the structure if it has not already been allocated by a | |
2193 | subclass. */ | |
2194 | if (ret == (struct elf32_arm_link_hash_entry *) NULL) | |
57e8b36a NC |
2195 | ret = bfd_hash_allocate (table, sizeof (struct elf32_arm_link_hash_entry)); |
2196 | if (ret == NULL) | |
780a67af NC |
2197 | return (struct bfd_hash_entry *) ret; |
2198 | ||
2199 | /* Call the allocation method of the superclass. */ | |
2200 | ret = ((struct elf32_arm_link_hash_entry *) | |
2201 | _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret, | |
2202 | table, string)); | |
57e8b36a | 2203 | if (ret != NULL) |
b7693d02 DJ |
2204 | { |
2205 | ret->relocs_copied = NULL; | |
ba93b8ac | 2206 | ret->tls_type = GOT_UNKNOWN; |
b7693d02 DJ |
2207 | ret->plt_thumb_refcount = 0; |
2208 | ret->plt_got_offset = -1; | |
a4fd1a8e | 2209 | ret->export_glue = NULL; |
b7693d02 | 2210 | } |
780a67af NC |
2211 | |
2212 | return (struct bfd_hash_entry *) ret; | |
2213 | } | |
2214 | ||
00a97672 RS |
2215 | /* Return true if NAME is the name of the relocation section associated |
2216 | with S. */ | |
2217 | ||
2218 | static bfd_boolean | |
2219 | reloc_section_p (struct elf32_arm_link_hash_table *htab, | |
2220 | const char *name, asection *s) | |
2221 | { | |
2222 | if (htab->use_rel) | |
0112cd26 | 2223 | return CONST_STRNEQ (name, ".rel") && strcmp (s->name, name + 4) == 0; |
00a97672 | 2224 | else |
0112cd26 | 2225 | return CONST_STRNEQ (name, ".rela") && strcmp (s->name, name + 5) == 0; |
00a97672 RS |
2226 | } |
2227 | ||
2228 | /* Create .got, .gotplt, and .rel(a).got sections in DYNOBJ, and set up | |
5e681ec4 PB |
2229 | shortcuts to them in our hash table. */ |
2230 | ||
2231 | static bfd_boolean | |
57e8b36a | 2232 | create_got_section (bfd *dynobj, struct bfd_link_info *info) |
5e681ec4 PB |
2233 | { |
2234 | struct elf32_arm_link_hash_table *htab; | |
2235 | ||
e5a52504 MM |
2236 | htab = elf32_arm_hash_table (info); |
2237 | /* BPABI objects never have a GOT, or associated sections. */ | |
2238 | if (htab->symbian_p) | |
2239 | return TRUE; | |
2240 | ||
5e681ec4 PB |
2241 | if (! _bfd_elf_create_got_section (dynobj, info)) |
2242 | return FALSE; | |
2243 | ||
5e681ec4 PB |
2244 | htab->sgot = bfd_get_section_by_name (dynobj, ".got"); |
2245 | htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt"); | |
2246 | if (!htab->sgot || !htab->sgotplt) | |
2247 | abort (); | |
2248 | ||
00a97672 RS |
2249 | htab->srelgot = bfd_make_section_with_flags (dynobj, |
2250 | RELOC_SECTION (htab, ".got"), | |
3496cb2a L |
2251 | (SEC_ALLOC | SEC_LOAD |
2252 | | SEC_HAS_CONTENTS | |
2253 | | SEC_IN_MEMORY | |
2254 | | SEC_LINKER_CREATED | |
2255 | | SEC_READONLY)); | |
5e681ec4 | 2256 | if (htab->srelgot == NULL |
5e681ec4 PB |
2257 | || ! bfd_set_section_alignment (dynobj, htab->srelgot, 2)) |
2258 | return FALSE; | |
2259 | return TRUE; | |
2260 | } | |
2261 | ||
00a97672 RS |
2262 | /* Create .plt, .rel(a).plt, .got, .got.plt, .rel(a).got, .dynbss, and |
2263 | .rel(a).bss sections in DYNOBJ, and set up shortcuts to them in our | |
5e681ec4 PB |
2264 | hash table. */ |
2265 | ||
2266 | static bfd_boolean | |
57e8b36a | 2267 | elf32_arm_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info) |
5e681ec4 PB |
2268 | { |
2269 | struct elf32_arm_link_hash_table *htab; | |
2270 | ||
2271 | htab = elf32_arm_hash_table (info); | |
2272 | if (!htab->sgot && !create_got_section (dynobj, info)) | |
2273 | return FALSE; | |
2274 | ||
2275 | if (!_bfd_elf_create_dynamic_sections (dynobj, info)) | |
2276 | return FALSE; | |
2277 | ||
2278 | htab->splt = bfd_get_section_by_name (dynobj, ".plt"); | |
00a97672 RS |
2279 | htab->srelplt = bfd_get_section_by_name (dynobj, |
2280 | RELOC_SECTION (htab, ".plt")); | |
5e681ec4 PB |
2281 | htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss"); |
2282 | if (!info->shared) | |
00a97672 RS |
2283 | htab->srelbss = bfd_get_section_by_name (dynobj, |
2284 | RELOC_SECTION (htab, ".bss")); | |
2285 | ||
2286 | if (htab->vxworks_p) | |
2287 | { | |
2288 | if (!elf_vxworks_create_dynamic_sections (dynobj, info, &htab->srelplt2)) | |
2289 | return FALSE; | |
2290 | ||
2291 | if (info->shared) | |
2292 | { | |
2293 | htab->plt_header_size = 0; | |
2294 | htab->plt_entry_size | |
2295 | = 4 * ARRAY_SIZE (elf32_arm_vxworks_shared_plt_entry); | |
2296 | } | |
2297 | else | |
2298 | { | |
2299 | htab->plt_header_size | |
2300 | = 4 * ARRAY_SIZE (elf32_arm_vxworks_exec_plt0_entry); | |
2301 | htab->plt_entry_size | |
2302 | = 4 * ARRAY_SIZE (elf32_arm_vxworks_exec_plt_entry); | |
2303 | } | |
2304 | } | |
5e681ec4 | 2305 | |
e5a52504 MM |
2306 | if (!htab->splt |
2307 | || !htab->srelplt | |
2308 | || !htab->sdynbss | |
5e681ec4 PB |
2309 | || (!info->shared && !htab->srelbss)) |
2310 | abort (); | |
2311 | ||
2312 | return TRUE; | |
2313 | } | |
2314 | ||
2315 | /* Copy the extra info we tack onto an elf_link_hash_entry. */ | |
2316 | ||
2317 | static void | |
fcfa13d2 | 2318 | elf32_arm_copy_indirect_symbol (struct bfd_link_info *info, |
5e681ec4 PB |
2319 | struct elf_link_hash_entry *dir, |
2320 | struct elf_link_hash_entry *ind) | |
2321 | { | |
2322 | struct elf32_arm_link_hash_entry *edir, *eind; | |
2323 | ||
2324 | edir = (struct elf32_arm_link_hash_entry *) dir; | |
2325 | eind = (struct elf32_arm_link_hash_entry *) ind; | |
2326 | ||
2327 | if (eind->relocs_copied != NULL) | |
2328 | { | |
2329 | if (edir->relocs_copied != NULL) | |
2330 | { | |
2331 | struct elf32_arm_relocs_copied **pp; | |
2332 | struct elf32_arm_relocs_copied *p; | |
2333 | ||
fcfa13d2 | 2334 | /* Add reloc counts against the indirect sym to the direct sym |
5e681ec4 PB |
2335 | list. Merge any entries against the same section. */ |
2336 | for (pp = &eind->relocs_copied; (p = *pp) != NULL; ) | |
2337 | { | |
2338 | struct elf32_arm_relocs_copied *q; | |
2339 | ||
2340 | for (q = edir->relocs_copied; q != NULL; q = q->next) | |
2341 | if (q->section == p->section) | |
2342 | { | |
ba93b8ac | 2343 | q->pc_count += p->pc_count; |
5e681ec4 PB |
2344 | q->count += p->count; |
2345 | *pp = p->next; | |
2346 | break; | |
2347 | } | |
2348 | if (q == NULL) | |
2349 | pp = &p->next; | |
2350 | } | |
2351 | *pp = edir->relocs_copied; | |
2352 | } | |
2353 | ||
2354 | edir->relocs_copied = eind->relocs_copied; | |
2355 | eind->relocs_copied = NULL; | |
2356 | } | |
2357 | ||
b34b2d70 | 2358 | if (ind->root.type == bfd_link_hash_indirect) |
ba93b8ac | 2359 | { |
b34b2d70 DJ |
2360 | /* Copy over PLT info. */ |
2361 | edir->plt_thumb_refcount += eind->plt_thumb_refcount; | |
2362 | eind->plt_thumb_refcount = 0; | |
2363 | ||
2364 | if (dir->got.refcount <= 0) | |
2365 | { | |
2366 | edir->tls_type = eind->tls_type; | |
2367 | eind->tls_type = GOT_UNKNOWN; | |
2368 | } | |
ba93b8ac DJ |
2369 | } |
2370 | ||
fcfa13d2 | 2371 | _bfd_elf_link_hash_copy_indirect (info, dir, ind); |
5e681ec4 PB |
2372 | } |
2373 | ||
9b485d32 | 2374 | /* Create an ARM elf linker hash table. */ |
252b5132 RH |
2375 | |
2376 | static struct bfd_link_hash_table * | |
57e8b36a | 2377 | elf32_arm_link_hash_table_create (bfd *abfd) |
252b5132 RH |
2378 | { |
2379 | struct elf32_arm_link_hash_table *ret; | |
dc810e39 | 2380 | bfd_size_type amt = sizeof (struct elf32_arm_link_hash_table); |
252b5132 | 2381 | |
57e8b36a NC |
2382 | ret = bfd_malloc (amt); |
2383 | if (ret == NULL) | |
252b5132 RH |
2384 | return NULL; |
2385 | ||
57e8b36a | 2386 | if (!_bfd_elf_link_hash_table_init (& ret->root, abfd, |
66eb6687 AM |
2387 | elf32_arm_link_hash_newfunc, |
2388 | sizeof (struct elf32_arm_link_hash_entry))) | |
252b5132 | 2389 | { |
e2d34d7d | 2390 | free (ret); |
252b5132 RH |
2391 | return NULL; |
2392 | } | |
2393 | ||
5e681ec4 PB |
2394 | ret->sgot = NULL; |
2395 | ret->sgotplt = NULL; | |
2396 | ret->srelgot = NULL; | |
2397 | ret->splt = NULL; | |
2398 | ret->srelplt = NULL; | |
2399 | ret->sdynbss = NULL; | |
2400 | ret->srelbss = NULL; | |
00a97672 | 2401 | ret->srelplt2 = NULL; |
252b5132 RH |
2402 | ret->thumb_glue_size = 0; |
2403 | ret->arm_glue_size = 0; | |
2404 | ret->bfd_of_glue_owner = NULL; | |
e489d0ae | 2405 | ret->byteswap_code = 0; |
9c504268 | 2406 | ret->target1_is_rel = 0; |
eb043451 | 2407 | ret->target2_reloc = R_ARM_NONE; |
e5a52504 MM |
2408 | #ifdef FOUR_WORD_PLT |
2409 | ret->plt_header_size = 16; | |
2410 | ret->plt_entry_size = 16; | |
2411 | #else | |
2412 | ret->plt_header_size = 20; | |
2413 | ret->plt_entry_size = 12; | |
2414 | #endif | |
33bfe774 JB |
2415 | ret->fix_v4bx = 0; |
2416 | ret->use_blx = 0; | |
00a97672 | 2417 | ret->vxworks_p = 0; |
e5a52504 | 2418 | ret->symbian_p = 0; |
4e7fd91e | 2419 | ret->use_rel = 1; |
5e681ec4 | 2420 | ret->sym_sec.abfd = NULL; |
b7693d02 | 2421 | ret->obfd = abfd; |
ba93b8ac | 2422 | ret->tls_ldm_got.refcount = 0; |
252b5132 RH |
2423 | |
2424 | return &ret->root.root; | |
2425 | } | |
2426 | ||
9b485d32 NC |
2427 | /* Locate the Thumb encoded calling stub for NAME. */ |
2428 | ||
252b5132 | 2429 | static struct elf_link_hash_entry * |
57e8b36a NC |
2430 | find_thumb_glue (struct bfd_link_info *link_info, |
2431 | const char *name, | |
2432 | bfd *input_bfd) | |
252b5132 RH |
2433 | { |
2434 | char *tmp_name; | |
2435 | struct elf_link_hash_entry *hash; | |
2436 | struct elf32_arm_link_hash_table *hash_table; | |
2437 | ||
2438 | /* We need a pointer to the armelf specific hash table. */ | |
2439 | hash_table = elf32_arm_hash_table (link_info); | |
2440 | ||
57e8b36a NC |
2441 | tmp_name = bfd_malloc ((bfd_size_type) strlen (name) |
2442 | + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1); | |
252b5132 RH |
2443 | |
2444 | BFD_ASSERT (tmp_name); | |
2445 | ||
2446 | sprintf (tmp_name, THUMB2ARM_GLUE_ENTRY_NAME, name); | |
2447 | ||
2448 | hash = elf_link_hash_lookup | |
b34976b6 | 2449 | (&(hash_table)->root, tmp_name, FALSE, FALSE, TRUE); |
252b5132 RH |
2450 | |
2451 | if (hash == NULL) | |
2452 | /* xgettext:c-format */ | |
d003868e AM |
2453 | (*_bfd_error_handler) (_("%B: unable to find THUMB glue '%s' for `%s'"), |
2454 | input_bfd, tmp_name, name); | |
252b5132 RH |
2455 | |
2456 | free (tmp_name); | |
2457 | ||
2458 | return hash; | |
2459 | } | |
2460 | ||
9b485d32 NC |
2461 | /* Locate the ARM encoded calling stub for NAME. */ |
2462 | ||
252b5132 | 2463 | static struct elf_link_hash_entry * |
57e8b36a NC |
2464 | find_arm_glue (struct bfd_link_info *link_info, |
2465 | const char *name, | |
2466 | bfd *input_bfd) | |
252b5132 RH |
2467 | { |
2468 | char *tmp_name; | |
2469 | struct elf_link_hash_entry *myh; | |
2470 | struct elf32_arm_link_hash_table *hash_table; | |
2471 | ||
2472 | /* We need a pointer to the elfarm specific hash table. */ | |
2473 | hash_table = elf32_arm_hash_table (link_info); | |
2474 | ||
57e8b36a NC |
2475 | tmp_name = bfd_malloc ((bfd_size_type) strlen (name) |
2476 | + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1); | |
252b5132 RH |
2477 | |
2478 | BFD_ASSERT (tmp_name); | |
2479 | ||
2480 | sprintf (tmp_name, ARM2THUMB_GLUE_ENTRY_NAME, name); | |
2481 | ||
2482 | myh = elf_link_hash_lookup | |
b34976b6 | 2483 | (&(hash_table)->root, tmp_name, FALSE, FALSE, TRUE); |
252b5132 RH |
2484 | |
2485 | if (myh == NULL) | |
2486 | /* xgettext:c-format */ | |
d003868e AM |
2487 | (*_bfd_error_handler) (_("%B: unable to find ARM glue '%s' for `%s'"), |
2488 | input_bfd, tmp_name, name); | |
252b5132 RH |
2489 | |
2490 | free (tmp_name); | |
2491 | ||
2492 | return myh; | |
2493 | } | |
2494 | ||
8f6277f5 | 2495 | /* ARM->Thumb glue (static images): |
252b5132 RH |
2496 | |
2497 | .arm | |
2498 | __func_from_arm: | |
2499 | ldr r12, __func_addr | |
2500 | bx r12 | |
2501 | __func_addr: | |
8f6277f5 | 2502 | .word func @ behave as if you saw a ARM_32 reloc. |
252b5132 | 2503 | |
8f6277f5 PB |
2504 | (relocatable images) |
2505 | .arm | |
2506 | __func_from_arm: | |
2507 | ldr r12, __func_offset | |
2508 | add r12, r12, pc | |
2509 | bx r12 | |
2510 | __func_offset: | |
2511 | .word func - . | |
2512 | */ | |
2513 | ||
2514 | #define ARM2THUMB_STATIC_GLUE_SIZE 12 | |
252b5132 RH |
2515 | static const insn32 a2t1_ldr_insn = 0xe59fc000; |
2516 | static const insn32 a2t2_bx_r12_insn = 0xe12fff1c; | |
2517 | static const insn32 a2t3_func_addr_insn = 0x00000001; | |
2518 | ||
8f6277f5 PB |
2519 | #define ARM2THUMB_PIC_GLUE_SIZE 16 |
2520 | static const insn32 a2t1p_ldr_insn = 0xe59fc004; | |
2521 | static const insn32 a2t2p_add_pc_insn = 0xe08cc00f; | |
2522 | static const insn32 a2t3p_bx_r12_insn = 0xe12fff1c; | |
2523 | ||
9b485d32 | 2524 | /* Thumb->ARM: Thumb->(non-interworking aware) ARM |
252b5132 RH |
2525 | |
2526 | .thumb .thumb | |
2527 | .align 2 .align 2 | |
2528 | __func_from_thumb: __func_from_thumb: | |
2529 | bx pc push {r6, lr} | |
2530 | nop ldr r6, __func_addr | |
2531 | .arm mov lr, pc | |
2532 | __func_change_to_arm: bx r6 | |
2533 | b func .arm | |
2534 | __func_back_to_thumb: | |
2535 | ldmia r13! {r6, lr} | |
2536 | bx lr | |
2537 | __func_addr: | |
9b485d32 | 2538 | .word func */ |
252b5132 RH |
2539 | |
2540 | #define THUMB2ARM_GLUE_SIZE 8 | |
2541 | static const insn16 t2a1_bx_pc_insn = 0x4778; | |
2542 | static const insn16 t2a2_noop_insn = 0x46c0; | |
2543 | static const insn32 t2a3_b_insn = 0xea000000; | |
2544 | ||
7e392df6 | 2545 | #ifndef ELFARM_NABI_C_INCLUDED |
b34976b6 | 2546 | bfd_boolean |
57e8b36a | 2547 | bfd_elf32_arm_allocate_interworking_sections (struct bfd_link_info * info) |
252b5132 RH |
2548 | { |
2549 | asection * s; | |
2550 | bfd_byte * foo; | |
2551 | struct elf32_arm_link_hash_table * globals; | |
2552 | ||
2553 | globals = elf32_arm_hash_table (info); | |
2554 | ||
2555 | BFD_ASSERT (globals != NULL); | |
2556 | ||
2557 | if (globals->arm_glue_size != 0) | |
2558 | { | |
2559 | BFD_ASSERT (globals->bfd_of_glue_owner != NULL); | |
2560 | ||
dc810e39 AM |
2561 | s = bfd_get_section_by_name (globals->bfd_of_glue_owner, |
2562 | ARM2THUMB_GLUE_SECTION_NAME); | |
252b5132 RH |
2563 | |
2564 | BFD_ASSERT (s != NULL); | |
2565 | ||
57e8b36a | 2566 | foo = bfd_alloc (globals->bfd_of_glue_owner, globals->arm_glue_size); |
252b5132 | 2567 | |
2f475487 | 2568 | BFD_ASSERT (s->size == globals->arm_glue_size); |
252b5132 RH |
2569 | s->contents = foo; |
2570 | } | |
2571 | ||
2572 | if (globals->thumb_glue_size != 0) | |
2573 | { | |
2574 | BFD_ASSERT (globals->bfd_of_glue_owner != NULL); | |
2575 | ||
2576 | s = bfd_get_section_by_name | |
2577 | (globals->bfd_of_glue_owner, THUMB2ARM_GLUE_SECTION_NAME); | |
2578 | ||
2579 | BFD_ASSERT (s != NULL); | |
2580 | ||
57e8b36a | 2581 | foo = bfd_alloc (globals->bfd_of_glue_owner, globals->thumb_glue_size); |
252b5132 | 2582 | |
2f475487 | 2583 | BFD_ASSERT (s->size == globals->thumb_glue_size); |
252b5132 RH |
2584 | s->contents = foo; |
2585 | } | |
2586 | ||
b34976b6 | 2587 | return TRUE; |
252b5132 RH |
2588 | } |
2589 | ||
a4fd1a8e PB |
2590 | /* Allocate space and symbols for calling a Thumb function from Arm mode. |
2591 | returns the symbol identifying teh stub. */ | |
2592 | static struct elf_link_hash_entry * | |
57e8b36a NC |
2593 | record_arm_to_thumb_glue (struct bfd_link_info * link_info, |
2594 | struct elf_link_hash_entry * h) | |
252b5132 RH |
2595 | { |
2596 | const char * name = h->root.root.string; | |
63b0f745 | 2597 | asection * s; |
252b5132 RH |
2598 | char * tmp_name; |
2599 | struct elf_link_hash_entry * myh; | |
14a793b2 | 2600 | struct bfd_link_hash_entry * bh; |
252b5132 | 2601 | struct elf32_arm_link_hash_table * globals; |
dc810e39 | 2602 | bfd_vma val; |
2f475487 | 2603 | bfd_size_type size; |
252b5132 RH |
2604 | |
2605 | globals = elf32_arm_hash_table (link_info); | |
2606 | ||
2607 | BFD_ASSERT (globals != NULL); | |
2608 | BFD_ASSERT (globals->bfd_of_glue_owner != NULL); | |
2609 | ||
2610 | s = bfd_get_section_by_name | |
2611 | (globals->bfd_of_glue_owner, ARM2THUMB_GLUE_SECTION_NAME); | |
2612 | ||
252b5132 RH |
2613 | BFD_ASSERT (s != NULL); |
2614 | ||
57e8b36a | 2615 | tmp_name = bfd_malloc ((bfd_size_type) strlen (name) + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1); |
252b5132 RH |
2616 | |
2617 | BFD_ASSERT (tmp_name); | |
2618 | ||
2619 | sprintf (tmp_name, ARM2THUMB_GLUE_ENTRY_NAME, name); | |
2620 | ||
2621 | myh = elf_link_hash_lookup | |
b34976b6 | 2622 | (&(globals)->root, tmp_name, FALSE, FALSE, TRUE); |
252b5132 RH |
2623 | |
2624 | if (myh != NULL) | |
2625 | { | |
9b485d32 | 2626 | /* We've already seen this guy. */ |
252b5132 | 2627 | free (tmp_name); |
a4fd1a8e | 2628 | return myh; |
252b5132 RH |
2629 | } |
2630 | ||
57e8b36a NC |
2631 | /* The only trick here is using hash_table->arm_glue_size as the value. |
2632 | Even though the section isn't allocated yet, this is where we will be | |
2633 | putting it. */ | |
14a793b2 | 2634 | bh = NULL; |
dc810e39 AM |
2635 | val = globals->arm_glue_size + 1; |
2636 | _bfd_generic_link_add_one_symbol (link_info, globals->bfd_of_glue_owner, | |
2637 | tmp_name, BSF_GLOBAL, s, val, | |
b34976b6 | 2638 | NULL, TRUE, FALSE, &bh); |
252b5132 | 2639 | |
b7693d02 DJ |
2640 | myh = (struct elf_link_hash_entry *) bh; |
2641 | myh->type = ELF_ST_INFO (STB_LOCAL, STT_FUNC); | |
2642 | myh->forced_local = 1; | |
2643 | ||
252b5132 RH |
2644 | free (tmp_name); |
2645 | ||
8f6277f5 | 2646 | if ((link_info->shared || globals->root.is_relocatable_executable)) |
2f475487 | 2647 | size = ARM2THUMB_PIC_GLUE_SIZE; |
8f6277f5 | 2648 | else |
2f475487 AM |
2649 | size = ARM2THUMB_STATIC_GLUE_SIZE; |
2650 | ||
2651 | s->size += size; | |
2652 | globals->arm_glue_size += size; | |
252b5132 | 2653 | |
a4fd1a8e | 2654 | return myh; |
252b5132 RH |
2655 | } |
2656 | ||
2657 | static void | |
57e8b36a NC |
2658 | record_thumb_to_arm_glue (struct bfd_link_info *link_info, |
2659 | struct elf_link_hash_entry *h) | |
252b5132 RH |
2660 | { |
2661 | const char *name = h->root.root.string; | |
63b0f745 | 2662 | asection *s; |
252b5132 RH |
2663 | char *tmp_name; |
2664 | struct elf_link_hash_entry *myh; | |
14a793b2 | 2665 | struct bfd_link_hash_entry *bh; |
252b5132 | 2666 | struct elf32_arm_link_hash_table *hash_table; |
dc810e39 | 2667 | bfd_vma val; |
252b5132 RH |
2668 | |
2669 | hash_table = elf32_arm_hash_table (link_info); | |
2670 | ||
2671 | BFD_ASSERT (hash_table != NULL); | |
2672 | BFD_ASSERT (hash_table->bfd_of_glue_owner != NULL); | |
2673 | ||
2674 | s = bfd_get_section_by_name | |
2675 | (hash_table->bfd_of_glue_owner, THUMB2ARM_GLUE_SECTION_NAME); | |
2676 | ||
2677 | BFD_ASSERT (s != NULL); | |
2678 | ||
57e8b36a NC |
2679 | tmp_name = bfd_malloc ((bfd_size_type) strlen (name) |
2680 | + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1); | |
252b5132 RH |
2681 | |
2682 | BFD_ASSERT (tmp_name); | |
2683 | ||
2684 | sprintf (tmp_name, THUMB2ARM_GLUE_ENTRY_NAME, name); | |
2685 | ||
2686 | myh = elf_link_hash_lookup | |
b34976b6 | 2687 | (&(hash_table)->root, tmp_name, FALSE, FALSE, TRUE); |
252b5132 RH |
2688 | |
2689 | if (myh != NULL) | |
2690 | { | |
9b485d32 | 2691 | /* We've already seen this guy. */ |
252b5132 | 2692 | free (tmp_name); |
9b485d32 | 2693 | return; |
252b5132 RH |
2694 | } |
2695 | ||
14a793b2 | 2696 | bh = NULL; |
dc810e39 AM |
2697 | val = hash_table->thumb_glue_size + 1; |
2698 | _bfd_generic_link_add_one_symbol (link_info, hash_table->bfd_of_glue_owner, | |
2699 | tmp_name, BSF_GLOBAL, s, val, | |
b34976b6 | 2700 | NULL, TRUE, FALSE, &bh); |
252b5132 | 2701 | |
9b485d32 | 2702 | /* If we mark it 'Thumb', the disassembler will do a better job. */ |
14a793b2 | 2703 | myh = (struct elf_link_hash_entry *) bh; |
b7693d02 DJ |
2704 | myh->type = ELF_ST_INFO (STB_LOCAL, STT_ARM_TFUNC); |
2705 | myh->forced_local = 1; | |
252b5132 RH |
2706 | |
2707 | free (tmp_name); | |
2708 | ||
252b5132 RH |
2709 | #define CHANGE_TO_ARM "__%s_change_to_arm" |
2710 | #define BACK_FROM_ARM "__%s_back_from_arm" | |
2711 | ||
9b485d32 | 2712 | /* Allocate another symbol to mark where we switch to Arm mode. */ |
57e8b36a NC |
2713 | tmp_name = bfd_malloc ((bfd_size_type) strlen (name) |
2714 | + strlen (CHANGE_TO_ARM) + 1); | |
252b5132 RH |
2715 | |
2716 | BFD_ASSERT (tmp_name); | |
2717 | ||
2718 | sprintf (tmp_name, CHANGE_TO_ARM, name); | |
2719 | ||
14a793b2 | 2720 | bh = NULL; |
dc810e39 AM |
2721 | val = hash_table->thumb_glue_size + 4, |
2722 | _bfd_generic_link_add_one_symbol (link_info, hash_table->bfd_of_glue_owner, | |
2723 | tmp_name, BSF_LOCAL, s, val, | |
b34976b6 | 2724 | NULL, TRUE, FALSE, &bh); |
252b5132 RH |
2725 | |
2726 | free (tmp_name); | |
2727 | ||
2f475487 | 2728 | s->size += THUMB2ARM_GLUE_SIZE; |
252b5132 RH |
2729 | hash_table->thumb_glue_size += THUMB2ARM_GLUE_SIZE; |
2730 | ||
2731 | return; | |
2732 | } | |
2733 | ||
8afb0e02 NC |
2734 | /* Add the glue sections to ABFD. This function is called from the |
2735 | linker scripts in ld/emultempl/{armelf}.em. */ | |
9b485d32 | 2736 | |
b34976b6 | 2737 | bfd_boolean |
57e8b36a NC |
2738 | bfd_elf32_arm_add_glue_sections_to_bfd (bfd *abfd, |
2739 | struct bfd_link_info *info) | |
252b5132 | 2740 | { |
252b5132 RH |
2741 | flagword flags; |
2742 | asection *sec; | |
2743 | ||
8afb0e02 NC |
2744 | /* If we are only performing a partial |
2745 | link do not bother adding the glue. */ | |
1049f94e | 2746 | if (info->relocatable) |
b34976b6 | 2747 | return TRUE; |
252b5132 | 2748 | |
252b5132 RH |
2749 | sec = bfd_get_section_by_name (abfd, ARM2THUMB_GLUE_SECTION_NAME); |
2750 | ||
2751 | if (sec == NULL) | |
2752 | { | |
57db232e NC |
2753 | /* Note: we do not include the flag SEC_LINKER_CREATED, as this |
2754 | will prevent elf_link_input_bfd() from processing the contents | |
2755 | of this section. */ | |
2f475487 AM |
2756 | flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY |
2757 | | SEC_CODE | SEC_READONLY); | |
252b5132 | 2758 | |
3496cb2a L |
2759 | sec = bfd_make_section_with_flags (abfd, |
2760 | ARM2THUMB_GLUE_SECTION_NAME, | |
2761 | flags); | |
252b5132 RH |
2762 | |
2763 | if (sec == NULL | |
252b5132 | 2764 | || !bfd_set_section_alignment (abfd, sec, 2)) |
b34976b6 | 2765 | return FALSE; |
9a5aca8c | 2766 | |
57db232e NC |
2767 | /* Set the gc mark to prevent the section from being removed by garbage |
2768 | collection, despite the fact that no relocs refer to this section. */ | |
2769 | sec->gc_mark = 1; | |
252b5132 RH |
2770 | } |
2771 | ||
2772 | sec = bfd_get_section_by_name (abfd, THUMB2ARM_GLUE_SECTION_NAME); | |
2773 | ||
2774 | if (sec == NULL) | |
2775 | { | |
2f475487 AM |
2776 | flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY |
2777 | | SEC_CODE | SEC_READONLY); | |
252b5132 | 2778 | |
3496cb2a L |
2779 | sec = bfd_make_section_with_flags (abfd, |
2780 | THUMB2ARM_GLUE_SECTION_NAME, | |
2781 | flags); | |
252b5132 RH |
2782 | |
2783 | if (sec == NULL | |
252b5132 | 2784 | || !bfd_set_section_alignment (abfd, sec, 2)) |
b34976b6 | 2785 | return FALSE; |
9a5aca8c | 2786 | |
57db232e | 2787 | sec->gc_mark = 1; |
252b5132 RH |
2788 | } |
2789 | ||
b34976b6 | 2790 | return TRUE; |
8afb0e02 NC |
2791 | } |
2792 | ||
2793 | /* Select a BFD to be used to hold the sections used by the glue code. | |
2794 | This function is called from the linker scripts in ld/emultempl/ | |
2795 | {armelf/pe}.em */ | |
2796 | ||
b34976b6 | 2797 | bfd_boolean |
57e8b36a | 2798 | bfd_elf32_arm_get_bfd_for_interworking (bfd *abfd, struct bfd_link_info *info) |
8afb0e02 NC |
2799 | { |
2800 | struct elf32_arm_link_hash_table *globals; | |
2801 | ||
2802 | /* If we are only performing a partial link | |
2803 | do not bother getting a bfd to hold the glue. */ | |
1049f94e | 2804 | if (info->relocatable) |
b34976b6 | 2805 | return TRUE; |
8afb0e02 | 2806 | |
b7693d02 DJ |
2807 | /* Make sure we don't attach the glue sections to a dynamic object. */ |
2808 | BFD_ASSERT (!(abfd->flags & DYNAMIC)); | |
2809 | ||
8afb0e02 NC |
2810 | globals = elf32_arm_hash_table (info); |
2811 | ||
2812 | BFD_ASSERT (globals != NULL); | |
2813 | ||
2814 | if (globals->bfd_of_glue_owner != NULL) | |
b34976b6 | 2815 | return TRUE; |
8afb0e02 | 2816 | |
252b5132 RH |
2817 | /* Save the bfd for later use. */ |
2818 | globals->bfd_of_glue_owner = abfd; | |
cedb70c5 | 2819 | |
b34976b6 | 2820 | return TRUE; |
252b5132 RH |
2821 | } |
2822 | ||
39b41c9c PB |
2823 | static void check_use_blx(struct elf32_arm_link_hash_table *globals) |
2824 | { | |
2825 | if (elf32_arm_get_eabi_attr_int (globals->obfd, Tag_CPU_arch) > 2) | |
2826 | globals->use_blx = 1; | |
2827 | } | |
2828 | ||
b34976b6 | 2829 | bfd_boolean |
57e8b36a NC |
2830 | bfd_elf32_arm_process_before_allocation (bfd *abfd, |
2831 | struct bfd_link_info *link_info, | |
eb043451 | 2832 | int byteswap_code) |
252b5132 RH |
2833 | { |
2834 | Elf_Internal_Shdr *symtab_hdr; | |
6cdc0ccc | 2835 | Elf_Internal_Rela *internal_relocs = NULL; |
252b5132 RH |
2836 | Elf_Internal_Rela *irel, *irelend; |
2837 | bfd_byte *contents = NULL; | |
252b5132 RH |
2838 | |
2839 | asection *sec; | |
2840 | struct elf32_arm_link_hash_table *globals; | |
2841 | ||
2842 | /* If we are only performing a partial link do not bother | |
2843 | to construct any glue. */ | |
1049f94e | 2844 | if (link_info->relocatable) |
b34976b6 | 2845 | return TRUE; |
252b5132 RH |
2846 | |
2847 | /* Here we have a bfd that is to be included on the link. We have a hook | |
2848 | to do reloc rummaging, before section sizes are nailed down. */ | |
252b5132 | 2849 | globals = elf32_arm_hash_table (link_info); |
39b41c9c | 2850 | check_use_blx (globals); |
252b5132 RH |
2851 | |
2852 | BFD_ASSERT (globals != NULL); | |
2853 | BFD_ASSERT (globals->bfd_of_glue_owner != NULL); | |
2854 | ||
e489d0ae PB |
2855 | if (byteswap_code && !bfd_big_endian (abfd)) |
2856 | { | |
d003868e AM |
2857 | _bfd_error_handler (_("%B: BE8 images only valid in big-endian mode."), |
2858 | abfd); | |
e489d0ae PB |
2859 | return FALSE; |
2860 | } | |
2861 | globals->byteswap_code = byteswap_code; | |
f21f3fe0 | 2862 | |
252b5132 RH |
2863 | /* Rummage around all the relocs and map the glue vectors. */ |
2864 | sec = abfd->sections; | |
2865 | ||
2866 | if (sec == NULL) | |
b34976b6 | 2867 | return TRUE; |
252b5132 RH |
2868 | |
2869 | for (; sec != NULL; sec = sec->next) | |
2870 | { | |
2871 | if (sec->reloc_count == 0) | |
2872 | continue; | |
2873 | ||
2f475487 AM |
2874 | if ((sec->flags & SEC_EXCLUDE) != 0) |
2875 | continue; | |
2876 | ||
252b5132 | 2877 | symtab_hdr = &elf_tdata (abfd)->symtab_hdr; |
252b5132 | 2878 | |
9b485d32 | 2879 | /* Load the relocs. */ |
6cdc0ccc | 2880 | internal_relocs |
57e8b36a | 2881 | = _bfd_elf_link_read_relocs (abfd, sec, (void *) NULL, |
45d6a902 | 2882 | (Elf_Internal_Rela *) NULL, FALSE); |
252b5132 | 2883 | |
6cdc0ccc AM |
2884 | if (internal_relocs == NULL) |
2885 | goto error_return; | |
252b5132 | 2886 | |
6cdc0ccc AM |
2887 | irelend = internal_relocs + sec->reloc_count; |
2888 | for (irel = internal_relocs; irel < irelend; irel++) | |
252b5132 RH |
2889 | { |
2890 | long r_type; | |
2891 | unsigned long r_index; | |
252b5132 RH |
2892 | |
2893 | struct elf_link_hash_entry *h; | |
2894 | ||
2895 | r_type = ELF32_R_TYPE (irel->r_info); | |
2896 | r_index = ELF32_R_SYM (irel->r_info); | |
2897 | ||
9b485d32 | 2898 | /* These are the only relocation types we care about. */ |
ba96a88f | 2899 | if ( r_type != R_ARM_PC24 |
b7693d02 | 2900 | && r_type != R_ARM_PLT32 |
5b5bb741 PB |
2901 | && r_type != R_ARM_CALL |
2902 | && r_type != R_ARM_JUMP24 | |
c19d1205 | 2903 | && r_type != R_ARM_THM_CALL) |
252b5132 RH |
2904 | continue; |
2905 | ||
2906 | /* Get the section contents if we haven't done so already. */ | |
2907 | if (contents == NULL) | |
2908 | { | |
2909 | /* Get cached copy if it exists. */ | |
2910 | if (elf_section_data (sec)->this_hdr.contents != NULL) | |
2911 | contents = elf_section_data (sec)->this_hdr.contents; | |
2912 | else | |
2913 | { | |
2914 | /* Go get them off disk. */ | |
57e8b36a | 2915 | if (! bfd_malloc_and_get_section (abfd, sec, &contents)) |
252b5132 RH |
2916 | goto error_return; |
2917 | } | |
2918 | } | |
2919 | ||
a7c10850 | 2920 | /* If the relocation is not against a symbol it cannot concern us. */ |
252b5132 RH |
2921 | h = NULL; |
2922 | ||
9b485d32 | 2923 | /* We don't care about local symbols. */ |
252b5132 RH |
2924 | if (r_index < symtab_hdr->sh_info) |
2925 | continue; | |
2926 | ||
9b485d32 | 2927 | /* This is an external symbol. */ |
252b5132 RH |
2928 | r_index -= symtab_hdr->sh_info; |
2929 | h = (struct elf_link_hash_entry *) | |
2930 | elf_sym_hashes (abfd)[r_index]; | |
2931 | ||
2932 | /* If the relocation is against a static symbol it must be within | |
2933 | the current section and so cannot be a cross ARM/Thumb relocation. */ | |
2934 | if (h == NULL) | |
2935 | continue; | |
2936 | ||
b7693d02 DJ |
2937 | /* If the call will go through a PLT entry then we do not need |
2938 | glue. */ | |
2939 | if (globals->splt != NULL && h->plt.offset != (bfd_vma) -1) | |
2940 | continue; | |
2941 | ||
252b5132 RH |
2942 | switch (r_type) |
2943 | { | |
2944 | case R_ARM_PC24: | |
c6596c5e | 2945 | case R_ARM_PLT32: |
5b5bb741 PB |
2946 | case R_ARM_CALL: |
2947 | case R_ARM_JUMP24: | |
252b5132 | 2948 | /* This one is a call from arm code. We need to look up |
2f0ca46a | 2949 | the target of the call. If it is a thumb target, we |
252b5132 | 2950 | insert glue. */ |
39b41c9c PB |
2951 | if (ELF_ST_TYPE(h->type) == STT_ARM_TFUNC |
2952 | && !(r_type == R_ARM_CALL && globals->use_blx)) | |
252b5132 RH |
2953 | record_arm_to_thumb_glue (link_info, h); |
2954 | break; | |
2955 | ||
c19d1205 | 2956 | case R_ARM_THM_CALL: |
f21f3fe0 | 2957 | /* This one is a call from thumb code. We look |
2f0ca46a | 2958 | up the target of the call. If it is not a thumb |
bcbdc74c | 2959 | target, we insert glue. */ |
39b41c9c | 2960 | if (ELF_ST_TYPE (h->type) != STT_ARM_TFUNC && !globals->use_blx) |
252b5132 RH |
2961 | record_thumb_to_arm_glue (link_info, h); |
2962 | break; | |
2963 | ||
2964 | default: | |
c6596c5e | 2965 | abort (); |
252b5132 RH |
2966 | } |
2967 | } | |
6cdc0ccc AM |
2968 | |
2969 | if (contents != NULL | |
2970 | && elf_section_data (sec)->this_hdr.contents != contents) | |
2971 | free (contents); | |
2972 | contents = NULL; | |
2973 | ||
2974 | if (internal_relocs != NULL | |
2975 | && elf_section_data (sec)->relocs != internal_relocs) | |
2976 | free (internal_relocs); | |
2977 | internal_relocs = NULL; | |
252b5132 RH |
2978 | } |
2979 | ||
b34976b6 | 2980 | return TRUE; |
9a5aca8c | 2981 | |
252b5132 | 2982 | error_return: |
6cdc0ccc AM |
2983 | if (contents != NULL |
2984 | && elf_section_data (sec)->this_hdr.contents != contents) | |
2985 | free (contents); | |
2986 | if (internal_relocs != NULL | |
2987 | && elf_section_data (sec)->relocs != internal_relocs) | |
2988 | free (internal_relocs); | |
9a5aca8c | 2989 | |
b34976b6 | 2990 | return FALSE; |
252b5132 | 2991 | } |
7e392df6 | 2992 | #endif |
252b5132 | 2993 | |
eb043451 | 2994 | |
eb043451 PB |
2995 | /* Set target relocation values needed during linking. */ |
2996 | ||
2997 | void | |
2998 | bfd_elf32_arm_set_target_relocs (struct bfd_link_info *link_info, | |
2999 | int target1_is_rel, | |
319850b4 | 3000 | char * target2_type, |
33bfe774 JB |
3001 | int fix_v4bx, |
3002 | int use_blx) | |
eb043451 PB |
3003 | { |
3004 | struct elf32_arm_link_hash_table *globals; | |
3005 | ||
3006 | globals = elf32_arm_hash_table (link_info); | |
3007 | ||
3008 | globals->target1_is_rel = target1_is_rel; | |
3009 | if (strcmp (target2_type, "rel") == 0) | |
3010 | globals->target2_reloc = R_ARM_REL32; | |
eeac373a PB |
3011 | else if (strcmp (target2_type, "abs") == 0) |
3012 | globals->target2_reloc = R_ARM_ABS32; | |
eb043451 PB |
3013 | else if (strcmp (target2_type, "got-rel") == 0) |
3014 | globals->target2_reloc = R_ARM_GOT_PREL; | |
3015 | else | |
3016 | { | |
3017 | _bfd_error_handler (_("Invalid TARGET2 relocation type '%s'."), | |
3018 | target2_type); | |
3019 | } | |
319850b4 | 3020 | globals->fix_v4bx = fix_v4bx; |
33bfe774 | 3021 | globals->use_blx |= use_blx; |
eb043451 | 3022 | } |
eb043451 | 3023 | |
252b5132 RH |
3024 | /* The thumb form of a long branch is a bit finicky, because the offset |
3025 | encoding is split over two fields, each in it's own instruction. They | |
f21f3fe0 | 3026 | can occur in any order. So given a thumb form of long branch, and an |
252b5132 | 3027 | offset, insert the offset into the thumb branch and return finished |
f21f3fe0 | 3028 | instruction. |
252b5132 | 3029 | |
f21f3fe0 | 3030 | It takes two thumb instructions to encode the target address. Each has |
4cc11e76 | 3031 | 11 bits to invest. The upper 11 bits are stored in one (identified by |
f21f3fe0 UD |
3032 | H-0.. see below), the lower 11 bits are stored in the other (identified |
3033 | by H-1). | |
252b5132 | 3034 | |
f21f3fe0 | 3035 | Combine together and shifted left by 1 (it's a half word address) and |
252b5132 RH |
3036 | there you have it. |
3037 | ||
3038 | Op: 1111 = F, | |
3039 | H-0, upper address-0 = 000 | |
3040 | Op: 1111 = F, | |
3041 | H-1, lower address-0 = 800 | |
3042 | ||
f21f3fe0 | 3043 | They can be ordered either way, but the arm tools I've seen always put |
252b5132 RH |
3044 | the lower one first. It probably doesn't matter. krk@cygnus.com |
3045 | ||
3046 | XXX: Actually the order does matter. The second instruction (H-1) | |
3047 | moves the computed address into the PC, so it must be the second one | |
3048 | in the sequence. The problem, however is that whilst little endian code | |
3049 | stores the instructions in HI then LOW order, big endian code does the | |
dfc5f959 | 3050 | reverse. nickc@cygnus.com. */ |
252b5132 | 3051 | |
dfc5f959 NC |
3052 | #define LOW_HI_ORDER 0xF800F000 |
3053 | #define HI_LOW_ORDER 0xF000F800 | |
252b5132 RH |
3054 | |
3055 | static insn32 | |
57e8b36a | 3056 | insert_thumb_branch (insn32 br_insn, int rel_off) |
252b5132 RH |
3057 | { |
3058 | unsigned int low_bits; | |
3059 | unsigned int high_bits; | |
3060 | ||
252b5132 RH |
3061 | BFD_ASSERT ((rel_off & 1) != 1); |
3062 | ||
dfc5f959 NC |
3063 | rel_off >>= 1; /* Half word aligned address. */ |
3064 | low_bits = rel_off & 0x000007FF; /* The bottom 11 bits. */ | |
3065 | high_bits = (rel_off >> 11) & 0x000007FF; /* The top 11 bits. */ | |
252b5132 RH |
3066 | |
3067 | if ((br_insn & LOW_HI_ORDER) == LOW_HI_ORDER) | |
3068 | br_insn = LOW_HI_ORDER | (low_bits << 16) | high_bits; | |
3069 | else if ((br_insn & HI_LOW_ORDER) == HI_LOW_ORDER) | |
3070 | br_insn = HI_LOW_ORDER | (high_bits << 16) | low_bits; | |
3071 | else | |
9b485d32 | 3072 | /* FIXME: abort is probably not the right call. krk@cygnus.com */ |
57e8b36a | 3073 | abort (); /* Error - not a valid branch instruction form. */ |
252b5132 | 3074 | |
252b5132 RH |
3075 | return br_insn; |
3076 | } | |
3077 | ||
52ab56c2 PB |
3078 | |
3079 | /* Store an Arm insn into an output section not processed by | |
3080 | elf32_arm_write_section. */ | |
3081 | ||
3082 | static void | |
3083 | put_arm_insn (struct elf32_arm_link_hash_table *htab, | |
3084 | bfd * output_bfd, bfd_vma val, void * ptr) | |
3085 | { | |
3086 | if (htab->byteswap_code != bfd_little_endian (output_bfd)) | |
3087 | bfd_putl32 (val, ptr); | |
3088 | else | |
3089 | bfd_putb32 (val, ptr); | |
3090 | } | |
3091 | ||
3092 | ||
3093 | /* Store a 16-bit Thumb insn into an output section not processed by | |
3094 | elf32_arm_write_section. */ | |
3095 | ||
3096 | static void | |
3097 | put_thumb_insn (struct elf32_arm_link_hash_table *htab, | |
3098 | bfd * output_bfd, bfd_vma val, void * ptr) | |
3099 | { | |
3100 | if (htab->byteswap_code != bfd_little_endian (output_bfd)) | |
3101 | bfd_putl16 (val, ptr); | |
3102 | else | |
3103 | bfd_putb16 (val, ptr); | |
3104 | } | |
3105 | ||
3106 | ||
9b485d32 NC |
3107 | /* Thumb code calling an ARM function. */ |
3108 | ||
252b5132 | 3109 | static int |
57e8b36a NC |
3110 | elf32_thumb_to_arm_stub (struct bfd_link_info * info, |
3111 | const char * name, | |
3112 | bfd * input_bfd, | |
3113 | bfd * output_bfd, | |
3114 | asection * input_section, | |
3115 | bfd_byte * hit_data, | |
3116 | asection * sym_sec, | |
3117 | bfd_vma offset, | |
3118 | bfd_signed_vma addend, | |
3119 | bfd_vma val) | |
252b5132 | 3120 | { |
bcbdc74c | 3121 | asection * s = 0; |
dc810e39 | 3122 | bfd_vma my_offset; |
252b5132 RH |
3123 | unsigned long int tmp; |
3124 | long int ret_offset; | |
bcbdc74c NC |
3125 | struct elf_link_hash_entry * myh; |
3126 | struct elf32_arm_link_hash_table * globals; | |
252b5132 RH |
3127 | |
3128 | myh = find_thumb_glue (info, name, input_bfd); | |
3129 | if (myh == NULL) | |
b34976b6 | 3130 | return FALSE; |
252b5132 RH |
3131 | |
3132 | globals = elf32_arm_hash_table (info); | |
3133 | ||
3134 | BFD_ASSERT (globals != NULL); | |
3135 | BFD_ASSERT (globals->bfd_of_glue_owner != NULL); | |
3136 | ||
3137 | my_offset = myh->root.u.def.value; | |
3138 | ||
3139 | s = bfd_get_section_by_name (globals->bfd_of_glue_owner, | |
3140 | THUMB2ARM_GLUE_SECTION_NAME); | |
3141 | ||
3142 | BFD_ASSERT (s != NULL); | |
3143 | BFD_ASSERT (s->contents != NULL); | |
3144 | BFD_ASSERT (s->output_section != NULL); | |
3145 | ||
3146 | if ((my_offset & 0x01) == 0x01) | |
3147 | { | |
3148 | if (sym_sec != NULL | |
3149 | && sym_sec->owner != NULL | |
3150 | && !INTERWORK_FLAG (sym_sec->owner)) | |
3151 | { | |
8f615d07 | 3152 | (*_bfd_error_handler) |
d003868e AM |
3153 | (_("%B(%s): warning: interworking not enabled.\n" |
3154 | " first occurrence: %B: thumb call to arm"), | |
3155 | sym_sec->owner, input_bfd, name); | |
252b5132 | 3156 | |
b34976b6 | 3157 | return FALSE; |
252b5132 RH |
3158 | } |
3159 | ||
3160 | --my_offset; | |
3161 | myh->root.u.def.value = my_offset; | |
3162 | ||
52ab56c2 PB |
3163 | put_thumb_insn (globals, output_bfd, (bfd_vma) t2a1_bx_pc_insn, |
3164 | s->contents + my_offset); | |
252b5132 | 3165 | |
52ab56c2 PB |
3166 | put_thumb_insn (globals, output_bfd, (bfd_vma) t2a2_noop_insn, |
3167 | s->contents + my_offset + 2); | |
252b5132 RH |
3168 | |
3169 | ret_offset = | |
9b485d32 NC |
3170 | /* Address of destination of the stub. */ |
3171 | ((bfd_signed_vma) val) | |
252b5132 | 3172 | - ((bfd_signed_vma) |
57e8b36a NC |
3173 | /* Offset from the start of the current section |
3174 | to the start of the stubs. */ | |
9b485d32 NC |
3175 | (s->output_offset |
3176 | /* Offset of the start of this stub from the start of the stubs. */ | |
3177 | + my_offset | |
3178 | /* Address of the start of the current section. */ | |
3179 | + s->output_section->vma) | |
3180 | /* The branch instruction is 4 bytes into the stub. */ | |
3181 | + 4 | |
3182 | /* ARM branches work from the pc of the instruction + 8. */ | |
3183 | + 8); | |
252b5132 | 3184 | |
52ab56c2 PB |
3185 | put_arm_insn (globals, output_bfd, |
3186 | (bfd_vma) t2a3_b_insn | ((ret_offset >> 2) & 0x00FFFFFF), | |
3187 | s->contents + my_offset + 4); | |
252b5132 RH |
3188 | } |
3189 | ||
3190 | BFD_ASSERT (my_offset <= globals->thumb_glue_size); | |
3191 | ||
427bfd90 NC |
3192 | /* Now go back and fix up the original BL insn to point to here. */ |
3193 | ret_offset = | |
3194 | /* Address of where the stub is located. */ | |
3195 | (s->output_section->vma + s->output_offset + my_offset) | |
3196 | /* Address of where the BL is located. */ | |
57e8b36a NC |
3197 | - (input_section->output_section->vma + input_section->output_offset |
3198 | + offset) | |
427bfd90 NC |
3199 | /* Addend in the relocation. */ |
3200 | - addend | |
3201 | /* Biassing for PC-relative addressing. */ | |
3202 | - 8; | |
252b5132 RH |
3203 | |
3204 | tmp = bfd_get_32 (input_bfd, hit_data | |
3205 | - input_section->vma); | |
3206 | ||
3207 | bfd_put_32 (output_bfd, | |
dc810e39 | 3208 | (bfd_vma) insert_thumb_branch (tmp, ret_offset), |
252b5132 RH |
3209 | hit_data - input_section->vma); |
3210 | ||
b34976b6 | 3211 | return TRUE; |
252b5132 RH |
3212 | } |
3213 | ||
a4fd1a8e | 3214 | /* Populate an Arm to Thumb stub. Returns the stub symbol. */ |
9b485d32 | 3215 | |
a4fd1a8e PB |
3216 | static struct elf_link_hash_entry * |
3217 | elf32_arm_create_thumb_stub (struct bfd_link_info * info, | |
3218 | const char * name, | |
3219 | bfd * input_bfd, | |
3220 | bfd * output_bfd, | |
3221 | asection * sym_sec, | |
3222 | bfd_vma val, | |
3223 | asection *s) | |
252b5132 | 3224 | { |
dc810e39 | 3225 | bfd_vma my_offset; |
252b5132 | 3226 | long int ret_offset; |
bcbdc74c NC |
3227 | struct elf_link_hash_entry * myh; |
3228 | struct elf32_arm_link_hash_table * globals; | |
252b5132 RH |
3229 | |
3230 | myh = find_arm_glue (info, name, input_bfd); | |
3231 | if (myh == NULL) | |
a4fd1a8e | 3232 | return NULL; |
252b5132 RH |
3233 | |
3234 | globals = elf32_arm_hash_table (info); | |
3235 | ||
3236 | BFD_ASSERT (globals != NULL); | |
3237 | BFD_ASSERT (globals->bfd_of_glue_owner != NULL); | |
3238 | ||
3239 | my_offset = myh->root.u.def.value; | |
252b5132 RH |
3240 | |
3241 | if ((my_offset & 0x01) == 0x01) | |
3242 | { | |
3243 | if (sym_sec != NULL | |
3244 | && sym_sec->owner != NULL | |
3245 | && !INTERWORK_FLAG (sym_sec->owner)) | |
3246 | { | |
8f615d07 | 3247 | (*_bfd_error_handler) |
d003868e AM |
3248 | (_("%B(%s): warning: interworking not enabled.\n" |
3249 | " first occurrence: %B: arm call to thumb"), | |
3250 | sym_sec->owner, input_bfd, name); | |
252b5132 | 3251 | } |
9b485d32 | 3252 | |
252b5132 RH |
3253 | --my_offset; |
3254 | myh->root.u.def.value = my_offset; | |
3255 | ||
8f6277f5 PB |
3256 | if ((info->shared || globals->root.is_relocatable_executable)) |
3257 | { | |
3258 | /* For relocatable objects we can't use absolute addresses, | |
3259 | so construct the address from a relative offset. */ | |
3260 | /* TODO: If the offset is small it's probably worth | |
3261 | constructing the address with adds. */ | |
52ab56c2 PB |
3262 | put_arm_insn (globals, output_bfd, (bfd_vma) a2t1p_ldr_insn, |
3263 | s->contents + my_offset); | |
3264 | put_arm_insn (globals, output_bfd, (bfd_vma) a2t2p_add_pc_insn, | |
3265 | s->contents + my_offset + 4); | |
3266 | put_arm_insn (globals, output_bfd, (bfd_vma) a2t3p_bx_r12_insn, | |
3267 | s->contents + my_offset + 8); | |
8f6277f5 PB |
3268 | /* Adjust the offset by 4 for the position of the add, |
3269 | and 8 for the pipeline offset. */ | |
3270 | ret_offset = (val - (s->output_offset | |
3271 | + s->output_section->vma | |
3272 | + my_offset + 12)) | |
3273 | | 1; | |
3274 | bfd_put_32 (output_bfd, ret_offset, | |
3275 | s->contents + my_offset + 12); | |
3276 | } | |
3277 | else | |
3278 | { | |
52ab56c2 PB |
3279 | put_arm_insn (globals, output_bfd, (bfd_vma) a2t1_ldr_insn, |
3280 | s->contents + my_offset); | |
252b5132 | 3281 | |
52ab56c2 PB |
3282 | put_arm_insn (globals, output_bfd, (bfd_vma) a2t2_bx_r12_insn, |
3283 | s->contents + my_offset + 4); | |
252b5132 | 3284 | |
8f6277f5 PB |
3285 | /* It's a thumb address. Add the low order bit. */ |
3286 | bfd_put_32 (output_bfd, val | a2t3_func_addr_insn, | |
3287 | s->contents + my_offset + 8); | |
3288 | } | |
252b5132 RH |
3289 | } |
3290 | ||
3291 | BFD_ASSERT (my_offset <= globals->arm_glue_size); | |
3292 | ||
a4fd1a8e PB |
3293 | return myh; |
3294 | } | |
3295 | ||
3296 | /* Arm code calling a Thumb function. */ | |
3297 | ||
3298 | static int | |
3299 | elf32_arm_to_thumb_stub (struct bfd_link_info * info, | |
3300 | const char * name, | |
3301 | bfd * input_bfd, | |
3302 | bfd * output_bfd, | |
3303 | asection * input_section, | |
3304 | bfd_byte * hit_data, | |
3305 | asection * sym_sec, | |
3306 | bfd_vma offset, | |
3307 | bfd_signed_vma addend, | |
3308 | bfd_vma val) | |
3309 | { | |
3310 | unsigned long int tmp; | |
3311 | bfd_vma my_offset; | |
3312 | asection * s; | |
3313 | long int ret_offset; | |
3314 | struct elf_link_hash_entry * myh; | |
3315 | struct elf32_arm_link_hash_table * globals; | |
3316 | ||
3317 | globals = elf32_arm_hash_table (info); | |
3318 | ||
3319 | BFD_ASSERT (globals != NULL); | |
3320 | BFD_ASSERT (globals->bfd_of_glue_owner != NULL); | |
3321 | ||
3322 | s = bfd_get_section_by_name (globals->bfd_of_glue_owner, | |
3323 | ARM2THUMB_GLUE_SECTION_NAME); | |
3324 | BFD_ASSERT (s != NULL); | |
3325 | BFD_ASSERT (s->contents != NULL); | |
3326 | BFD_ASSERT (s->output_section != NULL); | |
3327 | ||
3328 | myh = elf32_arm_create_thumb_stub (info, name, input_bfd, output_bfd, | |
3329 | sym_sec, val, s); | |
3330 | if (!myh) | |
3331 | return FALSE; | |
3332 | ||
3333 | my_offset = myh->root.u.def.value; | |
252b5132 RH |
3334 | tmp = bfd_get_32 (input_bfd, hit_data); |
3335 | tmp = tmp & 0xFF000000; | |
3336 | ||
9b485d32 | 3337 | /* Somehow these are both 4 too far, so subtract 8. */ |
dc810e39 AM |
3338 | ret_offset = (s->output_offset |
3339 | + my_offset | |
3340 | + s->output_section->vma | |
3341 | - (input_section->output_offset | |
3342 | + input_section->output_section->vma | |
3343 | + offset + addend) | |
3344 | - 8); | |
9a5aca8c | 3345 | |
252b5132 RH |
3346 | tmp = tmp | ((ret_offset >> 2) & 0x00FFFFFF); |
3347 | ||
dc810e39 | 3348 | bfd_put_32 (output_bfd, (bfd_vma) tmp, hit_data - input_section->vma); |
252b5132 | 3349 | |
b34976b6 | 3350 | return TRUE; |
252b5132 RH |
3351 | } |
3352 | ||
a4fd1a8e PB |
3353 | /* Populate Arm stub for an exported Thumb function. */ |
3354 | ||
3355 | static bfd_boolean | |
3356 | elf32_arm_to_thumb_export_stub (struct elf_link_hash_entry *h, void * inf) | |
3357 | { | |
3358 | struct bfd_link_info * info = (struct bfd_link_info *) inf; | |
3359 | asection * s; | |
3360 | struct elf_link_hash_entry * myh; | |
3361 | struct elf32_arm_link_hash_entry *eh; | |
3362 | struct elf32_arm_link_hash_table * globals; | |
3363 | asection *sec; | |
3364 | bfd_vma val; | |
3365 | ||
3366 | eh = elf32_arm_hash_entry(h); | |
3367 | /* Allocate stubs for exported Thumb functions on v4t. */ | |
3368 | if (eh->export_glue == NULL) | |
3369 | return TRUE; | |
3370 | ||
3371 | globals = elf32_arm_hash_table (info); | |
3372 | ||
3373 | BFD_ASSERT (globals != NULL); | |
3374 | BFD_ASSERT (globals->bfd_of_glue_owner != NULL); | |
3375 | ||
3376 | s = bfd_get_section_by_name (globals->bfd_of_glue_owner, | |
3377 | ARM2THUMB_GLUE_SECTION_NAME); | |
3378 | BFD_ASSERT (s != NULL); | |
3379 | BFD_ASSERT (s->contents != NULL); | |
3380 | BFD_ASSERT (s->output_section != NULL); | |
3381 | ||
3382 | sec = eh->export_glue->root.u.def.section; | |
3383 | val = eh->export_glue->root.u.def.value + sec->output_offset | |
3384 | + sec->output_section->vma; | |
3385 | myh = elf32_arm_create_thumb_stub (info, h->root.root.string, | |
3386 | h->root.u.def.section->owner, | |
3387 | globals->obfd, sec, val, s); | |
3388 | BFD_ASSERT (myh); | |
3389 | return TRUE; | |
3390 | } | |
3391 | ||
3392 | /* Generate Arm stubs for exported Thumb symbols. */ | |
3393 | static void | |
3394 | elf32_arm_begin_write_processing (bfd *abfd ATTRIBUTE_UNUSED, | |
3395 | struct bfd_link_info *link_info) | |
3396 | { | |
3397 | struct elf32_arm_link_hash_table * globals; | |
3398 | ||
3399 | if (!link_info) | |
3400 | return; | |
3401 | ||
3402 | globals = elf32_arm_hash_table (link_info); | |
84c08195 PB |
3403 | /* If blx is available then exported Thumb symbols are OK and there is |
3404 | nothing to do. */ | |
a4fd1a8e PB |
3405 | if (globals->use_blx) |
3406 | return; | |
3407 | ||
3408 | elf_link_hash_traverse (&globals->root, elf32_arm_to_thumb_export_stub, | |
3409 | link_info); | |
3410 | } | |
3411 | ||
eb043451 PB |
3412 | /* Some relocations map to different relocations depending on the |
3413 | target. Return the real relocation. */ | |
3414 | static int | |
3415 | arm_real_reloc_type (struct elf32_arm_link_hash_table * globals, | |
3416 | int r_type) | |
3417 | { | |
3418 | switch (r_type) | |
3419 | { | |
3420 | case R_ARM_TARGET1: | |
3421 | if (globals->target1_is_rel) | |
3422 | return R_ARM_REL32; | |
3423 | else | |
3424 | return R_ARM_ABS32; | |
3425 | ||
3426 | case R_ARM_TARGET2: | |
3427 | return globals->target2_reloc; | |
3428 | ||
3429 | default: | |
3430 | return r_type; | |
3431 | } | |
3432 | } | |
eb043451 | 3433 | |
ba93b8ac DJ |
3434 | /* Return the base VMA address which should be subtracted from real addresses |
3435 | when resolving @dtpoff relocation. | |
3436 | This is PT_TLS segment p_vaddr. */ | |
3437 | ||
3438 | static bfd_vma | |
3439 | dtpoff_base (struct bfd_link_info *info) | |
3440 | { | |
3441 | /* If tls_sec is NULL, we should have signalled an error already. */ | |
3442 | if (elf_hash_table (info)->tls_sec == NULL) | |
3443 | return 0; | |
3444 | return elf_hash_table (info)->tls_sec->vma; | |
3445 | } | |
3446 | ||
3447 | /* Return the relocation value for @tpoff relocation | |
3448 | if STT_TLS virtual address is ADDRESS. */ | |
3449 | ||
3450 | static bfd_vma | |
3451 | tpoff (struct bfd_link_info *info, bfd_vma address) | |
3452 | { | |
3453 | struct elf_link_hash_table *htab = elf_hash_table (info); | |
3454 | bfd_vma base; | |
3455 | ||
3456 | /* If tls_sec is NULL, we should have signalled an error already. */ | |
3457 | if (htab->tls_sec == NULL) | |
3458 | return 0; | |
3459 | base = align_power ((bfd_vma) TCB_SIZE, htab->tls_sec->alignment_power); | |
3460 | return address - htab->tls_sec->vma + base; | |
3461 | } | |
3462 | ||
00a97672 RS |
3463 | /* Perform an R_ARM_ABS12 relocation on the field pointed to by DATA. |
3464 | VALUE is the relocation value. */ | |
3465 | ||
3466 | static bfd_reloc_status_type | |
3467 | elf32_arm_abs12_reloc (bfd *abfd, void *data, bfd_vma value) | |
3468 | { | |
3469 | if (value > 0xfff) | |
3470 | return bfd_reloc_overflow; | |
3471 | ||
3472 | value |= bfd_get_32 (abfd, data) & 0xfffff000; | |
3473 | bfd_put_32 (abfd, value, data); | |
3474 | return bfd_reloc_ok; | |
3475 | } | |
3476 | ||
4962c51a MS |
3477 | /* For a given value of n, calculate the value of G_n as required to |
3478 | deal with group relocations. We return it in the form of an | |
3479 | encoded constant-and-rotation, together with the final residual. If n is | |
3480 | specified as less than zero, then final_residual is filled with the | |
3481 | input value and no further action is performed. */ | |
3482 | ||
3483 | static bfd_vma | |
3484 | calculate_group_reloc_mask (bfd_vma value, int n, bfd_vma *final_residual) | |
3485 | { | |
3486 | int current_n; | |
3487 | bfd_vma g_n; | |
3488 | bfd_vma encoded_g_n = 0; | |
3489 | bfd_vma residual = value; /* Also known as Y_n. */ | |
3490 | ||
3491 | for (current_n = 0; current_n <= n; current_n++) | |
3492 | { | |
3493 | int shift; | |
3494 | ||
3495 | /* Calculate which part of the value to mask. */ | |
3496 | if (residual == 0) | |
3497 | shift = 0; | |
3498 | else | |
3499 | { | |
3500 | int msb; | |
3501 | ||
3502 | /* Determine the most significant bit in the residual and | |
3503 | align the resulting value to a 2-bit boundary. */ | |
3504 | for (msb = 30; msb >= 0; msb -= 2) | |
3505 | if (residual & (3 << msb)) | |
3506 | break; | |
3507 | ||
3508 | /* The desired shift is now (msb - 6), or zero, whichever | |
3509 | is the greater. */ | |
3510 | shift = msb - 6; | |
3511 | if (shift < 0) | |
3512 | shift = 0; | |
3513 | } | |
3514 | ||
3515 | /* Calculate g_n in 32-bit as well as encoded constant+rotation form. */ | |
3516 | g_n = residual & (0xff << shift); | |
3517 | encoded_g_n = (g_n >> shift) | |
3518 | | ((g_n <= 0xff ? 0 : (32 - shift) / 2) << 8); | |
3519 | ||
3520 | /* Calculate the residual for the next time around. */ | |
3521 | residual &= ~g_n; | |
3522 | } | |
3523 | ||
3524 | *final_residual = residual; | |
3525 | ||
3526 | return encoded_g_n; | |
3527 | } | |
3528 | ||
3529 | /* Given an ARM instruction, determine whether it is an ADD or a SUB. | |
3530 | Returns 1 if it is an ADD, -1 if it is a SUB, and 0 otherwise. */ | |
3531 | static int | |
3532 | identify_add_or_sub(bfd_vma insn) | |
3533 | { | |
3534 | int opcode = insn & 0x1e00000; | |
3535 | ||
3536 | if (opcode == 1 << 23) /* ADD */ | |
3537 | return 1; | |
3538 | ||
3539 | if (opcode == 1 << 22) /* SUB */ | |
3540 | return -1; | |
3541 | ||
3542 | return 0; | |
3543 | } | |
3544 | ||
e95de063 MS |
3545 | /* Determine if we're dealing with a Thumb-2 object. */ |
3546 | ||
3547 | static int using_thumb2 (struct elf32_arm_link_hash_table *globals) | |
3548 | { | |
3549 | int arch = elf32_arm_get_eabi_attr_int (globals->obfd, Tag_CPU_arch); | |
3550 | return arch == TAG_CPU_ARCH_V6T2 || arch >= TAG_CPU_ARCH_V7; | |
3551 | } | |
3552 | ||
252b5132 | 3553 | /* Perform a relocation as part of a final link. */ |
9b485d32 | 3554 | |
252b5132 | 3555 | static bfd_reloc_status_type |
57e8b36a NC |
3556 | elf32_arm_final_link_relocate (reloc_howto_type * howto, |
3557 | bfd * input_bfd, | |
3558 | bfd * output_bfd, | |
3559 | asection * input_section, | |
3560 | bfd_byte * contents, | |
3561 | Elf_Internal_Rela * rel, | |
3562 | bfd_vma value, | |
3563 | struct bfd_link_info * info, | |
3564 | asection * sym_sec, | |
3565 | const char * sym_name, | |
3566 | int sym_flags, | |
0945cdfd DJ |
3567 | struct elf_link_hash_entry * h, |
3568 | bfd_boolean * unresolved_reloc_p) | |
252b5132 RH |
3569 | { |
3570 | unsigned long r_type = howto->type; | |
3571 | unsigned long r_symndx; | |
3572 | bfd_byte * hit_data = contents + rel->r_offset; | |
3573 | bfd * dynobj = NULL; | |
3574 | Elf_Internal_Shdr * symtab_hdr; | |
3575 | struct elf_link_hash_entry ** sym_hashes; | |
3576 | bfd_vma * local_got_offsets; | |
3577 | asection * sgot = NULL; | |
3578 | asection * splt = NULL; | |
3579 | asection * sreloc = NULL; | |
252b5132 | 3580 | bfd_vma addend; |
ba96a88f NC |
3581 | bfd_signed_vma signed_addend; |
3582 | struct elf32_arm_link_hash_table * globals; | |
f21f3fe0 | 3583 | |
9c504268 PB |
3584 | globals = elf32_arm_hash_table (info); |
3585 | ||
9c504268 PB |
3586 | /* Some relocation type map to different relocations depending on the |
3587 | target. We pick the right one here. */ | |
eb043451 PB |
3588 | r_type = arm_real_reloc_type (globals, r_type); |
3589 | if (r_type != howto->type) | |
3590 | howto = elf32_arm_howto_from_type (r_type); | |
9c504268 | 3591 | |
cac15327 NC |
3592 | /* If the start address has been set, then set the EF_ARM_HASENTRY |
3593 | flag. Setting this more than once is redundant, but the cost is | |
3594 | not too high, and it keeps the code simple. | |
99e4ae17 | 3595 | |
cac15327 NC |
3596 | The test is done here, rather than somewhere else, because the |
3597 | start address is only set just before the final link commences. | |
3598 | ||
3599 | Note - if the user deliberately sets a start address of 0, the | |
3600 | flag will not be set. */ | |
3601 | if (bfd_get_start_address (output_bfd) != 0) | |
3602 | elf_elfheader (output_bfd)->e_flags |= EF_ARM_HASENTRY; | |
99e4ae17 | 3603 | |
252b5132 RH |
3604 | dynobj = elf_hash_table (info)->dynobj; |
3605 | if (dynobj) | |
3606 | { | |
3607 | sgot = bfd_get_section_by_name (dynobj, ".got"); | |
3608 | splt = bfd_get_section_by_name (dynobj, ".plt"); | |
3609 | } | |
3610 | symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr; | |
3611 | sym_hashes = elf_sym_hashes (input_bfd); | |
3612 | local_got_offsets = elf_local_got_offsets (input_bfd); | |
3613 | r_symndx = ELF32_R_SYM (rel->r_info); | |
3614 | ||
4e7fd91e | 3615 | if (globals->use_rel) |
ba96a88f | 3616 | { |
4e7fd91e PB |
3617 | addend = bfd_get_32 (input_bfd, hit_data) & howto->src_mask; |
3618 | ||
3619 | if (addend & ((howto->src_mask + 1) >> 1)) | |
3620 | { | |
3621 | signed_addend = -1; | |
3622 | signed_addend &= ~ howto->src_mask; | |
3623 | signed_addend |= addend; | |
3624 | } | |
3625 | else | |
3626 | signed_addend = addend; | |
ba96a88f NC |
3627 | } |
3628 | else | |
4e7fd91e | 3629 | addend = signed_addend = rel->r_addend; |
f21f3fe0 | 3630 | |
252b5132 RH |
3631 | switch (r_type) |
3632 | { | |
3633 | case R_ARM_NONE: | |
28a094c2 DJ |
3634 | /* We don't need to find a value for this symbol. It's just a |
3635 | marker. */ | |
3636 | *unresolved_reloc_p = FALSE; | |
252b5132 RH |
3637 | return bfd_reloc_ok; |
3638 | ||
00a97672 RS |
3639 | case R_ARM_ABS12: |
3640 | if (!globals->vxworks_p) | |
3641 | return elf32_arm_abs12_reloc (input_bfd, hit_data, value + addend); | |
3642 | ||
252b5132 RH |
3643 | case R_ARM_PC24: |
3644 | case R_ARM_ABS32: | |
bb224fc3 | 3645 | case R_ARM_ABS32_NOI: |
252b5132 | 3646 | case R_ARM_REL32: |
bb224fc3 | 3647 | case R_ARM_REL32_NOI: |
5b5bb741 PB |
3648 | case R_ARM_CALL: |
3649 | case R_ARM_JUMP24: | |
dfc5f959 | 3650 | case R_ARM_XPC25: |
eb043451 | 3651 | case R_ARM_PREL31: |
7359ea65 | 3652 | case R_ARM_PLT32: |
5e681ec4 PB |
3653 | /* r_symndx will be zero only for relocs against symbols |
3654 | from removed linkonce sections, or sections discarded by | |
3655 | a linker script. */ | |
3656 | if (r_symndx == 0) | |
3657 | return bfd_reloc_ok; | |
3658 | ||
7359ea65 DJ |
3659 | /* Handle relocations which should use the PLT entry. ABS32/REL32 |
3660 | will use the symbol's value, which may point to a PLT entry, but we | |
3661 | don't need to handle that here. If we created a PLT entry, all | |
3662 | branches in this object should go to it. */ | |
bb224fc3 MS |
3663 | if ((r_type != R_ARM_ABS32 && r_type != R_ARM_REL32 |
3664 | && r_type != R_ARM_ABS32_NOI && r_type != R_ARM_REL32_NOI) | |
7359ea65 | 3665 | && h != NULL |
c84cd8ee | 3666 | && splt != NULL |
7359ea65 DJ |
3667 | && h->plt.offset != (bfd_vma) -1) |
3668 | { | |
c84cd8ee DJ |
3669 | /* If we've created a .plt section, and assigned a PLT entry to |
3670 | this function, it should not be known to bind locally. If | |
3671 | it were, we would have cleared the PLT entry. */ | |
7359ea65 DJ |
3672 | BFD_ASSERT (!SYMBOL_CALLS_LOCAL (info, h)); |
3673 | ||
3674 | value = (splt->output_section->vma | |
3675 | + splt->output_offset | |
3676 | + h->plt.offset); | |
0945cdfd | 3677 | *unresolved_reloc_p = FALSE; |
7359ea65 DJ |
3678 | return _bfd_final_link_relocate (howto, input_bfd, input_section, |
3679 | contents, rel->r_offset, value, | |
00a97672 | 3680 | rel->r_addend); |
7359ea65 DJ |
3681 | } |
3682 | ||
67687978 PB |
3683 | /* When generating a shared object or relocatable executable, these |
3684 | relocations are copied into the output file to be resolved at | |
3685 | run time. */ | |
3686 | if ((info->shared || globals->root.is_relocatable_executable) | |
7359ea65 | 3687 | && (input_section->flags & SEC_ALLOC) |
bb224fc3 | 3688 | && ((r_type != R_ARM_REL32 && r_type != R_ARM_REL32_NOI) |
ee06dc07 | 3689 | || !SYMBOL_CALLS_LOCAL (info, h)) |
7359ea65 DJ |
3690 | && (h == NULL |
3691 | || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT | |
3692 | || h->root.type != bfd_link_hash_undefweak) | |
3693 | && r_type != R_ARM_PC24 | |
5b5bb741 PB |
3694 | && r_type != R_ARM_CALL |
3695 | && r_type != R_ARM_JUMP24 | |
ee06dc07 | 3696 | && r_type != R_ARM_PREL31 |
7359ea65 | 3697 | && r_type != R_ARM_PLT32) |
252b5132 | 3698 | { |
947216bf AM |
3699 | Elf_Internal_Rela outrel; |
3700 | bfd_byte *loc; | |
b34976b6 | 3701 | bfd_boolean skip, relocate; |
f21f3fe0 | 3702 | |
0945cdfd DJ |
3703 | *unresolved_reloc_p = FALSE; |
3704 | ||
252b5132 RH |
3705 | if (sreloc == NULL) |
3706 | { | |
3707 | const char * name; | |
f21f3fe0 | 3708 | |
252b5132 RH |
3709 | name = (bfd_elf_string_from_elf_section |
3710 | (input_bfd, | |
3711 | elf_elfheader (input_bfd)->e_shstrndx, | |
3712 | elf_section_data (input_section)->rel_hdr.sh_name)); | |
3713 | if (name == NULL) | |
3714 | return bfd_reloc_notsupported; | |
f21f3fe0 | 3715 | |
00a97672 | 3716 | BFD_ASSERT (reloc_section_p (globals, name, input_section)); |
f21f3fe0 | 3717 | |
252b5132 RH |
3718 | sreloc = bfd_get_section_by_name (dynobj, name); |
3719 | BFD_ASSERT (sreloc != NULL); | |
3720 | } | |
f21f3fe0 | 3721 | |
b34976b6 AM |
3722 | skip = FALSE; |
3723 | relocate = FALSE; | |
f21f3fe0 | 3724 | |
00a97672 | 3725 | outrel.r_addend = addend; |
c629eae0 JJ |
3726 | outrel.r_offset = |
3727 | _bfd_elf_section_offset (output_bfd, info, input_section, | |
3728 | rel->r_offset); | |
3729 | if (outrel.r_offset == (bfd_vma) -1) | |
b34976b6 | 3730 | skip = TRUE; |
0bb2d96a | 3731 | else if (outrel.r_offset == (bfd_vma) -2) |
b34976b6 | 3732 | skip = TRUE, relocate = TRUE; |
252b5132 RH |
3733 | outrel.r_offset += (input_section->output_section->vma |
3734 | + input_section->output_offset); | |
f21f3fe0 | 3735 | |
252b5132 | 3736 | if (skip) |
0bb2d96a | 3737 | memset (&outrel, 0, sizeof outrel); |
5e681ec4 PB |
3738 | else if (h != NULL |
3739 | && h->dynindx != -1 | |
7359ea65 | 3740 | && (!info->shared |
5e681ec4 | 3741 | || !info->symbolic |
f5385ebf | 3742 | || !h->def_regular)) |
5e681ec4 | 3743 | outrel.r_info = ELF32_R_INFO (h->dynindx, r_type); |
252b5132 RH |
3744 | else |
3745 | { | |
a16385dc MM |
3746 | int symbol; |
3747 | ||
5e681ec4 | 3748 | /* This symbol is local, or marked to become local. */ |
b7693d02 DJ |
3749 | if (sym_flags == STT_ARM_TFUNC) |
3750 | value |= 1; | |
a16385dc | 3751 | if (globals->symbian_p) |
6366ff1e | 3752 | { |
74541ad4 AM |
3753 | asection *osec; |
3754 | ||
6366ff1e MM |
3755 | /* On Symbian OS, the data segment and text segement |
3756 | can be relocated independently. Therefore, we | |
3757 | must indicate the segment to which this | |
3758 | relocation is relative. The BPABI allows us to | |
3759 | use any symbol in the right segment; we just use | |
3760 | the section symbol as it is convenient. (We | |
3761 | cannot use the symbol given by "h" directly as it | |
74541ad4 AM |
3762 | will not appear in the dynamic symbol table.) |
3763 | ||
3764 | Note that the dynamic linker ignores the section | |
3765 | symbol value, so we don't subtract osec->vma | |
3766 | from the emitted reloc addend. */ | |
10dbd1f3 | 3767 | if (sym_sec) |
74541ad4 | 3768 | osec = sym_sec->output_section; |
10dbd1f3 | 3769 | else |
74541ad4 AM |
3770 | osec = input_section->output_section; |
3771 | symbol = elf_section_data (osec)->dynindx; | |
3772 | if (symbol == 0) | |
3773 | { | |
3774 | struct elf_link_hash_table *htab = elf_hash_table (info); | |
3775 | ||
3776 | if ((osec->flags & SEC_READONLY) == 0 | |
3777 | && htab->data_index_section != NULL) | |
3778 | osec = htab->data_index_section; | |
3779 | else | |
3780 | osec = htab->text_index_section; | |
3781 | symbol = elf_section_data (osec)->dynindx; | |
3782 | } | |
6366ff1e MM |
3783 | BFD_ASSERT (symbol != 0); |
3784 | } | |
a16385dc MM |
3785 | else |
3786 | /* On SVR4-ish systems, the dynamic loader cannot | |
3787 | relocate the text and data segments independently, | |
3788 | so the symbol does not matter. */ | |
3789 | symbol = 0; | |
3790 | outrel.r_info = ELF32_R_INFO (symbol, R_ARM_RELATIVE); | |
00a97672 RS |
3791 | if (globals->use_rel) |
3792 | relocate = TRUE; | |
3793 | else | |
3794 | outrel.r_addend += value; | |
252b5132 | 3795 | } |
f21f3fe0 | 3796 | |
947216bf | 3797 | loc = sreloc->contents; |
00a97672 RS |
3798 | loc += sreloc->reloc_count++ * RELOC_SIZE (globals); |
3799 | SWAP_RELOC_OUT (globals) (output_bfd, &outrel, loc); | |
9a5aca8c | 3800 | |
f21f3fe0 | 3801 | /* If this reloc is against an external symbol, we do not want to |
252b5132 | 3802 | fiddle with the addend. Otherwise, we need to include the symbol |
9b485d32 | 3803 | value so that it becomes an addend for the dynamic reloc. */ |
252b5132 RH |
3804 | if (! relocate) |
3805 | return bfd_reloc_ok; | |
9a5aca8c | 3806 | |
f21f3fe0 | 3807 | return _bfd_final_link_relocate (howto, input_bfd, input_section, |
252b5132 RH |
3808 | contents, rel->r_offset, value, |
3809 | (bfd_vma) 0); | |
3810 | } | |
3811 | else switch (r_type) | |
3812 | { | |
00a97672 RS |
3813 | case R_ARM_ABS12: |
3814 | return elf32_arm_abs12_reloc (input_bfd, hit_data, value + addend); | |
3815 | ||
dfc5f959 | 3816 | case R_ARM_XPC25: /* Arm BLX instruction. */ |
5b5bb741 PB |
3817 | case R_ARM_CALL: |
3818 | case R_ARM_JUMP24: | |
dfc5f959 | 3819 | case R_ARM_PC24: /* Arm B/BL instruction */ |
7359ea65 | 3820 | case R_ARM_PLT32: |
dfc5f959 | 3821 | if (r_type == R_ARM_XPC25) |
252b5132 | 3822 | { |
dfc5f959 NC |
3823 | /* Check for Arm calling Arm function. */ |
3824 | /* FIXME: Should we translate the instruction into a BL | |
3825 | instruction instead ? */ | |
3826 | if (sym_flags != STT_ARM_TFUNC) | |
d003868e AM |
3827 | (*_bfd_error_handler) |
3828 | (_("\%B: Warning: Arm BLX instruction targets Arm function '%s'."), | |
3829 | input_bfd, | |
3830 | h ? h->root.root.string : "(local)"); | |
dfc5f959 | 3831 | } |
39b41c9c | 3832 | else if (r_type != R_ARM_CALL || !globals->use_blx) |
dfc5f959 NC |
3833 | { |
3834 | /* Check for Arm calling Thumb function. */ | |
3835 | if (sym_flags == STT_ARM_TFUNC) | |
3836 | { | |
57e8b36a NC |
3837 | elf32_arm_to_thumb_stub (info, sym_name, input_bfd, |
3838 | output_bfd, input_section, | |
3839 | hit_data, sym_sec, rel->r_offset, | |
dfc5f959 NC |
3840 | signed_addend, value); |
3841 | return bfd_reloc_ok; | |
3842 | } | |
252b5132 | 3843 | } |
ba96a88f | 3844 | |
dea514f5 PB |
3845 | /* The ARM ELF ABI says that this reloc is computed as: S - P + A |
3846 | where: | |
3847 | S is the address of the symbol in the relocation. | |
3848 | P is address of the instruction being relocated. | |
3849 | A is the addend (extracted from the instruction) in bytes. | |
3850 | ||
3851 | S is held in 'value'. | |
3852 | P is the base address of the section containing the | |
3853 | instruction plus the offset of the reloc into that | |
3854 | section, ie: | |
3855 | (input_section->output_section->vma + | |
3856 | input_section->output_offset + | |
3857 | rel->r_offset). | |
3858 | A is the addend, converted into bytes, ie: | |
3859 | (signed_addend * 4) | |
3860 | ||
3861 | Note: None of these operations have knowledge of the pipeline | |
3862 | size of the processor, thus it is up to the assembler to | |
3863 | encode this information into the addend. */ | |
3864 | value -= (input_section->output_section->vma | |
3865 | + input_section->output_offset); | |
3866 | value -= rel->r_offset; | |
4e7fd91e PB |
3867 | if (globals->use_rel) |
3868 | value += (signed_addend << howto->size); | |
3869 | else | |
3870 | /* RELA addends do not have to be adjusted by howto->size. */ | |
3871 | value += signed_addend; | |
23080146 | 3872 | |
dcb5e6e6 NC |
3873 | signed_addend = value; |
3874 | signed_addend >>= howto->rightshift; | |
9a5aca8c | 3875 | |
59f2c4e7 NC |
3876 | /* It is not an error for an undefined weak reference to be |
3877 | out of range. Any program that branches to such a symbol | |
9a5aca8c AM |
3878 | is going to crash anyway, so there is no point worrying |
3879 | about getting the destination exactly right. */ | |
59f2c4e7 NC |
3880 | if (! h || h->root.type != bfd_link_hash_undefweak) |
3881 | { | |
9b485d32 | 3882 | /* Perform a signed range check. */ |
dcb5e6e6 | 3883 | if ( signed_addend > ((bfd_signed_vma) (howto->dst_mask >> 1)) |
59f2c4e7 NC |
3884 | || signed_addend < - ((bfd_signed_vma) ((howto->dst_mask + 1) >> 1))) |
3885 | return bfd_reloc_overflow; | |
3886 | } | |
9a5aca8c | 3887 | |
39b41c9c PB |
3888 | addend = (value & 2); |
3889 | ||
3890 | value = (signed_addend & howto->dst_mask) | |
3891 | | (bfd_get_32 (input_bfd, hit_data) & (~ howto->dst_mask)); | |
3892 | ||
3893 | /* Set the H bit in the BLX instruction. */ | |
3894 | if (sym_flags == STT_ARM_TFUNC) | |
3895 | { | |
3896 | if (addend) | |
3897 | value |= (1 << 24); | |
3898 | else | |
3899 | value &= ~(bfd_vma)(1 << 24); | |
3900 | } | |
3901 | if (r_type == R_ARM_CALL) | |
3902 | { | |
3903 | /* Select the correct instruction (BL or BLX). */ | |
3904 | if (sym_flags == STT_ARM_TFUNC) | |
3905 | value |= (1 << 28); | |
3906 | else | |
3907 | { | |
3908 | value &= ~(bfd_vma)(1 << 28); | |
3909 | value |= (1 << 24); | |
3910 | } | |
3911 | } | |
252b5132 | 3912 | break; |
f21f3fe0 | 3913 | |
252b5132 RH |
3914 | case R_ARM_ABS32: |
3915 | value += addend; | |
3916 | if (sym_flags == STT_ARM_TFUNC) | |
3917 | value |= 1; | |
3918 | break; | |
f21f3fe0 | 3919 | |
bb224fc3 MS |
3920 | case R_ARM_ABS32_NOI: |
3921 | value += addend; | |
3922 | break; | |
3923 | ||
252b5132 | 3924 | case R_ARM_REL32: |
a8bc6c78 PB |
3925 | value += addend; |
3926 | if (sym_flags == STT_ARM_TFUNC) | |
3927 | value |= 1; | |
252b5132 | 3928 | value -= (input_section->output_section->vma |
62efb346 | 3929 | + input_section->output_offset + rel->r_offset); |
252b5132 | 3930 | break; |
eb043451 | 3931 | |
bb224fc3 MS |
3932 | case R_ARM_REL32_NOI: |
3933 | value += addend; | |
3934 | value -= (input_section->output_section->vma | |
3935 | + input_section->output_offset + rel->r_offset); | |
3936 | break; | |
3937 | ||
eb043451 PB |
3938 | case R_ARM_PREL31: |
3939 | value -= (input_section->output_section->vma | |
3940 | + input_section->output_offset + rel->r_offset); | |
3941 | value += signed_addend; | |
3942 | if (! h || h->root.type != bfd_link_hash_undefweak) | |
3943 | { | |
3944 | /* Check for overflow */ | |
3945 | if ((value ^ (value >> 1)) & (1 << 30)) | |
3946 | return bfd_reloc_overflow; | |
3947 | } | |
3948 | value &= 0x7fffffff; | |
3949 | value |= (bfd_get_32 (input_bfd, hit_data) & 0x80000000); | |
3950 | if (sym_flags == STT_ARM_TFUNC) | |
3951 | value |= 1; | |
3952 | break; | |
252b5132 | 3953 | } |
f21f3fe0 | 3954 | |
252b5132 RH |
3955 | bfd_put_32 (input_bfd, value, hit_data); |
3956 | return bfd_reloc_ok; | |
3957 | ||
3958 | case R_ARM_ABS8: | |
3959 | value += addend; | |
3960 | if ((long) value > 0x7f || (long) value < -0x80) | |
3961 | return bfd_reloc_overflow; | |
3962 | ||
3963 | bfd_put_8 (input_bfd, value, hit_data); | |
3964 | return bfd_reloc_ok; | |
3965 | ||
3966 | case R_ARM_ABS16: | |
3967 | value += addend; | |
3968 | ||
3969 | if ((long) value > 0x7fff || (long) value < -0x8000) | |
3970 | return bfd_reloc_overflow; | |
3971 | ||
3972 | bfd_put_16 (input_bfd, value, hit_data); | |
3973 | return bfd_reloc_ok; | |
3974 | ||
252b5132 | 3975 | case R_ARM_THM_ABS5: |
9b485d32 | 3976 | /* Support ldr and str instructions for the thumb. */ |
4e7fd91e PB |
3977 | if (globals->use_rel) |
3978 | { | |
3979 | /* Need to refetch addend. */ | |
3980 | addend = bfd_get_16 (input_bfd, hit_data) & howto->src_mask; | |
3981 | /* ??? Need to determine shift amount from operand size. */ | |
3982 | addend >>= howto->rightshift; | |
3983 | } | |
252b5132 RH |
3984 | value += addend; |
3985 | ||
3986 | /* ??? Isn't value unsigned? */ | |
3987 | if ((long) value > 0x1f || (long) value < -0x10) | |
3988 | return bfd_reloc_overflow; | |
3989 | ||
3990 | /* ??? Value needs to be properly shifted into place first. */ | |
3991 | value |= bfd_get_16 (input_bfd, hit_data) & 0xf83f; | |
3992 | bfd_put_16 (input_bfd, value, hit_data); | |
3993 | return bfd_reloc_ok; | |
3994 | ||
2cab6cc3 MS |
3995 | case R_ARM_THM_ALU_PREL_11_0: |
3996 | /* Corresponds to: addw.w reg, pc, #offset (and similarly for subw). */ | |
3997 | { | |
3998 | bfd_vma insn; | |
3999 | bfd_signed_vma relocation; | |
4000 | ||
4001 | insn = (bfd_get_16 (input_bfd, hit_data) << 16) | |
4002 | | bfd_get_16 (input_bfd, hit_data + 2); | |
4003 | ||
4004 | if (globals->use_rel) | |
4005 | { | |
4006 | signed_addend = (insn & 0xff) | ((insn & 0x7000) >> 4) | |
4007 | | ((insn & (1 << 26)) >> 15); | |
4008 | if (insn & 0xf00000) | |
4009 | signed_addend = -signed_addend; | |
4010 | } | |
4011 | ||
4012 | relocation = value + signed_addend; | |
4013 | relocation -= (input_section->output_section->vma | |
4014 | + input_section->output_offset | |
4015 | + rel->r_offset); | |
4016 | ||
4017 | value = abs (relocation); | |
4018 | ||
4019 | if (value >= 0x1000) | |
4020 | return bfd_reloc_overflow; | |
4021 | ||
4022 | insn = (insn & 0xfb0f8f00) | (value & 0xff) | |
4023 | | ((value & 0x700) << 4) | |
4024 | | ((value & 0x800) << 15); | |
4025 | if (relocation < 0) | |
4026 | insn |= 0xa00000; | |
4027 | ||
4028 | bfd_put_16 (input_bfd, insn >> 16, hit_data); | |
4029 | bfd_put_16 (input_bfd, insn & 0xffff, hit_data + 2); | |
4030 | ||
4031 | return bfd_reloc_ok; | |
4032 | } | |
4033 | ||
4034 | case R_ARM_THM_PC12: | |
4035 | /* Corresponds to: ldr.w reg, [pc, #offset]. */ | |
4036 | { | |
4037 | bfd_vma insn; | |
4038 | bfd_signed_vma relocation; | |
4039 | ||
4040 | insn = (bfd_get_16 (input_bfd, hit_data) << 16) | |
4041 | | bfd_get_16 (input_bfd, hit_data + 2); | |
4042 | ||
4043 | if (globals->use_rel) | |
4044 | { | |
4045 | signed_addend = insn & 0xfff; | |
4046 | if (!(insn & (1 << 23))) | |
4047 | signed_addend = -signed_addend; | |
4048 | } | |
4049 | ||
4050 | relocation = value + signed_addend; | |
4051 | relocation -= (input_section->output_section->vma | |
4052 | + input_section->output_offset | |
4053 | + rel->r_offset); | |
4054 | ||
4055 | value = abs (relocation); | |
4056 | ||
4057 | if (value >= 0x1000) | |
4058 | return bfd_reloc_overflow; | |
4059 | ||
4060 | insn = (insn & 0xff7ff000) | value; | |
4061 | if (relocation >= 0) | |
4062 | insn |= (1 << 23); | |
4063 | ||
4064 | bfd_put_16 (input_bfd, insn >> 16, hit_data); | |
4065 | bfd_put_16 (input_bfd, insn & 0xffff, hit_data + 2); | |
4066 | ||
4067 | return bfd_reloc_ok; | |
4068 | } | |
4069 | ||
dfc5f959 | 4070 | case R_ARM_THM_XPC22: |
c19d1205 | 4071 | case R_ARM_THM_CALL: |
dfc5f959 | 4072 | /* Thumb BL (branch long instruction). */ |
252b5132 | 4073 | { |
b34976b6 | 4074 | bfd_vma relocation; |
e95de063 | 4075 | bfd_vma reloc_sign; |
b34976b6 AM |
4076 | bfd_boolean overflow = FALSE; |
4077 | bfd_vma upper_insn = bfd_get_16 (input_bfd, hit_data); | |
4078 | bfd_vma lower_insn = bfd_get_16 (input_bfd, hit_data + 2); | |
e95de063 MS |
4079 | bfd_signed_vma reloc_signed_max; |
4080 | bfd_signed_vma reloc_signed_min; | |
b34976b6 | 4081 | bfd_vma check; |
252b5132 | 4082 | bfd_signed_vma signed_check; |
e95de063 MS |
4083 | int bitsize; |
4084 | int thumb2 = using_thumb2 (globals); | |
252b5132 | 4085 | |
e95de063 MS |
4086 | /* Fetch the addend. We use the Thumb-2 encoding (backwards compatible |
4087 | with Thumb-1) involving the J1 and J2 bits. */ | |
4e7fd91e PB |
4088 | if (globals->use_rel) |
4089 | { | |
e95de063 MS |
4090 | bfd_vma s = (upper_insn & (1 << 10)) >> 10; |
4091 | bfd_vma upper = upper_insn & 0x3ff; | |
4092 | bfd_vma lower = lower_insn & 0x7ff; | |
4093 | bfd_vma j1 = (lower_insn & (1 << 13)) >> 13; | |
4094 | bfd_vma j2 = (lower_insn & (1 << 11)) >> 11; | |
4095 | bfd_vma i1 = j1 ^ s ? 0 : 1; | |
4096 | bfd_vma i2 = j2 ^ s ? 0 : 1; | |
4097 | ||
4098 | addend = (i1 << 23) | (i2 << 22) | (upper << 12) | (lower << 1); | |
4099 | /* Sign extend. */ | |
4100 | addend = (addend | ((s ? 0 : 1) << 24)) - (1 << 24); | |
4101 | ||
4e7fd91e PB |
4102 | signed_addend = addend; |
4103 | } | |
cb1afa5c | 4104 | |
dfc5f959 NC |
4105 | if (r_type == R_ARM_THM_XPC22) |
4106 | { | |
4107 | /* Check for Thumb to Thumb call. */ | |
4108 | /* FIXME: Should we translate the instruction into a BL | |
4109 | instruction instead ? */ | |
4110 | if (sym_flags == STT_ARM_TFUNC) | |
d003868e AM |
4111 | (*_bfd_error_handler) |
4112 | (_("%B: Warning: Thumb BLX instruction targets thumb function '%s'."), | |
4113 | input_bfd, | |
4114 | h ? h->root.root.string : "(local)"); | |
dfc5f959 NC |
4115 | } |
4116 | else | |
252b5132 | 4117 | { |
dfc5f959 NC |
4118 | /* If it is not a call to Thumb, assume call to Arm. |
4119 | If it is a call relative to a section name, then it is not a | |
b7693d02 DJ |
4120 | function call at all, but rather a long jump. Calls through |
4121 | the PLT do not require stubs. */ | |
4122 | if (sym_flags != STT_ARM_TFUNC && sym_flags != STT_SECTION | |
4123 | && (h == NULL || splt == NULL | |
4124 | || h->plt.offset == (bfd_vma) -1)) | |
dfc5f959 | 4125 | { |
39b41c9c PB |
4126 | if (globals->use_blx) |
4127 | { | |
4128 | /* Convert BL to BLX. */ | |
4129 | lower_insn = (lower_insn & ~0x1000) | 0x0800; | |
4130 | } | |
4131 | else if (elf32_thumb_to_arm_stub | |
dfc5f959 NC |
4132 | (info, sym_name, input_bfd, output_bfd, input_section, |
4133 | hit_data, sym_sec, rel->r_offset, signed_addend, value)) | |
4134 | return bfd_reloc_ok; | |
4135 | else | |
4136 | return bfd_reloc_dangerous; | |
4137 | } | |
39b41c9c PB |
4138 | else if (sym_flags == STT_ARM_TFUNC && globals->use_blx) |
4139 | { | |
4140 | /* Make sure this is a BL. */ | |
4141 | lower_insn |= 0x1800; | |
4142 | } | |
252b5132 | 4143 | } |
f21f3fe0 | 4144 | |
b7693d02 DJ |
4145 | /* Handle calls via the PLT. */ |
4146 | if (h != NULL && splt != NULL && h->plt.offset != (bfd_vma) -1) | |
4147 | { | |
4148 | value = (splt->output_section->vma | |
4149 | + splt->output_offset | |
4150 | + h->plt.offset); | |
33bfe774 JB |
4151 | if (globals->use_blx) |
4152 | { | |
4153 | /* If the Thumb BLX instruction is available, convert the | |
4154 | BL to a BLX instruction to call the ARM-mode PLT entry. */ | |
39b41c9c | 4155 | lower_insn = (lower_insn & ~0x1000) | 0x0800; |
33bfe774 JB |
4156 | } |
4157 | else | |
4158 | /* Target the Thumb stub before the ARM PLT entry. */ | |
4159 | value -= PLT_THUMB_STUB_SIZE; | |
0945cdfd | 4160 | *unresolved_reloc_p = FALSE; |
b7693d02 DJ |
4161 | } |
4162 | ||
ba96a88f | 4163 | relocation = value + signed_addend; |
f21f3fe0 | 4164 | |
252b5132 | 4165 | relocation -= (input_section->output_section->vma |
ba96a88f NC |
4166 | + input_section->output_offset |
4167 | + rel->r_offset); | |
9a5aca8c | 4168 | |
252b5132 RH |
4169 | check = relocation >> howto->rightshift; |
4170 | ||
4171 | /* If this is a signed value, the rightshift just dropped | |
4172 | leading 1 bits (assuming twos complement). */ | |
4173 | if ((bfd_signed_vma) relocation >= 0) | |
4174 | signed_check = check; | |
4175 | else | |
4176 | signed_check = check | ~((bfd_vma) -1 >> howto->rightshift); | |
4177 | ||
e95de063 MS |
4178 | /* Calculate the permissable maximum and minimum values for |
4179 | this relocation according to whether we're relocating for | |
4180 | Thumb-2 or not. */ | |
4181 | bitsize = howto->bitsize; | |
4182 | if (!thumb2) | |
4183 | bitsize -= 2; | |
4184 | reloc_signed_max = ((1 << (bitsize - 1)) - 1) >> howto->rightshift; | |
4185 | reloc_signed_min = ~reloc_signed_max; | |
4186 | ||
252b5132 | 4187 | /* Assumes two's complement. */ |
ba96a88f | 4188 | if (signed_check > reloc_signed_max || signed_check < reloc_signed_min) |
b34976b6 | 4189 | overflow = TRUE; |
252b5132 | 4190 | |
39b41c9c | 4191 | if ((lower_insn & 0x1800) == 0x0800) |
c62e1cc3 NC |
4192 | /* For a BLX instruction, make sure that the relocation is rounded up |
4193 | to a word boundary. This follows the semantics of the instruction | |
4194 | which specifies that bit 1 of the target address will come from bit | |
4195 | 1 of the base address. */ | |
4196 | relocation = (relocation + 2) & ~ 3; | |
cb1afa5c | 4197 | |
e95de063 MS |
4198 | /* Put RELOCATION back into the insn. Assumes two's complement. |
4199 | We use the Thumb-2 encoding, which is safe even if dealing with | |
4200 | a Thumb-1 instruction by virtue of our overflow check above. */ | |
4201 | reloc_sign = (signed_check < 0) ? 1 : 0; | |
4202 | upper_insn = (upper_insn & ~(bfd_vma) 0x7ff) | |
4203 | | ((relocation >> 12) & 0x3ff) | |
4204 | | (reloc_sign << 10); | |
4205 | lower_insn = (lower_insn & ~(bfd_vma) 0x2fff) | |
4206 | | (((!((relocation >> 23) & 1)) ^ reloc_sign) << 13) | |
4207 | | (((!((relocation >> 22) & 1)) ^ reloc_sign) << 11) | |
4208 | | ((relocation >> 1) & 0x7ff); | |
c62e1cc3 | 4209 | |
252b5132 RH |
4210 | /* Put the relocated value back in the object file: */ |
4211 | bfd_put_16 (input_bfd, upper_insn, hit_data); | |
4212 | bfd_put_16 (input_bfd, lower_insn, hit_data + 2); | |
4213 | ||
4214 | return (overflow ? bfd_reloc_overflow : bfd_reloc_ok); | |
4215 | } | |
4216 | break; | |
4217 | ||
c19d1205 ZW |
4218 | case R_ARM_THM_JUMP24: |
4219 | /* Thumb32 unconditional branch instruction. */ | |
4220 | { | |
4221 | bfd_vma relocation; | |
4222 | bfd_boolean overflow = FALSE; | |
4223 | bfd_vma upper_insn = bfd_get_16 (input_bfd, hit_data); | |
4224 | bfd_vma lower_insn = bfd_get_16 (input_bfd, hit_data + 2); | |
4225 | bfd_signed_vma reloc_signed_max = ((1 << (howto->bitsize - 1)) - 1) >> howto->rightshift; | |
4226 | bfd_signed_vma reloc_signed_min = ~ reloc_signed_max; | |
4227 | bfd_vma check; | |
4228 | bfd_signed_vma signed_check; | |
4229 | ||
4230 | /* Need to refetch the addend, reconstruct the top three bits, and glue the | |
4231 | two pieces together. */ | |
4232 | if (globals->use_rel) | |
4233 | { | |
4234 | bfd_vma S = (upper_insn & 0x0400) >> 10; | |
4235 | bfd_vma hi = (upper_insn & 0x03ff); | |
4236 | bfd_vma I1 = (lower_insn & 0x2000) >> 13; | |
4237 | bfd_vma I2 = (lower_insn & 0x0800) >> 11; | |
4238 | bfd_vma lo = (lower_insn & 0x07ff); | |
4239 | ||
4240 | I1 = !(I1 ^ S); | |
4241 | I2 = !(I2 ^ S); | |
4242 | S = !S; | |
4243 | ||
4244 | signed_addend = (S << 24) | (I1 << 23) | (I2 << 22) | (hi << 12) | (lo << 1); | |
4245 | signed_addend -= (1 << 24); /* Sign extend. */ | |
4246 | } | |
4247 | ||
4248 | /* ??? Should handle interworking? GCC might someday try to | |
4249 | use this for tail calls. */ | |
4250 | ||
4251 | relocation = value + signed_addend; | |
4252 | relocation -= (input_section->output_section->vma | |
4253 | + input_section->output_offset | |
4254 | + rel->r_offset); | |
4255 | ||
4256 | check = relocation >> howto->rightshift; | |
4257 | ||
4258 | /* If this is a signed value, the rightshift just dropped | |
4259 | leading 1 bits (assuming twos complement). */ | |
4260 | if ((bfd_signed_vma) relocation >= 0) | |
4261 | signed_check = check; | |
4262 | else | |
4263 | signed_check = check | ~((bfd_vma) -1 >> howto->rightshift); | |
4264 | ||
4265 | /* Assumes two's complement. */ | |
4266 | if (signed_check > reloc_signed_max || signed_check < reloc_signed_min) | |
4267 | overflow = TRUE; | |
4268 | ||
4269 | /* Put RELOCATION back into the insn. */ | |
4270 | { | |
4271 | bfd_vma S = (relocation & 0x01000000) >> 24; | |
4272 | bfd_vma I1 = (relocation & 0x00800000) >> 23; | |
4273 | bfd_vma I2 = (relocation & 0x00400000) >> 22; | |
4274 | bfd_vma hi = (relocation & 0x003ff000) >> 12; | |
4275 | bfd_vma lo = (relocation & 0x00000ffe) >> 1; | |
4276 | ||
4277 | I1 = !(I1 ^ S); | |
4278 | I2 = !(I2 ^ S); | |
4279 | ||
4280 | upper_insn = (upper_insn & (bfd_vma) 0xf800) | (S << 10) | hi; | |
4281 | lower_insn = (lower_insn & (bfd_vma) 0xd000) | (I1 << 13) | (I2 << 11) | lo; | |
4282 | } | |
4283 | ||
4284 | /* Put the relocated value back in the object file: */ | |
4285 | bfd_put_16 (input_bfd, upper_insn, hit_data); | |
4286 | bfd_put_16 (input_bfd, lower_insn, hit_data + 2); | |
4287 | ||
4288 | return (overflow ? bfd_reloc_overflow : bfd_reloc_ok); | |
4289 | } | |
4290 | ||
4291 | case R_ARM_THM_JUMP19: | |
4292 | /* Thumb32 conditional branch instruction. */ | |
4293 | { | |
4294 | bfd_vma relocation; | |
4295 | bfd_boolean overflow = FALSE; | |
4296 | bfd_vma upper_insn = bfd_get_16 (input_bfd, hit_data); | |
4297 | bfd_vma lower_insn = bfd_get_16 (input_bfd, hit_data + 2); | |
4298 | bfd_signed_vma reloc_signed_max = ((1 << (howto->bitsize - 1)) - 1) >> howto->rightshift; | |
4299 | bfd_signed_vma reloc_signed_min = ~ reloc_signed_max; | |
4300 | bfd_vma check; | |
4301 | bfd_signed_vma signed_check; | |
4302 | ||
4303 | /* Need to refetch the addend, reconstruct the top three bits, | |
4304 | and squish the two 11 bit pieces together. */ | |
4305 | if (globals->use_rel) | |
4306 | { | |
4307 | bfd_vma S = (upper_insn & 0x0400) >> 10; | |
4308 | bfd_vma upper = (upper_insn & 0x001f); | |
4309 | bfd_vma J1 = (lower_insn & 0x2000) >> 13; | |
4310 | bfd_vma J2 = (lower_insn & 0x0800) >> 11; | |
4311 | bfd_vma lower = (lower_insn & 0x07ff); | |
4312 | ||
4313 | upper |= J2 << 6; | |
4314 | upper |= J1 << 7; | |
4315 | upper |= ~S << 8; | |
4316 | upper -= 0x0100; /* Sign extend. */ | |
4317 | ||
4318 | addend = (upper << 12) | (lower << 1); | |
4319 | signed_addend = addend; | |
4320 | } | |
4321 | ||
4322 | /* ??? Should handle interworking? GCC might someday try to | |
4323 | use this for tail calls. */ | |
4324 | ||
4325 | relocation = value + signed_addend; | |
4326 | relocation -= (input_section->output_section->vma | |
4327 | + input_section->output_offset | |
4328 | + rel->r_offset); | |
4329 | ||
4330 | check = relocation >> howto->rightshift; | |
4331 | ||
4332 | /* If this is a signed value, the rightshift just dropped | |
4333 | leading 1 bits (assuming twos complement). */ | |
4334 | if ((bfd_signed_vma) relocation >= 0) | |
4335 | signed_check = check; | |
4336 | else | |
4337 | signed_check = check | ~((bfd_vma) -1 >> howto->rightshift); | |
4338 | ||
4339 | /* Assumes two's complement. */ | |
4340 | if (signed_check > reloc_signed_max || signed_check < reloc_signed_min) | |
4341 | overflow = TRUE; | |
4342 | ||
4343 | /* Put RELOCATION back into the insn. */ | |
4344 | { | |
4345 | bfd_vma S = (relocation & 0x00100000) >> 20; | |
4346 | bfd_vma J2 = (relocation & 0x00080000) >> 19; | |
4347 | bfd_vma J1 = (relocation & 0x00040000) >> 18; | |
4348 | bfd_vma hi = (relocation & 0x0003f000) >> 12; | |
4349 | bfd_vma lo = (relocation & 0x00000ffe) >> 1; | |
4350 | ||
4351 | upper_insn = (upper_insn & 0xfb30) | (S << 10) | hi; | |
4352 | lower_insn = (lower_insn & 0xd000) | (J1 << 13) | (J2 << 11) | lo; | |
4353 | } | |
4354 | ||
4355 | /* Put the relocated value back in the object file: */ | |
4356 | bfd_put_16 (input_bfd, upper_insn, hit_data); | |
4357 | bfd_put_16 (input_bfd, lower_insn, hit_data + 2); | |
4358 | ||
4359 | return (overflow ? bfd_reloc_overflow : bfd_reloc_ok); | |
4360 | } | |
4361 | ||
4362 | case R_ARM_THM_JUMP11: | |
4363 | case R_ARM_THM_JUMP8: | |
4364 | case R_ARM_THM_JUMP6: | |
51c5503b NC |
4365 | /* Thumb B (branch) instruction). */ |
4366 | { | |
6cf9e9fe | 4367 | bfd_signed_vma relocation; |
51c5503b NC |
4368 | bfd_signed_vma reloc_signed_max = (1 << (howto->bitsize - 1)) - 1; |
4369 | bfd_signed_vma reloc_signed_min = ~ reloc_signed_max; | |
51c5503b NC |
4370 | bfd_signed_vma signed_check; |
4371 | ||
c19d1205 ZW |
4372 | /* CZB cannot jump backward. */ |
4373 | if (r_type == R_ARM_THM_JUMP6) | |
4374 | reloc_signed_min = 0; | |
4375 | ||
4e7fd91e | 4376 | if (globals->use_rel) |
6cf9e9fe | 4377 | { |
4e7fd91e PB |
4378 | /* Need to refetch addend. */ |
4379 | addend = bfd_get_16 (input_bfd, hit_data) & howto->src_mask; | |
4380 | if (addend & ((howto->src_mask + 1) >> 1)) | |
4381 | { | |
4382 | signed_addend = -1; | |
4383 | signed_addend &= ~ howto->src_mask; | |
4384 | signed_addend |= addend; | |
4385 | } | |
4386 | else | |
4387 | signed_addend = addend; | |
4388 | /* The value in the insn has been right shifted. We need to | |
4389 | undo this, so that we can perform the address calculation | |
4390 | in terms of bytes. */ | |
4391 | signed_addend <<= howto->rightshift; | |
6cf9e9fe | 4392 | } |
6cf9e9fe | 4393 | relocation = value + signed_addend; |
51c5503b NC |
4394 | |
4395 | relocation -= (input_section->output_section->vma | |
4396 | + input_section->output_offset | |
4397 | + rel->r_offset); | |
4398 | ||
6cf9e9fe NC |
4399 | relocation >>= howto->rightshift; |
4400 | signed_check = relocation; | |
c19d1205 ZW |
4401 | |
4402 | if (r_type == R_ARM_THM_JUMP6) | |
4403 | relocation = ((relocation & 0x0020) << 4) | ((relocation & 0x001f) << 3); | |
4404 | else | |
4405 | relocation &= howto->dst_mask; | |
51c5503b | 4406 | relocation |= (bfd_get_16 (input_bfd, hit_data) & (~ howto->dst_mask)); |
cedb70c5 | 4407 | |
51c5503b NC |
4408 | bfd_put_16 (input_bfd, relocation, hit_data); |
4409 | ||
4410 | /* Assumes two's complement. */ | |
4411 | if (signed_check > reloc_signed_max || signed_check < reloc_signed_min) | |
4412 | return bfd_reloc_overflow; | |
4413 | ||
4414 | return bfd_reloc_ok; | |
4415 | } | |
cedb70c5 | 4416 | |
8375c36b PB |
4417 | case R_ARM_ALU_PCREL7_0: |
4418 | case R_ARM_ALU_PCREL15_8: | |
4419 | case R_ARM_ALU_PCREL23_15: | |
4420 | { | |
4421 | bfd_vma insn; | |
4422 | bfd_vma relocation; | |
4423 | ||
4424 | insn = bfd_get_32 (input_bfd, hit_data); | |
4e7fd91e PB |
4425 | if (globals->use_rel) |
4426 | { | |
4427 | /* Extract the addend. */ | |
4428 | addend = (insn & 0xff) << ((insn & 0xf00) >> 7); | |
4429 | signed_addend = addend; | |
4430 | } | |
8375c36b PB |
4431 | relocation = value + signed_addend; |
4432 | ||
4433 | relocation -= (input_section->output_section->vma | |
4434 | + input_section->output_offset | |
4435 | + rel->r_offset); | |
4436 | insn = (insn & ~0xfff) | |
4437 | | ((howto->bitpos << 7) & 0xf00) | |
4438 | | ((relocation >> howto->bitpos) & 0xff); | |
4439 | bfd_put_32 (input_bfd, value, hit_data); | |
4440 | } | |
4441 | return bfd_reloc_ok; | |
4442 | ||
252b5132 RH |
4443 | case R_ARM_GNU_VTINHERIT: |
4444 | case R_ARM_GNU_VTENTRY: | |
4445 | return bfd_reloc_ok; | |
4446 | ||
c19d1205 | 4447 | case R_ARM_GOTOFF32: |
252b5132 RH |
4448 | /* Relocation is relative to the start of the |
4449 | global offset table. */ | |
4450 | ||
4451 | BFD_ASSERT (sgot != NULL); | |
4452 | if (sgot == NULL) | |
4453 | return bfd_reloc_notsupported; | |
9a5aca8c | 4454 | |
cedb70c5 | 4455 | /* If we are addressing a Thumb function, we need to adjust the |
ee29b9fb RE |
4456 | address by one, so that attempts to call the function pointer will |
4457 | correctly interpret it as Thumb code. */ | |
4458 | if (sym_flags == STT_ARM_TFUNC) | |
4459 | value += 1; | |
4460 | ||
252b5132 RH |
4461 | /* Note that sgot->output_offset is not involved in this |
4462 | calculation. We always want the start of .got. If we | |
4463 | define _GLOBAL_OFFSET_TABLE in a different way, as is | |
4464 | permitted by the ABI, we might have to change this | |
9b485d32 | 4465 | calculation. */ |
252b5132 | 4466 | value -= sgot->output_section->vma; |
f21f3fe0 | 4467 | return _bfd_final_link_relocate (howto, input_bfd, input_section, |
99e4ae17 | 4468 | contents, rel->r_offset, value, |
00a97672 | 4469 | rel->r_addend); |
252b5132 RH |
4470 | |
4471 | case R_ARM_GOTPC: | |
a7c10850 | 4472 | /* Use global offset table as symbol value. */ |
252b5132 | 4473 | BFD_ASSERT (sgot != NULL); |
f21f3fe0 | 4474 | |
252b5132 RH |
4475 | if (sgot == NULL) |
4476 | return bfd_reloc_notsupported; | |
4477 | ||
0945cdfd | 4478 | *unresolved_reloc_p = FALSE; |
252b5132 | 4479 | value = sgot->output_section->vma; |
f21f3fe0 | 4480 | return _bfd_final_link_relocate (howto, input_bfd, input_section, |
99e4ae17 | 4481 | contents, rel->r_offset, value, |
00a97672 | 4482 | rel->r_addend); |
f21f3fe0 | 4483 | |
252b5132 | 4484 | case R_ARM_GOT32: |
eb043451 | 4485 | case R_ARM_GOT_PREL: |
252b5132 | 4486 | /* Relocation is to the entry for this symbol in the |
9b485d32 | 4487 | global offset table. */ |
252b5132 RH |
4488 | if (sgot == NULL) |
4489 | return bfd_reloc_notsupported; | |
f21f3fe0 | 4490 | |
252b5132 RH |
4491 | if (h != NULL) |
4492 | { | |
4493 | bfd_vma off; | |
5e681ec4 | 4494 | bfd_boolean dyn; |
f21f3fe0 | 4495 | |
252b5132 RH |
4496 | off = h->got.offset; |
4497 | BFD_ASSERT (off != (bfd_vma) -1); | |
5e681ec4 | 4498 | dyn = globals->root.dynamic_sections_created; |
f21f3fe0 | 4499 | |
5e681ec4 | 4500 | if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h) |
50d6c878 | 4501 | || (info->shared |
5e681ec4 PB |
4502 | && SYMBOL_REFERENCES_LOCAL (info, h)) |
4503 | || (ELF_ST_VISIBILITY (h->other) | |
4504 | && h->root.type == bfd_link_hash_undefweak)) | |
252b5132 RH |
4505 | { |
4506 | /* This is actually a static link, or it is a -Bsymbolic link | |
4507 | and the symbol is defined locally. We must initialize this | |
4508 | entry in the global offset table. Since the offset must | |
4509 | always be a multiple of 4, we use the least significant bit | |
4510 | to record whether we have initialized it already. | |
f21f3fe0 | 4511 | |
00a97672 | 4512 | When doing a dynamic link, we create a .rel(a).got relocation |
f21f3fe0 | 4513 | entry to initialize the value. This is done in the |
9b485d32 | 4514 | finish_dynamic_symbol routine. */ |
252b5132 RH |
4515 | if ((off & 1) != 0) |
4516 | off &= ~1; | |
4517 | else | |
4518 | { | |
ee29b9fb RE |
4519 | /* If we are addressing a Thumb function, we need to |
4520 | adjust the address by one, so that attempts to | |
4521 | call the function pointer will correctly | |
4522 | interpret it as Thumb code. */ | |
4523 | if (sym_flags == STT_ARM_TFUNC) | |
4524 | value |= 1; | |
4525 | ||
252b5132 RH |
4526 | bfd_put_32 (output_bfd, value, sgot->contents + off); |
4527 | h->got.offset |= 1; | |
4528 | } | |
4529 | } | |
0945cdfd DJ |
4530 | else |
4531 | *unresolved_reloc_p = FALSE; | |
f21f3fe0 | 4532 | |
252b5132 RH |
4533 | value = sgot->output_offset + off; |
4534 | } | |
4535 | else | |
4536 | { | |
4537 | bfd_vma off; | |
f21f3fe0 | 4538 | |
252b5132 RH |
4539 | BFD_ASSERT (local_got_offsets != NULL && |
4540 | local_got_offsets[r_symndx] != (bfd_vma) -1); | |
f21f3fe0 | 4541 | |
252b5132 | 4542 | off = local_got_offsets[r_symndx]; |
f21f3fe0 | 4543 | |
252b5132 RH |
4544 | /* The offset must always be a multiple of 4. We use the |
4545 | least significant bit to record whether we have already | |
9b485d32 | 4546 | generated the necessary reloc. */ |
252b5132 RH |
4547 | if ((off & 1) != 0) |
4548 | off &= ~1; | |
4549 | else | |
4550 | { | |
b7693d02 DJ |
4551 | /* If we are addressing a Thumb function, we need to |
4552 | adjust the address by one, so that attempts to | |
4553 | call the function pointer will correctly | |
4554 | interpret it as Thumb code. */ | |
4555 | if (sym_flags == STT_ARM_TFUNC) | |
4556 | value |= 1; | |
4557 | ||
00a97672 RS |
4558 | if (globals->use_rel) |
4559 | bfd_put_32 (output_bfd, value, sgot->contents + off); | |
f21f3fe0 | 4560 | |
252b5132 RH |
4561 | if (info->shared) |
4562 | { | |
4563 | asection * srelgot; | |
947216bf AM |
4564 | Elf_Internal_Rela outrel; |
4565 | bfd_byte *loc; | |
f21f3fe0 | 4566 | |
00a97672 RS |
4567 | srelgot = (bfd_get_section_by_name |
4568 | (dynobj, RELOC_SECTION (globals, ".got"))); | |
252b5132 | 4569 | BFD_ASSERT (srelgot != NULL); |
f21f3fe0 | 4570 | |
00a97672 | 4571 | outrel.r_addend = addend + value; |
252b5132 | 4572 | outrel.r_offset = (sgot->output_section->vma |
f21f3fe0 | 4573 | + sgot->output_offset |
252b5132 RH |
4574 | + off); |
4575 | outrel.r_info = ELF32_R_INFO (0, R_ARM_RELATIVE); | |
947216bf | 4576 | loc = srelgot->contents; |
00a97672 RS |
4577 | loc += srelgot->reloc_count++ * RELOC_SIZE (globals); |
4578 | SWAP_RELOC_OUT (globals) (output_bfd, &outrel, loc); | |
252b5132 | 4579 | } |
f21f3fe0 | 4580 | |
252b5132 RH |
4581 | local_got_offsets[r_symndx] |= 1; |
4582 | } | |
f21f3fe0 | 4583 | |
252b5132 RH |
4584 | value = sgot->output_offset + off; |
4585 | } | |
eb043451 PB |
4586 | if (r_type != R_ARM_GOT32) |
4587 | value += sgot->output_section->vma; | |
9a5aca8c | 4588 | |
f21f3fe0 | 4589 | return _bfd_final_link_relocate (howto, input_bfd, input_section, |
99e4ae17 | 4590 | contents, rel->r_offset, value, |
00a97672 | 4591 | rel->r_addend); |
f21f3fe0 | 4592 | |
ba93b8ac DJ |
4593 | case R_ARM_TLS_LDO32: |
4594 | value = value - dtpoff_base (info); | |
4595 | ||
4596 | return _bfd_final_link_relocate (howto, input_bfd, input_section, | |
00a97672 RS |
4597 | contents, rel->r_offset, value, |
4598 | rel->r_addend); | |
ba93b8ac DJ |
4599 | |
4600 | case R_ARM_TLS_LDM32: | |
4601 | { | |
4602 | bfd_vma off; | |
4603 | ||
4604 | if (globals->sgot == NULL) | |
4605 | abort (); | |
4606 | ||
4607 | off = globals->tls_ldm_got.offset; | |
4608 | ||
4609 | if ((off & 1) != 0) | |
4610 | off &= ~1; | |
4611 | else | |
4612 | { | |
4613 | /* If we don't know the module number, create a relocation | |
4614 | for it. */ | |
4615 | if (info->shared) | |
4616 | { | |
4617 | Elf_Internal_Rela outrel; | |
4618 | bfd_byte *loc; | |
4619 | ||
4620 | if (globals->srelgot == NULL) | |
4621 | abort (); | |
4622 | ||
00a97672 | 4623 | outrel.r_addend = 0; |
ba93b8ac DJ |
4624 | outrel.r_offset = (globals->sgot->output_section->vma |
4625 | + globals->sgot->output_offset + off); | |
4626 | outrel.r_info = ELF32_R_INFO (0, R_ARM_TLS_DTPMOD32); | |
4627 | ||
00a97672 RS |
4628 | if (globals->use_rel) |
4629 | bfd_put_32 (output_bfd, outrel.r_addend, | |
4630 | globals->sgot->contents + off); | |
ba93b8ac DJ |
4631 | |
4632 | loc = globals->srelgot->contents; | |
00a97672 RS |
4633 | loc += globals->srelgot->reloc_count++ * RELOC_SIZE (globals); |
4634 | SWAP_RELOC_OUT (globals) (output_bfd, &outrel, loc); | |
ba93b8ac DJ |
4635 | } |
4636 | else | |
4637 | bfd_put_32 (output_bfd, 1, globals->sgot->contents + off); | |
4638 | ||
4639 | globals->tls_ldm_got.offset |= 1; | |
4640 | } | |
4641 | ||
4642 | value = globals->sgot->output_section->vma + globals->sgot->output_offset + off | |
4643 | - (input_section->output_section->vma + input_section->output_offset + rel->r_offset); | |
4644 | ||
4645 | return _bfd_final_link_relocate (howto, input_bfd, input_section, | |
4646 | contents, rel->r_offset, value, | |
00a97672 | 4647 | rel->r_addend); |
ba93b8ac DJ |
4648 | } |
4649 | ||
4650 | case R_ARM_TLS_GD32: | |
4651 | case R_ARM_TLS_IE32: | |
4652 | { | |
4653 | bfd_vma off; | |
4654 | int indx; | |
4655 | char tls_type; | |
4656 | ||
4657 | if (globals->sgot == NULL) | |
4658 | abort (); | |
4659 | ||
4660 | indx = 0; | |
4661 | if (h != NULL) | |
4662 | { | |
4663 | bfd_boolean dyn; | |
4664 | dyn = globals->root.dynamic_sections_created; | |
4665 | if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h) | |
4666 | && (!info->shared | |
4667 | || !SYMBOL_REFERENCES_LOCAL (info, h))) | |
4668 | { | |
4669 | *unresolved_reloc_p = FALSE; | |
4670 | indx = h->dynindx; | |
4671 | } | |
4672 | off = h->got.offset; | |
4673 | tls_type = ((struct elf32_arm_link_hash_entry *) h)->tls_type; | |
4674 | } | |
4675 | else | |
4676 | { | |
4677 | if (local_got_offsets == NULL) | |
4678 | abort (); | |
4679 | off = local_got_offsets[r_symndx]; | |
4680 | tls_type = elf32_arm_local_got_tls_type (input_bfd)[r_symndx]; | |
4681 | } | |
4682 | ||
4683 | if (tls_type == GOT_UNKNOWN) | |
4684 | abort (); | |
4685 | ||
4686 | if ((off & 1) != 0) | |
4687 | off &= ~1; | |
4688 | else | |
4689 | { | |
4690 | bfd_boolean need_relocs = FALSE; | |
4691 | Elf_Internal_Rela outrel; | |
4692 | bfd_byte *loc = NULL; | |
4693 | int cur_off = off; | |
4694 | ||
4695 | /* The GOT entries have not been initialized yet. Do it | |
4696 | now, and emit any relocations. If both an IE GOT and a | |
4697 | GD GOT are necessary, we emit the GD first. */ | |
4698 | ||
4699 | if ((info->shared || indx != 0) | |
4700 | && (h == NULL | |
4701 | || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT | |
4702 | || h->root.type != bfd_link_hash_undefweak)) | |
4703 | { | |
4704 | need_relocs = TRUE; | |
4705 | if (globals->srelgot == NULL) | |
4706 | abort (); | |
4707 | loc = globals->srelgot->contents; | |
00a97672 | 4708 | loc += globals->srelgot->reloc_count * RELOC_SIZE (globals); |
ba93b8ac DJ |
4709 | } |
4710 | ||
4711 | if (tls_type & GOT_TLS_GD) | |
4712 | { | |
4713 | if (need_relocs) | |
4714 | { | |
00a97672 | 4715 | outrel.r_addend = 0; |
ba93b8ac | 4716 | outrel.r_offset = (globals->sgot->output_section->vma |
00a97672 RS |
4717 | + globals->sgot->output_offset |
4718 | + cur_off); | |
ba93b8ac | 4719 | outrel.r_info = ELF32_R_INFO (indx, R_ARM_TLS_DTPMOD32); |
ba93b8ac | 4720 | |
00a97672 RS |
4721 | if (globals->use_rel) |
4722 | bfd_put_32 (output_bfd, outrel.r_addend, | |
4723 | globals->sgot->contents + cur_off); | |
4724 | ||
4725 | SWAP_RELOC_OUT (globals) (output_bfd, &outrel, loc); | |
ba93b8ac | 4726 | globals->srelgot->reloc_count++; |
00a97672 | 4727 | loc += RELOC_SIZE (globals); |
ba93b8ac DJ |
4728 | |
4729 | if (indx == 0) | |
4730 | bfd_put_32 (output_bfd, value - dtpoff_base (info), | |
4731 | globals->sgot->contents + cur_off + 4); | |
4732 | else | |
4733 | { | |
00a97672 | 4734 | outrel.r_addend = 0; |
ba93b8ac DJ |
4735 | outrel.r_info = ELF32_R_INFO (indx, |
4736 | R_ARM_TLS_DTPOFF32); | |
4737 | outrel.r_offset += 4; | |
00a97672 RS |
4738 | |
4739 | if (globals->use_rel) | |
4740 | bfd_put_32 (output_bfd, outrel.r_addend, | |
4741 | globals->sgot->contents + cur_off + 4); | |
4742 | ||
4743 | ||
4744 | SWAP_RELOC_OUT (globals) (output_bfd, &outrel, loc); | |
ba93b8ac | 4745 | globals->srelgot->reloc_count++; |
00a97672 | 4746 | loc += RELOC_SIZE (globals); |
ba93b8ac DJ |
4747 | } |
4748 | } | |
4749 | else | |
4750 | { | |
4751 | /* If we are not emitting relocations for a | |
4752 | general dynamic reference, then we must be in a | |
4753 | static link or an executable link with the | |
4754 | symbol binding locally. Mark it as belonging | |
4755 | to module 1, the executable. */ | |
4756 | bfd_put_32 (output_bfd, 1, | |
4757 | globals->sgot->contents + cur_off); | |
4758 | bfd_put_32 (output_bfd, value - dtpoff_base (info), | |
4759 | globals->sgot->contents + cur_off + 4); | |
4760 | } | |
4761 | ||
4762 | cur_off += 8; | |
4763 | } | |
4764 | ||
4765 | if (tls_type & GOT_TLS_IE) | |
4766 | { | |
4767 | if (need_relocs) | |
4768 | { | |
00a97672 RS |
4769 | if (indx == 0) |
4770 | outrel.r_addend = value - dtpoff_base (info); | |
4771 | else | |
4772 | outrel.r_addend = 0; | |
ba93b8ac DJ |
4773 | outrel.r_offset = (globals->sgot->output_section->vma |
4774 | + globals->sgot->output_offset | |
4775 | + cur_off); | |
4776 | outrel.r_info = ELF32_R_INFO (indx, R_ARM_TLS_TPOFF32); | |
4777 | ||
00a97672 RS |
4778 | if (globals->use_rel) |
4779 | bfd_put_32 (output_bfd, outrel.r_addend, | |
ba93b8ac DJ |
4780 | globals->sgot->contents + cur_off); |
4781 | ||
00a97672 | 4782 | SWAP_RELOC_OUT (globals) (output_bfd, &outrel, loc); |
ba93b8ac | 4783 | globals->srelgot->reloc_count++; |
00a97672 | 4784 | loc += RELOC_SIZE (globals); |
ba93b8ac DJ |
4785 | } |
4786 | else | |
4787 | bfd_put_32 (output_bfd, tpoff (info, value), | |
4788 | globals->sgot->contents + cur_off); | |
4789 | cur_off += 4; | |
4790 | } | |
4791 | ||
4792 | if (h != NULL) | |
4793 | h->got.offset |= 1; | |
4794 | else | |
4795 | local_got_offsets[r_symndx] |= 1; | |
4796 | } | |
4797 | ||
4798 | if ((tls_type & GOT_TLS_GD) && r_type != R_ARM_TLS_GD32) | |
4799 | off += 8; | |
4800 | value = globals->sgot->output_section->vma + globals->sgot->output_offset + off | |
4801 | - (input_section->output_section->vma + input_section->output_offset + rel->r_offset); | |
4802 | ||
4803 | return _bfd_final_link_relocate (howto, input_bfd, input_section, | |
4804 | contents, rel->r_offset, value, | |
00a97672 | 4805 | rel->r_addend); |
ba93b8ac DJ |
4806 | } |
4807 | ||
4808 | case R_ARM_TLS_LE32: | |
4809 | if (info->shared) | |
4810 | { | |
4811 | (*_bfd_error_handler) | |
4812 | (_("%B(%A+0x%lx): R_ARM_TLS_LE32 relocation not permitted in shared object"), | |
4813 | input_bfd, input_section, | |
4814 | (long) rel->r_offset, howto->name); | |
4815 | return FALSE; | |
4816 | } | |
4817 | else | |
4818 | value = tpoff (info, value); | |
4819 | ||
4820 | return _bfd_final_link_relocate (howto, input_bfd, input_section, | |
00a97672 RS |
4821 | contents, rel->r_offset, value, |
4822 | rel->r_addend); | |
ba93b8ac | 4823 | |
319850b4 JB |
4824 | case R_ARM_V4BX: |
4825 | if (globals->fix_v4bx) | |
4826 | { | |
4827 | bfd_vma insn = bfd_get_32 (input_bfd, hit_data); | |
4828 | ||
4829 | /* Ensure that we have a BX instruction. */ | |
4830 | BFD_ASSERT ((insn & 0x0ffffff0) == 0x012fff10); | |
4831 | ||
4832 | /* Preserve Rm (lowest four bits) and the condition code | |
4833 | (highest four bits). Other bits encode MOV PC,Rm. */ | |
4834 | insn = (insn & 0xf000000f) | 0x01a0f000; | |
4835 | ||
4836 | bfd_put_32 (input_bfd, insn, hit_data); | |
4837 | } | |
4838 | return bfd_reloc_ok; | |
4839 | ||
b6895b4f PB |
4840 | case R_ARM_MOVW_ABS_NC: |
4841 | case R_ARM_MOVT_ABS: | |
4842 | case R_ARM_MOVW_PREL_NC: | |
4843 | case R_ARM_MOVT_PREL: | |
92f5d02b MS |
4844 | /* Until we properly support segment-base-relative addressing then |
4845 | we assume the segment base to be zero, as for the group relocations. | |
4846 | Thus R_ARM_MOVW_BREL_NC has the same semantics as R_ARM_MOVW_ABS_NC | |
4847 | and R_ARM_MOVT_BREL has the same semantics as R_ARM_MOVT_ABS. */ | |
4848 | case R_ARM_MOVW_BREL_NC: | |
4849 | case R_ARM_MOVW_BREL: | |
4850 | case R_ARM_MOVT_BREL: | |
b6895b4f PB |
4851 | { |
4852 | bfd_vma insn = bfd_get_32 (input_bfd, hit_data); | |
4853 | ||
4854 | if (globals->use_rel) | |
4855 | { | |
4856 | addend = ((insn >> 4) & 0xf000) | (insn & 0xfff); | |
4857 | signed_addend = (addend ^ 0x10000) - 0x10000; | |
4858 | } | |
92f5d02b | 4859 | |
b6895b4f | 4860 | value += signed_addend; |
b6895b4f PB |
4861 | |
4862 | if (r_type == R_ARM_MOVW_PREL_NC || r_type == R_ARM_MOVT_PREL) | |
4863 | value -= (input_section->output_section->vma | |
4864 | + input_section->output_offset + rel->r_offset); | |
4865 | ||
92f5d02b MS |
4866 | if (r_type == R_ARM_MOVW_BREL && value >= 0x10000) |
4867 | return bfd_reloc_overflow; | |
4868 | ||
4869 | if (sym_flags == STT_ARM_TFUNC) | |
4870 | value |= 1; | |
4871 | ||
4872 | if (r_type == R_ARM_MOVT_ABS || r_type == R_ARM_MOVT_PREL | |
4873 | || r_type == R_ARM_MOVT_BREL) | |
b6895b4f PB |
4874 | value >>= 16; |
4875 | ||
4876 | insn &= 0xfff0f000; | |
4877 | insn |= value & 0xfff; | |
4878 | insn |= (value & 0xf000) << 4; | |
4879 | bfd_put_32 (input_bfd, insn, hit_data); | |
4880 | } | |
4881 | return bfd_reloc_ok; | |
4882 | ||
4883 | case R_ARM_THM_MOVW_ABS_NC: | |
4884 | case R_ARM_THM_MOVT_ABS: | |
4885 | case R_ARM_THM_MOVW_PREL_NC: | |
4886 | case R_ARM_THM_MOVT_PREL: | |
92f5d02b MS |
4887 | /* Until we properly support segment-base-relative addressing then |
4888 | we assume the segment base to be zero, as for the above relocations. | |
4889 | Thus R_ARM_THM_MOVW_BREL_NC has the same semantics as | |
4890 | R_ARM_THM_MOVW_ABS_NC and R_ARM_THM_MOVT_BREL has the same semantics | |
4891 | as R_ARM_THM_MOVT_ABS. */ | |
4892 | case R_ARM_THM_MOVW_BREL_NC: | |
4893 | case R_ARM_THM_MOVW_BREL: | |
4894 | case R_ARM_THM_MOVT_BREL: | |
b6895b4f PB |
4895 | { |
4896 | bfd_vma insn; | |
4897 | ||
4898 | insn = bfd_get_16 (input_bfd, hit_data) << 16; | |
4899 | insn |= bfd_get_16 (input_bfd, hit_data + 2); | |
4900 | ||
4901 | if (globals->use_rel) | |
4902 | { | |
4903 | addend = ((insn >> 4) & 0xf000) | |
4904 | | ((insn >> 15) & 0x0800) | |
4905 | | ((insn >> 4) & 0x0700) | |
4906 | | (insn & 0x00ff); | |
4907 | signed_addend = (addend ^ 0x10000) - 0x10000; | |
4908 | } | |
92f5d02b | 4909 | |
b6895b4f | 4910 | value += signed_addend; |
b6895b4f PB |
4911 | |
4912 | if (r_type == R_ARM_THM_MOVW_PREL_NC || r_type == R_ARM_THM_MOVT_PREL) | |
4913 | value -= (input_section->output_section->vma | |
4914 | + input_section->output_offset + rel->r_offset); | |
4915 | ||
92f5d02b MS |
4916 | if (r_type == R_ARM_THM_MOVW_BREL && value >= 0x10000) |
4917 | return bfd_reloc_overflow; | |
4918 | ||
4919 | if (sym_flags == STT_ARM_TFUNC) | |
4920 | value |= 1; | |
4921 | ||
4922 | if (r_type == R_ARM_THM_MOVT_ABS || r_type == R_ARM_THM_MOVT_PREL | |
4923 | || r_type == R_ARM_THM_MOVT_BREL) | |
b6895b4f PB |
4924 | value >>= 16; |
4925 | ||
4926 | insn &= 0xfbf08f00; | |
4927 | insn |= (value & 0xf000) << 4; | |
4928 | insn |= (value & 0x0800) << 15; | |
4929 | insn |= (value & 0x0700) << 4; | |
4930 | insn |= (value & 0x00ff); | |
4931 | ||
4932 | bfd_put_16 (input_bfd, insn >> 16, hit_data); | |
4933 | bfd_put_16 (input_bfd, insn & 0xffff, hit_data + 2); | |
4934 | } | |
4935 | return bfd_reloc_ok; | |
4936 | ||
4962c51a MS |
4937 | case R_ARM_ALU_PC_G0_NC: |
4938 | case R_ARM_ALU_PC_G1_NC: | |
4939 | case R_ARM_ALU_PC_G0: | |
4940 | case R_ARM_ALU_PC_G1: | |
4941 | case R_ARM_ALU_PC_G2: | |
4942 | case R_ARM_ALU_SB_G0_NC: | |
4943 | case R_ARM_ALU_SB_G1_NC: | |
4944 | case R_ARM_ALU_SB_G0: | |
4945 | case R_ARM_ALU_SB_G1: | |
4946 | case R_ARM_ALU_SB_G2: | |
4947 | { | |
4948 | bfd_vma insn = bfd_get_32 (input_bfd, hit_data); | |
4949 | bfd_vma pc = input_section->output_section->vma | |
4950 | + input_section->output_offset + rel->r_offset; | |
4951 | /* sb should be the origin of the *segment* containing the symbol. | |
4952 | It is not clear how to obtain this OS-dependent value, so we | |
4953 | make an arbitrary choice of zero. */ | |
4954 | bfd_vma sb = 0; | |
4955 | bfd_vma residual; | |
4956 | bfd_vma g_n; | |
4957 | bfd_signed_vma signed_value; | |
4958 | int group = 0; | |
4959 | ||
4960 | /* Determine which group of bits to select. */ | |
4961 | switch (r_type) | |
4962 | { | |
4963 | case R_ARM_ALU_PC_G0_NC: | |
4964 | case R_ARM_ALU_PC_G0: | |
4965 | case R_ARM_ALU_SB_G0_NC: | |
4966 | case R_ARM_ALU_SB_G0: | |
4967 | group = 0; | |
4968 | break; | |
4969 | ||
4970 | case R_ARM_ALU_PC_G1_NC: | |
4971 | case R_ARM_ALU_PC_G1: | |
4972 | case R_ARM_ALU_SB_G1_NC: | |
4973 | case R_ARM_ALU_SB_G1: | |
4974 | group = 1; | |
4975 | break; | |
4976 | ||
4977 | case R_ARM_ALU_PC_G2: | |
4978 | case R_ARM_ALU_SB_G2: | |
4979 | group = 2; | |
4980 | break; | |
4981 | ||
4982 | default: | |
4983 | abort(); | |
4984 | } | |
4985 | ||
4986 | /* If REL, extract the addend from the insn. If RELA, it will | |
4987 | have already been fetched for us. */ | |
4988 | if (globals->use_rel) | |
4989 | { | |
4990 | int negative; | |
4991 | bfd_vma constant = insn & 0xff; | |
4992 | bfd_vma rotation = (insn & 0xf00) >> 8; | |
4993 | ||
4994 | if (rotation == 0) | |
4995 | signed_addend = constant; | |
4996 | else | |
4997 | { | |
4998 | /* Compensate for the fact that in the instruction, the | |
4999 | rotation is stored in multiples of 2 bits. */ | |
5000 | rotation *= 2; | |
5001 | ||
5002 | /* Rotate "constant" right by "rotation" bits. */ | |
5003 | signed_addend = (constant >> rotation) | | |
5004 | (constant << (8 * sizeof (bfd_vma) - rotation)); | |
5005 | } | |
5006 | ||
5007 | /* Determine if the instruction is an ADD or a SUB. | |
5008 | (For REL, this determines the sign of the addend.) */ | |
5009 | negative = identify_add_or_sub (insn); | |
5010 | if (negative == 0) | |
5011 | { | |
5012 | (*_bfd_error_handler) | |
5013 | (_("%B(%A+0x%lx): Only ADD or SUB instructions are allowed for ALU group relocations"), | |
5014 | input_bfd, input_section, | |
5015 | (long) rel->r_offset, howto->name); | |
5016 | return bfd_reloc_overflow; | |
5017 | } | |
5018 | ||
5019 | signed_addend *= negative; | |
5020 | } | |
5021 | ||
5022 | /* Compute the value (X) to go in the place. */ | |
5023 | if (r_type == R_ARM_ALU_PC_G0_NC | |
5024 | || r_type == R_ARM_ALU_PC_G1_NC | |
5025 | || r_type == R_ARM_ALU_PC_G0 | |
5026 | || r_type == R_ARM_ALU_PC_G1 | |
5027 | || r_type == R_ARM_ALU_PC_G2) | |
5028 | /* PC relative. */ | |
5029 | signed_value = value - pc + signed_addend; | |
5030 | else | |
5031 | /* Section base relative. */ | |
5032 | signed_value = value - sb + signed_addend; | |
5033 | ||
5034 | /* If the target symbol is a Thumb function, then set the | |
5035 | Thumb bit in the address. */ | |
5036 | if (sym_flags == STT_ARM_TFUNC) | |
5037 | signed_value |= 1; | |
5038 | ||
5039 | /* Calculate the value of the relevant G_n, in encoded | |
5040 | constant-with-rotation format. */ | |
5041 | g_n = calculate_group_reloc_mask (abs (signed_value), group, | |
5042 | &residual); | |
5043 | ||
5044 | /* Check for overflow if required. */ | |
5045 | if ((r_type == R_ARM_ALU_PC_G0 | |
5046 | || r_type == R_ARM_ALU_PC_G1 | |
5047 | || r_type == R_ARM_ALU_PC_G2 | |
5048 | || r_type == R_ARM_ALU_SB_G0 | |
5049 | || r_type == R_ARM_ALU_SB_G1 | |
5050 | || r_type == R_ARM_ALU_SB_G2) && residual != 0) | |
5051 | { | |
5052 | (*_bfd_error_handler) | |
5053 | (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"), | |
5054 | input_bfd, input_section, | |
5055 | (long) rel->r_offset, abs (signed_value), howto->name); | |
5056 | return bfd_reloc_overflow; | |
5057 | } | |
5058 | ||
5059 | /* Mask out the value and the ADD/SUB part of the opcode; take care | |
5060 | not to destroy the S bit. */ | |
5061 | insn &= 0xff1ff000; | |
5062 | ||
5063 | /* Set the opcode according to whether the value to go in the | |
5064 | place is negative. */ | |
5065 | if (signed_value < 0) | |
5066 | insn |= 1 << 22; | |
5067 | else | |
5068 | insn |= 1 << 23; | |
5069 | ||
5070 | /* Encode the offset. */ | |
5071 | insn |= g_n; | |
5072 | ||
5073 | bfd_put_32 (input_bfd, insn, hit_data); | |
5074 | } | |
5075 | return bfd_reloc_ok; | |
5076 | ||
5077 | case R_ARM_LDR_PC_G0: | |
5078 | case R_ARM_LDR_PC_G1: | |
5079 | case R_ARM_LDR_PC_G2: | |
5080 | case R_ARM_LDR_SB_G0: | |
5081 | case R_ARM_LDR_SB_G1: | |
5082 | case R_ARM_LDR_SB_G2: | |
5083 | { | |
5084 | bfd_vma insn = bfd_get_32 (input_bfd, hit_data); | |
5085 | bfd_vma pc = input_section->output_section->vma | |
5086 | + input_section->output_offset + rel->r_offset; | |
5087 | bfd_vma sb = 0; /* See note above. */ | |
5088 | bfd_vma residual; | |
5089 | bfd_signed_vma signed_value; | |
5090 | int group = 0; | |
5091 | ||
5092 | /* Determine which groups of bits to calculate. */ | |
5093 | switch (r_type) | |
5094 | { | |
5095 | case R_ARM_LDR_PC_G0: | |
5096 | case R_ARM_LDR_SB_G0: | |
5097 | group = 0; | |
5098 | break; | |
5099 | ||
5100 | case R_ARM_LDR_PC_G1: | |
5101 | case R_ARM_LDR_SB_G1: | |
5102 | group = 1; | |
5103 | break; | |
5104 | ||
5105 | case R_ARM_LDR_PC_G2: | |
5106 | case R_ARM_LDR_SB_G2: | |
5107 | group = 2; | |
5108 | break; | |
5109 | ||
5110 | default: | |
5111 | abort(); | |
5112 | } | |
5113 | ||
5114 | /* If REL, extract the addend from the insn. If RELA, it will | |
5115 | have already been fetched for us. */ | |
5116 | if (globals->use_rel) | |
5117 | { | |
5118 | int negative = (insn & (1 << 23)) ? 1 : -1; | |
5119 | signed_addend = negative * (insn & 0xfff); | |
5120 | } | |
5121 | ||
5122 | /* Compute the value (X) to go in the place. */ | |
5123 | if (r_type == R_ARM_LDR_PC_G0 | |
5124 | || r_type == R_ARM_LDR_PC_G1 | |
5125 | || r_type == R_ARM_LDR_PC_G2) | |
5126 | /* PC relative. */ | |
5127 | signed_value = value - pc + signed_addend; | |
5128 | else | |
5129 | /* Section base relative. */ | |
5130 | signed_value = value - sb + signed_addend; | |
5131 | ||
5132 | /* Calculate the value of the relevant G_{n-1} to obtain | |
5133 | the residual at that stage. */ | |
5134 | calculate_group_reloc_mask (abs (signed_value), group - 1, &residual); | |
5135 | ||
5136 | /* Check for overflow. */ | |
5137 | if (residual >= 0x1000) | |
5138 | { | |
5139 | (*_bfd_error_handler) | |
5140 | (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"), | |
5141 | input_bfd, input_section, | |
5142 | (long) rel->r_offset, abs (signed_value), howto->name); | |
5143 | return bfd_reloc_overflow; | |
5144 | } | |
5145 | ||
5146 | /* Mask out the value and U bit. */ | |
5147 | insn &= 0xff7ff000; | |
5148 | ||
5149 | /* Set the U bit if the value to go in the place is non-negative. */ | |
5150 | if (signed_value >= 0) | |
5151 | insn |= 1 << 23; | |
5152 | ||
5153 | /* Encode the offset. */ | |
5154 | insn |= residual; | |
5155 | ||
5156 | bfd_put_32 (input_bfd, insn, hit_data); | |
5157 | } | |
5158 | return bfd_reloc_ok; | |
5159 | ||
5160 | case R_ARM_LDRS_PC_G0: | |
5161 | case R_ARM_LDRS_PC_G1: | |
5162 | case R_ARM_LDRS_PC_G2: | |
5163 | case R_ARM_LDRS_SB_G0: | |
5164 | case R_ARM_LDRS_SB_G1: | |
5165 | case R_ARM_LDRS_SB_G2: | |
5166 | { | |
5167 | bfd_vma insn = bfd_get_32 (input_bfd, hit_data); | |
5168 | bfd_vma pc = input_section->output_section->vma | |
5169 | + input_section->output_offset + rel->r_offset; | |
5170 | bfd_vma sb = 0; /* See note above. */ | |
5171 | bfd_vma residual; | |
5172 | bfd_signed_vma signed_value; | |
5173 | int group = 0; | |
5174 | ||
5175 | /* Determine which groups of bits to calculate. */ | |
5176 | switch (r_type) | |
5177 | { | |
5178 | case R_ARM_LDRS_PC_G0: | |
5179 | case R_ARM_LDRS_SB_G0: | |
5180 | group = 0; | |
5181 | break; | |
5182 | ||
5183 | case R_ARM_LDRS_PC_G1: | |
5184 | case R_ARM_LDRS_SB_G1: | |
5185 | group = 1; | |
5186 | break; | |
5187 | ||
5188 | case R_ARM_LDRS_PC_G2: | |
5189 | case R_ARM_LDRS_SB_G2: | |
5190 | group = 2; | |
5191 | break; | |
5192 | ||
5193 | default: | |
5194 | abort(); | |
5195 | } | |
5196 | ||
5197 | /* If REL, extract the addend from the insn. If RELA, it will | |
5198 | have already been fetched for us. */ | |
5199 | if (globals->use_rel) | |
5200 | { | |
5201 | int negative = (insn & (1 << 23)) ? 1 : -1; | |
5202 | signed_addend = negative * (((insn & 0xf00) >> 4) + (insn & 0xf)); | |
5203 | } | |
5204 | ||
5205 | /* Compute the value (X) to go in the place. */ | |
5206 | if (r_type == R_ARM_LDRS_PC_G0 | |
5207 | || r_type == R_ARM_LDRS_PC_G1 | |
5208 | || r_type == R_ARM_LDRS_PC_G2) | |
5209 | /* PC relative. */ | |
5210 | signed_value = value - pc + signed_addend; | |
5211 | else | |
5212 | /* Section base relative. */ | |
5213 | signed_value = value - sb + signed_addend; | |
5214 | ||
5215 | /* Calculate the value of the relevant G_{n-1} to obtain | |
5216 | the residual at that stage. */ | |
5217 | calculate_group_reloc_mask (abs (signed_value), group - 1, &residual); | |
5218 | ||
5219 | /* Check for overflow. */ | |
5220 | if (residual >= 0x100) | |
5221 | { | |
5222 | (*_bfd_error_handler) | |
5223 | (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"), | |
5224 | input_bfd, input_section, | |
5225 | (long) rel->r_offset, abs (signed_value), howto->name); | |
5226 | return bfd_reloc_overflow; | |
5227 | } | |
5228 | ||
5229 | /* Mask out the value and U bit. */ | |
5230 | insn &= 0xff7ff0f0; | |
5231 | ||
5232 | /* Set the U bit if the value to go in the place is non-negative. */ | |
5233 | if (signed_value >= 0) | |
5234 | insn |= 1 << 23; | |
5235 | ||
5236 | /* Encode the offset. */ | |
5237 | insn |= ((residual & 0xf0) << 4) | (residual & 0xf); | |
5238 | ||
5239 | bfd_put_32 (input_bfd, insn, hit_data); | |
5240 | } | |
5241 | return bfd_reloc_ok; | |
5242 | ||
5243 | case R_ARM_LDC_PC_G0: | |
5244 | case R_ARM_LDC_PC_G1: | |
5245 | case R_ARM_LDC_PC_G2: | |
5246 | case R_ARM_LDC_SB_G0: | |
5247 | case R_ARM_LDC_SB_G1: | |
5248 | case R_ARM_LDC_SB_G2: | |
5249 | { | |
5250 | bfd_vma insn = bfd_get_32 (input_bfd, hit_data); | |
5251 | bfd_vma pc = input_section->output_section->vma | |
5252 | + input_section->output_offset + rel->r_offset; | |
5253 | bfd_vma sb = 0; /* See note above. */ | |
5254 | bfd_vma residual; | |
5255 | bfd_signed_vma signed_value; | |
5256 | int group = 0; | |
5257 | ||
5258 | /* Determine which groups of bits to calculate. */ | |
5259 | switch (r_type) | |
5260 | { | |
5261 | case R_ARM_LDC_PC_G0: | |
5262 | case R_ARM_LDC_SB_G0: | |
5263 | group = 0; | |
5264 | break; | |
5265 | ||
5266 | case R_ARM_LDC_PC_G1: | |
5267 | case R_ARM_LDC_SB_G1: | |
5268 | group = 1; | |
5269 | break; | |
5270 | ||
5271 | case R_ARM_LDC_PC_G2: | |
5272 | case R_ARM_LDC_SB_G2: | |
5273 | group = 2; | |
5274 | break; | |
5275 | ||
5276 | default: | |
5277 | abort(); | |
5278 | } | |
5279 | ||
5280 | /* If REL, extract the addend from the insn. If RELA, it will | |
5281 | have already been fetched for us. */ | |
5282 | if (globals->use_rel) | |
5283 | { | |
5284 | int negative = (insn & (1 << 23)) ? 1 : -1; | |
5285 | signed_addend = negative * ((insn & 0xff) << 2); | |
5286 | } | |
5287 | ||
5288 | /* Compute the value (X) to go in the place. */ | |
5289 | if (r_type == R_ARM_LDC_PC_G0 | |
5290 | || r_type == R_ARM_LDC_PC_G1 | |
5291 | || r_type == R_ARM_LDC_PC_G2) | |
5292 | /* PC relative. */ | |
5293 | signed_value = value - pc + signed_addend; | |
5294 | else | |
5295 | /* Section base relative. */ | |
5296 | signed_value = value - sb + signed_addend; | |
5297 | ||
5298 | /* Calculate the value of the relevant G_{n-1} to obtain | |
5299 | the residual at that stage. */ | |
5300 | calculate_group_reloc_mask (abs (signed_value), group - 1, &residual); | |
5301 | ||
5302 | /* Check for overflow. (The absolute value to go in the place must be | |
5303 | divisible by four and, after having been divided by four, must | |
5304 | fit in eight bits.) */ | |
5305 | if ((residual & 0x3) != 0 || residual >= 0x400) | |
5306 | { | |
5307 | (*_bfd_error_handler) | |
5308 | (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"), | |
5309 | input_bfd, input_section, | |
5310 | (long) rel->r_offset, abs (signed_value), howto->name); | |
5311 | return bfd_reloc_overflow; | |
5312 | } | |
5313 | ||
5314 | /* Mask out the value and U bit. */ | |
5315 | insn &= 0xff7fff00; | |
5316 | ||
5317 | /* Set the U bit if the value to go in the place is non-negative. */ | |
5318 | if (signed_value >= 0) | |
5319 | insn |= 1 << 23; | |
5320 | ||
5321 | /* Encode the offset. */ | |
5322 | insn |= residual >> 2; | |
5323 | ||
5324 | bfd_put_32 (input_bfd, insn, hit_data); | |
5325 | } | |
5326 | return bfd_reloc_ok; | |
5327 | ||
252b5132 RH |
5328 | default: |
5329 | return bfd_reloc_notsupported; | |
5330 | } | |
5331 | } | |
5332 | ||
ee065d83 PB |
5333 | |
5334 | static int | |
5335 | uleb128_size (unsigned int i) | |
5336 | { | |
5337 | int size; | |
5338 | size = 1; | |
5339 | while (i >= 0x80) | |
5340 | { | |
5341 | i >>= 7; | |
5342 | size++; | |
5343 | } | |
5344 | return size; | |
5345 | } | |
5346 | ||
5347 | /* Return TRUE if the attribute has the default value (0/""). */ | |
5348 | static bfd_boolean | |
5349 | is_default_attr (aeabi_attribute *attr) | |
5350 | { | |
5351 | if ((attr->type & 1) && attr->i != 0) | |
5352 | return FALSE; | |
5353 | if ((attr->type & 2) && attr->s && *attr->s) | |
5354 | return FALSE; | |
5355 | ||
5356 | return TRUE; | |
5357 | } | |
5358 | ||
5359 | /* Return the size of a single attribute. */ | |
5360 | static bfd_vma | |
5361 | eabi_attr_size(int tag, aeabi_attribute *attr) | |
5362 | { | |
5363 | bfd_vma size; | |
5364 | ||
5365 | if (is_default_attr (attr)) | |
5366 | return 0; | |
5367 | ||
5368 | size = uleb128_size (tag); | |
5369 | if (attr->type & 1) | |
5370 | size += uleb128_size (attr->i); | |
5371 | if (attr->type & 2) | |
5372 | size += strlen ((char *)attr->s) + 1; | |
5373 | return size; | |
5374 | } | |
5375 | ||
5376 | /* Returns the size of the eabi object attributess section. */ | |
5377 | bfd_vma | |
5378 | elf32_arm_eabi_attr_size (bfd *abfd) | |
5379 | { | |
5380 | bfd_vma size; | |
5381 | aeabi_attribute *attr; | |
5382 | aeabi_attribute_list *list; | |
5383 | int i; | |
5384 | ||
5385 | attr = elf32_arm_tdata (abfd)->known_eabi_attributes; | |
5386 | size = 16; /* 'A' <size> "aeabi" 0x1 <size>. */ | |
5387 | for (i = 4; i < NUM_KNOWN_ATTRIBUTES; i++) | |
5388 | size += eabi_attr_size (i, &attr[i]); | |
5389 | ||
5390 | for (list = elf32_arm_tdata (abfd)->other_eabi_attributes; | |
5391 | list; | |
5392 | list = list->next) | |
5393 | size += eabi_attr_size (list->tag, &list->attr); | |
5394 | ||
5395 | return size; | |
5396 | } | |
5397 | ||
5398 | static bfd_byte * | |
5399 | write_uleb128 (bfd_byte *p, unsigned int val) | |
5400 | { | |
5401 | bfd_byte c; | |
5402 | do | |
5403 | { | |
5404 | c = val & 0x7f; | |
5405 | val >>= 7; | |
5406 | if (val) | |
5407 | c |= 0x80; | |
5408 | *(p++) = c; | |
5409 | } | |
5410 | while (val); | |
5411 | return p; | |
5412 | } | |
5413 | ||
5414 | /* Write attribute ATTR to butter P, and return a pointer to the following | |
5415 | byte. */ | |
5416 | static bfd_byte * | |
5417 | write_eabi_attribute (bfd_byte *p, int tag, aeabi_attribute *attr) | |
5418 | { | |
5419 | /* Suppress default entries. */ | |
5420 | if (is_default_attr(attr)) | |
5421 | return p; | |
5422 | ||
5423 | p = write_uleb128 (p, tag); | |
5424 | if (attr->type & 1) | |
5425 | p = write_uleb128 (p, attr->i); | |
5426 | if (attr->type & 2) | |
5427 | { | |
5428 | int len; | |
5429 | ||
5430 | len = strlen (attr->s) + 1; | |
5431 | memcpy (p, attr->s, len); | |
5432 | p += len; | |
5433 | } | |
5434 | ||
5435 | return p; | |
5436 | } | |
5437 | ||
5438 | /* Write the contents of the eabi attributes section to p. */ | |
5439 | void | |
5440 | elf32_arm_set_eabi_attr_contents (bfd *abfd, bfd_byte *contents, bfd_vma size) | |
5441 | { | |
5442 | bfd_byte *p; | |
5443 | aeabi_attribute *attr; | |
5444 | aeabi_attribute_list *list; | |
5445 | int i; | |
5446 | ||
5447 | p = contents; | |
5448 | *(p++) = 'A'; | |
5449 | bfd_put_32 (abfd, size - 1, p); | |
5450 | p += 4; | |
5451 | memcpy (p, "aeabi", 6); | |
5452 | p += 6; | |
5453 | *(p++) = Tag_File; | |
5454 | bfd_put_32 (abfd, size - 11, p); | |
5455 | p += 4; | |
5456 | ||
5457 | attr = elf32_arm_tdata (abfd)->known_eabi_attributes; | |
5458 | for (i = 4; i < NUM_KNOWN_ATTRIBUTES; i++) | |
5459 | p = write_eabi_attribute (p, i, &attr[i]); | |
5460 | ||
5461 | for (list = elf32_arm_tdata (abfd)->other_eabi_attributes; | |
5462 | list; | |
5463 | list = list->next) | |
5464 | p = write_eabi_attribute (p, list->tag, &list->attr); | |
5465 | } | |
5466 | ||
5467 | /* Override final_link to handle EABI object attribute sections. */ | |
5468 | ||
5469 | static bfd_boolean | |
5470 | elf32_arm_bfd_final_link (bfd *abfd, struct bfd_link_info *info) | |
5471 | { | |
5472 | asection *o; | |
5473 | struct bfd_link_order *p; | |
5474 | asection *attr_section = NULL; | |
5475 | bfd_byte *contents; | |
5476 | bfd_vma size = 0; | |
5477 | ||
5478 | /* elf32_arm_merge_private_bfd_data will already have merged the | |
5479 | object attributes. Remove the input sections from the link, and set | |
5480 | the contents of the output secton. */ | |
5481 | for (o = abfd->sections; o != NULL; o = o->next) | |
5482 | { | |
5483 | if (strcmp (o->name, ".ARM.attributes") == 0) | |
5484 | { | |
5485 | for (p = o->map_head.link_order; p != NULL; p = p->next) | |
5486 | { | |
5487 | asection *input_section; | |
5488 | ||
5489 | if (p->type != bfd_indirect_link_order) | |
5490 | continue; | |
5491 | input_section = p->u.indirect.section; | |
5492 | /* Hack: reset the SEC_HAS_CONTENTS flag so that | |
5493 | elf_link_input_bfd ignores this section. */ | |
5494 | input_section->flags &= ~SEC_HAS_CONTENTS; | |
5495 | } | |
5496 | ||
5497 | size = elf32_arm_eabi_attr_size (abfd); | |
5498 | bfd_set_section_size (abfd, o, size); | |
5499 | attr_section = o; | |
5500 | /* Skip this section later on. */ | |
5501 | o->map_head.link_order = NULL; | |
5502 | } | |
5503 | } | |
5504 | /* Invoke the ELF linker to do all the work. */ | |
5505 | if (!bfd_elf_final_link (abfd, info)) | |
5506 | return FALSE; | |
5507 | ||
5508 | if (attr_section) | |
5509 | { | |
5510 | contents = bfd_malloc(size); | |
5511 | if (contents == NULL) | |
5512 | return FALSE; | |
5513 | elf32_arm_set_eabi_attr_contents (abfd, contents, size); | |
5514 | bfd_set_section_contents (abfd, attr_section, contents, 0, size); | |
5515 | free (contents); | |
5516 | } | |
5517 | return TRUE; | |
5518 | } | |
5519 | ||
5520 | ||
98c1d4aa NC |
5521 | /* Add INCREMENT to the reloc (of type HOWTO) at ADDRESS. */ |
5522 | static void | |
57e8b36a NC |
5523 | arm_add_to_rel (bfd * abfd, |
5524 | bfd_byte * address, | |
5525 | reloc_howto_type * howto, | |
5526 | bfd_signed_vma increment) | |
98c1d4aa | 5527 | { |
98c1d4aa NC |
5528 | bfd_signed_vma addend; |
5529 | ||
c19d1205 | 5530 | if (howto->type == R_ARM_THM_CALL) |
98c1d4aa | 5531 | { |
9a5aca8c AM |
5532 | int upper_insn, lower_insn; |
5533 | int upper, lower; | |
98c1d4aa | 5534 | |
9a5aca8c AM |
5535 | upper_insn = bfd_get_16 (abfd, address); |
5536 | lower_insn = bfd_get_16 (abfd, address + 2); | |
5537 | upper = upper_insn & 0x7ff; | |
5538 | lower = lower_insn & 0x7ff; | |
5539 | ||
5540 | addend = (upper << 12) | (lower << 1); | |
ddda4409 | 5541 | addend += increment; |
9a5aca8c | 5542 | addend >>= 1; |
98c1d4aa | 5543 | |
9a5aca8c AM |
5544 | upper_insn = (upper_insn & 0xf800) | ((addend >> 11) & 0x7ff); |
5545 | lower_insn = (lower_insn & 0xf800) | (addend & 0x7ff); | |
5546 | ||
dc810e39 AM |
5547 | bfd_put_16 (abfd, (bfd_vma) upper_insn, address); |
5548 | bfd_put_16 (abfd, (bfd_vma) lower_insn, address + 2); | |
9a5aca8c AM |
5549 | } |
5550 | else | |
5551 | { | |
5552 | bfd_vma contents; | |
5553 | ||
5554 | contents = bfd_get_32 (abfd, address); | |
5555 | ||
5556 | /* Get the (signed) value from the instruction. */ | |
5557 | addend = contents & howto->src_mask; | |
5558 | if (addend & ((howto->src_mask + 1) >> 1)) | |
5559 | { | |
5560 | bfd_signed_vma mask; | |
5561 | ||
5562 | mask = -1; | |
5563 | mask &= ~ howto->src_mask; | |
5564 | addend |= mask; | |
5565 | } | |
5566 | ||
5567 | /* Add in the increment, (which is a byte value). */ | |
5568 | switch (howto->type) | |
5569 | { | |
5570 | default: | |
5571 | addend += increment; | |
5572 | break; | |
5573 | ||
5574 | case R_ARM_PC24: | |
c6596c5e | 5575 | case R_ARM_PLT32: |
5b5bb741 PB |
5576 | case R_ARM_CALL: |
5577 | case R_ARM_JUMP24: | |
9a5aca8c | 5578 | addend <<= howto->size; |
dc810e39 | 5579 | addend += increment; |
9a5aca8c AM |
5580 | |
5581 | /* Should we check for overflow here ? */ | |
5582 | ||
5583 | /* Drop any undesired bits. */ | |
5584 | addend >>= howto->rightshift; | |
5585 | break; | |
5586 | } | |
5587 | ||
5588 | contents = (contents & ~ howto->dst_mask) | (addend & howto->dst_mask); | |
5589 | ||
5590 | bfd_put_32 (abfd, contents, address); | |
ddda4409 | 5591 | } |
98c1d4aa | 5592 | } |
252b5132 | 5593 | |
ba93b8ac DJ |
5594 | #define IS_ARM_TLS_RELOC(R_TYPE) \ |
5595 | ((R_TYPE) == R_ARM_TLS_GD32 \ | |
5596 | || (R_TYPE) == R_ARM_TLS_LDO32 \ | |
5597 | || (R_TYPE) == R_ARM_TLS_LDM32 \ | |
5598 | || (R_TYPE) == R_ARM_TLS_DTPOFF32 \ | |
5599 | || (R_TYPE) == R_ARM_TLS_DTPMOD32 \ | |
5600 | || (R_TYPE) == R_ARM_TLS_TPOFF32 \ | |
5601 | || (R_TYPE) == R_ARM_TLS_LE32 \ | |
5602 | || (R_TYPE) == R_ARM_TLS_IE32) | |
5603 | ||
252b5132 | 5604 | /* Relocate an ARM ELF section. */ |
b34976b6 | 5605 | static bfd_boolean |
57e8b36a NC |
5606 | elf32_arm_relocate_section (bfd * output_bfd, |
5607 | struct bfd_link_info * info, | |
5608 | bfd * input_bfd, | |
5609 | asection * input_section, | |
5610 | bfd_byte * contents, | |
5611 | Elf_Internal_Rela * relocs, | |
5612 | Elf_Internal_Sym * local_syms, | |
5613 | asection ** local_sections) | |
252b5132 | 5614 | { |
b34976b6 AM |
5615 | Elf_Internal_Shdr *symtab_hdr; |
5616 | struct elf_link_hash_entry **sym_hashes; | |
5617 | Elf_Internal_Rela *rel; | |
5618 | Elf_Internal_Rela *relend; | |
5619 | const char *name; | |
b32d3aa2 | 5620 | struct elf32_arm_link_hash_table * globals; |
252b5132 | 5621 | |
4e7fd91e PB |
5622 | globals = elf32_arm_hash_table (info); |
5623 | if (info->relocatable && !globals->use_rel) | |
b34976b6 | 5624 | return TRUE; |
b491616a | 5625 | |
252b5132 RH |
5626 | symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr; |
5627 | sym_hashes = elf_sym_hashes (input_bfd); | |
5628 | ||
5629 | rel = relocs; | |
5630 | relend = relocs + input_section->reloc_count; | |
5631 | for (; rel < relend; rel++) | |
5632 | { | |
ba96a88f NC |
5633 | int r_type; |
5634 | reloc_howto_type * howto; | |
5635 | unsigned long r_symndx; | |
5636 | Elf_Internal_Sym * sym; | |
5637 | asection * sec; | |
252b5132 | 5638 | struct elf_link_hash_entry * h; |
ba96a88f NC |
5639 | bfd_vma relocation; |
5640 | bfd_reloc_status_type r; | |
5641 | arelent bfd_reloc; | |
ba93b8ac | 5642 | char sym_type; |
0945cdfd | 5643 | bfd_boolean unresolved_reloc = FALSE; |
f21f3fe0 | 5644 | |
252b5132 | 5645 | r_symndx = ELF32_R_SYM (rel->r_info); |
ba96a88f | 5646 | r_type = ELF32_R_TYPE (rel->r_info); |
b32d3aa2 | 5647 | r_type = arm_real_reloc_type (globals, r_type); |
252b5132 | 5648 | |
ba96a88f NC |
5649 | if ( r_type == R_ARM_GNU_VTENTRY |
5650 | || r_type == R_ARM_GNU_VTINHERIT) | |
252b5132 RH |
5651 | continue; |
5652 | ||
b32d3aa2 | 5653 | bfd_reloc.howto = elf32_arm_howto_from_type (r_type); |
ba96a88f | 5654 | howto = bfd_reloc.howto; |
252b5132 | 5655 | |
4e7fd91e | 5656 | if (info->relocatable && globals->use_rel) |
252b5132 | 5657 | { |
1049f94e | 5658 | /* This is a relocatable link. We don't have to change |
252b5132 RH |
5659 | anything, unless the reloc is against a section symbol, |
5660 | in which case we have to adjust according to where the | |
5661 | section symbol winds up in the output section. */ | |
5662 | if (r_symndx < symtab_hdr->sh_info) | |
5663 | { | |
5664 | sym = local_syms + r_symndx; | |
5665 | if (ELF_ST_TYPE (sym->st_info) == STT_SECTION) | |
5666 | { | |
5667 | sec = local_sections[r_symndx]; | |
98c1d4aa | 5668 | arm_add_to_rel (input_bfd, contents + rel->r_offset, |
dc810e39 AM |
5669 | howto, |
5670 | (bfd_signed_vma) (sec->output_offset | |
5671 | + sym->st_value)); | |
252b5132 RH |
5672 | } |
5673 | } | |
5674 | ||
5675 | continue; | |
5676 | } | |
5677 | ||
5678 | /* This is a final link. */ | |
5679 | h = NULL; | |
5680 | sym = NULL; | |
5681 | sec = NULL; | |
9b485d32 | 5682 | |
252b5132 RH |
5683 | if (r_symndx < symtab_hdr->sh_info) |
5684 | { | |
5685 | sym = local_syms + r_symndx; | |
ba93b8ac | 5686 | sym_type = ELF32_ST_TYPE (sym->st_info); |
252b5132 | 5687 | sec = local_sections[r_symndx]; |
4e7fd91e | 5688 | if (globals->use_rel) |
f8df10f4 | 5689 | { |
4e7fd91e PB |
5690 | relocation = (sec->output_section->vma |
5691 | + sec->output_offset | |
5692 | + sym->st_value); | |
5693 | if ((sec->flags & SEC_MERGE) | |
5694 | && ELF_ST_TYPE (sym->st_info) == STT_SECTION) | |
f8df10f4 | 5695 | { |
4e7fd91e PB |
5696 | asection *msec; |
5697 | bfd_vma addend, value; | |
5698 | ||
5699 | if (howto->rightshift) | |
5700 | { | |
5701 | (*_bfd_error_handler) | |
5702 | (_("%B(%A+0x%lx): %s relocation against SEC_MERGE section"), | |
5703 | input_bfd, input_section, | |
5704 | (long) rel->r_offset, howto->name); | |
5705 | return FALSE; | |
5706 | } | |
f8df10f4 | 5707 | |
4e7fd91e | 5708 | value = bfd_get_32 (input_bfd, contents + rel->r_offset); |
f8df10f4 | 5709 | |
4e7fd91e PB |
5710 | /* Get the (signed) value from the instruction. */ |
5711 | addend = value & howto->src_mask; | |
5712 | if (addend & ((howto->src_mask + 1) >> 1)) | |
5713 | { | |
5714 | bfd_signed_vma mask; | |
f8df10f4 | 5715 | |
4e7fd91e PB |
5716 | mask = -1; |
5717 | mask &= ~ howto->src_mask; | |
5718 | addend |= mask; | |
5719 | } | |
5720 | msec = sec; | |
5721 | addend = | |
5722 | _bfd_elf_rel_local_sym (output_bfd, sym, &msec, addend) | |
5723 | - relocation; | |
5724 | addend += msec->output_section->vma + msec->output_offset; | |
5725 | value = (value & ~ howto->dst_mask) | (addend & howto->dst_mask); | |
5726 | bfd_put_32 (input_bfd, value, contents + rel->r_offset); | |
f8df10f4 | 5727 | } |
f8df10f4 | 5728 | } |
4e7fd91e PB |
5729 | else |
5730 | relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel); | |
252b5132 RH |
5731 | } |
5732 | else | |
5733 | { | |
560e09e9 | 5734 | bfd_boolean warned; |
560e09e9 | 5735 | |
b2a8e766 AM |
5736 | RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, |
5737 | r_symndx, symtab_hdr, sym_hashes, | |
5738 | h, sec, relocation, | |
5739 | unresolved_reloc, warned); | |
ba93b8ac DJ |
5740 | |
5741 | sym_type = h->type; | |
252b5132 RH |
5742 | } |
5743 | ||
5744 | if (h != NULL) | |
5745 | name = h->root.root.string; | |
5746 | else | |
5747 | { | |
5748 | name = (bfd_elf_string_from_elf_section | |
5749 | (input_bfd, symtab_hdr->sh_link, sym->st_name)); | |
5750 | if (name == NULL || *name == '\0') | |
5751 | name = bfd_section_name (input_bfd, sec); | |
5752 | } | |
f21f3fe0 | 5753 | |
ba93b8ac DJ |
5754 | if (r_symndx != 0 |
5755 | && r_type != R_ARM_NONE | |
5756 | && (h == NULL | |
5757 | || h->root.type == bfd_link_hash_defined | |
5758 | || h->root.type == bfd_link_hash_defweak) | |
5759 | && IS_ARM_TLS_RELOC (r_type) != (sym_type == STT_TLS)) | |
5760 | { | |
5761 | (*_bfd_error_handler) | |
5762 | ((sym_type == STT_TLS | |
5763 | ? _("%B(%A+0x%lx): %s used with TLS symbol %s") | |
5764 | : _("%B(%A+0x%lx): %s used with non-TLS symbol %s")), | |
5765 | input_bfd, | |
5766 | input_section, | |
5767 | (long) rel->r_offset, | |
5768 | howto->name, | |
5769 | name); | |
5770 | } | |
5771 | ||
252b5132 RH |
5772 | r = elf32_arm_final_link_relocate (howto, input_bfd, output_bfd, |
5773 | input_section, contents, rel, | |
5774 | relocation, info, sec, name, | |
5775 | (h ? ELF_ST_TYPE (h->type) : | |
0945cdfd DJ |
5776 | ELF_ST_TYPE (sym->st_info)), h, |
5777 | &unresolved_reloc); | |
5778 | ||
5779 | /* Dynamic relocs are not propagated for SEC_DEBUGGING sections | |
5780 | because such sections are not SEC_ALLOC and thus ld.so will | |
5781 | not process them. */ | |
5782 | if (unresolved_reloc | |
5783 | && !((input_section->flags & SEC_DEBUGGING) != 0 | |
5784 | && h->def_dynamic)) | |
5785 | { | |
5786 | (*_bfd_error_handler) | |
843fe662 L |
5787 | (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"), |
5788 | input_bfd, | |
5789 | input_section, | |
5790 | (long) rel->r_offset, | |
5791 | howto->name, | |
5792 | h->root.root.string); | |
0945cdfd DJ |
5793 | return FALSE; |
5794 | } | |
252b5132 RH |
5795 | |
5796 | if (r != bfd_reloc_ok) | |
5797 | { | |
5798 | const char * msg = (const char *) 0; | |
5799 | ||
5800 | switch (r) | |
5801 | { | |
5802 | case bfd_reloc_overflow: | |
cf919dfd PB |
5803 | /* If the overflowing reloc was to an undefined symbol, |
5804 | we have already printed one error message and there | |
5805 | is no point complaining again. */ | |
5806 | if ((! h || | |
5807 | h->root.type != bfd_link_hash_undefined) | |
5808 | && (!((*info->callbacks->reloc_overflow) | |
dfeffb9f L |
5809 | (info, (h ? &h->root : NULL), name, howto->name, |
5810 | (bfd_vma) 0, input_bfd, input_section, | |
5811 | rel->r_offset)))) | |
b34976b6 | 5812 | return FALSE; |
252b5132 RH |
5813 | break; |
5814 | ||
5815 | case bfd_reloc_undefined: | |
5816 | if (!((*info->callbacks->undefined_symbol) | |
5817 | (info, name, input_bfd, input_section, | |
b34976b6 AM |
5818 | rel->r_offset, TRUE))) |
5819 | return FALSE; | |
252b5132 RH |
5820 | break; |
5821 | ||
5822 | case bfd_reloc_outofrange: | |
9b485d32 | 5823 | msg = _("internal error: out of range error"); |
252b5132 RH |
5824 | goto common_error; |
5825 | ||
5826 | case bfd_reloc_notsupported: | |
9b485d32 | 5827 | msg = _("internal error: unsupported relocation error"); |
252b5132 RH |
5828 | goto common_error; |
5829 | ||
5830 | case bfd_reloc_dangerous: | |
9b485d32 | 5831 | msg = _("internal error: dangerous error"); |
252b5132 RH |
5832 | goto common_error; |
5833 | ||
5834 | default: | |
9b485d32 | 5835 | msg = _("internal error: unknown error"); |
252b5132 RH |
5836 | /* fall through */ |
5837 | ||
5838 | common_error: | |
5839 | if (!((*info->callbacks->warning) | |
5840 | (info, msg, name, input_bfd, input_section, | |
5841 | rel->r_offset))) | |
b34976b6 | 5842 | return FALSE; |
252b5132 RH |
5843 | break; |
5844 | } | |
5845 | } | |
5846 | } | |
5847 | ||
b34976b6 | 5848 | return TRUE; |
252b5132 RH |
5849 | } |
5850 | ||
ee065d83 PB |
5851 | /* Allocate/find an object attribute. */ |
5852 | static aeabi_attribute * | |
5853 | elf32_arm_new_eabi_attr (bfd *abfd, int tag) | |
5854 | { | |
5855 | aeabi_attribute *attr; | |
5856 | aeabi_attribute_list *list; | |
5857 | aeabi_attribute_list *p; | |
5858 | aeabi_attribute_list **lastp; | |
5859 | ||
5860 | ||
5861 | if (tag < NUM_KNOWN_ATTRIBUTES) | |
5862 | { | |
5863 | /* Knwon tags are preallocated. */ | |
5864 | attr = &elf32_arm_tdata (abfd)->known_eabi_attributes[tag]; | |
5865 | } | |
5866 | else | |
5867 | { | |
5868 | /* Create a new tag. */ | |
5869 | list = (aeabi_attribute_list *) | |
5870 | bfd_alloc (abfd, sizeof (aeabi_attribute_list)); | |
5871 | memset (list, 0, sizeof (aeabi_attribute_list)); | |
5872 | list->tag = tag; | |
5873 | /* Keep the tag list in order. */ | |
5874 | lastp = &elf32_arm_tdata (abfd)->other_eabi_attributes; | |
5875 | for (p = *lastp; p; p = p->next) | |
5876 | { | |
5877 | if (tag < p->tag) | |
5878 | break; | |
5879 | lastp = &p->next; | |
5880 | } | |
5881 | list->next = *lastp; | |
5882 | *lastp = list; | |
5883 | attr = &list->attr; | |
5884 | } | |
5885 | ||
5886 | return attr; | |
5887 | } | |
5888 | ||
39b41c9c PB |
5889 | int |
5890 | elf32_arm_get_eabi_attr_int (bfd *abfd, int tag) | |
5891 | { | |
5892 | aeabi_attribute_list *p; | |
5893 | ||
5894 | if (tag < NUM_KNOWN_ATTRIBUTES) | |
5895 | { | |
5896 | /* Knwon tags are preallocated. */ | |
5897 | return elf32_arm_tdata (abfd)->known_eabi_attributes[tag].i; | |
5898 | } | |
5899 | else | |
5900 | { | |
5901 | for (p = elf32_arm_tdata (abfd)->other_eabi_attributes; | |
5902 | p; | |
5903 | p = p->next) | |
5904 | { | |
5905 | if (tag == p->tag) | |
5906 | return p->attr.i; | |
5907 | if (tag < p->tag) | |
5908 | break; | |
5909 | } | |
5910 | return 0; | |
5911 | } | |
5912 | } | |
5913 | ||
ee065d83 PB |
5914 | void |
5915 | elf32_arm_add_eabi_attr_int (bfd *abfd, int tag, unsigned int i) | |
5916 | { | |
5917 | aeabi_attribute *attr; | |
5918 | ||
5919 | attr = elf32_arm_new_eabi_attr (abfd, tag); | |
5920 | attr->type = 1; | |
5921 | attr->i = i; | |
5922 | } | |
5923 | ||
5924 | static char * | |
5925 | attr_strdup (bfd *abfd, const char * s) | |
5926 | { | |
5927 | char * p; | |
5928 | int len; | |
5929 | ||
5930 | len = strlen (s) + 1; | |
5931 | p = (char *)bfd_alloc(abfd, len); | |
5932 | return memcpy (p, s, len); | |
5933 | } | |
5934 | ||
5935 | void | |
5936 | elf32_arm_add_eabi_attr_string (bfd *abfd, int tag, const char *s) | |
5937 | { | |
5938 | aeabi_attribute *attr; | |
5939 | ||
5940 | attr = elf32_arm_new_eabi_attr (abfd, tag); | |
5941 | attr->type = 2; | |
5942 | attr->s = attr_strdup (abfd, s); | |
5943 | } | |
5944 | ||
5945 | void | |
5946 | elf32_arm_add_eabi_attr_compat (bfd *abfd, unsigned int i, const char *s) | |
5947 | { | |
5948 | aeabi_attribute_list *list; | |
5949 | aeabi_attribute_list *p; | |
5950 | aeabi_attribute_list **lastp; | |
5951 | ||
5952 | list = (aeabi_attribute_list *) | |
5953 | bfd_alloc (abfd, sizeof (aeabi_attribute_list)); | |
5954 | memset (list, 0, sizeof (aeabi_attribute_list)); | |
5955 | list->tag = Tag_compatibility; | |
5956 | list->attr.type = 3; | |
5957 | list->attr.i = i; | |
5958 | list->attr.s = attr_strdup (abfd, s); | |
5959 | ||
5960 | lastp = &elf32_arm_tdata (abfd)->other_eabi_attributes; | |
5961 | for (p = *lastp; p; p = p->next) | |
5962 | { | |
5963 | int cmp; | |
5964 | if (p->tag != Tag_compatibility) | |
5965 | break; | |
5966 | cmp = strcmp(s, p->attr.s); | |
5967 | if (cmp < 0 || (cmp == 0 && i < p->attr.i)) | |
5968 | break; | |
5969 | lastp = &p->next; | |
5970 | } | |
5971 | list->next = *lastp; | |
5972 | *lastp = list; | |
5973 | } | |
5974 | ||
c178919b NC |
5975 | /* Set the right machine number. */ |
5976 | ||
5977 | static bfd_boolean | |
57e8b36a | 5978 | elf32_arm_object_p (bfd *abfd) |
c178919b | 5979 | { |
5a6c6817 | 5980 | unsigned int mach; |
57e8b36a | 5981 | |
5a6c6817 | 5982 | mach = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); |
c178919b | 5983 | |
5a6c6817 NC |
5984 | if (mach != bfd_mach_arm_unknown) |
5985 | bfd_default_set_arch_mach (abfd, bfd_arch_arm, mach); | |
5986 | ||
5987 | else if (elf_elfheader (abfd)->e_flags & EF_ARM_MAVERICK_FLOAT) | |
5988 | bfd_default_set_arch_mach (abfd, bfd_arch_arm, bfd_mach_arm_ep9312); | |
e16bb312 | 5989 | |
e16bb312 | 5990 | else |
5a6c6817 | 5991 | bfd_default_set_arch_mach (abfd, bfd_arch_arm, mach); |
c178919b NC |
5992 | |
5993 | return TRUE; | |
5994 | } | |
5995 | ||
fc830a83 | 5996 | /* Function to keep ARM specific flags in the ELF header. */ |
3c9458e9 | 5997 | |
b34976b6 | 5998 | static bfd_boolean |
57e8b36a | 5999 | elf32_arm_set_private_flags (bfd *abfd, flagword flags) |
252b5132 RH |
6000 | { |
6001 | if (elf_flags_init (abfd) | |
6002 | && elf_elfheader (abfd)->e_flags != flags) | |
6003 | { | |
fc830a83 NC |
6004 | if (EF_ARM_EABI_VERSION (flags) == EF_ARM_EABI_UNKNOWN) |
6005 | { | |
fd2ec330 | 6006 | if (flags & EF_ARM_INTERWORK) |
d003868e AM |
6007 | (*_bfd_error_handler) |
6008 | (_("Warning: Not setting interworking flag of %B since it has already been specified as non-interworking"), | |
6009 | abfd); | |
fc830a83 | 6010 | else |
d003868e AM |
6011 | _bfd_error_handler |
6012 | (_("Warning: Clearing the interworking flag of %B due to outside request"), | |
6013 | abfd); | |
fc830a83 | 6014 | } |
252b5132 RH |
6015 | } |
6016 | else | |
6017 | { | |
6018 | elf_elfheader (abfd)->e_flags = flags; | |
b34976b6 | 6019 | elf_flags_init (abfd) = TRUE; |
252b5132 RH |
6020 | } |
6021 | ||
b34976b6 | 6022 | return TRUE; |
252b5132 RH |
6023 | } |
6024 | ||
ee065d83 PB |
6025 | /* Copy the eabi object attribute from IBFD to OBFD. */ |
6026 | static void | |
6027 | copy_eabi_attributes (bfd *ibfd, bfd *obfd) | |
6028 | { | |
6029 | aeabi_attribute *in_attr; | |
6030 | aeabi_attribute *out_attr; | |
6031 | aeabi_attribute_list *list; | |
6032 | int i; | |
6033 | ||
6034 | in_attr = elf32_arm_tdata (ibfd)->known_eabi_attributes; | |
6035 | out_attr = elf32_arm_tdata (obfd)->known_eabi_attributes; | |
6036 | for (i = 4; i < NUM_KNOWN_ATTRIBUTES; i++) | |
6037 | { | |
6038 | out_attr->i = in_attr->i; | |
6039 | if (in_attr->s && *in_attr->s) | |
6040 | out_attr->s = attr_strdup (obfd, in_attr->s); | |
6041 | in_attr++; | |
6042 | out_attr++; | |
6043 | } | |
6044 | ||
6045 | for (list = elf32_arm_tdata (ibfd)->other_eabi_attributes; | |
6046 | list; | |
6047 | list = list->next) | |
6048 | { | |
6049 | in_attr = &list->attr; | |
6050 | switch (in_attr->type) | |
6051 | { | |
6052 | case 1: | |
6053 | elf32_arm_add_eabi_attr_int (obfd, list->tag, in_attr->i); | |
6054 | break; | |
6055 | case 2: | |
6056 | elf32_arm_add_eabi_attr_string (obfd, list->tag, in_attr->s); | |
6057 | break; | |
6058 | case 3: | |
6059 | elf32_arm_add_eabi_attr_compat (obfd, in_attr->i, in_attr->s); | |
6060 | break; | |
6061 | default: | |
6062 | abort(); | |
6063 | } | |
6064 | } | |
6065 | } | |
6066 | ||
6067 | ||
fc830a83 | 6068 | /* Copy backend specific data from one object module to another. */ |
9b485d32 | 6069 | |
b34976b6 | 6070 | static bfd_boolean |
57e8b36a | 6071 | elf32_arm_copy_private_bfd_data (bfd *ibfd, bfd *obfd) |
252b5132 RH |
6072 | { |
6073 | flagword in_flags; | |
6074 | flagword out_flags; | |
6075 | ||
fc830a83 | 6076 | if ( bfd_get_flavour (ibfd) != bfd_target_elf_flavour |
252b5132 | 6077 | || bfd_get_flavour (obfd) != bfd_target_elf_flavour) |
b34976b6 | 6078 | return TRUE; |
252b5132 | 6079 | |
fc830a83 | 6080 | in_flags = elf_elfheader (ibfd)->e_flags; |
252b5132 RH |
6081 | out_flags = elf_elfheader (obfd)->e_flags; |
6082 | ||
fc830a83 NC |
6083 | if (elf_flags_init (obfd) |
6084 | && EF_ARM_EABI_VERSION (out_flags) == EF_ARM_EABI_UNKNOWN | |
6085 | && in_flags != out_flags) | |
252b5132 | 6086 | { |
252b5132 | 6087 | /* Cannot mix APCS26 and APCS32 code. */ |
fd2ec330 | 6088 | if ((in_flags & EF_ARM_APCS_26) != (out_flags & EF_ARM_APCS_26)) |
b34976b6 | 6089 | return FALSE; |
252b5132 RH |
6090 | |
6091 | /* Cannot mix float APCS and non-float APCS code. */ | |
fd2ec330 | 6092 | if ((in_flags & EF_ARM_APCS_FLOAT) != (out_flags & EF_ARM_APCS_FLOAT)) |
b34976b6 | 6093 | return FALSE; |
252b5132 RH |
6094 | |
6095 | /* If the src and dest have different interworking flags | |
6096 | then turn off the interworking bit. */ | |
fd2ec330 | 6097 | if ((in_flags & EF_ARM_INTERWORK) != (out_flags & EF_ARM_INTERWORK)) |
252b5132 | 6098 | { |
fd2ec330 | 6099 | if (out_flags & EF_ARM_INTERWORK) |
d003868e AM |
6100 | _bfd_error_handler |
6101 | (_("Warning: Clearing the interworking flag of %B because non-interworking code in %B has been linked with it"), | |
6102 | obfd, ibfd); | |
252b5132 | 6103 | |
fd2ec330 | 6104 | in_flags &= ~EF_ARM_INTERWORK; |
252b5132 | 6105 | } |
1006ba19 PB |
6106 | |
6107 | /* Likewise for PIC, though don't warn for this case. */ | |
fd2ec330 PB |
6108 | if ((in_flags & EF_ARM_PIC) != (out_flags & EF_ARM_PIC)) |
6109 | in_flags &= ~EF_ARM_PIC; | |
252b5132 RH |
6110 | } |
6111 | ||
6112 | elf_elfheader (obfd)->e_flags = in_flags; | |
b34976b6 | 6113 | elf_flags_init (obfd) = TRUE; |
252b5132 | 6114 | |
94a3258f PB |
6115 | /* Also copy the EI_OSABI field. */ |
6116 | elf_elfheader (obfd)->e_ident[EI_OSABI] = | |
6117 | elf_elfheader (ibfd)->e_ident[EI_OSABI]; | |
6118 | ||
ee065d83 PB |
6119 | /* Copy EABI object attributes. */ |
6120 | copy_eabi_attributes (ibfd, obfd); | |
6121 | ||
6122 | return TRUE; | |
6123 | } | |
6124 | ||
6125 | /* Values for Tag_ABI_PCS_R9_use. */ | |
6126 | enum | |
6127 | { | |
6128 | AEABI_R9_V6, | |
6129 | AEABI_R9_SB, | |
6130 | AEABI_R9_TLS, | |
6131 | AEABI_R9_unused | |
6132 | }; | |
6133 | ||
6134 | /* Values for Tag_ABI_PCS_RW_data. */ | |
6135 | enum | |
6136 | { | |
6137 | AEABI_PCS_RW_data_absolute, | |
6138 | AEABI_PCS_RW_data_PCrel, | |
6139 | AEABI_PCS_RW_data_SBrel, | |
6140 | AEABI_PCS_RW_data_unused | |
6141 | }; | |
6142 | ||
6143 | /* Values for Tag_ABI_enum_size. */ | |
6144 | enum | |
6145 | { | |
6146 | AEABI_enum_unused, | |
6147 | AEABI_enum_short, | |
6148 | AEABI_enum_wide, | |
6149 | AEABI_enum_forced_wide | |
6150 | }; | |
6151 | ||
6152 | /* Merge EABI object attributes from IBFD into OBFD. Raise an error if there | |
6153 | are conflicting attributes. */ | |
6154 | static bfd_boolean | |
6155 | elf32_arm_merge_eabi_attributes (bfd *ibfd, bfd *obfd) | |
6156 | { | |
6157 | aeabi_attribute *in_attr; | |
6158 | aeabi_attribute *out_attr; | |
6159 | aeabi_attribute_list *in_list; | |
6160 | aeabi_attribute_list *out_list; | |
6161 | /* Some tags have 0 = don't care, 1 = strong requirement, | |
6162 | 2 = weak requirement. */ | |
6163 | static const int order_312[3] = {3, 1, 2}; | |
6164 | int i; | |
6165 | ||
6166 | if (!elf32_arm_tdata (ibfd)->known_eabi_attributes[0].i) | |
6167 | { | |
6168 | /* This is the first object. Copy the attributes. */ | |
6169 | copy_eabi_attributes (ibfd, obfd); | |
6170 | return TRUE; | |
6171 | } | |
6172 | ||
6173 | /* Use the Tag_null value to indicate the attributes have been | |
6174 | initialized. */ | |
6175 | elf32_arm_tdata (ibfd)->known_eabi_attributes[0].i = 1; | |
6176 | ||
6177 | in_attr = elf32_arm_tdata (ibfd)->known_eabi_attributes; | |
6178 | out_attr = elf32_arm_tdata (obfd)->known_eabi_attributes; | |
6179 | /* This needs to happen before Tag_ABI_FP_number_model is merged. */ | |
6180 | if (in_attr[Tag_ABI_VFP_args].i != out_attr[Tag_ABI_VFP_args].i) | |
6181 | { | |
6182 | /* Ignore mismatches if teh object doesn't use floating point. */ | |
6183 | if (out_attr[Tag_ABI_FP_number_model].i == 0) | |
6184 | out_attr[Tag_ABI_VFP_args].i = in_attr[Tag_ABI_VFP_args].i; | |
6185 | else if (in_attr[Tag_ABI_FP_number_model].i != 0) | |
6186 | { | |
6187 | _bfd_error_handler | |
6188 | (_("ERROR: %B uses VFP register arguments, %B does not"), | |
6189 | ibfd, obfd); | |
6190 | return FALSE; | |
6191 | } | |
6192 | } | |
6193 | ||
6194 | for (i = 4; i < NUM_KNOWN_ATTRIBUTES; i++) | |
6195 | { | |
6196 | /* Merge this attribute with existing attributes. */ | |
6197 | switch (i) | |
6198 | { | |
6199 | case Tag_CPU_raw_name: | |
6200 | case Tag_CPU_name: | |
6201 | /* Use whichever has the greatest architecture requirements. */ | |
6202 | if (in_attr[Tag_CPU_arch].i > out_attr[Tag_CPU_arch].i) | |
6203 | out_attr[i].s = attr_strdup(obfd, in_attr[i].s); | |
6204 | break; | |
6205 | ||
6206 | case Tag_ABI_optimization_goals: | |
6207 | case Tag_ABI_FP_optimization_goals: | |
6208 | /* Use the first value seen. */ | |
6209 | break; | |
6210 | ||
6211 | case Tag_CPU_arch: | |
6212 | case Tag_ARM_ISA_use: | |
6213 | case Tag_THUMB_ISA_use: | |
6214 | case Tag_VFP_arch: | |
6215 | case Tag_WMMX_arch: | |
6216 | case Tag_NEON_arch: | |
6217 | /* ??? Do NEON and WMMX conflict? */ | |
6218 | case Tag_ABI_FP_rounding: | |
6219 | case Tag_ABI_FP_denormal: | |
6220 | case Tag_ABI_FP_exceptions: | |
6221 | case Tag_ABI_FP_user_exceptions: | |
6222 | case Tag_ABI_FP_number_model: | |
6223 | case Tag_ABI_align8_preserved: | |
6224 | case Tag_ABI_HardFP_use: | |
6225 | /* Use the largest value specified. */ | |
6226 | if (in_attr[i].i > out_attr[i].i) | |
6227 | out_attr[i].i = in_attr[i].i; | |
6228 | break; | |
6229 | ||
6230 | case Tag_CPU_arch_profile: | |
6231 | /* Warn if conflicting architecture profiles used. */ | |
6232 | if (out_attr[i].i && in_attr[i].i && in_attr[i].i != out_attr[i].i) | |
6233 | { | |
6234 | _bfd_error_handler | |
6235 | (_("ERROR: %B: Conflicting architecture profiles %c/%c"), | |
6236 | ibfd, in_attr[i].i, out_attr[i].i); | |
6237 | return FALSE; | |
6238 | } | |
6239 | if (in_attr[i].i) | |
6240 | out_attr[i].i = in_attr[i].i; | |
6241 | break; | |
6242 | case Tag_PCS_config: | |
6243 | if (out_attr[i].i == 0) | |
6244 | out_attr[i].i = in_attr[i].i; | |
6245 | else if (in_attr[i].i != 0 && out_attr[i].i != 0) | |
6246 | { | |
6247 | /* It's sometimes ok to mix different configs, so this is only | |
6248 | a warning. */ | |
6249 | _bfd_error_handler | |
6250 | (_("Warning: %B: Conflicting platform configuration"), ibfd); | |
6251 | } | |
6252 | break; | |
6253 | case Tag_ABI_PCS_R9_use: | |
6254 | if (out_attr[i].i != AEABI_R9_unused | |
6255 | && in_attr[i].i != AEABI_R9_unused) | |
6256 | { | |
6257 | _bfd_error_handler | |
6258 | (_("ERROR: %B: Conflicting use of R9"), ibfd); | |
6259 | return FALSE; | |
6260 | } | |
6261 | if (out_attr[i].i == AEABI_R9_unused) | |
6262 | out_attr[i].i = in_attr[i].i; | |
6263 | break; | |
6264 | case Tag_ABI_PCS_RW_data: | |
6265 | if (in_attr[i].i == AEABI_PCS_RW_data_SBrel | |
6266 | && out_attr[Tag_ABI_PCS_R9_use].i != AEABI_R9_SB | |
6267 | && out_attr[Tag_ABI_PCS_R9_use].i != AEABI_R9_unused) | |
6268 | { | |
6269 | _bfd_error_handler | |
6270 | (_("ERROR: %B: SB relative addressing conflicts with use of R9"), | |
6271 | ibfd); | |
6272 | return FALSE; | |
6273 | } | |
6274 | /* Use the smallest value specified. */ | |
6275 | if (in_attr[i].i < out_attr[i].i) | |
6276 | out_attr[i].i = in_attr[i].i; | |
6277 | break; | |
6278 | case Tag_ABI_PCS_RO_data: | |
6279 | /* Use the smallest value specified. */ | |
6280 | if (in_attr[i].i < out_attr[i].i) | |
6281 | out_attr[i].i = in_attr[i].i; | |
6282 | break; | |
6283 | case Tag_ABI_PCS_GOT_use: | |
6284 | if (in_attr[i].i > 2 || out_attr[i].i > 2 | |
6285 | || order_312[in_attr[i].i] < order_312[out_attr[i].i]) | |
6286 | out_attr[i].i = in_attr[i].i; | |
6287 | break; | |
6288 | case Tag_ABI_PCS_wchar_t: | |
6289 | if (out_attr[i].i && in_attr[i].i && out_attr[i].i != in_attr[i].i) | |
6290 | { | |
6291 | _bfd_error_handler | |
6292 | (_("ERROR: %B: Conflicting definitions of wchar_t"), ibfd); | |
6293 | return FALSE; | |
6294 | } | |
6295 | if (in_attr[i].i) | |
6296 | out_attr[i].i = in_attr[i].i; | |
6297 | break; | |
6298 | case Tag_ABI_align8_needed: | |
6299 | /* ??? Check against Tag_ABI_align8_preserved. */ | |
6300 | if (in_attr[i].i > 2 || out_attr[i].i > 2 | |
6301 | || order_312[in_attr[i].i] < order_312[out_attr[i].i]) | |
6302 | out_attr[i].i = in_attr[i].i; | |
6303 | break; | |
6304 | case Tag_ABI_enum_size: | |
6305 | if (in_attr[i].i != AEABI_enum_unused) | |
6306 | { | |
6307 | if (out_attr[i].i == AEABI_enum_unused | |
6308 | || out_attr[i].i == AEABI_enum_forced_wide) | |
6309 | { | |
6310 | /* The existing object is compatible with anything. | |
6311 | Use whatever requirements the new object has. */ | |
6312 | out_attr[i].i = in_attr[i].i; | |
6313 | } | |
6314 | else if (in_attr[i].i != AEABI_enum_forced_wide | |
6315 | && out_attr[i].i != in_attr[i].i) | |
6316 | { | |
6317 | _bfd_error_handler | |
6318 | (_("ERROR: %B: Conflicting enum sizes"), ibfd); | |
6319 | } | |
6320 | } | |
6321 | break; | |
6322 | case Tag_ABI_VFP_args: | |
6323 | /* Aready done. */ | |
6324 | break; | |
6325 | case Tag_ABI_WMMX_args: | |
6326 | if (in_attr[i].i != out_attr[i].i) | |
6327 | { | |
6328 | _bfd_error_handler | |
6329 | (_("ERROR: %B uses iWMMXt register arguments, %B does not"), | |
6330 | ibfd, obfd); | |
6331 | return FALSE; | |
6332 | } | |
6333 | break; | |
6334 | default: /* All known attributes should be explicitly covered. */ | |
6335 | abort (); | |
6336 | } | |
6337 | } | |
6338 | ||
6339 | in_list = elf32_arm_tdata (ibfd)->other_eabi_attributes; | |
6340 | out_list = elf32_arm_tdata (ibfd)->other_eabi_attributes; | |
6341 | while (in_list && in_list->tag == Tag_compatibility) | |
6342 | { | |
6343 | in_attr = &in_list->attr; | |
6344 | if (in_attr->i == 0) | |
6345 | continue; | |
6346 | if (in_attr->i == 1) | |
6347 | { | |
6348 | _bfd_error_handler | |
6349 | (_("ERROR: %B: Must be processed by '%s' toolchain"), | |
6350 | ibfd, in_attr->s); | |
6351 | return FALSE; | |
6352 | } | |
6353 | if (!out_list || out_list->tag != Tag_compatibility | |
6354 | || strcmp (in_attr->s, out_list->attr.s) != 0) | |
6355 | { | |
6356 | /* Add this compatibility tag to the output. */ | |
6357 | elf32_arm_add_eabi_attr_compat (obfd, in_attr->i, in_attr->s); | |
6358 | continue; | |
6359 | } | |
6360 | out_attr = &out_list->attr; | |
6361 | /* Check all the input tags with the same identifier. */ | |
6362 | for (;;) | |
6363 | { | |
6364 | if (out_list->tag != Tag_compatibility | |
6365 | || in_attr->i != out_attr->i | |
6366 | || strcmp (in_attr->s, out_attr->s) != 0) | |
6367 | { | |
6368 | _bfd_error_handler | |
6369 | (_("ERROR: %B: Incompatible object tag '%s':%d"), | |
6370 | ibfd, in_attr->s, in_attr->i); | |
6371 | return FALSE; | |
6372 | } | |
6373 | in_list = in_list->next; | |
6374 | if (in_list->tag != Tag_compatibility | |
6375 | || strcmp (in_attr->s, in_list->attr.s) != 0) | |
6376 | break; | |
6377 | in_attr = &in_list->attr; | |
6378 | out_list = out_list->next; | |
6379 | if (out_list) | |
6380 | out_attr = &out_list->attr; | |
6381 | } | |
6382 | ||
6383 | /* Check the output doesn't have extra tags with this identifier. */ | |
6384 | if (out_list && out_list->tag == Tag_compatibility | |
6385 | && strcmp (in_attr->s, out_list->attr.s) == 0) | |
6386 | { | |
6387 | _bfd_error_handler | |
6388 | (_("ERROR: %B: Incompatible object tag '%s':%d"), | |
6389 | ibfd, in_attr->s, out_list->attr.i); | |
6390 | return FALSE; | |
6391 | } | |
6392 | } | |
6393 | ||
6394 | for (; in_list; in_list = in_list->next) | |
6395 | { | |
6396 | if ((in_list->tag & 128) < 64) | |
eb111b1f BE |
6397 | { |
6398 | _bfd_error_handler | |
6399 | (_("Warning: %B: Unknown EABI object attribute %d"), | |
6400 | ibfd, in_list->tag); | |
6401 | break; | |
6402 | } | |
ee065d83 | 6403 | } |
b34976b6 | 6404 | return TRUE; |
252b5132 RH |
6405 | } |
6406 | ||
3a4a14e9 PB |
6407 | |
6408 | /* Return TRUE if the two EABI versions are incompatible. */ | |
6409 | ||
6410 | static bfd_boolean | |
6411 | elf32_arm_versions_compatible (unsigned iver, unsigned over) | |
6412 | { | |
6413 | /* v4 and v5 are the same spec before and after it was released, | |
6414 | so allow mixing them. */ | |
6415 | if ((iver == EF_ARM_EABI_VER4 && over == EF_ARM_EABI_VER5) | |
6416 | || (iver == EF_ARM_EABI_VER5 && over == EF_ARM_EABI_VER4)) | |
6417 | return TRUE; | |
6418 | ||
6419 | return (iver == over); | |
6420 | } | |
6421 | ||
252b5132 RH |
6422 | /* Merge backend specific data from an object file to the output |
6423 | object file when linking. */ | |
9b485d32 | 6424 | |
b34976b6 | 6425 | static bfd_boolean |
57e8b36a | 6426 | elf32_arm_merge_private_bfd_data (bfd * ibfd, bfd * obfd) |
252b5132 RH |
6427 | { |
6428 | flagword out_flags; | |
6429 | flagword in_flags; | |
b34976b6 | 6430 | bfd_boolean flags_compatible = TRUE; |
cf919dfd | 6431 | asection *sec; |
252b5132 | 6432 | |
9b485d32 | 6433 | /* Check if we have the same endianess. */ |
82e51918 | 6434 | if (! _bfd_generic_verify_endian_match (ibfd, obfd)) |
b34976b6 | 6435 | return FALSE; |
1fe494a5 | 6436 | |
252b5132 RH |
6437 | if ( bfd_get_flavour (ibfd) != bfd_target_elf_flavour |
6438 | || bfd_get_flavour (obfd) != bfd_target_elf_flavour) | |
b34976b6 | 6439 | return TRUE; |
252b5132 | 6440 | |
ee065d83 PB |
6441 | if (!elf32_arm_merge_eabi_attributes (ibfd, obfd)) |
6442 | return FALSE; | |
6443 | ||
252b5132 RH |
6444 | /* The input BFD must have had its flags initialised. */ |
6445 | /* The following seems bogus to me -- The flags are initialized in | |
6446 | the assembler but I don't think an elf_flags_init field is | |
9b485d32 | 6447 | written into the object. */ |
252b5132 RH |
6448 | /* BFD_ASSERT (elf_flags_init (ibfd)); */ |
6449 | ||
6450 | in_flags = elf_elfheader (ibfd)->e_flags; | |
6451 | out_flags = elf_elfheader (obfd)->e_flags; | |
6452 | ||
6453 | if (!elf_flags_init (obfd)) | |
6454 | { | |
fe077fa6 NC |
6455 | /* If the input is the default architecture and had the default |
6456 | flags then do not bother setting the flags for the output | |
6457 | architecture, instead allow future merges to do this. If no | |
6458 | future merges ever set these flags then they will retain their | |
6459 | uninitialised values, which surprise surprise, correspond | |
252b5132 | 6460 | to the default values. */ |
fe077fa6 NC |
6461 | if (bfd_get_arch_info (ibfd)->the_default |
6462 | && elf_elfheader (ibfd)->e_flags == 0) | |
b34976b6 | 6463 | return TRUE; |
252b5132 | 6464 | |
b34976b6 | 6465 | elf_flags_init (obfd) = TRUE; |
252b5132 RH |
6466 | elf_elfheader (obfd)->e_flags = in_flags; |
6467 | ||
6468 | if (bfd_get_arch (obfd) == bfd_get_arch (ibfd) | |
6469 | && bfd_get_arch_info (obfd)->the_default) | |
6470 | return bfd_set_arch_mach (obfd, bfd_get_arch (ibfd), bfd_get_mach (ibfd)); | |
6471 | ||
b34976b6 | 6472 | return TRUE; |
252b5132 RH |
6473 | } |
6474 | ||
5a6c6817 NC |
6475 | /* Determine what should happen if the input ARM architecture |
6476 | does not match the output ARM architecture. */ | |
6477 | if (! bfd_arm_merge_machines (ibfd, obfd)) | |
6478 | return FALSE; | |
e16bb312 | 6479 | |
1006ba19 | 6480 | /* Identical flags must be compatible. */ |
252b5132 | 6481 | if (in_flags == out_flags) |
b34976b6 | 6482 | return TRUE; |
252b5132 | 6483 | |
35a0f415 DJ |
6484 | /* Check to see if the input BFD actually contains any sections. If |
6485 | not, its flags may not have been initialised either, but it | |
8e3de13a | 6486 | cannot actually cause any incompatiblity. Do not short-circuit |
35a0f415 | 6487 | dynamic objects; their section list may be emptied by |
d1f161ea | 6488 | elf_link_add_object_symbols. |
35a0f415 | 6489 | |
d1f161ea NC |
6490 | Also check to see if there are no code sections in the input. |
6491 | In this case there is no need to check for code specific flags. | |
6492 | XXX - do we need to worry about floating-point format compatability | |
6493 | in data sections ? */ | |
35a0f415 | 6494 | if (!(ibfd->flags & DYNAMIC)) |
cf919dfd | 6495 | { |
35a0f415 | 6496 | bfd_boolean null_input_bfd = TRUE; |
d1f161ea | 6497 | bfd_boolean only_data_sections = TRUE; |
35a0f415 DJ |
6498 | |
6499 | for (sec = ibfd->sections; sec != NULL; sec = sec->next) | |
cf919dfd | 6500 | { |
35a0f415 DJ |
6501 | /* Ignore synthetic glue sections. */ |
6502 | if (strcmp (sec->name, ".glue_7") | |
6503 | && strcmp (sec->name, ".glue_7t")) | |
6504 | { | |
d1f161ea NC |
6505 | if ((bfd_get_section_flags (ibfd, sec) |
6506 | & (SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS)) | |
6507 | == (SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS)) | |
6508 | only_data_sections = FALSE; | |
6509 | ||
35a0f415 DJ |
6510 | null_input_bfd = FALSE; |
6511 | break; | |
6512 | } | |
cf919dfd | 6513 | } |
d1f161ea NC |
6514 | |
6515 | if (null_input_bfd || only_data_sections) | |
35a0f415 | 6516 | return TRUE; |
cf919dfd | 6517 | } |
cf919dfd | 6518 | |
252b5132 | 6519 | /* Complain about various flag mismatches. */ |
3a4a14e9 PB |
6520 | if (!elf32_arm_versions_compatible (EF_ARM_EABI_VERSION (in_flags), |
6521 | EF_ARM_EABI_VERSION (out_flags))) | |
fc830a83 | 6522 | { |
d003868e | 6523 | _bfd_error_handler |
3656d5e3 | 6524 | (_("ERROR: Source object %B has EABI version %d, but target %B has EABI version %d"), |
d003868e AM |
6525 | ibfd, obfd, |
6526 | (in_flags & EF_ARM_EABIMASK) >> 24, | |
6527 | (out_flags & EF_ARM_EABIMASK) >> 24); | |
b34976b6 | 6528 | return FALSE; |
fc830a83 | 6529 | } |
252b5132 | 6530 | |
1006ba19 | 6531 | /* Not sure what needs to be checked for EABI versions >= 1. */ |
00a97672 RS |
6532 | /* VxWorks libraries do not use these flags. */ |
6533 | if (get_elf_backend_data (obfd) != &elf32_arm_vxworks_bed | |
6534 | && get_elf_backend_data (ibfd) != &elf32_arm_vxworks_bed | |
6535 | && EF_ARM_EABI_VERSION (in_flags) == EF_ARM_EABI_UNKNOWN) | |
1006ba19 | 6536 | { |
fd2ec330 | 6537 | if ((in_flags & EF_ARM_APCS_26) != (out_flags & EF_ARM_APCS_26)) |
1006ba19 | 6538 | { |
d003868e AM |
6539 | _bfd_error_handler |
6540 | (_("ERROR: %B is compiled for APCS-%d, whereas target %B uses APCS-%d"), | |
6541 | ibfd, obfd, | |
6542 | in_flags & EF_ARM_APCS_26 ? 26 : 32, | |
6543 | out_flags & EF_ARM_APCS_26 ? 26 : 32); | |
b34976b6 | 6544 | flags_compatible = FALSE; |
1006ba19 | 6545 | } |
252b5132 | 6546 | |
fd2ec330 | 6547 | if ((in_flags & EF_ARM_APCS_FLOAT) != (out_flags & EF_ARM_APCS_FLOAT)) |
1006ba19 | 6548 | { |
5eefb65f | 6549 | if (in_flags & EF_ARM_APCS_FLOAT) |
d003868e AM |
6550 | _bfd_error_handler |
6551 | (_("ERROR: %B passes floats in float registers, whereas %B passes them in integer registers"), | |
6552 | ibfd, obfd); | |
5eefb65f | 6553 | else |
d003868e AM |
6554 | _bfd_error_handler |
6555 | (_("ERROR: %B passes floats in integer registers, whereas %B passes them in float registers"), | |
6556 | ibfd, obfd); | |
63b0f745 | 6557 | |
b34976b6 | 6558 | flags_compatible = FALSE; |
1006ba19 | 6559 | } |
252b5132 | 6560 | |
96a846ea | 6561 | if ((in_flags & EF_ARM_VFP_FLOAT) != (out_flags & EF_ARM_VFP_FLOAT)) |
1006ba19 | 6562 | { |
96a846ea | 6563 | if (in_flags & EF_ARM_VFP_FLOAT) |
d003868e AM |
6564 | _bfd_error_handler |
6565 | (_("ERROR: %B uses VFP instructions, whereas %B does not"), | |
6566 | ibfd, obfd); | |
5eefb65f | 6567 | else |
d003868e AM |
6568 | _bfd_error_handler |
6569 | (_("ERROR: %B uses FPA instructions, whereas %B does not"), | |
6570 | ibfd, obfd); | |
fde78edd NC |
6571 | |
6572 | flags_compatible = FALSE; | |
6573 | } | |
6574 | ||
6575 | if ((in_flags & EF_ARM_MAVERICK_FLOAT) != (out_flags & EF_ARM_MAVERICK_FLOAT)) | |
6576 | { | |
6577 | if (in_flags & EF_ARM_MAVERICK_FLOAT) | |
d003868e AM |
6578 | _bfd_error_handler |
6579 | (_("ERROR: %B uses Maverick instructions, whereas %B does not"), | |
6580 | ibfd, obfd); | |
fde78edd | 6581 | else |
d003868e AM |
6582 | _bfd_error_handler |
6583 | (_("ERROR: %B does not use Maverick instructions, whereas %B does"), | |
6584 | ibfd, obfd); | |
63b0f745 | 6585 | |
b34976b6 | 6586 | flags_compatible = FALSE; |
1006ba19 | 6587 | } |
96a846ea RE |
6588 | |
6589 | #ifdef EF_ARM_SOFT_FLOAT | |
6590 | if ((in_flags & EF_ARM_SOFT_FLOAT) != (out_flags & EF_ARM_SOFT_FLOAT)) | |
6591 | { | |
6592 | /* We can allow interworking between code that is VFP format | |
6593 | layout, and uses either soft float or integer regs for | |
6594 | passing floating point arguments and results. We already | |
6595 | know that the APCS_FLOAT flags match; similarly for VFP | |
6596 | flags. */ | |
6597 | if ((in_flags & EF_ARM_APCS_FLOAT) != 0 | |
6598 | || (in_flags & EF_ARM_VFP_FLOAT) == 0) | |
6599 | { | |
6600 | if (in_flags & EF_ARM_SOFT_FLOAT) | |
d003868e AM |
6601 | _bfd_error_handler |
6602 | (_("ERROR: %B uses software FP, whereas %B uses hardware FP"), | |
6603 | ibfd, obfd); | |
96a846ea | 6604 | else |
d003868e AM |
6605 | _bfd_error_handler |
6606 | (_("ERROR: %B uses hardware FP, whereas %B uses software FP"), | |
6607 | ibfd, obfd); | |
96a846ea | 6608 | |
b34976b6 | 6609 | flags_compatible = FALSE; |
96a846ea RE |
6610 | } |
6611 | } | |
ee43f35e | 6612 | #endif |
252b5132 | 6613 | |
1006ba19 | 6614 | /* Interworking mismatch is only a warning. */ |
fd2ec330 | 6615 | if ((in_flags & EF_ARM_INTERWORK) != (out_flags & EF_ARM_INTERWORK)) |
8f615d07 | 6616 | { |
e3c8793a NC |
6617 | if (in_flags & EF_ARM_INTERWORK) |
6618 | { | |
d003868e AM |
6619 | _bfd_error_handler |
6620 | (_("Warning: %B supports interworking, whereas %B does not"), | |
6621 | ibfd, obfd); | |
e3c8793a NC |
6622 | } |
6623 | else | |
6624 | { | |
d003868e AM |
6625 | _bfd_error_handler |
6626 | (_("Warning: %B does not support interworking, whereas %B does"), | |
6627 | ibfd, obfd); | |
e3c8793a | 6628 | } |
8f615d07 | 6629 | } |
252b5132 | 6630 | } |
63b0f745 | 6631 | |
1006ba19 | 6632 | return flags_compatible; |
252b5132 RH |
6633 | } |
6634 | ||
9b485d32 NC |
6635 | /* Display the flags field. */ |
6636 | ||
b34976b6 | 6637 | static bfd_boolean |
57e8b36a | 6638 | elf32_arm_print_private_bfd_data (bfd *abfd, void * ptr) |
252b5132 | 6639 | { |
fc830a83 NC |
6640 | FILE * file = (FILE *) ptr; |
6641 | unsigned long flags; | |
252b5132 RH |
6642 | |
6643 | BFD_ASSERT (abfd != NULL && ptr != NULL); | |
6644 | ||
6645 | /* Print normal ELF private data. */ | |
6646 | _bfd_elf_print_private_bfd_data (abfd, ptr); | |
6647 | ||
fc830a83 | 6648 | flags = elf_elfheader (abfd)->e_flags; |
9b485d32 NC |
6649 | /* Ignore init flag - it may not be set, despite the flags field |
6650 | containing valid data. */ | |
252b5132 RH |
6651 | |
6652 | /* xgettext:c-format */ | |
9b485d32 | 6653 | fprintf (file, _("private flags = %lx:"), elf_elfheader (abfd)->e_flags); |
252b5132 | 6654 | |
fc830a83 NC |
6655 | switch (EF_ARM_EABI_VERSION (flags)) |
6656 | { | |
6657 | case EF_ARM_EABI_UNKNOWN: | |
4cc11e76 | 6658 | /* The following flag bits are GNU extensions and not part of the |
fc830a83 NC |
6659 | official ARM ELF extended ABI. Hence they are only decoded if |
6660 | the EABI version is not set. */ | |
fd2ec330 | 6661 | if (flags & EF_ARM_INTERWORK) |
9b485d32 | 6662 | fprintf (file, _(" [interworking enabled]")); |
9a5aca8c | 6663 | |
fd2ec330 | 6664 | if (flags & EF_ARM_APCS_26) |
6c571f00 | 6665 | fprintf (file, " [APCS-26]"); |
fc830a83 | 6666 | else |
6c571f00 | 6667 | fprintf (file, " [APCS-32]"); |
9a5aca8c | 6668 | |
96a846ea RE |
6669 | if (flags & EF_ARM_VFP_FLOAT) |
6670 | fprintf (file, _(" [VFP float format]")); | |
fde78edd NC |
6671 | else if (flags & EF_ARM_MAVERICK_FLOAT) |
6672 | fprintf (file, _(" [Maverick float format]")); | |
96a846ea RE |
6673 | else |
6674 | fprintf (file, _(" [FPA float format]")); | |
6675 | ||
fd2ec330 | 6676 | if (flags & EF_ARM_APCS_FLOAT) |
9b485d32 | 6677 | fprintf (file, _(" [floats passed in float registers]")); |
9a5aca8c | 6678 | |
fd2ec330 | 6679 | if (flags & EF_ARM_PIC) |
9b485d32 | 6680 | fprintf (file, _(" [position independent]")); |
fc830a83 | 6681 | |
fd2ec330 | 6682 | if (flags & EF_ARM_NEW_ABI) |
9b485d32 | 6683 | fprintf (file, _(" [new ABI]")); |
9a5aca8c | 6684 | |
fd2ec330 | 6685 | if (flags & EF_ARM_OLD_ABI) |
9b485d32 | 6686 | fprintf (file, _(" [old ABI]")); |
9a5aca8c | 6687 | |
fd2ec330 | 6688 | if (flags & EF_ARM_SOFT_FLOAT) |
9b485d32 | 6689 | fprintf (file, _(" [software FP]")); |
9a5aca8c | 6690 | |
96a846ea RE |
6691 | flags &= ~(EF_ARM_INTERWORK | EF_ARM_APCS_26 | EF_ARM_APCS_FLOAT |
6692 | | EF_ARM_PIC | EF_ARM_NEW_ABI | EF_ARM_OLD_ABI | |
fde78edd NC |
6693 | | EF_ARM_SOFT_FLOAT | EF_ARM_VFP_FLOAT |
6694 | | EF_ARM_MAVERICK_FLOAT); | |
fc830a83 | 6695 | break; |
9a5aca8c | 6696 | |
fc830a83 | 6697 | case EF_ARM_EABI_VER1: |
9b485d32 | 6698 | fprintf (file, _(" [Version1 EABI]")); |
9a5aca8c | 6699 | |
fc830a83 | 6700 | if (flags & EF_ARM_SYMSARESORTED) |
9b485d32 | 6701 | fprintf (file, _(" [sorted symbol table]")); |
fc830a83 | 6702 | else |
9b485d32 | 6703 | fprintf (file, _(" [unsorted symbol table]")); |
9a5aca8c | 6704 | |
fc830a83 NC |
6705 | flags &= ~ EF_ARM_SYMSARESORTED; |
6706 | break; | |
9a5aca8c | 6707 | |
fd2ec330 PB |
6708 | case EF_ARM_EABI_VER2: |
6709 | fprintf (file, _(" [Version2 EABI]")); | |
6710 | ||
6711 | if (flags & EF_ARM_SYMSARESORTED) | |
6712 | fprintf (file, _(" [sorted symbol table]")); | |
6713 | else | |
6714 | fprintf (file, _(" [unsorted symbol table]")); | |
6715 | ||
6716 | if (flags & EF_ARM_DYNSYMSUSESEGIDX) | |
6717 | fprintf (file, _(" [dynamic symbols use segment index]")); | |
6718 | ||
6719 | if (flags & EF_ARM_MAPSYMSFIRST) | |
6720 | fprintf (file, _(" [mapping symbols precede others]")); | |
6721 | ||
99e4ae17 | 6722 | flags &= ~(EF_ARM_SYMSARESORTED | EF_ARM_DYNSYMSUSESEGIDX |
fd2ec330 PB |
6723 | | EF_ARM_MAPSYMSFIRST); |
6724 | break; | |
6725 | ||
d507cf36 PB |
6726 | case EF_ARM_EABI_VER3: |
6727 | fprintf (file, _(" [Version3 EABI]")); | |
8cb51566 PB |
6728 | break; |
6729 | ||
6730 | case EF_ARM_EABI_VER4: | |
6731 | fprintf (file, _(" [Version4 EABI]")); | |
3a4a14e9 | 6732 | goto eabi; |
d507cf36 | 6733 | |
3a4a14e9 PB |
6734 | case EF_ARM_EABI_VER5: |
6735 | fprintf (file, _(" [Version5 EABI]")); | |
6736 | eabi: | |
d507cf36 PB |
6737 | if (flags & EF_ARM_BE8) |
6738 | fprintf (file, _(" [BE8]")); | |
6739 | ||
6740 | if (flags & EF_ARM_LE8) | |
6741 | fprintf (file, _(" [LE8]")); | |
6742 | ||
6743 | flags &= ~(EF_ARM_LE8 | EF_ARM_BE8); | |
6744 | break; | |
6745 | ||
fc830a83 | 6746 | default: |
9b485d32 | 6747 | fprintf (file, _(" <EABI version unrecognised>")); |
fc830a83 NC |
6748 | break; |
6749 | } | |
252b5132 | 6750 | |
fc830a83 | 6751 | flags &= ~ EF_ARM_EABIMASK; |
252b5132 | 6752 | |
fc830a83 | 6753 | if (flags & EF_ARM_RELEXEC) |
9b485d32 | 6754 | fprintf (file, _(" [relocatable executable]")); |
252b5132 | 6755 | |
fc830a83 | 6756 | if (flags & EF_ARM_HASENTRY) |
9b485d32 | 6757 | fprintf (file, _(" [has entry point]")); |
252b5132 | 6758 | |
fc830a83 NC |
6759 | flags &= ~ (EF_ARM_RELEXEC | EF_ARM_HASENTRY); |
6760 | ||
6761 | if (flags) | |
9b485d32 | 6762 | fprintf (file, _("<Unrecognised flag bits set>")); |
9a5aca8c | 6763 | |
252b5132 RH |
6764 | fputc ('\n', file); |
6765 | ||
b34976b6 | 6766 | return TRUE; |
252b5132 RH |
6767 | } |
6768 | ||
6769 | static int | |
57e8b36a | 6770 | elf32_arm_get_symbol_type (Elf_Internal_Sym * elf_sym, int type) |
252b5132 | 6771 | { |
2f0ca46a NC |
6772 | switch (ELF_ST_TYPE (elf_sym->st_info)) |
6773 | { | |
6774 | case STT_ARM_TFUNC: | |
6775 | return ELF_ST_TYPE (elf_sym->st_info); | |
ce855c42 | 6776 | |
2f0ca46a NC |
6777 | case STT_ARM_16BIT: |
6778 | /* If the symbol is not an object, return the STT_ARM_16BIT flag. | |
6779 | This allows us to distinguish between data used by Thumb instructions | |
6780 | and non-data (which is probably code) inside Thumb regions of an | |
6781 | executable. */ | |
1a0eb693 | 6782 | if (type != STT_OBJECT && type != STT_TLS) |
2f0ca46a NC |
6783 | return ELF_ST_TYPE (elf_sym->st_info); |
6784 | break; | |
9a5aca8c | 6785 | |
ce855c42 NC |
6786 | default: |
6787 | break; | |
2f0ca46a NC |
6788 | } |
6789 | ||
6790 | return type; | |
252b5132 | 6791 | } |
f21f3fe0 | 6792 | |
252b5132 | 6793 | static asection * |
07adf181 AM |
6794 | elf32_arm_gc_mark_hook (asection *sec, |
6795 | struct bfd_link_info *info, | |
6796 | Elf_Internal_Rela *rel, | |
6797 | struct elf_link_hash_entry *h, | |
6798 | Elf_Internal_Sym *sym) | |
252b5132 RH |
6799 | { |
6800 | if (h != NULL) | |
07adf181 | 6801 | switch (ELF32_R_TYPE (rel->r_info)) |
252b5132 RH |
6802 | { |
6803 | case R_ARM_GNU_VTINHERIT: | |
6804 | case R_ARM_GNU_VTENTRY: | |
07adf181 AM |
6805 | return NULL; |
6806 | } | |
9ad5cbcf | 6807 | |
07adf181 | 6808 | return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym); |
252b5132 RH |
6809 | } |
6810 | ||
780a67af NC |
6811 | /* Update the got entry reference counts for the section being removed. */ |
6812 | ||
b34976b6 | 6813 | static bfd_boolean |
ba93b8ac DJ |
6814 | elf32_arm_gc_sweep_hook (bfd * abfd, |
6815 | struct bfd_link_info * info, | |
6816 | asection * sec, | |
6817 | const Elf_Internal_Rela * relocs) | |
252b5132 | 6818 | { |
5e681ec4 PB |
6819 | Elf_Internal_Shdr *symtab_hdr; |
6820 | struct elf_link_hash_entry **sym_hashes; | |
6821 | bfd_signed_vma *local_got_refcounts; | |
6822 | const Elf_Internal_Rela *rel, *relend; | |
eb043451 PB |
6823 | struct elf32_arm_link_hash_table * globals; |
6824 | ||
6825 | globals = elf32_arm_hash_table (info); | |
5e681ec4 PB |
6826 | |
6827 | elf_section_data (sec)->local_dynrel = NULL; | |
6828 | ||
6829 | symtab_hdr = &elf_tdata (abfd)->symtab_hdr; | |
6830 | sym_hashes = elf_sym_hashes (abfd); | |
6831 | local_got_refcounts = elf_local_got_refcounts (abfd); | |
6832 | ||
6833 | relend = relocs + sec->reloc_count; | |
6834 | for (rel = relocs; rel < relend; rel++) | |
eb043451 | 6835 | { |
3eb128b2 AM |
6836 | unsigned long r_symndx; |
6837 | struct elf_link_hash_entry *h = NULL; | |
eb043451 | 6838 | int r_type; |
5e681ec4 | 6839 | |
3eb128b2 AM |
6840 | r_symndx = ELF32_R_SYM (rel->r_info); |
6841 | if (r_symndx >= symtab_hdr->sh_info) | |
6842 | { | |
6843 | h = sym_hashes[r_symndx - symtab_hdr->sh_info]; | |
6844 | while (h->root.type == bfd_link_hash_indirect | |
6845 | || h->root.type == bfd_link_hash_warning) | |
6846 | h = (struct elf_link_hash_entry *) h->root.u.i.link; | |
6847 | } | |
6848 | ||
eb043451 | 6849 | r_type = ELF32_R_TYPE (rel->r_info); |
eb043451 | 6850 | r_type = arm_real_reloc_type (globals, r_type); |
eb043451 PB |
6851 | switch (r_type) |
6852 | { | |
6853 | case R_ARM_GOT32: | |
eb043451 | 6854 | case R_ARM_GOT_PREL: |
ba93b8ac DJ |
6855 | case R_ARM_TLS_GD32: |
6856 | case R_ARM_TLS_IE32: | |
3eb128b2 | 6857 | if (h != NULL) |
eb043451 | 6858 | { |
eb043451 PB |
6859 | if (h->got.refcount > 0) |
6860 | h->got.refcount -= 1; | |
6861 | } | |
6862 | else if (local_got_refcounts != NULL) | |
6863 | { | |
6864 | if (local_got_refcounts[r_symndx] > 0) | |
6865 | local_got_refcounts[r_symndx] -= 1; | |
6866 | } | |
6867 | break; | |
6868 | ||
ba93b8ac DJ |
6869 | case R_ARM_TLS_LDM32: |
6870 | elf32_arm_hash_table (info)->tls_ldm_got.refcount -= 1; | |
6871 | break; | |
6872 | ||
eb043451 | 6873 | case R_ARM_ABS32: |
bb224fc3 | 6874 | case R_ARM_ABS32_NOI: |
eb043451 | 6875 | case R_ARM_REL32: |
bb224fc3 | 6876 | case R_ARM_REL32_NOI: |
eb043451 PB |
6877 | case R_ARM_PC24: |
6878 | case R_ARM_PLT32: | |
5b5bb741 PB |
6879 | case R_ARM_CALL: |
6880 | case R_ARM_JUMP24: | |
eb043451 | 6881 | case R_ARM_PREL31: |
c19d1205 | 6882 | case R_ARM_THM_CALL: |
b6895b4f PB |
6883 | case R_ARM_MOVW_ABS_NC: |
6884 | case R_ARM_MOVT_ABS: | |
6885 | case R_ARM_MOVW_PREL_NC: | |
6886 | case R_ARM_MOVT_PREL: | |
6887 | case R_ARM_THM_MOVW_ABS_NC: | |
6888 | case R_ARM_THM_MOVT_ABS: | |
6889 | case R_ARM_THM_MOVW_PREL_NC: | |
6890 | case R_ARM_THM_MOVT_PREL: | |
b7693d02 DJ |
6891 | /* Should the interworking branches be here also? */ |
6892 | ||
3eb128b2 | 6893 | if (h != NULL) |
eb043451 PB |
6894 | { |
6895 | struct elf32_arm_link_hash_entry *eh; | |
6896 | struct elf32_arm_relocs_copied **pp; | |
6897 | struct elf32_arm_relocs_copied *p; | |
5e681ec4 | 6898 | |
b7693d02 | 6899 | eh = (struct elf32_arm_link_hash_entry *) h; |
5e681ec4 | 6900 | |
eb043451 | 6901 | if (h->plt.refcount > 0) |
b7693d02 DJ |
6902 | { |
6903 | h->plt.refcount -= 1; | |
c19d1205 | 6904 | if (ELF32_R_TYPE (rel->r_info) == R_ARM_THM_CALL) |
b7693d02 DJ |
6905 | eh->plt_thumb_refcount--; |
6906 | } | |
5e681ec4 | 6907 | |
eb043451 | 6908 | if (r_type == R_ARM_ABS32 |
bb224fc3 MS |
6909 | || r_type == R_ARM_REL32 |
6910 | || r_type == R_ARM_ABS32_NOI | |
6911 | || r_type == R_ARM_REL32_NOI) | |
eb043451 | 6912 | { |
eb043451 PB |
6913 | for (pp = &eh->relocs_copied; (p = *pp) != NULL; |
6914 | pp = &p->next) | |
6915 | if (p->section == sec) | |
6916 | { | |
6917 | p->count -= 1; | |
bb224fc3 MS |
6918 | if (ELF32_R_TYPE (rel->r_info) == R_ARM_REL32 |
6919 | || ELF32_R_TYPE (rel->r_info) == R_ARM_REL32_NOI) | |
ba93b8ac | 6920 | p->pc_count -= 1; |
eb043451 PB |
6921 | if (p->count == 0) |
6922 | *pp = p->next; | |
6923 | break; | |
6924 | } | |
6925 | } | |
6926 | } | |
6927 | break; | |
5e681ec4 | 6928 | |
eb043451 PB |
6929 | default: |
6930 | break; | |
6931 | } | |
6932 | } | |
5e681ec4 | 6933 | |
b34976b6 | 6934 | return TRUE; |
252b5132 RH |
6935 | } |
6936 | ||
780a67af NC |
6937 | /* Look through the relocs for a section during the first phase. */ |
6938 | ||
b34976b6 | 6939 | static bfd_boolean |
57e8b36a NC |
6940 | elf32_arm_check_relocs (bfd *abfd, struct bfd_link_info *info, |
6941 | asection *sec, const Elf_Internal_Rela *relocs) | |
252b5132 | 6942 | { |
b34976b6 AM |
6943 | Elf_Internal_Shdr *symtab_hdr; |
6944 | struct elf_link_hash_entry **sym_hashes; | |
6945 | struct elf_link_hash_entry **sym_hashes_end; | |
6946 | const Elf_Internal_Rela *rel; | |
6947 | const Elf_Internal_Rela *rel_end; | |
6948 | bfd *dynobj; | |
5e681ec4 | 6949 | asection *sreloc; |
b34976b6 | 6950 | bfd_vma *local_got_offsets; |
5e681ec4 | 6951 | struct elf32_arm_link_hash_table *htab; |
9a5aca8c | 6952 | |
1049f94e | 6953 | if (info->relocatable) |
b34976b6 | 6954 | return TRUE; |
9a5aca8c | 6955 | |
5e681ec4 PB |
6956 | htab = elf32_arm_hash_table (info); |
6957 | sreloc = NULL; | |
9a5aca8c | 6958 | |
67687978 PB |
6959 | /* Create dynamic sections for relocatable executables so that we can |
6960 | copy relocations. */ | |
6961 | if (htab->root.is_relocatable_executable | |
6962 | && ! htab->root.dynamic_sections_created) | |
6963 | { | |
6964 | if (! _bfd_elf_link_create_dynamic_sections (abfd, info)) | |
6965 | return FALSE; | |
6966 | } | |
6967 | ||
252b5132 RH |
6968 | dynobj = elf_hash_table (info)->dynobj; |
6969 | local_got_offsets = elf_local_got_offsets (abfd); | |
f21f3fe0 | 6970 | |
252b5132 RH |
6971 | symtab_hdr = &elf_tdata (abfd)->symtab_hdr; |
6972 | sym_hashes = elf_sym_hashes (abfd); | |
9b485d32 NC |
6973 | sym_hashes_end = sym_hashes |
6974 | + symtab_hdr->sh_size / sizeof (Elf32_External_Sym); | |
6975 | ||
252b5132 RH |
6976 | if (!elf_bad_symtab (abfd)) |
6977 | sym_hashes_end -= symtab_hdr->sh_info; | |
9b485d32 | 6978 | |
252b5132 RH |
6979 | rel_end = relocs + sec->reloc_count; |
6980 | for (rel = relocs; rel < rel_end; rel++) | |
6981 | { | |
6982 | struct elf_link_hash_entry *h; | |
b7693d02 | 6983 | struct elf32_arm_link_hash_entry *eh; |
252b5132 | 6984 | unsigned long r_symndx; |
eb043451 | 6985 | int r_type; |
9a5aca8c | 6986 | |
252b5132 | 6987 | r_symndx = ELF32_R_SYM (rel->r_info); |
eb043451 | 6988 | r_type = ELF32_R_TYPE (rel->r_info); |
eb043451 | 6989 | r_type = arm_real_reloc_type (htab, r_type); |
ba93b8ac DJ |
6990 | |
6991 | if (r_symndx >= NUM_SHDR_ENTRIES (symtab_hdr)) | |
6992 | { | |
6993 | (*_bfd_error_handler) (_("%B: bad symbol index: %d"), abfd, | |
6994 | r_symndx); | |
6995 | return FALSE; | |
6996 | } | |
6997 | ||
252b5132 RH |
6998 | if (r_symndx < symtab_hdr->sh_info) |
6999 | h = NULL; | |
7000 | else | |
973a3492 L |
7001 | { |
7002 | h = sym_hashes[r_symndx - symtab_hdr->sh_info]; | |
7003 | while (h->root.type == bfd_link_hash_indirect | |
7004 | || h->root.type == bfd_link_hash_warning) | |
7005 | h = (struct elf_link_hash_entry *) h->root.u.i.link; | |
7006 | } | |
9a5aca8c | 7007 | |
b7693d02 DJ |
7008 | eh = (struct elf32_arm_link_hash_entry *) h; |
7009 | ||
eb043451 | 7010 | switch (r_type) |
252b5132 | 7011 | { |
5e681ec4 | 7012 | case R_ARM_GOT32: |
eb043451 | 7013 | case R_ARM_GOT_PREL: |
ba93b8ac DJ |
7014 | case R_ARM_TLS_GD32: |
7015 | case R_ARM_TLS_IE32: | |
5e681ec4 | 7016 | /* This symbol requires a global offset table entry. */ |
ba93b8ac DJ |
7017 | { |
7018 | int tls_type, old_tls_type; | |
5e681ec4 | 7019 | |
ba93b8ac DJ |
7020 | switch (r_type) |
7021 | { | |
7022 | case R_ARM_TLS_GD32: tls_type = GOT_TLS_GD; break; | |
7023 | case R_ARM_TLS_IE32: tls_type = GOT_TLS_IE; break; | |
7024 | default: tls_type = GOT_NORMAL; break; | |
7025 | } | |
252b5132 | 7026 | |
ba93b8ac DJ |
7027 | if (h != NULL) |
7028 | { | |
7029 | h->got.refcount++; | |
7030 | old_tls_type = elf32_arm_hash_entry (h)->tls_type; | |
7031 | } | |
7032 | else | |
7033 | { | |
7034 | bfd_signed_vma *local_got_refcounts; | |
7035 | ||
7036 | /* This is a global offset table entry for a local symbol. */ | |
7037 | local_got_refcounts = elf_local_got_refcounts (abfd); | |
7038 | if (local_got_refcounts == NULL) | |
7039 | { | |
7040 | bfd_size_type size; | |
7041 | ||
7042 | size = symtab_hdr->sh_info; | |
7043 | size *= (sizeof (bfd_signed_vma) + sizeof(char)); | |
7044 | local_got_refcounts = bfd_zalloc (abfd, size); | |
7045 | if (local_got_refcounts == NULL) | |
7046 | return FALSE; | |
7047 | elf_local_got_refcounts (abfd) = local_got_refcounts; | |
7048 | elf32_arm_local_got_tls_type (abfd) | |
7049 | = (char *) (local_got_refcounts + symtab_hdr->sh_info); | |
7050 | } | |
7051 | local_got_refcounts[r_symndx] += 1; | |
7052 | old_tls_type = elf32_arm_local_got_tls_type (abfd) [r_symndx]; | |
7053 | } | |
7054 | ||
7055 | /* We will already have issued an error message if there is a | |
7056 | TLS / non-TLS mismatch, based on the symbol type. We don't | |
7057 | support any linker relaxations. So just combine any TLS | |
7058 | types needed. */ | |
7059 | if (old_tls_type != GOT_UNKNOWN && old_tls_type != GOT_NORMAL | |
7060 | && tls_type != GOT_NORMAL) | |
7061 | tls_type |= old_tls_type; | |
7062 | ||
7063 | if (old_tls_type != tls_type) | |
7064 | { | |
7065 | if (h != NULL) | |
7066 | elf32_arm_hash_entry (h)->tls_type = tls_type; | |
7067 | else | |
7068 | elf32_arm_local_got_tls_type (abfd) [r_symndx] = tls_type; | |
7069 | } | |
7070 | } | |
7071 | /* Fall through */ | |
7072 | ||
7073 | case R_ARM_TLS_LDM32: | |
7074 | if (r_type == R_ARM_TLS_LDM32) | |
7075 | htab->tls_ldm_got.refcount++; | |
7076 | /* Fall through */ | |
252b5132 | 7077 | |
c19d1205 | 7078 | case R_ARM_GOTOFF32: |
5e681ec4 PB |
7079 | case R_ARM_GOTPC: |
7080 | if (htab->sgot == NULL) | |
7081 | { | |
7082 | if (htab->root.dynobj == NULL) | |
7083 | htab->root.dynobj = abfd; | |
7084 | if (!create_got_section (htab->root.dynobj, info)) | |
7085 | return FALSE; | |
7086 | } | |
252b5132 RH |
7087 | break; |
7088 | ||
00a97672 RS |
7089 | case R_ARM_ABS12: |
7090 | /* VxWorks uses dynamic R_ARM_ABS12 relocations for | |
7091 | ldr __GOTT_INDEX__ offsets. */ | |
7092 | if (!htab->vxworks_p) | |
7093 | break; | |
7094 | /* Fall through */ | |
7095 | ||
252b5132 | 7096 | case R_ARM_ABS32: |
bb224fc3 | 7097 | case R_ARM_ABS32_NOI: |
252b5132 | 7098 | case R_ARM_REL32: |
bb224fc3 | 7099 | case R_ARM_REL32_NOI: |
252b5132 | 7100 | case R_ARM_PC24: |
7359ea65 | 7101 | case R_ARM_PLT32: |
5b5bb741 PB |
7102 | case R_ARM_CALL: |
7103 | case R_ARM_JUMP24: | |
eb043451 | 7104 | case R_ARM_PREL31: |
c19d1205 | 7105 | case R_ARM_THM_CALL: |
b6895b4f PB |
7106 | case R_ARM_MOVW_ABS_NC: |
7107 | case R_ARM_MOVT_ABS: | |
7108 | case R_ARM_MOVW_PREL_NC: | |
7109 | case R_ARM_MOVT_PREL: | |
7110 | case R_ARM_THM_MOVW_ABS_NC: | |
7111 | case R_ARM_THM_MOVT_ABS: | |
7112 | case R_ARM_THM_MOVW_PREL_NC: | |
7113 | case R_ARM_THM_MOVT_PREL: | |
b7693d02 | 7114 | /* Should the interworking branches be listed here? */ |
7359ea65 | 7115 | if (h != NULL) |
5e681ec4 PB |
7116 | { |
7117 | /* If this reloc is in a read-only section, we might | |
7118 | need a copy reloc. We can't check reliably at this | |
7119 | stage whether the section is read-only, as input | |
7120 | sections have not yet been mapped to output sections. | |
7121 | Tentatively set the flag for now, and correct in | |
7122 | adjust_dynamic_symbol. */ | |
7359ea65 | 7123 | if (!info->shared) |
f5385ebf | 7124 | h->non_got_ref = 1; |
7359ea65 | 7125 | |
5e681ec4 | 7126 | /* We may need a .plt entry if the function this reloc |
c84cd8ee DJ |
7127 | refers to is in a different object. We can't tell for |
7128 | sure yet, because something later might force the | |
7129 | symbol local. */ | |
bb224fc3 MS |
7130 | if (r_type != R_ARM_ABS32 |
7131 | && r_type != R_ARM_REL32 | |
7132 | && r_type != R_ARM_ABS32_NOI | |
7133 | && r_type != R_ARM_REL32_NOI) | |
f5385ebf | 7134 | h->needs_plt = 1; |
4f199be3 DJ |
7135 | |
7136 | /* If we create a PLT entry, this relocation will reference | |
7137 | it, even if it's an ABS32 relocation. */ | |
7138 | h->plt.refcount += 1; | |
b7693d02 | 7139 | |
c19d1205 | 7140 | if (r_type == R_ARM_THM_CALL) |
b7693d02 | 7141 | eh->plt_thumb_refcount += 1; |
5e681ec4 PB |
7142 | } |
7143 | ||
67687978 PB |
7144 | /* If we are creating a shared library or relocatable executable, |
7145 | and this is a reloc against a global symbol, or a non PC | |
7146 | relative reloc against a local symbol, then we need to copy | |
7147 | the reloc into the shared library. However, if we are linking | |
7148 | with -Bsymbolic, we do not need to copy a reloc against a | |
252b5132 RH |
7149 | global symbol which is defined in an object we are |
7150 | including in the link (i.e., DEF_REGULAR is set). At | |
7151 | this point we have not seen all the input files, so it is | |
7152 | possible that DEF_REGULAR is not set now but will be set | |
7153 | later (it is never cleared). We account for that | |
7154 | possibility below by storing information in the | |
5e681ec4 | 7155 | relocs_copied field of the hash table entry. */ |
67687978 | 7156 | if ((info->shared || htab->root.is_relocatable_executable) |
5e681ec4 | 7157 | && (sec->flags & SEC_ALLOC) != 0 |
bb224fc3 | 7158 | && ((r_type == R_ARM_ABS32 || r_type == R_ARM_ABS32_NOI) |
71a976dd DJ |
7159 | || (h != NULL && ! h->needs_plt |
7160 | && (! info->symbolic || ! h->def_regular)))) | |
252b5132 | 7161 | { |
5e681ec4 PB |
7162 | struct elf32_arm_relocs_copied *p, **head; |
7163 | ||
252b5132 RH |
7164 | /* When creating a shared object, we must copy these |
7165 | reloc types into the output file. We create a reloc | |
7166 | section in dynobj and make room for this reloc. */ | |
7167 | if (sreloc == NULL) | |
7168 | { | |
7169 | const char * name; | |
7170 | ||
7171 | name = (bfd_elf_string_from_elf_section | |
7172 | (abfd, | |
7173 | elf_elfheader (abfd)->e_shstrndx, | |
7174 | elf_section_data (sec)->rel_hdr.sh_name)); | |
7175 | if (name == NULL) | |
b34976b6 | 7176 | return FALSE; |
252b5132 | 7177 | |
00a97672 | 7178 | BFD_ASSERT (reloc_section_p (htab, name, sec)); |
252b5132 RH |
7179 | |
7180 | sreloc = bfd_get_section_by_name (dynobj, name); | |
7181 | if (sreloc == NULL) | |
7182 | { | |
7183 | flagword flags; | |
7184 | ||
252b5132 RH |
7185 | flags = (SEC_HAS_CONTENTS | SEC_READONLY |
7186 | | SEC_IN_MEMORY | SEC_LINKER_CREATED); | |
e5a52504 MM |
7187 | if ((sec->flags & SEC_ALLOC) != 0 |
7188 | /* BPABI objects never have dynamic | |
7189 | relocations mapped. */ | |
7190 | && !htab->symbian_p) | |
252b5132 | 7191 | flags |= SEC_ALLOC | SEC_LOAD; |
3496cb2a L |
7192 | sreloc = bfd_make_section_with_flags (dynobj, |
7193 | name, | |
7194 | flags); | |
252b5132 | 7195 | if (sreloc == NULL |
252b5132 | 7196 | || ! bfd_set_section_alignment (dynobj, sreloc, 2)) |
b34976b6 | 7197 | return FALSE; |
252b5132 | 7198 | } |
5e681ec4 PB |
7199 | |
7200 | elf_section_data (sec)->sreloc = sreloc; | |
252b5132 RH |
7201 | } |
7202 | ||
5e681ec4 PB |
7203 | /* If this is a global symbol, we count the number of |
7204 | relocations we need for this symbol. */ | |
7205 | if (h != NULL) | |
252b5132 | 7206 | { |
5e681ec4 PB |
7207 | head = &((struct elf32_arm_link_hash_entry *) h)->relocs_copied; |
7208 | } | |
7209 | else | |
7210 | { | |
7211 | /* Track dynamic relocs needed for local syms too. | |
7212 | We really need local syms available to do this | |
7213 | easily. Oh well. */ | |
57e8b36a | 7214 | |
5e681ec4 | 7215 | asection *s; |
6edfbbad DJ |
7216 | void *vpp; |
7217 | ||
5e681ec4 PB |
7218 | s = bfd_section_from_r_symndx (abfd, &htab->sym_sec, |
7219 | sec, r_symndx); | |
7220 | if (s == NULL) | |
7221 | return FALSE; | |
57e8b36a | 7222 | |
6edfbbad DJ |
7223 | vpp = &elf_section_data (s)->local_dynrel; |
7224 | head = (struct elf32_arm_relocs_copied **) vpp; | |
5e681ec4 | 7225 | } |
57e8b36a | 7226 | |
5e681ec4 PB |
7227 | p = *head; |
7228 | if (p == NULL || p->section != sec) | |
7229 | { | |
7230 | bfd_size_type amt = sizeof *p; | |
57e8b36a | 7231 | |
5e681ec4 | 7232 | p = bfd_alloc (htab->root.dynobj, amt); |
252b5132 | 7233 | if (p == NULL) |
5e681ec4 PB |
7234 | return FALSE; |
7235 | p->next = *head; | |
7236 | *head = p; | |
7237 | p->section = sec; | |
7238 | p->count = 0; | |
ba93b8ac | 7239 | p->pc_count = 0; |
252b5132 | 7240 | } |
57e8b36a | 7241 | |
bb224fc3 | 7242 | if (r_type == R_ARM_REL32 || r_type == R_ARM_REL32_NOI) |
ba93b8ac | 7243 | p->pc_count += 1; |
71a976dd | 7244 | p->count += 1; |
252b5132 RH |
7245 | } |
7246 | break; | |
7247 | ||
7248 | /* This relocation describes the C++ object vtable hierarchy. | |
7249 | Reconstruct it for later use during GC. */ | |
7250 | case R_ARM_GNU_VTINHERIT: | |
c152c796 | 7251 | if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset)) |
b34976b6 | 7252 | return FALSE; |
252b5132 | 7253 | break; |
9a5aca8c | 7254 | |
252b5132 RH |
7255 | /* This relocation describes which C++ vtable entries are actually |
7256 | used. Record for later use during GC. */ | |
7257 | case R_ARM_GNU_VTENTRY: | |
c152c796 | 7258 | if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset)) |
b34976b6 | 7259 | return FALSE; |
252b5132 RH |
7260 | break; |
7261 | } | |
7262 | } | |
f21f3fe0 | 7263 | |
b34976b6 | 7264 | return TRUE; |
252b5132 RH |
7265 | } |
7266 | ||
3c9458e9 NC |
7267 | /* Treat mapping symbols as special target symbols. */ |
7268 | ||
7269 | static bfd_boolean | |
7270 | elf32_arm_is_target_special_symbol (bfd * abfd ATTRIBUTE_UNUSED, asymbol * sym) | |
7271 | { | |
b0796911 PB |
7272 | return bfd_is_arm_special_symbol_name (sym->name, |
7273 | BFD_ARM_SPECIAL_SYM_TYPE_ANY); | |
3c9458e9 NC |
7274 | } |
7275 | ||
0367ecfb NC |
7276 | /* This is a copy of elf_find_function() from elf.c except that |
7277 | ARM mapping symbols are ignored when looking for function names | |
7278 | and STT_ARM_TFUNC is considered to a function type. */ | |
252b5132 | 7279 | |
0367ecfb NC |
7280 | static bfd_boolean |
7281 | arm_elf_find_function (bfd * abfd ATTRIBUTE_UNUSED, | |
7282 | asection * section, | |
7283 | asymbol ** symbols, | |
7284 | bfd_vma offset, | |
7285 | const char ** filename_ptr, | |
7286 | const char ** functionname_ptr) | |
7287 | { | |
7288 | const char * filename = NULL; | |
7289 | asymbol * func = NULL; | |
7290 | bfd_vma low_func = 0; | |
7291 | asymbol ** p; | |
252b5132 RH |
7292 | |
7293 | for (p = symbols; *p != NULL; p++) | |
7294 | { | |
7295 | elf_symbol_type *q; | |
7296 | ||
7297 | q = (elf_symbol_type *) *p; | |
7298 | ||
252b5132 RH |
7299 | switch (ELF_ST_TYPE (q->internal_elf_sym.st_info)) |
7300 | { | |
7301 | default: | |
7302 | break; | |
7303 | case STT_FILE: | |
7304 | filename = bfd_asymbol_name (&q->symbol); | |
7305 | break; | |
252b5132 RH |
7306 | case STT_FUNC: |
7307 | case STT_ARM_TFUNC: | |
9d2da7ca | 7308 | case STT_NOTYPE: |
b0796911 | 7309 | /* Skip mapping symbols. */ |
0367ecfb | 7310 | if ((q->symbol.flags & BSF_LOCAL) |
b0796911 PB |
7311 | && bfd_is_arm_special_symbol_name (q->symbol.name, |
7312 | BFD_ARM_SPECIAL_SYM_TYPE_ANY)) | |
0367ecfb NC |
7313 | continue; |
7314 | /* Fall through. */ | |
6b40fcba | 7315 | if (bfd_get_section (&q->symbol) == section |
252b5132 RH |
7316 | && q->symbol.value >= low_func |
7317 | && q->symbol.value <= offset) | |
7318 | { | |
7319 | func = (asymbol *) q; | |
7320 | low_func = q->symbol.value; | |
7321 | } | |
7322 | break; | |
7323 | } | |
7324 | } | |
7325 | ||
7326 | if (func == NULL) | |
b34976b6 | 7327 | return FALSE; |
252b5132 | 7328 | |
0367ecfb NC |
7329 | if (filename_ptr) |
7330 | *filename_ptr = filename; | |
7331 | if (functionname_ptr) | |
7332 | *functionname_ptr = bfd_asymbol_name (func); | |
7333 | ||
7334 | return TRUE; | |
7335 | } | |
7336 | ||
7337 | ||
7338 | /* Find the nearest line to a particular section and offset, for error | |
7339 | reporting. This code is a duplicate of the code in elf.c, except | |
7340 | that it uses arm_elf_find_function. */ | |
7341 | ||
7342 | static bfd_boolean | |
7343 | elf32_arm_find_nearest_line (bfd * abfd, | |
7344 | asection * section, | |
7345 | asymbol ** symbols, | |
7346 | bfd_vma offset, | |
7347 | const char ** filename_ptr, | |
7348 | const char ** functionname_ptr, | |
7349 | unsigned int * line_ptr) | |
7350 | { | |
7351 | bfd_boolean found = FALSE; | |
7352 | ||
7353 | /* We skip _bfd_dwarf1_find_nearest_line since no known ARM toolchain uses it. */ | |
7354 | ||
7355 | if (_bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset, | |
7356 | filename_ptr, functionname_ptr, | |
7357 | line_ptr, 0, | |
7358 | & elf_tdata (abfd)->dwarf2_find_line_info)) | |
7359 | { | |
7360 | if (!*functionname_ptr) | |
7361 | arm_elf_find_function (abfd, section, symbols, offset, | |
7362 | *filename_ptr ? NULL : filename_ptr, | |
7363 | functionname_ptr); | |
f21f3fe0 | 7364 | |
0367ecfb NC |
7365 | return TRUE; |
7366 | } | |
7367 | ||
7368 | if (! _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, | |
7369 | & found, filename_ptr, | |
7370 | functionname_ptr, line_ptr, | |
7371 | & elf_tdata (abfd)->line_info)) | |
7372 | return FALSE; | |
7373 | ||
7374 | if (found && (*functionname_ptr || *line_ptr)) | |
7375 | return TRUE; | |
7376 | ||
7377 | if (symbols == NULL) | |
7378 | return FALSE; | |
7379 | ||
7380 | if (! arm_elf_find_function (abfd, section, symbols, offset, | |
7381 | filename_ptr, functionname_ptr)) | |
7382 | return FALSE; | |
7383 | ||
7384 | *line_ptr = 0; | |
b34976b6 | 7385 | return TRUE; |
252b5132 RH |
7386 | } |
7387 | ||
4ab527b0 FF |
7388 | static bfd_boolean |
7389 | elf32_arm_find_inliner_info (bfd * abfd, | |
7390 | const char ** filename_ptr, | |
7391 | const char ** functionname_ptr, | |
7392 | unsigned int * line_ptr) | |
7393 | { | |
7394 | bfd_boolean found; | |
7395 | found = _bfd_dwarf2_find_inliner_info (abfd, filename_ptr, | |
7396 | functionname_ptr, line_ptr, | |
7397 | & elf_tdata (abfd)->dwarf2_find_line_info); | |
7398 | return found; | |
7399 | } | |
7400 | ||
252b5132 RH |
7401 | /* Adjust a symbol defined by a dynamic object and referenced by a |
7402 | regular object. The current definition is in some section of the | |
7403 | dynamic object, but we're not including those sections. We have to | |
7404 | change the definition to something the rest of the link can | |
7405 | understand. */ | |
7406 | ||
b34976b6 | 7407 | static bfd_boolean |
57e8b36a NC |
7408 | elf32_arm_adjust_dynamic_symbol (struct bfd_link_info * info, |
7409 | struct elf_link_hash_entry * h) | |
252b5132 RH |
7410 | { |
7411 | bfd * dynobj; | |
7412 | asection * s; | |
7413 | unsigned int power_of_two; | |
b7693d02 | 7414 | struct elf32_arm_link_hash_entry * eh; |
67687978 | 7415 | struct elf32_arm_link_hash_table *globals; |
252b5132 | 7416 | |
67687978 | 7417 | globals = elf32_arm_hash_table (info); |
252b5132 RH |
7418 | dynobj = elf_hash_table (info)->dynobj; |
7419 | ||
7420 | /* Make sure we know what is going on here. */ | |
7421 | BFD_ASSERT (dynobj != NULL | |
f5385ebf | 7422 | && (h->needs_plt |
f6e332e6 | 7423 | || h->u.weakdef != NULL |
f5385ebf AM |
7424 | || (h->def_dynamic |
7425 | && h->ref_regular | |
7426 | && !h->def_regular))); | |
252b5132 | 7427 | |
b7693d02 DJ |
7428 | eh = (struct elf32_arm_link_hash_entry *) h; |
7429 | ||
252b5132 RH |
7430 | /* If this is a function, put it in the procedure linkage table. We |
7431 | will fill in the contents of the procedure linkage table later, | |
7432 | when we know the address of the .got section. */ | |
b7693d02 | 7433 | if (h->type == STT_FUNC || h->type == STT_ARM_TFUNC |
f5385ebf | 7434 | || h->needs_plt) |
252b5132 | 7435 | { |
5e681ec4 PB |
7436 | if (h->plt.refcount <= 0 |
7437 | || SYMBOL_CALLS_LOCAL (info, h) | |
7438 | || (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT | |
7439 | && h->root.type == bfd_link_hash_undefweak)) | |
252b5132 RH |
7440 | { |
7441 | /* This case can occur if we saw a PLT32 reloc in an input | |
5e681ec4 PB |
7442 | file, but the symbol was never referred to by a dynamic |
7443 | object, or if all references were garbage collected. In | |
7444 | such a case, we don't actually need to build a procedure | |
7445 | linkage table, and we can just do a PC24 reloc instead. */ | |
7446 | h->plt.offset = (bfd_vma) -1; | |
b7693d02 | 7447 | eh->plt_thumb_refcount = 0; |
f5385ebf | 7448 | h->needs_plt = 0; |
252b5132 RH |
7449 | } |
7450 | ||
b34976b6 | 7451 | return TRUE; |
252b5132 | 7452 | } |
5e681ec4 | 7453 | else |
b7693d02 DJ |
7454 | { |
7455 | /* It's possible that we incorrectly decided a .plt reloc was | |
7456 | needed for an R_ARM_PC24 or similar reloc to a non-function sym | |
7457 | in check_relocs. We can't decide accurately between function | |
7458 | and non-function syms in check-relocs; Objects loaded later in | |
7459 | the link may change h->type. So fix it now. */ | |
7460 | h->plt.offset = (bfd_vma) -1; | |
7461 | eh->plt_thumb_refcount = 0; | |
7462 | } | |
252b5132 RH |
7463 | |
7464 | /* If this is a weak symbol, and there is a real definition, the | |
7465 | processor independent code will have arranged for us to see the | |
7466 | real definition first, and we can just use the same value. */ | |
f6e332e6 | 7467 | if (h->u.weakdef != NULL) |
252b5132 | 7468 | { |
f6e332e6 AM |
7469 | BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined |
7470 | || h->u.weakdef->root.type == bfd_link_hash_defweak); | |
7471 | h->root.u.def.section = h->u.weakdef->root.u.def.section; | |
7472 | h->root.u.def.value = h->u.weakdef->root.u.def.value; | |
b34976b6 | 7473 | return TRUE; |
252b5132 RH |
7474 | } |
7475 | ||
ba93b8ac DJ |
7476 | /* If there are no non-GOT references, we do not need a copy |
7477 | relocation. */ | |
7478 | if (!h->non_got_ref) | |
7479 | return TRUE; | |
7480 | ||
252b5132 RH |
7481 | /* This is a reference to a symbol defined by a dynamic object which |
7482 | is not a function. */ | |
7483 | ||
7484 | /* If we are creating a shared library, we must presume that the | |
7485 | only references to the symbol are via the global offset table. | |
7486 | For such cases we need not do anything here; the relocations will | |
67687978 PB |
7487 | be handled correctly by relocate_section. Relocatable executables |
7488 | can reference data in shared objects directly, so we don't need to | |
7489 | do anything here. */ | |
7490 | if (info->shared || globals->root.is_relocatable_executable) | |
b34976b6 | 7491 | return TRUE; |
252b5132 | 7492 | |
909272ee AM |
7493 | if (h->size == 0) |
7494 | { | |
7495 | (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"), | |
7496 | h->root.root.string); | |
7497 | return TRUE; | |
7498 | } | |
7499 | ||
252b5132 RH |
7500 | /* We must allocate the symbol in our .dynbss section, which will |
7501 | become part of the .bss section of the executable. There will be | |
7502 | an entry for this symbol in the .dynsym section. The dynamic | |
7503 | object will contain position independent code, so all references | |
7504 | from the dynamic object to this symbol will go through the global | |
7505 | offset table. The dynamic linker will use the .dynsym entry to | |
7506 | determine the address it must put in the global offset table, so | |
7507 | both the dynamic object and the regular object will refer to the | |
7508 | same memory location for the variable. */ | |
252b5132 RH |
7509 | s = bfd_get_section_by_name (dynobj, ".dynbss"); |
7510 | BFD_ASSERT (s != NULL); | |
7511 | ||
7512 | /* We must generate a R_ARM_COPY reloc to tell the dynamic linker to | |
7513 | copy the initial value out of the dynamic object and into the | |
7514 | runtime process image. We need to remember the offset into the | |
00a97672 | 7515 | .rel(a).bss section we are going to use. */ |
252b5132 RH |
7516 | if ((h->root.u.def.section->flags & SEC_ALLOC) != 0) |
7517 | { | |
7518 | asection *srel; | |
7519 | ||
00a97672 | 7520 | srel = bfd_get_section_by_name (dynobj, RELOC_SECTION (globals, ".bss")); |
252b5132 | 7521 | BFD_ASSERT (srel != NULL); |
00a97672 | 7522 | srel->size += RELOC_SIZE (globals); |
f5385ebf | 7523 | h->needs_copy = 1; |
252b5132 RH |
7524 | } |
7525 | ||
7526 | /* We need to figure out the alignment required for this symbol. I | |
7527 | have no idea how ELF linkers handle this. */ | |
7528 | power_of_two = bfd_log2 (h->size); | |
7529 | if (power_of_two > 3) | |
7530 | power_of_two = 3; | |
7531 | ||
7532 | /* Apply the required alignment. */ | |
eea6121a | 7533 | s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); |
252b5132 RH |
7534 | if (power_of_two > bfd_get_section_alignment (dynobj, s)) |
7535 | { | |
7536 | if (! bfd_set_section_alignment (dynobj, s, power_of_two)) | |
b34976b6 | 7537 | return FALSE; |
252b5132 RH |
7538 | } |
7539 | ||
7540 | /* Define the symbol as being at this point in the section. */ | |
7541 | h->root.u.def.section = s; | |
eea6121a | 7542 | h->root.u.def.value = s->size; |
252b5132 RH |
7543 | |
7544 | /* Increment the section size to make room for the symbol. */ | |
eea6121a | 7545 | s->size += h->size; |
252b5132 | 7546 | |
b34976b6 | 7547 | return TRUE; |
252b5132 RH |
7548 | } |
7549 | ||
5e681ec4 PB |
7550 | /* Allocate space in .plt, .got and associated reloc sections for |
7551 | dynamic relocs. */ | |
7552 | ||
7553 | static bfd_boolean | |
57e8b36a | 7554 | allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf) |
5e681ec4 PB |
7555 | { |
7556 | struct bfd_link_info *info; | |
7557 | struct elf32_arm_link_hash_table *htab; | |
7558 | struct elf32_arm_link_hash_entry *eh; | |
7559 | struct elf32_arm_relocs_copied *p; | |
7560 | ||
b7693d02 DJ |
7561 | eh = (struct elf32_arm_link_hash_entry *) h; |
7562 | ||
5e681ec4 PB |
7563 | if (h->root.type == bfd_link_hash_indirect) |
7564 | return TRUE; | |
7565 | ||
7566 | if (h->root.type == bfd_link_hash_warning) | |
7567 | /* When warning symbols are created, they **replace** the "real" | |
7568 | entry in the hash table, thus we never get to see the real | |
7569 | symbol in a hash traversal. So look at it now. */ | |
7570 | h = (struct elf_link_hash_entry *) h->root.u.i.link; | |
7571 | ||
7572 | info = (struct bfd_link_info *) inf; | |
7573 | htab = elf32_arm_hash_table (info); | |
7574 | ||
7575 | if (htab->root.dynamic_sections_created | |
7576 | && h->plt.refcount > 0) | |
7577 | { | |
7578 | /* Make sure this symbol is output as a dynamic symbol. | |
7579 | Undefined weak syms won't yet be marked as dynamic. */ | |
7580 | if (h->dynindx == -1 | |
f5385ebf | 7581 | && !h->forced_local) |
5e681ec4 | 7582 | { |
c152c796 | 7583 | if (! bfd_elf_link_record_dynamic_symbol (info, h)) |
5e681ec4 PB |
7584 | return FALSE; |
7585 | } | |
7586 | ||
7587 | if (info->shared | |
7359ea65 | 7588 | || WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, 0, h)) |
5e681ec4 PB |
7589 | { |
7590 | asection *s = htab->splt; | |
7591 | ||
7592 | /* If this is the first .plt entry, make room for the special | |
7593 | first entry. */ | |
eea6121a | 7594 | if (s->size == 0) |
e5a52504 | 7595 | s->size += htab->plt_header_size; |
5e681ec4 | 7596 | |
eea6121a | 7597 | h->plt.offset = s->size; |
5e681ec4 | 7598 | |
b7693d02 DJ |
7599 | /* If we will insert a Thumb trampoline before this PLT, leave room |
7600 | for it. */ | |
33bfe774 | 7601 | if (!htab->use_blx && eh->plt_thumb_refcount > 0) |
b7693d02 DJ |
7602 | { |
7603 | h->plt.offset += PLT_THUMB_STUB_SIZE; | |
7604 | s->size += PLT_THUMB_STUB_SIZE; | |
7605 | } | |
7606 | ||
5e681ec4 PB |
7607 | /* If this symbol is not defined in a regular file, and we are |
7608 | not generating a shared library, then set the symbol to this | |
7609 | location in the .plt. This is required to make function | |
7610 | pointers compare as equal between the normal executable and | |
7611 | the shared library. */ | |
7612 | if (! info->shared | |
f5385ebf | 7613 | && !h->def_regular) |
5e681ec4 PB |
7614 | { |
7615 | h->root.u.def.section = s; | |
7616 | h->root.u.def.value = h->plt.offset; | |
b7693d02 DJ |
7617 | |
7618 | /* Make sure the function is not marked as Thumb, in case | |
7619 | it is the target of an ABS32 relocation, which will | |
7620 | point to the PLT entry. */ | |
7621 | if (ELF_ST_TYPE (h->type) == STT_ARM_TFUNC) | |
7622 | h->type = ELF_ST_INFO (ELF_ST_BIND (h->type), STT_FUNC); | |
5e681ec4 PB |
7623 | } |
7624 | ||
7625 | /* Make room for this entry. */ | |
e5a52504 | 7626 | s->size += htab->plt_entry_size; |
5e681ec4 | 7627 | |
e5a52504 | 7628 | if (!htab->symbian_p) |
b7693d02 DJ |
7629 | { |
7630 | /* We also need to make an entry in the .got.plt section, which | |
7631 | will be placed in the .got section by the linker script. */ | |
7632 | eh->plt_got_offset = htab->sgotplt->size; | |
7633 | htab->sgotplt->size += 4; | |
7634 | } | |
5e681ec4 | 7635 | |
00a97672 RS |
7636 | /* We also need to make an entry in the .rel(a).plt section. */ |
7637 | htab->srelplt->size += RELOC_SIZE (htab); | |
7638 | ||
7639 | /* VxWorks executables have a second set of relocations for | |
7640 | each PLT entry. They go in a separate relocation section, | |
7641 | which is processed by the kernel loader. */ | |
7642 | if (htab->vxworks_p && !info->shared) | |
7643 | { | |
7644 | /* There is a relocation for the initial PLT entry: | |
7645 | an R_ARM_32 relocation for _GLOBAL_OFFSET_TABLE_. */ | |
7646 | if (h->plt.offset == htab->plt_header_size) | |
7647 | htab->srelplt2->size += RELOC_SIZE (htab); | |
7648 | ||
7649 | /* There are two extra relocations for each subsequent | |
7650 | PLT entry: an R_ARM_32 relocation for the GOT entry, | |
7651 | and an R_ARM_32 relocation for the PLT entry. */ | |
7652 | htab->srelplt2->size += RELOC_SIZE (htab) * 2; | |
7653 | } | |
5e681ec4 PB |
7654 | } |
7655 | else | |
7656 | { | |
7657 | h->plt.offset = (bfd_vma) -1; | |
f5385ebf | 7658 | h->needs_plt = 0; |
5e681ec4 PB |
7659 | } |
7660 | } | |
7661 | else | |
7662 | { | |
7663 | h->plt.offset = (bfd_vma) -1; | |
f5385ebf | 7664 | h->needs_plt = 0; |
5e681ec4 PB |
7665 | } |
7666 | ||
7667 | if (h->got.refcount > 0) | |
7668 | { | |
7669 | asection *s; | |
7670 | bfd_boolean dyn; | |
ba93b8ac DJ |
7671 | int tls_type = elf32_arm_hash_entry (h)->tls_type; |
7672 | int indx; | |
5e681ec4 PB |
7673 | |
7674 | /* Make sure this symbol is output as a dynamic symbol. | |
7675 | Undefined weak syms won't yet be marked as dynamic. */ | |
7676 | if (h->dynindx == -1 | |
f5385ebf | 7677 | && !h->forced_local) |
5e681ec4 | 7678 | { |
c152c796 | 7679 | if (! bfd_elf_link_record_dynamic_symbol (info, h)) |
5e681ec4 PB |
7680 | return FALSE; |
7681 | } | |
7682 | ||
e5a52504 MM |
7683 | if (!htab->symbian_p) |
7684 | { | |
7685 | s = htab->sgot; | |
7686 | h->got.offset = s->size; | |
ba93b8ac DJ |
7687 | |
7688 | if (tls_type == GOT_UNKNOWN) | |
7689 | abort (); | |
7690 | ||
7691 | if (tls_type == GOT_NORMAL) | |
7692 | /* Non-TLS symbols need one GOT slot. */ | |
7693 | s->size += 4; | |
7694 | else | |
7695 | { | |
7696 | if (tls_type & GOT_TLS_GD) | |
7697 | /* R_ARM_TLS_GD32 needs 2 consecutive GOT slots. */ | |
7698 | s->size += 8; | |
7699 | if (tls_type & GOT_TLS_IE) | |
7700 | /* R_ARM_TLS_IE32 needs one GOT slot. */ | |
7701 | s->size += 4; | |
7702 | } | |
7703 | ||
e5a52504 | 7704 | dyn = htab->root.dynamic_sections_created; |
ba93b8ac DJ |
7705 | |
7706 | indx = 0; | |
7707 | if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h) | |
7708 | && (!info->shared | |
7709 | || !SYMBOL_REFERENCES_LOCAL (info, h))) | |
7710 | indx = h->dynindx; | |
7711 | ||
7712 | if (tls_type != GOT_NORMAL | |
7713 | && (info->shared || indx != 0) | |
7714 | && (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT | |
7715 | || h->root.type != bfd_link_hash_undefweak)) | |
7716 | { | |
7717 | if (tls_type & GOT_TLS_IE) | |
00a97672 | 7718 | htab->srelgot->size += RELOC_SIZE (htab); |
ba93b8ac DJ |
7719 | |
7720 | if (tls_type & GOT_TLS_GD) | |
00a97672 | 7721 | htab->srelgot->size += RELOC_SIZE (htab); |
ba93b8ac DJ |
7722 | |
7723 | if ((tls_type & GOT_TLS_GD) && indx != 0) | |
00a97672 | 7724 | htab->srelgot->size += RELOC_SIZE (htab); |
ba93b8ac DJ |
7725 | } |
7726 | else if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT | |
7727 | || h->root.type != bfd_link_hash_undefweak) | |
7728 | && (info->shared | |
7729 | || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h))) | |
00a97672 | 7730 | htab->srelgot->size += RELOC_SIZE (htab); |
e5a52504 | 7731 | } |
5e681ec4 PB |
7732 | } |
7733 | else | |
7734 | h->got.offset = (bfd_vma) -1; | |
7735 | ||
a4fd1a8e PB |
7736 | /* Allocate stubs for exported Thumb functions on v4t. */ |
7737 | if (!htab->use_blx && h->dynindx != -1 | |
7738 | && ELF_ST_TYPE (h->type) == STT_ARM_TFUNC | |
7739 | && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) | |
7740 | { | |
7741 | struct elf_link_hash_entry * th; | |
7742 | struct bfd_link_hash_entry * bh; | |
7743 | struct elf_link_hash_entry * myh; | |
7744 | char name[1024]; | |
7745 | asection *s; | |
7746 | bh = NULL; | |
7747 | /* Create a new symbol to regist the real location of the function. */ | |
7748 | s = h->root.u.def.section; | |
7749 | sprintf(name, "__real_%s", h->root.root.string); | |
7750 | _bfd_generic_link_add_one_symbol (info, s->owner, | |
7751 | name, BSF_GLOBAL, s, | |
7752 | h->root.u.def.value, | |
7753 | NULL, TRUE, FALSE, &bh); | |
7754 | ||
7755 | myh = (struct elf_link_hash_entry *) bh; | |
7756 | myh->type = ELF_ST_INFO (STB_LOCAL, STT_ARM_TFUNC); | |
7757 | myh->forced_local = 1; | |
7758 | eh->export_glue = myh; | |
7759 | th = record_arm_to_thumb_glue (info, h); | |
7760 | /* Point the symbol at the stub. */ | |
7761 | h->type = ELF_ST_INFO (ELF_ST_BIND (h->type), STT_FUNC); | |
7762 | h->root.u.def.section = th->root.u.def.section; | |
7763 | h->root.u.def.value = th->root.u.def.value & ~1; | |
7764 | } | |
7765 | ||
5e681ec4 PB |
7766 | if (eh->relocs_copied == NULL) |
7767 | return TRUE; | |
7768 | ||
7769 | /* In the shared -Bsymbolic case, discard space allocated for | |
7770 | dynamic pc-relative relocs against symbols which turn out to be | |
7771 | defined in regular objects. For the normal shared case, discard | |
7772 | space for pc-relative relocs that have become local due to symbol | |
7773 | visibility changes. */ | |
7774 | ||
67687978 | 7775 | if (info->shared || htab->root.is_relocatable_executable) |
5e681ec4 | 7776 | { |
bb224fc3 MS |
7777 | /* The only reloc thats uses pc_count are R_ARM_REL32 and |
7778 | R_ARM_REL32_NOI, which will appear on something like | |
7779 | ".long foo - .". We want calls to protected symbols to resolve | |
7780 | directly to the function rather than going via the plt. If people | |
7781 | want function pointer comparisons to work as expected then they | |
7782 | should avoid writing assembly like ".long foo - .". */ | |
ba93b8ac DJ |
7783 | if (SYMBOL_CALLS_LOCAL (info, h)) |
7784 | { | |
7785 | struct elf32_arm_relocs_copied **pp; | |
7786 | ||
7787 | for (pp = &eh->relocs_copied; (p = *pp) != NULL; ) | |
7788 | { | |
7789 | p->count -= p->pc_count; | |
7790 | p->pc_count = 0; | |
7791 | if (p->count == 0) | |
7792 | *pp = p->next; | |
7793 | else | |
7794 | pp = &p->next; | |
7795 | } | |
7796 | } | |
7797 | ||
7798 | /* Also discard relocs on undefined weak syms with non-default | |
7359ea65 | 7799 | visibility. */ |
22d606e9 | 7800 | if (eh->relocs_copied != NULL |
5e681ec4 | 7801 | && h->root.type == bfd_link_hash_undefweak) |
22d606e9 AM |
7802 | { |
7803 | if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT) | |
7804 | eh->relocs_copied = NULL; | |
7805 | ||
7806 | /* Make sure undefined weak symbols are output as a dynamic | |
7807 | symbol in PIEs. */ | |
7808 | else if (h->dynindx == -1 | |
7809 | && !h->forced_local) | |
7810 | { | |
7811 | if (! bfd_elf_link_record_dynamic_symbol (info, h)) | |
7812 | return FALSE; | |
7813 | } | |
7814 | } | |
7815 | ||
67687978 PB |
7816 | else if (htab->root.is_relocatable_executable && h->dynindx == -1 |
7817 | && h->root.type == bfd_link_hash_new) | |
7818 | { | |
7819 | /* Output absolute symbols so that we can create relocations | |
7820 | against them. For normal symbols we output a relocation | |
7821 | against the section that contains them. */ | |
7822 | if (! bfd_elf_link_record_dynamic_symbol (info, h)) | |
7823 | return FALSE; | |
7824 | } | |
7825 | ||
5e681ec4 PB |
7826 | } |
7827 | else | |
7828 | { | |
7829 | /* For the non-shared case, discard space for relocs against | |
7830 | symbols which turn out to need copy relocs or are not | |
7831 | dynamic. */ | |
7832 | ||
f5385ebf AM |
7833 | if (!h->non_got_ref |
7834 | && ((h->def_dynamic | |
7835 | && !h->def_regular) | |
5e681ec4 PB |
7836 | || (htab->root.dynamic_sections_created |
7837 | && (h->root.type == bfd_link_hash_undefweak | |
7838 | || h->root.type == bfd_link_hash_undefined)))) | |
7839 | { | |
7840 | /* Make sure this symbol is output as a dynamic symbol. | |
7841 | Undefined weak syms won't yet be marked as dynamic. */ | |
7842 | if (h->dynindx == -1 | |
f5385ebf | 7843 | && !h->forced_local) |
5e681ec4 | 7844 | { |
c152c796 | 7845 | if (! bfd_elf_link_record_dynamic_symbol (info, h)) |
5e681ec4 PB |
7846 | return FALSE; |
7847 | } | |
7848 | ||
7849 | /* If that succeeded, we know we'll be keeping all the | |
7850 | relocs. */ | |
7851 | if (h->dynindx != -1) | |
7852 | goto keep; | |
7853 | } | |
7854 | ||
7855 | eh->relocs_copied = NULL; | |
7856 | ||
7857 | keep: ; | |
7858 | } | |
7859 | ||
7860 | /* Finally, allocate space. */ | |
7861 | for (p = eh->relocs_copied; p != NULL; p = p->next) | |
7862 | { | |
7863 | asection *sreloc = elf_section_data (p->section)->sreloc; | |
00a97672 | 7864 | sreloc->size += p->count * RELOC_SIZE (htab); |
5e681ec4 PB |
7865 | } |
7866 | ||
7867 | return TRUE; | |
7868 | } | |
7869 | ||
08d1f311 DJ |
7870 | /* Find any dynamic relocs that apply to read-only sections. */ |
7871 | ||
7872 | static bfd_boolean | |
7873 | elf32_arm_readonly_dynrelocs (struct elf_link_hash_entry *h, PTR inf) | |
7874 | { | |
7875 | struct elf32_arm_link_hash_entry *eh; | |
7876 | struct elf32_arm_relocs_copied *p; | |
7877 | ||
7878 | if (h->root.type == bfd_link_hash_warning) | |
7879 | h = (struct elf_link_hash_entry *) h->root.u.i.link; | |
7880 | ||
7881 | eh = (struct elf32_arm_link_hash_entry *) h; | |
7882 | for (p = eh->relocs_copied; p != NULL; p = p->next) | |
7883 | { | |
7884 | asection *s = p->section; | |
7885 | ||
7886 | if (s != NULL && (s->flags & SEC_READONLY) != 0) | |
7887 | { | |
7888 | struct bfd_link_info *info = (struct bfd_link_info *) inf; | |
7889 | ||
7890 | info->flags |= DF_TEXTREL; | |
7891 | ||
7892 | /* Not an error, just cut short the traversal. */ | |
7893 | return FALSE; | |
7894 | } | |
7895 | } | |
7896 | return TRUE; | |
7897 | } | |
7898 | ||
252b5132 RH |
7899 | /* Set the sizes of the dynamic sections. */ |
7900 | ||
b34976b6 | 7901 | static bfd_boolean |
57e8b36a NC |
7902 | elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, |
7903 | struct bfd_link_info * info) | |
252b5132 RH |
7904 | { |
7905 | bfd * dynobj; | |
7906 | asection * s; | |
b34976b6 AM |
7907 | bfd_boolean plt; |
7908 | bfd_boolean relocs; | |
5e681ec4 PB |
7909 | bfd *ibfd; |
7910 | struct elf32_arm_link_hash_table *htab; | |
252b5132 | 7911 | |
5e681ec4 | 7912 | htab = elf32_arm_hash_table (info); |
252b5132 RH |
7913 | dynobj = elf_hash_table (info)->dynobj; |
7914 | BFD_ASSERT (dynobj != NULL); | |
39b41c9c | 7915 | check_use_blx (htab); |
252b5132 RH |
7916 | |
7917 | if (elf_hash_table (info)->dynamic_sections_created) | |
7918 | { | |
7919 | /* Set the contents of the .interp section to the interpreter. */ | |
893c4fe2 | 7920 | if (info->executable) |
252b5132 RH |
7921 | { |
7922 | s = bfd_get_section_by_name (dynobj, ".interp"); | |
7923 | BFD_ASSERT (s != NULL); | |
eea6121a | 7924 | s->size = sizeof ELF_DYNAMIC_INTERPRETER; |
252b5132 RH |
7925 | s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; |
7926 | } | |
7927 | } | |
5e681ec4 PB |
7928 | |
7929 | /* Set up .got offsets for local syms, and space for local dynamic | |
7930 | relocs. */ | |
7931 | for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next) | |
252b5132 | 7932 | { |
5e681ec4 PB |
7933 | bfd_signed_vma *local_got; |
7934 | bfd_signed_vma *end_local_got; | |
7935 | char *local_tls_type; | |
7936 | bfd_size_type locsymcount; | |
7937 | Elf_Internal_Shdr *symtab_hdr; | |
7938 | asection *srel; | |
7939 | ||
7940 | if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour) | |
7941 | continue; | |
7942 | ||
7943 | for (s = ibfd->sections; s != NULL; s = s->next) | |
7944 | { | |
7945 | struct elf32_arm_relocs_copied *p; | |
7946 | ||
6edfbbad | 7947 | for (p = elf_section_data (s)->local_dynrel; p != NULL; p = p->next) |
5e681ec4 PB |
7948 | { |
7949 | if (!bfd_is_abs_section (p->section) | |
7950 | && bfd_is_abs_section (p->section->output_section)) | |
7951 | { | |
7952 | /* Input section has been discarded, either because | |
7953 | it is a copy of a linkonce section or due to | |
7954 | linker script /DISCARD/, so we'll be discarding | |
7955 | the relocs too. */ | |
7956 | } | |
7957 | else if (p->count != 0) | |
7958 | { | |
7959 | srel = elf_section_data (p->section)->sreloc; | |
00a97672 | 7960 | srel->size += p->count * RELOC_SIZE (htab); |
5e681ec4 PB |
7961 | if ((p->section->output_section->flags & SEC_READONLY) != 0) |
7962 | info->flags |= DF_TEXTREL; | |
7963 | } | |
7964 | } | |
7965 | } | |
7966 | ||
7967 | local_got = elf_local_got_refcounts (ibfd); | |
7968 | if (!local_got) | |
7969 | continue; | |
7970 | ||
7971 | symtab_hdr = &elf_tdata (ibfd)->symtab_hdr; | |
7972 | locsymcount = symtab_hdr->sh_info; | |
7973 | end_local_got = local_got + locsymcount; | |
ba93b8ac | 7974 | local_tls_type = elf32_arm_local_got_tls_type (ibfd); |
5e681ec4 PB |
7975 | s = htab->sgot; |
7976 | srel = htab->srelgot; | |
7977 | for (; local_got < end_local_got; ++local_got, ++local_tls_type) | |
7978 | { | |
7979 | if (*local_got > 0) | |
7980 | { | |
eea6121a | 7981 | *local_got = s->size; |
ba93b8ac DJ |
7982 | if (*local_tls_type & GOT_TLS_GD) |
7983 | /* TLS_GD relocs need an 8-byte structure in the GOT. */ | |
7984 | s->size += 8; | |
7985 | if (*local_tls_type & GOT_TLS_IE) | |
7986 | s->size += 4; | |
7987 | if (*local_tls_type == GOT_NORMAL) | |
7988 | s->size += 4; | |
7989 | ||
7990 | if (info->shared || *local_tls_type == GOT_TLS_GD) | |
00a97672 | 7991 | srel->size += RELOC_SIZE (htab); |
5e681ec4 PB |
7992 | } |
7993 | else | |
7994 | *local_got = (bfd_vma) -1; | |
7995 | } | |
252b5132 RH |
7996 | } |
7997 | ||
ba93b8ac DJ |
7998 | if (htab->tls_ldm_got.refcount > 0) |
7999 | { | |
8000 | /* Allocate two GOT entries and one dynamic relocation (if necessary) | |
8001 | for R_ARM_TLS_LDM32 relocations. */ | |
8002 | htab->tls_ldm_got.offset = htab->sgot->size; | |
8003 | htab->sgot->size += 8; | |
8004 | if (info->shared) | |
00a97672 | 8005 | htab->srelgot->size += RELOC_SIZE (htab); |
ba93b8ac DJ |
8006 | } |
8007 | else | |
8008 | htab->tls_ldm_got.offset = -1; | |
8009 | ||
5e681ec4 PB |
8010 | /* Allocate global sym .plt and .got entries, and space for global |
8011 | sym dynamic relocs. */ | |
57e8b36a | 8012 | elf_link_hash_traverse (& htab->root, allocate_dynrelocs, info); |
252b5132 RH |
8013 | |
8014 | /* The check_relocs and adjust_dynamic_symbol entry points have | |
8015 | determined the sizes of the various dynamic sections. Allocate | |
8016 | memory for them. */ | |
b34976b6 AM |
8017 | plt = FALSE; |
8018 | relocs = FALSE; | |
252b5132 RH |
8019 | for (s = dynobj->sections; s != NULL; s = s->next) |
8020 | { | |
8021 | const char * name; | |
252b5132 RH |
8022 | |
8023 | if ((s->flags & SEC_LINKER_CREATED) == 0) | |
8024 | continue; | |
8025 | ||
8026 | /* It's OK to base decisions on the section name, because none | |
8027 | of the dynobj section names depend upon the input files. */ | |
8028 | name = bfd_get_section_name (dynobj, s); | |
8029 | ||
24a1ba0f | 8030 | if (strcmp (name, ".plt") == 0) |
252b5132 | 8031 | { |
c456f082 AM |
8032 | /* Remember whether there is a PLT. */ |
8033 | plt = s->size != 0; | |
252b5132 | 8034 | } |
0112cd26 | 8035 | else if (CONST_STRNEQ (name, ".rel")) |
252b5132 | 8036 | { |
c456f082 | 8037 | if (s->size != 0) |
252b5132 | 8038 | { |
252b5132 | 8039 | /* Remember whether there are any reloc sections other |
00a97672 RS |
8040 | than .rel(a).plt and .rela.plt.unloaded. */ |
8041 | if (s != htab->srelplt && s != htab->srelplt2) | |
b34976b6 | 8042 | relocs = TRUE; |
252b5132 RH |
8043 | |
8044 | /* We use the reloc_count field as a counter if we need | |
8045 | to copy relocs into the output file. */ | |
8046 | s->reloc_count = 0; | |
8047 | } | |
8048 | } | |
0112cd26 | 8049 | else if (! CONST_STRNEQ (name, ".got") |
c456f082 | 8050 | && strcmp (name, ".dynbss") != 0) |
252b5132 RH |
8051 | { |
8052 | /* It's not one of our sections, so don't allocate space. */ | |
8053 | continue; | |
8054 | } | |
8055 | ||
c456f082 | 8056 | if (s->size == 0) |
252b5132 | 8057 | { |
c456f082 | 8058 | /* If we don't need this section, strip it from the |
00a97672 RS |
8059 | output file. This is mostly to handle .rel(a).bss and |
8060 | .rel(a).plt. We must create both sections in | |
c456f082 AM |
8061 | create_dynamic_sections, because they must be created |
8062 | before the linker maps input sections to output | |
8063 | sections. The linker does that before | |
8064 | adjust_dynamic_symbol is called, and it is that | |
8065 | function which decides whether anything needs to go | |
8066 | into these sections. */ | |
8423293d | 8067 | s->flags |= SEC_EXCLUDE; |
252b5132 RH |
8068 | continue; |
8069 | } | |
8070 | ||
c456f082 AM |
8071 | if ((s->flags & SEC_HAS_CONTENTS) == 0) |
8072 | continue; | |
8073 | ||
252b5132 | 8074 | /* Allocate memory for the section contents. */ |
eea6121a | 8075 | s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size); |
c456f082 | 8076 | if (s->contents == NULL) |
b34976b6 | 8077 | return FALSE; |
252b5132 RH |
8078 | } |
8079 | ||
8080 | if (elf_hash_table (info)->dynamic_sections_created) | |
8081 | { | |
8082 | /* Add some entries to the .dynamic section. We fill in the | |
8083 | values later, in elf32_arm_finish_dynamic_sections, but we | |
8084 | must add the entries now so that we get the correct size for | |
8085 | the .dynamic section. The DT_DEBUG entry is filled in by the | |
8086 | dynamic linker and used by the debugger. */ | |
dc810e39 | 8087 | #define add_dynamic_entry(TAG, VAL) \ |
5a580b3a | 8088 | _bfd_elf_add_dynamic_entry (info, TAG, VAL) |
dc810e39 | 8089 | |
8532796c | 8090 | if (info->executable) |
252b5132 | 8091 | { |
dc810e39 | 8092 | if (!add_dynamic_entry (DT_DEBUG, 0)) |
b34976b6 | 8093 | return FALSE; |
252b5132 RH |
8094 | } |
8095 | ||
8096 | if (plt) | |
8097 | { | |
dc810e39 AM |
8098 | if ( !add_dynamic_entry (DT_PLTGOT, 0) |
8099 | || !add_dynamic_entry (DT_PLTRELSZ, 0) | |
00a97672 RS |
8100 | || !add_dynamic_entry (DT_PLTREL, |
8101 | htab->use_rel ? DT_REL : DT_RELA) | |
dc810e39 | 8102 | || !add_dynamic_entry (DT_JMPREL, 0)) |
b34976b6 | 8103 | return FALSE; |
252b5132 RH |
8104 | } |
8105 | ||
8106 | if (relocs) | |
8107 | { | |
00a97672 RS |
8108 | if (htab->use_rel) |
8109 | { | |
8110 | if (!add_dynamic_entry (DT_REL, 0) | |
8111 | || !add_dynamic_entry (DT_RELSZ, 0) | |
8112 | || !add_dynamic_entry (DT_RELENT, RELOC_SIZE (htab))) | |
8113 | return FALSE; | |
8114 | } | |
8115 | else | |
8116 | { | |
8117 | if (!add_dynamic_entry (DT_RELA, 0) | |
8118 | || !add_dynamic_entry (DT_RELASZ, 0) | |
8119 | || !add_dynamic_entry (DT_RELAENT, RELOC_SIZE (htab))) | |
8120 | return FALSE; | |
8121 | } | |
252b5132 RH |
8122 | } |
8123 | ||
08d1f311 DJ |
8124 | /* If any dynamic relocs apply to a read-only section, |
8125 | then we need a DT_TEXTREL entry. */ | |
8126 | if ((info->flags & DF_TEXTREL) == 0) | |
8127 | elf_link_hash_traverse (&htab->root, elf32_arm_readonly_dynrelocs, | |
8128 | (PTR) info); | |
8129 | ||
99e4ae17 | 8130 | if ((info->flags & DF_TEXTREL) != 0) |
252b5132 | 8131 | { |
dc810e39 | 8132 | if (!add_dynamic_entry (DT_TEXTREL, 0)) |
b34976b6 | 8133 | return FALSE; |
252b5132 RH |
8134 | } |
8135 | } | |
8532796c | 8136 | #undef add_dynamic_entry |
252b5132 | 8137 | |
b34976b6 | 8138 | return TRUE; |
252b5132 RH |
8139 | } |
8140 | ||
252b5132 RH |
8141 | /* Finish up dynamic symbol handling. We set the contents of various |
8142 | dynamic sections here. */ | |
8143 | ||
b34976b6 | 8144 | static bfd_boolean |
57e8b36a NC |
8145 | elf32_arm_finish_dynamic_symbol (bfd * output_bfd, struct bfd_link_info * info, |
8146 | struct elf_link_hash_entry * h, Elf_Internal_Sym * sym) | |
252b5132 RH |
8147 | { |
8148 | bfd * dynobj; | |
e5a52504 | 8149 | struct elf32_arm_link_hash_table *htab; |
b7693d02 | 8150 | struct elf32_arm_link_hash_entry *eh; |
252b5132 RH |
8151 | |
8152 | dynobj = elf_hash_table (info)->dynobj; | |
e5a52504 | 8153 | htab = elf32_arm_hash_table (info); |
b7693d02 | 8154 | eh = (struct elf32_arm_link_hash_entry *) h; |
252b5132 RH |
8155 | |
8156 | if (h->plt.offset != (bfd_vma) -1) | |
8157 | { | |
8158 | asection * splt; | |
252b5132 | 8159 | asection * srel; |
e5a52504 | 8160 | bfd_byte *loc; |
24a1ba0f | 8161 | bfd_vma plt_index; |
947216bf | 8162 | Elf_Internal_Rela rel; |
252b5132 RH |
8163 | |
8164 | /* This symbol has an entry in the procedure linkage table. Set | |
8165 | it up. */ | |
8166 | ||
8167 | BFD_ASSERT (h->dynindx != -1); | |
8168 | ||
8169 | splt = bfd_get_section_by_name (dynobj, ".plt"); | |
00a97672 | 8170 | srel = bfd_get_section_by_name (dynobj, RELOC_SECTION (htab, ".plt")); |
e5a52504 | 8171 | BFD_ASSERT (splt != NULL && srel != NULL); |
252b5132 | 8172 | |
e5a52504 MM |
8173 | /* Fill in the entry in the procedure linkage table. */ |
8174 | if (htab->symbian_p) | |
8175 | { | |
52ab56c2 PB |
8176 | put_arm_insn (htab, output_bfd, |
8177 | elf32_arm_symbian_plt_entry[0], | |
8178 | splt->contents + h->plt.offset); | |
8179 | bfd_put_32 (output_bfd, | |
8180 | elf32_arm_symbian_plt_entry[1], | |
8181 | splt->contents + h->plt.offset + 4); | |
e5a52504 MM |
8182 | |
8183 | /* Fill in the entry in the .rel.plt section. */ | |
2a1b9a48 MM |
8184 | rel.r_offset = (splt->output_section->vma |
8185 | + splt->output_offset | |
52ab56c2 | 8186 | + h->plt.offset + 4); |
e5a52504 | 8187 | rel.r_info = ELF32_R_INFO (h->dynindx, R_ARM_GLOB_DAT); |
b7693d02 DJ |
8188 | |
8189 | /* Get the index in the procedure linkage table which | |
8190 | corresponds to this symbol. This is the index of this symbol | |
8191 | in all the symbols for which we are making plt entries. The | |
8192 | first entry in the procedure linkage table is reserved. */ | |
8193 | plt_index = ((h->plt.offset - htab->plt_header_size) | |
8194 | / htab->plt_entry_size); | |
e5a52504 MM |
8195 | } |
8196 | else | |
8197 | { | |
00a97672 | 8198 | bfd_vma got_offset, got_address, plt_address; |
e5a52504 MM |
8199 | bfd_vma got_displacement; |
8200 | asection * sgot; | |
52ab56c2 | 8201 | bfd_byte * ptr; |
e5a52504 MM |
8202 | |
8203 | sgot = bfd_get_section_by_name (dynobj, ".got.plt"); | |
8204 | BFD_ASSERT (sgot != NULL); | |
8205 | ||
b7693d02 DJ |
8206 | /* Get the offset into the .got.plt table of the entry that |
8207 | corresponds to this function. */ | |
8208 | got_offset = eh->plt_got_offset; | |
8209 | ||
8210 | /* Get the index in the procedure linkage table which | |
8211 | corresponds to this symbol. This is the index of this symbol | |
8212 | in all the symbols for which we are making plt entries. The | |
8213 | first three entries in .got.plt are reserved; after that | |
8214 | symbols appear in the same order as in .plt. */ | |
8215 | plt_index = (got_offset - 12) / 4; | |
e5a52504 | 8216 | |
00a97672 RS |
8217 | /* Calculate the address of the GOT entry. */ |
8218 | got_address = (sgot->output_section->vma | |
8219 | + sgot->output_offset | |
8220 | + got_offset); | |
5e681ec4 | 8221 | |
00a97672 RS |
8222 | /* ...and the address of the PLT entry. */ |
8223 | plt_address = (splt->output_section->vma | |
8224 | + splt->output_offset | |
8225 | + h->plt.offset); | |
5e681ec4 | 8226 | |
52ab56c2 | 8227 | ptr = htab->splt->contents + h->plt.offset; |
00a97672 RS |
8228 | if (htab->vxworks_p && info->shared) |
8229 | { | |
8230 | unsigned int i; | |
8231 | bfd_vma val; | |
8232 | ||
52ab56c2 | 8233 | for (i = 0; i != htab->plt_entry_size / 4; i++, ptr += 4) |
00a97672 RS |
8234 | { |
8235 | val = elf32_arm_vxworks_shared_plt_entry[i]; | |
8236 | if (i == 2) | |
8237 | val |= got_address - sgot->output_section->vma; | |
8238 | if (i == 5) | |
8239 | val |= plt_index * RELOC_SIZE (htab); | |
52ab56c2 PB |
8240 | if (i == 2 || i == 5) |
8241 | bfd_put_32 (output_bfd, val, ptr); | |
8242 | else | |
8243 | put_arm_insn (htab, output_bfd, val, ptr); | |
00a97672 RS |
8244 | } |
8245 | } | |
8246 | else if (htab->vxworks_p) | |
b7693d02 | 8247 | { |
00a97672 RS |
8248 | unsigned int i; |
8249 | bfd_vma val; | |
8250 | ||
8251 | for (i = 0; i != htab->plt_entry_size / 4; i++) | |
8252 | { | |
8253 | val = elf32_arm_vxworks_exec_plt_entry[i]; | |
8254 | if (i == 2) | |
8255 | val |= got_address; | |
8256 | if (i == 4) | |
8257 | val |= 0xffffff & -((h->plt.offset + i * 4 + 8) >> 2); | |
8258 | if (i == 5) | |
8259 | val |= plt_index * RELOC_SIZE (htab); | |
52ab56c2 PB |
8260 | if (i == 2 || i == 5) |
8261 | bfd_put_32 (output_bfd, val, ptr); | |
8262 | else | |
8263 | put_arm_insn (htab, output_bfd, val, ptr); | |
00a97672 RS |
8264 | } |
8265 | ||
8266 | loc = (htab->srelplt2->contents | |
8267 | + (plt_index * 2 + 1) * RELOC_SIZE (htab)); | |
8268 | ||
8269 | /* Create the .rela.plt.unloaded R_ARM_ABS32 relocation | |
8270 | referencing the GOT for this PLT entry. */ | |
8271 | rel.r_offset = plt_address + 8; | |
8272 | rel.r_info = ELF32_R_INFO (htab->root.hgot->indx, R_ARM_ABS32); | |
8273 | rel.r_addend = got_offset; | |
8274 | SWAP_RELOC_OUT (htab) (output_bfd, &rel, loc); | |
8275 | loc += RELOC_SIZE (htab); | |
8276 | ||
8277 | /* Create the R_ARM_ABS32 relocation referencing the | |
8278 | beginning of the PLT for this GOT entry. */ | |
8279 | rel.r_offset = got_address; | |
8280 | rel.r_info = ELF32_R_INFO (htab->root.hplt->indx, R_ARM_ABS32); | |
8281 | rel.r_addend = 0; | |
8282 | SWAP_RELOC_OUT (htab) (output_bfd, &rel, loc); | |
b7693d02 | 8283 | } |
00a97672 RS |
8284 | else |
8285 | { | |
8286 | /* Calculate the displacement between the PLT slot and the | |
8287 | entry in the GOT. The eight-byte offset accounts for the | |
8288 | value produced by adding to pc in the first instruction | |
8289 | of the PLT stub. */ | |
8290 | got_displacement = got_address - (plt_address + 8); | |
b7693d02 | 8291 | |
00a97672 RS |
8292 | BFD_ASSERT ((got_displacement & 0xf0000000) == 0); |
8293 | ||
8294 | if (!htab->use_blx && eh->plt_thumb_refcount > 0) | |
8295 | { | |
52ab56c2 PB |
8296 | put_thumb_insn (htab, output_bfd, |
8297 | elf32_arm_plt_thumb_stub[0], ptr - 4); | |
8298 | put_thumb_insn (htab, output_bfd, | |
8299 | elf32_arm_plt_thumb_stub[1], ptr - 2); | |
00a97672 RS |
8300 | } |
8301 | ||
52ab56c2 PB |
8302 | put_arm_insn (htab, output_bfd, |
8303 | elf32_arm_plt_entry[0] | |
8304 | | ((got_displacement & 0x0ff00000) >> 20), | |
8305 | ptr + 0); | |
8306 | put_arm_insn (htab, output_bfd, | |
8307 | elf32_arm_plt_entry[1] | |
8308 | | ((got_displacement & 0x000ff000) >> 12), | |
8309 | ptr+ 4); | |
8310 | put_arm_insn (htab, output_bfd, | |
8311 | elf32_arm_plt_entry[2] | |
8312 | | (got_displacement & 0x00000fff), | |
8313 | ptr + 8); | |
5e681ec4 | 8314 | #ifdef FOUR_WORD_PLT |
52ab56c2 | 8315 | bfd_put_32 (output_bfd, elf32_arm_plt_entry[3], ptr + 12); |
5e681ec4 | 8316 | #endif |
00a97672 | 8317 | } |
252b5132 | 8318 | |
e5a52504 MM |
8319 | /* Fill in the entry in the global offset table. */ |
8320 | bfd_put_32 (output_bfd, | |
8321 | (splt->output_section->vma | |
8322 | + splt->output_offset), | |
8323 | sgot->contents + got_offset); | |
8324 | ||
00a97672 RS |
8325 | /* Fill in the entry in the .rel(a).plt section. */ |
8326 | rel.r_addend = 0; | |
8327 | rel.r_offset = got_address; | |
e5a52504 MM |
8328 | rel.r_info = ELF32_R_INFO (h->dynindx, R_ARM_JUMP_SLOT); |
8329 | } | |
57e8b36a | 8330 | |
00a97672 RS |
8331 | loc = srel->contents + plt_index * RELOC_SIZE (htab); |
8332 | SWAP_RELOC_OUT (htab) (output_bfd, &rel, loc); | |
252b5132 | 8333 | |
f5385ebf | 8334 | if (!h->def_regular) |
252b5132 RH |
8335 | { |
8336 | /* Mark the symbol as undefined, rather than as defined in | |
8337 | the .plt section. Leave the value alone. */ | |
8338 | sym->st_shndx = SHN_UNDEF; | |
d982ba73 PB |
8339 | /* If the symbol is weak, we do need to clear the value. |
8340 | Otherwise, the PLT entry would provide a definition for | |
8341 | the symbol even if the symbol wasn't defined anywhere, | |
8342 | and so the symbol would never be NULL. */ | |
f5385ebf | 8343 | if (!h->ref_regular_nonweak) |
d982ba73 | 8344 | sym->st_value = 0; |
252b5132 RH |
8345 | } |
8346 | } | |
8347 | ||
ba93b8ac DJ |
8348 | if (h->got.offset != (bfd_vma) -1 |
8349 | && (elf32_arm_hash_entry (h)->tls_type & GOT_TLS_GD) == 0 | |
8350 | && (elf32_arm_hash_entry (h)->tls_type & GOT_TLS_IE) == 0) | |
252b5132 RH |
8351 | { |
8352 | asection * sgot; | |
8353 | asection * srel; | |
947216bf AM |
8354 | Elf_Internal_Rela rel; |
8355 | bfd_byte *loc; | |
00a97672 | 8356 | bfd_vma offset; |
252b5132 RH |
8357 | |
8358 | /* This symbol has an entry in the global offset table. Set it | |
8359 | up. */ | |
252b5132 | 8360 | sgot = bfd_get_section_by_name (dynobj, ".got"); |
00a97672 | 8361 | srel = bfd_get_section_by_name (dynobj, RELOC_SECTION (htab, ".got")); |
252b5132 RH |
8362 | BFD_ASSERT (sgot != NULL && srel != NULL); |
8363 | ||
00a97672 RS |
8364 | offset = (h->got.offset & ~(bfd_vma) 1); |
8365 | rel.r_addend = 0; | |
252b5132 RH |
8366 | rel.r_offset = (sgot->output_section->vma |
8367 | + sgot->output_offset | |
00a97672 | 8368 | + offset); |
252b5132 | 8369 | |
5e681ec4 PB |
8370 | /* If this is a static link, or it is a -Bsymbolic link and the |
8371 | symbol is defined locally or was forced to be local because | |
8372 | of a version file, we just want to emit a RELATIVE reloc. | |
8373 | The entry in the global offset table will already have been | |
8374 | initialized in the relocate_section function. */ | |
252b5132 | 8375 | if (info->shared |
5e681ec4 PB |
8376 | && SYMBOL_REFERENCES_LOCAL (info, h)) |
8377 | { | |
8378 | BFD_ASSERT((h->got.offset & 1) != 0); | |
8379 | rel.r_info = ELF32_R_INFO (0, R_ARM_RELATIVE); | |
00a97672 RS |
8380 | if (!htab->use_rel) |
8381 | { | |
8382 | rel.r_addend = bfd_get_32 (output_bfd, sgot->contents + offset); | |
8383 | bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + offset); | |
8384 | } | |
5e681ec4 | 8385 | } |
252b5132 RH |
8386 | else |
8387 | { | |
5e681ec4 | 8388 | BFD_ASSERT((h->got.offset & 1) == 0); |
00a97672 | 8389 | bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + offset); |
252b5132 RH |
8390 | rel.r_info = ELF32_R_INFO (h->dynindx, R_ARM_GLOB_DAT); |
8391 | } | |
8392 | ||
00a97672 RS |
8393 | loc = srel->contents + srel->reloc_count++ * RELOC_SIZE (htab); |
8394 | SWAP_RELOC_OUT (htab) (output_bfd, &rel, loc); | |
252b5132 RH |
8395 | } |
8396 | ||
f5385ebf | 8397 | if (h->needs_copy) |
252b5132 RH |
8398 | { |
8399 | asection * s; | |
947216bf AM |
8400 | Elf_Internal_Rela rel; |
8401 | bfd_byte *loc; | |
252b5132 RH |
8402 | |
8403 | /* This symbol needs a copy reloc. Set it up. */ | |
252b5132 RH |
8404 | BFD_ASSERT (h->dynindx != -1 |
8405 | && (h->root.type == bfd_link_hash_defined | |
8406 | || h->root.type == bfd_link_hash_defweak)); | |
8407 | ||
8408 | s = bfd_get_section_by_name (h->root.u.def.section->owner, | |
00a97672 | 8409 | RELOC_SECTION (htab, ".bss")); |
252b5132 RH |
8410 | BFD_ASSERT (s != NULL); |
8411 | ||
00a97672 | 8412 | rel.r_addend = 0; |
252b5132 RH |
8413 | rel.r_offset = (h->root.u.def.value |
8414 | + h->root.u.def.section->output_section->vma | |
8415 | + h->root.u.def.section->output_offset); | |
8416 | rel.r_info = ELF32_R_INFO (h->dynindx, R_ARM_COPY); | |
00a97672 RS |
8417 | loc = s->contents + s->reloc_count++ * RELOC_SIZE (htab); |
8418 | SWAP_RELOC_OUT (htab) (output_bfd, &rel, loc); | |
252b5132 RH |
8419 | } |
8420 | ||
00a97672 RS |
8421 | /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. On VxWorks, |
8422 | the _GLOBAL_OFFSET_TABLE_ symbol is not absolute: it is relative | |
8423 | to the ".got" section. */ | |
252b5132 | 8424 | if (strcmp (h->root.root.string, "_DYNAMIC") == 0 |
00a97672 | 8425 | || (!htab->vxworks_p && h == htab->root.hgot)) |
252b5132 RH |
8426 | sym->st_shndx = SHN_ABS; |
8427 | ||
b34976b6 | 8428 | return TRUE; |
252b5132 RH |
8429 | } |
8430 | ||
8431 | /* Finish up the dynamic sections. */ | |
8432 | ||
b34976b6 | 8433 | static bfd_boolean |
57e8b36a | 8434 | elf32_arm_finish_dynamic_sections (bfd * output_bfd, struct bfd_link_info * info) |
252b5132 RH |
8435 | { |
8436 | bfd * dynobj; | |
8437 | asection * sgot; | |
8438 | asection * sdyn; | |
8439 | ||
8440 | dynobj = elf_hash_table (info)->dynobj; | |
8441 | ||
8442 | sgot = bfd_get_section_by_name (dynobj, ".got.plt"); | |
229fcec5 | 8443 | BFD_ASSERT (elf32_arm_hash_table (info)->symbian_p || sgot != NULL); |
252b5132 RH |
8444 | sdyn = bfd_get_section_by_name (dynobj, ".dynamic"); |
8445 | ||
8446 | if (elf_hash_table (info)->dynamic_sections_created) | |
8447 | { | |
8448 | asection *splt; | |
8449 | Elf32_External_Dyn *dyncon, *dynconend; | |
229fcec5 | 8450 | struct elf32_arm_link_hash_table *htab; |
252b5132 | 8451 | |
229fcec5 | 8452 | htab = elf32_arm_hash_table (info); |
252b5132 | 8453 | splt = bfd_get_section_by_name (dynobj, ".plt"); |
24a1ba0f | 8454 | BFD_ASSERT (splt != NULL && sdyn != NULL); |
252b5132 RH |
8455 | |
8456 | dyncon = (Elf32_External_Dyn *) sdyn->contents; | |
eea6121a | 8457 | dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size); |
9b485d32 | 8458 | |
252b5132 RH |
8459 | for (; dyncon < dynconend; dyncon++) |
8460 | { | |
8461 | Elf_Internal_Dyn dyn; | |
8462 | const char * name; | |
8463 | asection * s; | |
8464 | ||
8465 | bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn); | |
8466 | ||
8467 | switch (dyn.d_tag) | |
8468 | { | |
229fcec5 MM |
8469 | unsigned int type; |
8470 | ||
252b5132 RH |
8471 | default: |
8472 | break; | |
8473 | ||
229fcec5 MM |
8474 | case DT_HASH: |
8475 | name = ".hash"; | |
8476 | goto get_vma_if_bpabi; | |
8477 | case DT_STRTAB: | |
8478 | name = ".dynstr"; | |
8479 | goto get_vma_if_bpabi; | |
8480 | case DT_SYMTAB: | |
8481 | name = ".dynsym"; | |
8482 | goto get_vma_if_bpabi; | |
c0042f5d MM |
8483 | case DT_VERSYM: |
8484 | name = ".gnu.version"; | |
8485 | goto get_vma_if_bpabi; | |
8486 | case DT_VERDEF: | |
8487 | name = ".gnu.version_d"; | |
8488 | goto get_vma_if_bpabi; | |
8489 | case DT_VERNEED: | |
8490 | name = ".gnu.version_r"; | |
8491 | goto get_vma_if_bpabi; | |
8492 | ||
252b5132 RH |
8493 | case DT_PLTGOT: |
8494 | name = ".got"; | |
8495 | goto get_vma; | |
8496 | case DT_JMPREL: | |
00a97672 | 8497 | name = RELOC_SECTION (htab, ".plt"); |
252b5132 RH |
8498 | get_vma: |
8499 | s = bfd_get_section_by_name (output_bfd, name); | |
8500 | BFD_ASSERT (s != NULL); | |
229fcec5 MM |
8501 | if (!htab->symbian_p) |
8502 | dyn.d_un.d_ptr = s->vma; | |
8503 | else | |
8504 | /* In the BPABI, tags in the PT_DYNAMIC section point | |
8505 | at the file offset, not the memory address, for the | |
8506 | convenience of the post linker. */ | |
8507 | dyn.d_un.d_ptr = s->filepos; | |
252b5132 RH |
8508 | bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); |
8509 | break; | |
8510 | ||
229fcec5 MM |
8511 | get_vma_if_bpabi: |
8512 | if (htab->symbian_p) | |
8513 | goto get_vma; | |
8514 | break; | |
8515 | ||
252b5132 | 8516 | case DT_PLTRELSZ: |
00a97672 RS |
8517 | s = bfd_get_section_by_name (output_bfd, |
8518 | RELOC_SECTION (htab, ".plt")); | |
252b5132 | 8519 | BFD_ASSERT (s != NULL); |
eea6121a | 8520 | dyn.d_un.d_val = s->size; |
252b5132 RH |
8521 | bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); |
8522 | break; | |
229fcec5 | 8523 | |
252b5132 | 8524 | case DT_RELSZ: |
00a97672 | 8525 | case DT_RELASZ: |
229fcec5 MM |
8526 | if (!htab->symbian_p) |
8527 | { | |
8528 | /* My reading of the SVR4 ABI indicates that the | |
8529 | procedure linkage table relocs (DT_JMPREL) should be | |
8530 | included in the overall relocs (DT_REL). This is | |
8531 | what Solaris does. However, UnixWare can not handle | |
8532 | that case. Therefore, we override the DT_RELSZ entry | |
8533 | here to make it not include the JMPREL relocs. Since | |
00a97672 | 8534 | the linker script arranges for .rel(a).plt to follow all |
229fcec5 MM |
8535 | other relocation sections, we don't have to worry |
8536 | about changing the DT_REL entry. */ | |
00a97672 RS |
8537 | s = bfd_get_section_by_name (output_bfd, |
8538 | RELOC_SECTION (htab, ".plt")); | |
229fcec5 MM |
8539 | if (s != NULL) |
8540 | dyn.d_un.d_val -= s->size; | |
8541 | bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); | |
8542 | break; | |
8543 | } | |
8544 | /* Fall through */ | |
8545 | ||
8546 | case DT_REL: | |
8547 | case DT_RELA: | |
229fcec5 MM |
8548 | /* In the BPABI, the DT_REL tag must point at the file |
8549 | offset, not the VMA, of the first relocation | |
8550 | section. So, we use code similar to that in | |
8551 | elflink.c, but do not check for SHF_ALLOC on the | |
8552 | relcoation section, since relocations sections are | |
8553 | never allocated under the BPABI. The comments above | |
8554 | about Unixware notwithstanding, we include all of the | |
8555 | relocations here. */ | |
8556 | if (htab->symbian_p) | |
8557 | { | |
8558 | unsigned int i; | |
8559 | type = ((dyn.d_tag == DT_REL || dyn.d_tag == DT_RELSZ) | |
8560 | ? SHT_REL : SHT_RELA); | |
8561 | dyn.d_un.d_val = 0; | |
8562 | for (i = 1; i < elf_numsections (output_bfd); i++) | |
8563 | { | |
8564 | Elf_Internal_Shdr *hdr | |
8565 | = elf_elfsections (output_bfd)[i]; | |
8566 | if (hdr->sh_type == type) | |
8567 | { | |
8568 | if (dyn.d_tag == DT_RELSZ | |
8569 | || dyn.d_tag == DT_RELASZ) | |
8570 | dyn.d_un.d_val += hdr->sh_size; | |
de52dba4 AM |
8571 | else if ((ufile_ptr) hdr->sh_offset |
8572 | <= dyn.d_un.d_val - 1) | |
229fcec5 MM |
8573 | dyn.d_un.d_val = hdr->sh_offset; |
8574 | } | |
8575 | } | |
8576 | bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); | |
8577 | } | |
252b5132 | 8578 | break; |
88f7bcd5 NC |
8579 | |
8580 | /* Set the bottom bit of DT_INIT/FINI if the | |
8581 | corresponding function is Thumb. */ | |
8582 | case DT_INIT: | |
8583 | name = info->init_function; | |
8584 | goto get_sym; | |
8585 | case DT_FINI: | |
8586 | name = info->fini_function; | |
8587 | get_sym: | |
8588 | /* If it wasn't set by elf_bfd_final_link | |
4cc11e76 | 8589 | then there is nothing to adjust. */ |
88f7bcd5 NC |
8590 | if (dyn.d_un.d_val != 0) |
8591 | { | |
8592 | struct elf_link_hash_entry * eh; | |
8593 | ||
8594 | eh = elf_link_hash_lookup (elf_hash_table (info), name, | |
b34976b6 | 8595 | FALSE, FALSE, TRUE); |
88f7bcd5 NC |
8596 | if (eh != (struct elf_link_hash_entry *) NULL |
8597 | && ELF_ST_TYPE (eh->type) == STT_ARM_TFUNC) | |
8598 | { | |
8599 | dyn.d_un.d_val |= 1; | |
b34976b6 | 8600 | bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); |
88f7bcd5 NC |
8601 | } |
8602 | } | |
8603 | break; | |
252b5132 RH |
8604 | } |
8605 | } | |
8606 | ||
24a1ba0f | 8607 | /* Fill in the first entry in the procedure linkage table. */ |
e5a52504 | 8608 | if (splt->size > 0 && elf32_arm_hash_table (info)->plt_header_size) |
f7a74f8c | 8609 | { |
00a97672 RS |
8610 | const bfd_vma *plt0_entry; |
8611 | bfd_vma got_address, plt_address, got_displacement; | |
8612 | ||
8613 | /* Calculate the addresses of the GOT and PLT. */ | |
8614 | got_address = sgot->output_section->vma + sgot->output_offset; | |
8615 | plt_address = splt->output_section->vma + splt->output_offset; | |
8616 | ||
8617 | if (htab->vxworks_p) | |
8618 | { | |
8619 | /* The VxWorks GOT is relocated by the dynamic linker. | |
8620 | Therefore, we must emit relocations rather than simply | |
8621 | computing the values now. */ | |
8622 | Elf_Internal_Rela rel; | |
8623 | ||
8624 | plt0_entry = elf32_arm_vxworks_exec_plt0_entry; | |
52ab56c2 PB |
8625 | put_arm_insn (htab, output_bfd, plt0_entry[0], |
8626 | splt->contents + 0); | |
8627 | put_arm_insn (htab, output_bfd, plt0_entry[1], | |
8628 | splt->contents + 4); | |
8629 | put_arm_insn (htab, output_bfd, plt0_entry[2], | |
8630 | splt->contents + 8); | |
00a97672 RS |
8631 | bfd_put_32 (output_bfd, got_address, splt->contents + 12); |
8632 | ||
8633 | /* Generate a relocation for _GLOBAL_OFFSET_TABLE_. */ | |
8634 | rel.r_offset = plt_address + 12; | |
8635 | rel.r_info = ELF32_R_INFO (htab->root.hgot->indx, R_ARM_ABS32); | |
8636 | rel.r_addend = 0; | |
8637 | SWAP_RELOC_OUT (htab) (output_bfd, &rel, | |
8638 | htab->srelplt2->contents); | |
8639 | } | |
8640 | else | |
8641 | { | |
8642 | got_displacement = got_address - (plt_address + 16); | |
8643 | ||
8644 | plt0_entry = elf32_arm_plt0_entry; | |
52ab56c2 PB |
8645 | put_arm_insn (htab, output_bfd, plt0_entry[0], |
8646 | splt->contents + 0); | |
8647 | put_arm_insn (htab, output_bfd, plt0_entry[1], | |
8648 | splt->contents + 4); | |
8649 | put_arm_insn (htab, output_bfd, plt0_entry[2], | |
8650 | splt->contents + 8); | |
8651 | put_arm_insn (htab, output_bfd, plt0_entry[3], | |
8652 | splt->contents + 12); | |
5e681ec4 | 8653 | |
5e681ec4 | 8654 | #ifdef FOUR_WORD_PLT |
00a97672 RS |
8655 | /* The displacement value goes in the otherwise-unused |
8656 | last word of the second entry. */ | |
8657 | bfd_put_32 (output_bfd, got_displacement, splt->contents + 28); | |
5e681ec4 | 8658 | #else |
00a97672 | 8659 | bfd_put_32 (output_bfd, got_displacement, splt->contents + 16); |
5e681ec4 | 8660 | #endif |
00a97672 | 8661 | } |
f7a74f8c | 8662 | } |
252b5132 RH |
8663 | |
8664 | /* UnixWare sets the entsize of .plt to 4, although that doesn't | |
8665 | really seem like the right value. */ | |
74541ad4 AM |
8666 | if (splt->output_section->owner == output_bfd) |
8667 | elf_section_data (splt->output_section)->this_hdr.sh_entsize = 4; | |
00a97672 RS |
8668 | |
8669 | if (htab->vxworks_p && !info->shared && htab->splt->size > 0) | |
8670 | { | |
8671 | /* Correct the .rel(a).plt.unloaded relocations. They will have | |
8672 | incorrect symbol indexes. */ | |
8673 | int num_plts; | |
eed62c48 | 8674 | unsigned char *p; |
00a97672 RS |
8675 | |
8676 | num_plts = ((htab->splt->size - htab->plt_header_size) | |
8677 | / htab->plt_entry_size); | |
8678 | p = htab->srelplt2->contents + RELOC_SIZE (htab); | |
8679 | ||
8680 | for (; num_plts; num_plts--) | |
8681 | { | |
8682 | Elf_Internal_Rela rel; | |
8683 | ||
8684 | SWAP_RELOC_IN (htab) (output_bfd, p, &rel); | |
8685 | rel.r_info = ELF32_R_INFO (htab->root.hgot->indx, R_ARM_ABS32); | |
8686 | SWAP_RELOC_OUT (htab) (output_bfd, &rel, p); | |
8687 | p += RELOC_SIZE (htab); | |
8688 | ||
8689 | SWAP_RELOC_IN (htab) (output_bfd, p, &rel); | |
8690 | rel.r_info = ELF32_R_INFO (htab->root.hplt->indx, R_ARM_ABS32); | |
8691 | SWAP_RELOC_OUT (htab) (output_bfd, &rel, p); | |
8692 | p += RELOC_SIZE (htab); | |
8693 | } | |
8694 | } | |
252b5132 RH |
8695 | } |
8696 | ||
8697 | /* Fill in the first three entries in the global offset table. */ | |
229fcec5 | 8698 | if (sgot) |
252b5132 | 8699 | { |
229fcec5 MM |
8700 | if (sgot->size > 0) |
8701 | { | |
8702 | if (sdyn == NULL) | |
8703 | bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents); | |
8704 | else | |
8705 | bfd_put_32 (output_bfd, | |
8706 | sdyn->output_section->vma + sdyn->output_offset, | |
8707 | sgot->contents); | |
8708 | bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + 4); | |
8709 | bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + 8); | |
8710 | } | |
252b5132 | 8711 | |
229fcec5 MM |
8712 | elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4; |
8713 | } | |
252b5132 | 8714 | |
b34976b6 | 8715 | return TRUE; |
252b5132 RH |
8716 | } |
8717 | ||
ba96a88f | 8718 | static void |
57e8b36a | 8719 | elf32_arm_post_process_headers (bfd * abfd, struct bfd_link_info * link_info ATTRIBUTE_UNUSED) |
ba96a88f | 8720 | { |
9b485d32 | 8721 | Elf_Internal_Ehdr * i_ehdrp; /* ELF file header, internal form. */ |
e489d0ae | 8722 | struct elf32_arm_link_hash_table *globals; |
ba96a88f NC |
8723 | |
8724 | i_ehdrp = elf_elfheader (abfd); | |
8725 | ||
94a3258f PB |
8726 | if (EF_ARM_EABI_VERSION (i_ehdrp->e_flags) == EF_ARM_EABI_UNKNOWN) |
8727 | i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_ARM; | |
8728 | else | |
8729 | i_ehdrp->e_ident[EI_OSABI] = 0; | |
ba96a88f | 8730 | i_ehdrp->e_ident[EI_ABIVERSION] = ARM_ELF_ABI_VERSION; |
e489d0ae | 8731 | |
93204d3a PB |
8732 | if (link_info) |
8733 | { | |
8734 | globals = elf32_arm_hash_table (link_info); | |
8735 | if (globals->byteswap_code) | |
8736 | i_ehdrp->e_flags |= EF_ARM_BE8; | |
8737 | } | |
ba96a88f NC |
8738 | } |
8739 | ||
99e4ae17 | 8740 | static enum elf_reloc_type_class |
57e8b36a | 8741 | elf32_arm_reloc_type_class (const Elf_Internal_Rela *rela) |
99e4ae17 | 8742 | { |
f51e552e | 8743 | switch ((int) ELF32_R_TYPE (rela->r_info)) |
99e4ae17 AJ |
8744 | { |
8745 | case R_ARM_RELATIVE: | |
8746 | return reloc_class_relative; | |
8747 | case R_ARM_JUMP_SLOT: | |
8748 | return reloc_class_plt; | |
8749 | case R_ARM_COPY: | |
8750 | return reloc_class_copy; | |
8751 | default: | |
8752 | return reloc_class_normal; | |
8753 | } | |
8754 | } | |
8755 | ||
e16bb312 NC |
8756 | /* Set the right machine number for an Arm ELF file. */ |
8757 | ||
8758 | static bfd_boolean | |
57e8b36a | 8759 | elf32_arm_section_flags (flagword *flags, const Elf_Internal_Shdr *hdr) |
e16bb312 NC |
8760 | { |
8761 | if (hdr->sh_type == SHT_NOTE) | |
8762 | *flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_SAME_CONTENTS; | |
8763 | ||
8764 | return TRUE; | |
8765 | } | |
8766 | ||
e489d0ae | 8767 | static void |
57e8b36a | 8768 | elf32_arm_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED) |
e16bb312 | 8769 | { |
5a6c6817 | 8770 | bfd_arm_update_notes (abfd, ARM_NOTE_SECTION); |
e16bb312 NC |
8771 | } |
8772 | ||
40a18ebd NC |
8773 | /* Return TRUE if this is an unwinding table entry. */ |
8774 | ||
8775 | static bfd_boolean | |
8776 | is_arm_elf_unwind_section_name (bfd * abfd ATTRIBUTE_UNUSED, const char * name) | |
8777 | { | |
0112cd26 NC |
8778 | return (CONST_STRNEQ (name, ELF_STRING_ARM_unwind) |
8779 | || CONST_STRNEQ (name, ELF_STRING_ARM_unwind_once)); | |
40a18ebd NC |
8780 | } |
8781 | ||
8782 | ||
8783 | /* Set the type and flags for an ARM section. We do this by | |
8784 | the section name, which is a hack, but ought to work. */ | |
8785 | ||
8786 | static bfd_boolean | |
8787 | elf32_arm_fake_sections (bfd * abfd, Elf_Internal_Shdr * hdr, asection * sec) | |
8788 | { | |
8789 | const char * name; | |
8790 | ||
8791 | name = bfd_get_section_name (abfd, sec); | |
8792 | ||
8793 | if (is_arm_elf_unwind_section_name (abfd, name)) | |
8794 | { | |
8795 | hdr->sh_type = SHT_ARM_EXIDX; | |
8796 | hdr->sh_flags |= SHF_LINK_ORDER; | |
8797 | } | |
ee065d83 PB |
8798 | else if (strcmp(name, ".ARM.attributes") == 0) |
8799 | { | |
8800 | hdr->sh_type = SHT_ARM_ATTRIBUTES; | |
8801 | } | |
40a18ebd NC |
8802 | return TRUE; |
8803 | } | |
8804 | ||
ee065d83 PB |
8805 | /* Parse an Arm EABI attributes section. */ |
8806 | static void | |
8807 | elf32_arm_parse_attributes (bfd *abfd, Elf_Internal_Shdr * hdr) | |
8808 | { | |
8809 | bfd_byte *contents; | |
8810 | bfd_byte *p; | |
8811 | bfd_vma len; | |
8812 | ||
8813 | contents = bfd_malloc (hdr->sh_size); | |
8814 | if (!contents) | |
8815 | return; | |
8816 | if (!bfd_get_section_contents (abfd, hdr->bfd_section, contents, 0, | |
8817 | hdr->sh_size)) | |
8818 | { | |
8819 | free (contents); | |
8820 | return; | |
8821 | } | |
8822 | p = contents; | |
8823 | if (*(p++) == 'A') | |
8824 | { | |
8825 | len = hdr->sh_size - 1; | |
8826 | while (len > 0) | |
8827 | { | |
8828 | int namelen; | |
8829 | bfd_vma section_len; | |
8830 | ||
8831 | section_len = bfd_get_32 (abfd, p); | |
8832 | p += 4; | |
8833 | if (section_len > len) | |
8834 | section_len = len; | |
8835 | len -= section_len; | |
8836 | namelen = strlen ((char *)p) + 1; | |
8837 | section_len -= namelen + 4; | |
8838 | if (strcmp((char *)p, "aeabi") != 0) | |
8839 | { | |
8840 | /* Vendor section. Ignore it. */ | |
8841 | p += namelen + section_len; | |
8842 | } | |
8843 | else | |
8844 | { | |
8845 | p += namelen; | |
8846 | while (section_len > 0) | |
8847 | { | |
8848 | int tag; | |
8849 | unsigned int n; | |
8850 | unsigned int val; | |
8851 | bfd_vma subsection_len; | |
8852 | bfd_byte *end; | |
8853 | ||
8854 | tag = read_unsigned_leb128 (abfd, p, &n); | |
8855 | p += n; | |
8856 | subsection_len = bfd_get_32 (abfd, p); | |
8857 | p += 4; | |
8858 | if (subsection_len > section_len) | |
8859 | subsection_len = section_len; | |
8860 | section_len -= subsection_len; | |
8861 | subsection_len -= n + 4; | |
8862 | end = p + subsection_len; | |
8863 | switch (tag) | |
8864 | { | |
8865 | case Tag_File: | |
8866 | while (p < end) | |
8867 | { | |
8868 | bfd_boolean is_string; | |
8869 | ||
8870 | tag = read_unsigned_leb128 (abfd, p, &n); | |
8871 | p += n; | |
8872 | if (tag == 4 || tag == 5) | |
8873 | is_string = 1; | |
8874 | else if (tag < 32) | |
8875 | is_string = 0; | |
8876 | else | |
8877 | is_string = (tag & 1) != 0; | |
8878 | if (tag == Tag_compatibility) | |
8879 | { | |
8880 | val = read_unsigned_leb128 (abfd, p, &n); | |
8881 | p += n; | |
8882 | elf32_arm_add_eabi_attr_compat (abfd, val, | |
8883 | (char *)p); | |
8884 | p += strlen ((char *)p) + 1; | |
8885 | } | |
8886 | else if (is_string) | |
8887 | { | |
8888 | elf32_arm_add_eabi_attr_string (abfd, tag, | |
8889 | (char *)p); | |
8890 | p += strlen ((char *)p) + 1; | |
8891 | } | |
8892 | else | |
8893 | { | |
8894 | val = read_unsigned_leb128 (abfd, p, &n); | |
8895 | p += n; | |
8896 | elf32_arm_add_eabi_attr_int (abfd, tag, val); | |
8897 | } | |
8898 | } | |
8899 | break; | |
8900 | case Tag_Section: | |
8901 | case Tag_Symbol: | |
8902 | /* Don't have anywhere convenient to attach these. | |
8903 | Fall through for now. */ | |
8904 | default: | |
8905 | /* Ignore things we don't kow about. */ | |
8906 | p += subsection_len; | |
8907 | subsection_len = 0; | |
8908 | break; | |
8909 | } | |
8910 | } | |
8911 | } | |
8912 | } | |
8913 | } | |
8914 | free (contents); | |
8915 | } | |
8916 | ||
6dc132d9 L |
8917 | /* Handle an ARM specific section when reading an object file. This is |
8918 | called when bfd_section_from_shdr finds a section with an unknown | |
8919 | type. */ | |
40a18ebd NC |
8920 | |
8921 | static bfd_boolean | |
8922 | elf32_arm_section_from_shdr (bfd *abfd, | |
8923 | Elf_Internal_Shdr * hdr, | |
6dc132d9 L |
8924 | const char *name, |
8925 | int shindex) | |
40a18ebd NC |
8926 | { |
8927 | /* There ought to be a place to keep ELF backend specific flags, but | |
8928 | at the moment there isn't one. We just keep track of the | |
8929 | sections by their name, instead. Fortunately, the ABI gives | |
8930 | names for all the ARM specific sections, so we will probably get | |
8931 | away with this. */ | |
8932 | switch (hdr->sh_type) | |
8933 | { | |
8934 | case SHT_ARM_EXIDX: | |
0951f019 RE |
8935 | case SHT_ARM_PREEMPTMAP: |
8936 | case SHT_ARM_ATTRIBUTES: | |
40a18ebd NC |
8937 | break; |
8938 | ||
8939 | default: | |
8940 | return FALSE; | |
8941 | } | |
8942 | ||
6dc132d9 | 8943 | if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex)) |
40a18ebd NC |
8944 | return FALSE; |
8945 | ||
ee065d83 PB |
8946 | if (hdr->sh_type == SHT_ARM_ATTRIBUTES) |
8947 | elf32_arm_parse_attributes(abfd, hdr); | |
40a18ebd NC |
8948 | return TRUE; |
8949 | } | |
e489d0ae | 8950 | |
8e3de13a NC |
8951 | /* A structure used to record a list of sections, independently |
8952 | of the next and prev fields in the asection structure. */ | |
8953 | typedef struct section_list | |
8954 | { | |
8955 | asection * sec; | |
8956 | struct section_list * next; | |
8957 | struct section_list * prev; | |
8958 | } | |
8959 | section_list; | |
8960 | ||
8961 | /* Unfortunately we need to keep a list of sections for which | |
8962 | an _arm_elf_section_data structure has been allocated. This | |
8963 | is because it is possible for functions like elf32_arm_write_section | |
8964 | to be called on a section which has had an elf_data_structure | |
8965 | allocated for it (and so the used_by_bfd field is valid) but | |
8966 | for which the ARM extended version of this structure - the | |
8967 | _arm_elf_section_data structure - has not been allocated. */ | |
8968 | static section_list * sections_with_arm_elf_section_data = NULL; | |
8969 | ||
8970 | static void | |
957c6e41 | 8971 | record_section_with_arm_elf_section_data (asection * sec) |
8e3de13a NC |
8972 | { |
8973 | struct section_list * entry; | |
8974 | ||
957c6e41 | 8975 | entry = bfd_malloc (sizeof (* entry)); |
8e3de13a NC |
8976 | if (entry == NULL) |
8977 | return; | |
8978 | entry->sec = sec; | |
8979 | entry->next = sections_with_arm_elf_section_data; | |
8980 | entry->prev = NULL; | |
8981 | if (entry->next != NULL) | |
8982 | entry->next->prev = entry; | |
8983 | sections_with_arm_elf_section_data = entry; | |
8984 | } | |
8985 | ||
44444f50 NC |
8986 | static struct section_list * |
8987 | find_arm_elf_section_entry (asection * sec) | |
8e3de13a NC |
8988 | { |
8989 | struct section_list * entry; | |
bd4aae00 | 8990 | static struct section_list * last_entry = NULL; |
8e3de13a | 8991 | |
bd4aae00 NC |
8992 | /* This is a short cut for the typical case where the sections are added |
8993 | to the sections_with_arm_elf_section_data list in forward order and | |
8994 | then looked up here in backwards order. This makes a real difference | |
8995 | to the ld-srec/sec64k.exp linker test. */ | |
44444f50 | 8996 | entry = sections_with_arm_elf_section_data; |
bd4aae00 NC |
8997 | if (last_entry != NULL) |
8998 | { | |
8999 | if (last_entry->sec == sec) | |
44444f50 NC |
9000 | entry = last_entry; |
9001 | else if (last_entry->next != NULL | |
9002 | && last_entry->next->sec == sec) | |
9003 | entry = last_entry->next; | |
bd4aae00 | 9004 | } |
44444f50 NC |
9005 | |
9006 | for (; entry; entry = entry->next) | |
8e3de13a | 9007 | if (entry->sec == sec) |
44444f50 | 9008 | break; |
bd4aae00 | 9009 | |
44444f50 NC |
9010 | if (entry) |
9011 | /* Record the entry prior to this one - it is the entry we are most | |
9012 | likely to want to locate next time. Also this way if we have been | |
9013 | called from unrecord_section_with_arm_elf_section_data() we will not | |
9014 | be caching a pointer that is about to be freed. */ | |
9015 | last_entry = entry->prev; | |
9016 | ||
9017 | return entry; | |
9018 | } | |
9019 | ||
9020 | static _arm_elf_section_data * | |
9021 | get_arm_elf_section_data (asection * sec) | |
9022 | { | |
9023 | struct section_list * entry; | |
9024 | ||
9025 | entry = find_arm_elf_section_entry (sec); | |
9026 | ||
9027 | if (entry) | |
9028 | return elf32_arm_section_data (entry->sec); | |
9029 | else | |
9030 | return NULL; | |
8e3de13a NC |
9031 | } |
9032 | ||
9033 | static void | |
9034 | unrecord_section_with_arm_elf_section_data (asection * sec) | |
9035 | { | |
9036 | struct section_list * entry; | |
9037 | ||
44444f50 NC |
9038 | entry = find_arm_elf_section_entry (sec); |
9039 | ||
9040 | if (entry) | |
9041 | { | |
9042 | if (entry->prev != NULL) | |
9043 | entry->prev->next = entry->next; | |
9044 | if (entry->next != NULL) | |
9045 | entry->next->prev = entry->prev; | |
9046 | if (entry == sections_with_arm_elf_section_data) | |
9047 | sections_with_arm_elf_section_data = entry->next; | |
9048 | free (entry); | |
9049 | } | |
8e3de13a NC |
9050 | } |
9051 | ||
e489d0ae PB |
9052 | /* Called for each symbol. Builds a section map based on mapping symbols. |
9053 | Does not alter any of the symbols. */ | |
9054 | ||
9055 | static bfd_boolean | |
9056 | elf32_arm_output_symbol_hook (struct bfd_link_info *info, | |
9057 | const char *name, | |
9058 | Elf_Internal_Sym *elfsym, | |
9059 | asection *input_sec, | |
00a97672 | 9060 | struct elf_link_hash_entry *h) |
e489d0ae PB |
9061 | { |
9062 | int mapcount; | |
9063 | elf32_arm_section_map *map; | |
8e3de13a NC |
9064 | elf32_arm_section_map *newmap; |
9065 | _arm_elf_section_data *arm_data; | |
e489d0ae PB |
9066 | struct elf32_arm_link_hash_table *globals; |
9067 | ||
00a97672 RS |
9068 | globals = elf32_arm_hash_table (info); |
9069 | if (globals->vxworks_p | |
9070 | && !elf_vxworks_link_output_symbol_hook (info, name, elfsym, | |
9071 | input_sec, h)) | |
9072 | return FALSE; | |
9073 | ||
e489d0ae PB |
9074 | /* Only do this on final link. */ |
9075 | if (info->relocatable) | |
9076 | return TRUE; | |
9077 | ||
9078 | /* Only build a map if we need to byteswap code. */ | |
e489d0ae PB |
9079 | if (!globals->byteswap_code) |
9080 | return TRUE; | |
9081 | ||
9082 | /* We only want mapping symbols. */ | |
b0796911 | 9083 | if (!bfd_is_arm_special_symbol_name (name, BFD_ARM_SPECIAL_SYM_TYPE_MAP)) |
e489d0ae PB |
9084 | return TRUE; |
9085 | ||
8e3de13a NC |
9086 | /* If this section has not been allocated an _arm_elf_section_data |
9087 | structure then we cannot record anything. */ | |
9088 | arm_data = get_arm_elf_section_data (input_sec); | |
9089 | if (arm_data == NULL) | |
9090 | return TRUE; | |
9091 | ||
9092 | mapcount = arm_data->mapcount + 1; | |
9093 | map = arm_data->map; | |
d7f735da | 9094 | |
e489d0ae PB |
9095 | /* TODO: This may be inefficient, but we probably don't usually have many |
9096 | mapping symbols per section. */ | |
8e3de13a NC |
9097 | newmap = bfd_realloc (map, mapcount * sizeof (* map)); |
9098 | if (newmap != NULL) | |
9099 | { | |
9100 | arm_data->map = newmap; | |
9101 | arm_data->mapcount = mapcount; | |
9102 | ||
d7f735da NC |
9103 | newmap[mapcount - 1].vma = elfsym->st_value; |
9104 | newmap[mapcount - 1].type = name[1]; | |
8e3de13a | 9105 | } |
57e8b36a | 9106 | |
e489d0ae PB |
9107 | return TRUE; |
9108 | } | |
9109 | ||
4e617b1e PB |
9110 | typedef struct |
9111 | { | |
9112 | void *finfo; | |
9113 | struct bfd_link_info *info; | |
9114 | int plt_shndx; | |
9115 | bfd_vma plt_offset; | |
9116 | bfd_boolean (*func) (void *, const char *, Elf_Internal_Sym *, | |
9117 | asection *, struct elf_link_hash_entry *); | |
9118 | } output_arch_syminfo; | |
9119 | ||
9120 | enum map_symbol_type | |
9121 | { | |
9122 | ARM_MAP_ARM, | |
9123 | ARM_MAP_THUMB, | |
9124 | ARM_MAP_DATA | |
9125 | }; | |
9126 | ||
9127 | ||
9128 | /* Output a single PLT mapping symbol. */ | |
9129 | ||
9130 | static bfd_boolean | |
9131 | elf32_arm_ouput_plt_map_sym (output_arch_syminfo *osi, | |
9132 | enum map_symbol_type type, | |
9133 | bfd_vma offset) | |
9134 | { | |
9135 | static const char *names[3] = {"$a", "$t", "$d"}; | |
9136 | struct elf32_arm_link_hash_table *htab; | |
9137 | Elf_Internal_Sym sym; | |
9138 | ||
9139 | htab = elf32_arm_hash_table (osi->info); | |
9140 | sym.st_value = osi->plt_offset + offset; | |
9141 | sym.st_size = 0; | |
9142 | sym.st_other = 0; | |
9143 | sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_NOTYPE); | |
9144 | sym.st_shndx = osi->plt_shndx; | |
9145 | if (!osi->func (osi->finfo, names[type], &sym, htab->splt, NULL)) | |
9146 | return FALSE; | |
9147 | return TRUE; | |
9148 | } | |
9149 | ||
9150 | ||
9151 | /* Output mapping symbols for PLT entries associated with H. */ | |
9152 | ||
9153 | static bfd_boolean | |
9154 | elf32_arm_output_plt_map (struct elf_link_hash_entry *h, void *inf) | |
9155 | { | |
9156 | output_arch_syminfo *osi = (output_arch_syminfo *) inf; | |
9157 | struct elf32_arm_link_hash_table *htab; | |
9158 | struct elf32_arm_link_hash_entry *eh; | |
9159 | bfd_vma addr; | |
9160 | ||
9161 | htab = elf32_arm_hash_table (osi->info); | |
9162 | ||
9163 | if (h->root.type == bfd_link_hash_indirect) | |
9164 | return TRUE; | |
9165 | ||
9166 | if (h->root.type == bfd_link_hash_warning) | |
9167 | /* When warning symbols are created, they **replace** the "real" | |
9168 | entry in the hash table, thus we never get to see the real | |
9169 | symbol in a hash traversal. So look at it now. */ | |
9170 | h = (struct elf_link_hash_entry *) h->root.u.i.link; | |
9171 | ||
9172 | if (h->plt.offset == (bfd_vma) -1) | |
9173 | return TRUE; | |
9174 | ||
9175 | eh = (struct elf32_arm_link_hash_entry *) h; | |
9176 | addr = h->plt.offset; | |
9177 | if (htab->symbian_p) | |
9178 | { | |
9179 | if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_ARM, addr)) | |
9180 | return FALSE; | |
9181 | if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_DATA, addr + 4)) | |
9182 | return FALSE; | |
9183 | } | |
9184 | else if (htab->vxworks_p) | |
9185 | { | |
9186 | if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_ARM, addr)) | |
9187 | return FALSE; | |
9188 | if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_DATA, addr + 8)) | |
9189 | return FALSE; | |
9190 | if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_ARM, addr + 12)) | |
9191 | return FALSE; | |
9192 | if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_DATA, addr + 20)) | |
9193 | return FALSE; | |
9194 | } | |
9195 | else | |
9196 | { | |
9197 | bfd_boolean thumb_stub; | |
9198 | ||
9199 | thumb_stub = eh->plt_thumb_refcount > 0 && !htab->use_blx; | |
9200 | if (thumb_stub) | |
9201 | { | |
9202 | if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_THUMB, addr - 4)) | |
9203 | return FALSE; | |
9204 | } | |
9205 | #ifdef FOUR_WORD_PLT | |
9206 | if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_ARM, addr)) | |
9207 | return FALSE; | |
9208 | if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_DATA, addr + 12)) | |
9209 | return FALSE; | |
9210 | #else | |
9211 | /* A three-word PLT with no Thumb thunk contains only Arm code, | |
9212 | so only need to output a mapping symbol for the first PLT entry and | |
9213 | entries with thumb thunks. */ | |
9214 | if (thumb_stub || addr == 20) | |
9215 | { | |
9216 | if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_ARM, addr)) | |
9217 | return FALSE; | |
9218 | } | |
9219 | #endif | |
9220 | } | |
9221 | ||
9222 | return TRUE; | |
9223 | } | |
9224 | ||
9225 | ||
9226 | /* Output mapping symbols for the PLT. */ | |
9227 | ||
9228 | static bfd_boolean | |
9229 | elf32_arm_output_arch_local_syms (bfd *output_bfd, | |
9230 | struct bfd_link_info *info, | |
9231 | void *finfo, bfd_boolean (*func) (void *, const char *, | |
9232 | Elf_Internal_Sym *, | |
9233 | asection *, | |
9234 | struct elf_link_hash_entry *)) | |
9235 | { | |
9236 | output_arch_syminfo osi; | |
9237 | struct elf32_arm_link_hash_table *htab; | |
9238 | ||
9239 | htab = elf32_arm_hash_table (info); | |
9240 | if (!htab->splt || htab->splt->size == 0) | |
9241 | return TRUE; | |
9242 | ||
9243 | check_use_blx(htab); | |
9244 | osi.finfo = finfo; | |
9245 | osi.info = info; | |
9246 | osi.func = func; | |
9247 | osi.plt_shndx = _bfd_elf_section_from_bfd_section (output_bfd, | |
9248 | htab->splt->output_section); | |
9249 | osi.plt_offset = htab->splt->output_section->vma; | |
9250 | ||
9251 | /* Output mapping symbols for the plt header. SymbianOS does not have a | |
9252 | plt header. */ | |
9253 | if (htab->vxworks_p) | |
9254 | { | |
9255 | /* VxWorks shared libraries have no PLT header. */ | |
9256 | if (!info->shared) | |
9257 | { | |
9258 | if (!elf32_arm_ouput_plt_map_sym (&osi, ARM_MAP_ARM, 0)) | |
9259 | return FALSE; | |
9260 | if (!elf32_arm_ouput_plt_map_sym (&osi, ARM_MAP_DATA, 12)) | |
9261 | return FALSE; | |
9262 | } | |
9263 | } | |
9264 | else if (!htab->symbian_p) | |
9265 | { | |
9266 | if (!elf32_arm_ouput_plt_map_sym (&osi, ARM_MAP_ARM, 0)) | |
9267 | return FALSE; | |
9268 | #ifndef FOUR_WORD_PLT | |
9269 | if (!elf32_arm_ouput_plt_map_sym (&osi, ARM_MAP_DATA, 16)) | |
9270 | return FALSE; | |
9271 | #endif | |
9272 | } | |
9273 | ||
9274 | elf_link_hash_traverse (&htab->root, elf32_arm_output_plt_map, (void *) &osi); | |
9275 | return TRUE; | |
9276 | } | |
9277 | ||
e489d0ae PB |
9278 | /* Allocate target specific section data. */ |
9279 | ||
9280 | static bfd_boolean | |
9281 | elf32_arm_new_section_hook (bfd *abfd, asection *sec) | |
9282 | { | |
f592407e AM |
9283 | if (!sec->used_by_bfd) |
9284 | { | |
9285 | _arm_elf_section_data *sdata; | |
9286 | bfd_size_type amt = sizeof (*sdata); | |
e489d0ae | 9287 | |
f592407e AM |
9288 | sdata = bfd_zalloc (abfd, amt); |
9289 | if (sdata == NULL) | |
9290 | return FALSE; | |
9291 | sec->used_by_bfd = sdata; | |
9292 | } | |
e489d0ae | 9293 | |
957c6e41 | 9294 | record_section_with_arm_elf_section_data (sec); |
8e3de13a | 9295 | |
e489d0ae PB |
9296 | return _bfd_elf_new_section_hook (abfd, sec); |
9297 | } | |
9298 | ||
9299 | ||
9300 | /* Used to order a list of mapping symbols by address. */ | |
9301 | ||
9302 | static int | |
9303 | elf32_arm_compare_mapping (const void * a, const void * b) | |
9304 | { | |
9305 | return ((const elf32_arm_section_map *) a)->vma | |
9306 | > ((const elf32_arm_section_map *) b)->vma; | |
9307 | } | |
9308 | ||
9309 | ||
9310 | /* Do code byteswapping. Return FALSE afterwards so that the section is | |
9311 | written out as normal. */ | |
9312 | ||
9313 | static bfd_boolean | |
9314 | elf32_arm_write_section (bfd *output_bfd ATTRIBUTE_UNUSED, asection *sec, | |
9315 | bfd_byte *contents) | |
9316 | { | |
9317 | int mapcount; | |
8e3de13a | 9318 | _arm_elf_section_data *arm_data; |
e489d0ae PB |
9319 | elf32_arm_section_map *map; |
9320 | bfd_vma ptr; | |
9321 | bfd_vma end; | |
9322 | bfd_vma offset; | |
9323 | bfd_byte tmp; | |
9324 | int i; | |
57e8b36a | 9325 | |
8e3de13a NC |
9326 | /* If this section has not been allocated an _arm_elf_section_data |
9327 | structure then we cannot record anything. */ | |
9328 | arm_data = get_arm_elf_section_data (sec); | |
9329 | if (arm_data == NULL) | |
9330 | return FALSE; | |
9331 | ||
9332 | mapcount = arm_data->mapcount; | |
9333 | map = arm_data->map; | |
e489d0ae PB |
9334 | |
9335 | if (mapcount == 0) | |
9336 | return FALSE; | |
9337 | ||
8e3de13a | 9338 | qsort (map, mapcount, sizeof (* map), elf32_arm_compare_mapping); |
e489d0ae PB |
9339 | |
9340 | offset = sec->output_section->vma + sec->output_offset; | |
9341 | ptr = map[0].vma - offset; | |
9342 | for (i = 0; i < mapcount; i++) | |
9343 | { | |
9344 | if (i == mapcount - 1) | |
eea6121a | 9345 | end = sec->size; |
e489d0ae PB |
9346 | else |
9347 | end = map[i + 1].vma - offset; | |
57e8b36a | 9348 | |
e489d0ae PB |
9349 | switch (map[i].type) |
9350 | { | |
9351 | case 'a': | |
9352 | /* Byte swap code words. */ | |
9353 | while (ptr + 3 < end) | |
9354 | { | |
9355 | tmp = contents[ptr]; | |
9356 | contents[ptr] = contents[ptr + 3]; | |
9357 | contents[ptr + 3] = tmp; | |
9358 | tmp = contents[ptr + 1]; | |
9359 | contents[ptr + 1] = contents[ptr + 2]; | |
9360 | contents[ptr + 2] = tmp; | |
9361 | ptr += 4; | |
9362 | } | |
9363 | break; | |
9364 | ||
9365 | case 't': | |
9366 | /* Byte swap code halfwords. */ | |
9367 | while (ptr + 1 < end) | |
9368 | { | |
9369 | tmp = contents[ptr]; | |
9370 | contents[ptr] = contents[ptr + 1]; | |
9371 | contents[ptr + 1] = tmp; | |
9372 | ptr += 2; | |
9373 | } | |
9374 | break; | |
9375 | ||
9376 | case 'd': | |
9377 | /* Leave data alone. */ | |
9378 | break; | |
9379 | } | |
9380 | ptr = end; | |
9381 | } | |
8e3de13a | 9382 | |
93204d3a | 9383 | free (map); |
8e3de13a NC |
9384 | arm_data->mapcount = 0; |
9385 | arm_data->map = NULL; | |
9386 | unrecord_section_with_arm_elf_section_data (sec); | |
9387 | ||
e489d0ae PB |
9388 | return FALSE; |
9389 | } | |
9390 | ||
957c6e41 NC |
9391 | static void |
9392 | unrecord_section_via_map_over_sections (bfd * abfd ATTRIBUTE_UNUSED, | |
9393 | asection * sec, | |
9394 | void * ignore ATTRIBUTE_UNUSED) | |
9395 | { | |
9396 | unrecord_section_with_arm_elf_section_data (sec); | |
9397 | } | |
9398 | ||
9399 | static bfd_boolean | |
9400 | elf32_arm_close_and_cleanup (bfd * abfd) | |
9401 | { | |
b25e3d87 L |
9402 | if (abfd->sections) |
9403 | bfd_map_over_sections (abfd, | |
9404 | unrecord_section_via_map_over_sections, | |
9405 | NULL); | |
957c6e41 NC |
9406 | |
9407 | return _bfd_elf_close_and_cleanup (abfd); | |
9408 | } | |
9409 | ||
b25e3d87 L |
9410 | static bfd_boolean |
9411 | elf32_arm_bfd_free_cached_info (bfd * abfd) | |
9412 | { | |
9413 | if (abfd->sections) | |
9414 | bfd_map_over_sections (abfd, | |
9415 | unrecord_section_via_map_over_sections, | |
9416 | NULL); | |
9417 | ||
9418 | return _bfd_free_cached_info (abfd); | |
9419 | } | |
9420 | ||
b7693d02 DJ |
9421 | /* Display STT_ARM_TFUNC symbols as functions. */ |
9422 | ||
9423 | static void | |
9424 | elf32_arm_symbol_processing (bfd *abfd ATTRIBUTE_UNUSED, | |
9425 | asymbol *asym) | |
9426 | { | |
9427 | elf_symbol_type *elfsym = (elf_symbol_type *) asym; | |
9428 | ||
9429 | if (ELF_ST_TYPE (elfsym->internal_elf_sym.st_info) == STT_ARM_TFUNC) | |
9430 | elfsym->symbol.flags |= BSF_FUNCTION; | |
9431 | } | |
9432 | ||
0beaef2b PB |
9433 | |
9434 | /* Mangle thumb function symbols as we read them in. */ | |
9435 | ||
8384fb8f | 9436 | static bfd_boolean |
0beaef2b PB |
9437 | elf32_arm_swap_symbol_in (bfd * abfd, |
9438 | const void *psrc, | |
9439 | const void *pshn, | |
9440 | Elf_Internal_Sym *dst) | |
9441 | { | |
8384fb8f AM |
9442 | if (!bfd_elf32_swap_symbol_in (abfd, psrc, pshn, dst)) |
9443 | return FALSE; | |
0beaef2b PB |
9444 | |
9445 | /* New EABI objects mark thumb function symbols by setting the low bit of | |
9446 | the address. Turn these into STT_ARM_TFUNC. */ | |
9447 | if (ELF_ST_TYPE (dst->st_info) == STT_FUNC | |
9448 | && (dst->st_value & 1)) | |
9449 | { | |
9450 | dst->st_info = ELF_ST_INFO (ELF_ST_BIND (dst->st_info), STT_ARM_TFUNC); | |
9451 | dst->st_value &= ~(bfd_vma) 1; | |
9452 | } | |
8384fb8f | 9453 | return TRUE; |
0beaef2b PB |
9454 | } |
9455 | ||
9456 | ||
9457 | /* Mangle thumb function symbols as we write them out. */ | |
9458 | ||
9459 | static void | |
9460 | elf32_arm_swap_symbol_out (bfd *abfd, | |
9461 | const Elf_Internal_Sym *src, | |
9462 | void *cdst, | |
9463 | void *shndx) | |
9464 | { | |
9465 | Elf_Internal_Sym newsym; | |
9466 | ||
9467 | /* We convert STT_ARM_TFUNC symbols into STT_FUNC with the low bit | |
9468 | of the address set, as per the new EABI. We do this unconditionally | |
9469 | because objcopy does not set the elf header flags until after | |
9470 | it writes out the symbol table. */ | |
9471 | if (ELF_ST_TYPE (src->st_info) == STT_ARM_TFUNC) | |
9472 | { | |
9473 | newsym = *src; | |
9474 | newsym.st_info = ELF_ST_INFO (ELF_ST_BIND (src->st_info), STT_FUNC); | |
0fa3dcad PB |
9475 | if (newsym.st_shndx != SHN_UNDEF) |
9476 | { | |
9477 | /* Do this only for defined symbols. At link type, the static | |
9478 | linker will simulate the work of dynamic linker of resolving | |
9479 | symbols and will carry over the thumbness of found symbols to | |
9480 | the output symbol table. It's not clear how it happens, but | |
b0fead2b | 9481 | the thumbness of undefined symbols can well be different at |
0fa3dcad PB |
9482 | runtime, and writing '1' for them will be confusing for users |
9483 | and possibly for dynamic linker itself. | |
9484 | */ | |
9485 | newsym.st_value |= 1; | |
9486 | } | |
0beaef2b PB |
9487 | |
9488 | src = &newsym; | |
9489 | } | |
9490 | bfd_elf32_swap_symbol_out (abfd, src, cdst, shndx); | |
9491 | } | |
9492 | ||
b294bdf8 MM |
9493 | /* Add the PT_ARM_EXIDX program header. */ |
9494 | ||
9495 | static bfd_boolean | |
9496 | elf32_arm_modify_segment_map (bfd *abfd, | |
9497 | struct bfd_link_info *info ATTRIBUTE_UNUSED) | |
9498 | { | |
9499 | struct elf_segment_map *m; | |
9500 | asection *sec; | |
9501 | ||
9502 | sec = bfd_get_section_by_name (abfd, ".ARM.exidx"); | |
9503 | if (sec != NULL && (sec->flags & SEC_LOAD) != 0) | |
9504 | { | |
9505 | /* If there is already a PT_ARM_EXIDX header, then we do not | |
9506 | want to add another one. This situation arises when running | |
9507 | "strip"; the input binary already has the header. */ | |
9508 | m = elf_tdata (abfd)->segment_map; | |
9509 | while (m && m->p_type != PT_ARM_EXIDX) | |
9510 | m = m->next; | |
9511 | if (!m) | |
9512 | { | |
9513 | m = bfd_zalloc (abfd, sizeof (struct elf_segment_map)); | |
9514 | if (m == NULL) | |
9515 | return FALSE; | |
9516 | m->p_type = PT_ARM_EXIDX; | |
9517 | m->count = 1; | |
9518 | m->sections[0] = sec; | |
9519 | ||
9520 | m->next = elf_tdata (abfd)->segment_map; | |
9521 | elf_tdata (abfd)->segment_map = m; | |
9522 | } | |
9523 | } | |
9524 | ||
9525 | return TRUE; | |
9526 | } | |
9527 | ||
9528 | /* We may add a PT_ARM_EXIDX program header. */ | |
9529 | ||
9530 | static int | |
a6b96beb AM |
9531 | elf32_arm_additional_program_headers (bfd *abfd, |
9532 | struct bfd_link_info *info ATTRIBUTE_UNUSED) | |
b294bdf8 MM |
9533 | { |
9534 | asection *sec; | |
9535 | ||
9536 | sec = bfd_get_section_by_name (abfd, ".ARM.exidx"); | |
9537 | if (sec != NULL && (sec->flags & SEC_LOAD) != 0) | |
9538 | return 1; | |
9539 | else | |
9540 | return 0; | |
9541 | } | |
9542 | ||
0beaef2b PB |
9543 | /* We use this to override swap_symbol_in and swap_symbol_out. */ |
9544 | const struct elf_size_info elf32_arm_size_info = { | |
9545 | sizeof (Elf32_External_Ehdr), | |
9546 | sizeof (Elf32_External_Phdr), | |
9547 | sizeof (Elf32_External_Shdr), | |
9548 | sizeof (Elf32_External_Rel), | |
9549 | sizeof (Elf32_External_Rela), | |
9550 | sizeof (Elf32_External_Sym), | |
9551 | sizeof (Elf32_External_Dyn), | |
9552 | sizeof (Elf_External_Note), | |
9553 | 4, | |
9554 | 1, | |
9555 | 32, 2, | |
9556 | ELFCLASS32, EV_CURRENT, | |
9557 | bfd_elf32_write_out_phdrs, | |
9558 | bfd_elf32_write_shdrs_and_ehdr, | |
9559 | bfd_elf32_write_relocs, | |
9560 | elf32_arm_swap_symbol_in, | |
9561 | elf32_arm_swap_symbol_out, | |
9562 | bfd_elf32_slurp_reloc_table, | |
9563 | bfd_elf32_slurp_symbol_table, | |
9564 | bfd_elf32_swap_dyn_in, | |
9565 | bfd_elf32_swap_dyn_out, | |
9566 | bfd_elf32_swap_reloc_in, | |
9567 | bfd_elf32_swap_reloc_out, | |
9568 | bfd_elf32_swap_reloca_in, | |
9569 | bfd_elf32_swap_reloca_out | |
9570 | }; | |
9571 | ||
252b5132 RH |
9572 | #define ELF_ARCH bfd_arch_arm |
9573 | #define ELF_MACHINE_CODE EM_ARM | |
d0facd1b NC |
9574 | #ifdef __QNXTARGET__ |
9575 | #define ELF_MAXPAGESIZE 0x1000 | |
9576 | #else | |
f21f3fe0 | 9577 | #define ELF_MAXPAGESIZE 0x8000 |
d0facd1b | 9578 | #endif |
b1342370 | 9579 | #define ELF_MINPAGESIZE 0x1000 |
24718e3b | 9580 | #define ELF_COMMONPAGESIZE 0x1000 |
252b5132 | 9581 | |
ba93b8ac DJ |
9582 | #define bfd_elf32_mkobject elf32_arm_mkobject |
9583 | ||
99e4ae17 AJ |
9584 | #define bfd_elf32_bfd_copy_private_bfd_data elf32_arm_copy_private_bfd_data |
9585 | #define bfd_elf32_bfd_merge_private_bfd_data elf32_arm_merge_private_bfd_data | |
252b5132 RH |
9586 | #define bfd_elf32_bfd_set_private_flags elf32_arm_set_private_flags |
9587 | #define bfd_elf32_bfd_print_private_bfd_data elf32_arm_print_private_bfd_data | |
9588 | #define bfd_elf32_bfd_link_hash_table_create elf32_arm_link_hash_table_create | |
dc810e39 | 9589 | #define bfd_elf32_bfd_reloc_type_lookup elf32_arm_reloc_type_lookup |
252b5132 | 9590 | #define bfd_elf32_find_nearest_line elf32_arm_find_nearest_line |
4ab527b0 | 9591 | #define bfd_elf32_find_inliner_info elf32_arm_find_inliner_info |
e489d0ae | 9592 | #define bfd_elf32_new_section_hook elf32_arm_new_section_hook |
3c9458e9 | 9593 | #define bfd_elf32_bfd_is_target_special_symbol elf32_arm_is_target_special_symbol |
957c6e41 | 9594 | #define bfd_elf32_close_and_cleanup elf32_arm_close_and_cleanup |
b25e3d87 | 9595 | #define bfd_elf32_bfd_free_cached_info elf32_arm_bfd_free_cached_info |
ee065d83 | 9596 | #define bfd_elf32_bfd_final_link elf32_arm_bfd_final_link |
252b5132 RH |
9597 | |
9598 | #define elf_backend_get_symbol_type elf32_arm_get_symbol_type | |
9599 | #define elf_backend_gc_mark_hook elf32_arm_gc_mark_hook | |
9600 | #define elf_backend_gc_sweep_hook elf32_arm_gc_sweep_hook | |
9601 | #define elf_backend_check_relocs elf32_arm_check_relocs | |
dc810e39 | 9602 | #define elf_backend_relocate_section elf32_arm_relocate_section |
e489d0ae | 9603 | #define elf_backend_write_section elf32_arm_write_section |
252b5132 | 9604 | #define elf_backend_adjust_dynamic_symbol elf32_arm_adjust_dynamic_symbol |
5e681ec4 | 9605 | #define elf_backend_create_dynamic_sections elf32_arm_create_dynamic_sections |
252b5132 RH |
9606 | #define elf_backend_finish_dynamic_symbol elf32_arm_finish_dynamic_symbol |
9607 | #define elf_backend_finish_dynamic_sections elf32_arm_finish_dynamic_sections | |
e489d0ae | 9608 | #define elf_backend_link_output_symbol_hook elf32_arm_output_symbol_hook |
252b5132 | 9609 | #define elf_backend_size_dynamic_sections elf32_arm_size_dynamic_sections |
74541ad4 | 9610 | #define elf_backend_init_index_section _bfd_elf_init_2_index_sections |
ba96a88f | 9611 | #define elf_backend_post_process_headers elf32_arm_post_process_headers |
99e4ae17 | 9612 | #define elf_backend_reloc_type_class elf32_arm_reloc_type_class |
c178919b | 9613 | #define elf_backend_object_p elf32_arm_object_p |
e16bb312 | 9614 | #define elf_backend_section_flags elf32_arm_section_flags |
40a18ebd NC |
9615 | #define elf_backend_fake_sections elf32_arm_fake_sections |
9616 | #define elf_backend_section_from_shdr elf32_arm_section_from_shdr | |
e16bb312 | 9617 | #define elf_backend_final_write_processing elf32_arm_final_write_processing |
5e681ec4 | 9618 | #define elf_backend_copy_indirect_symbol elf32_arm_copy_indirect_symbol |
b7693d02 | 9619 | #define elf_backend_symbol_processing elf32_arm_symbol_processing |
0beaef2b | 9620 | #define elf_backend_size_info elf32_arm_size_info |
b294bdf8 MM |
9621 | #define elf_backend_modify_segment_map elf32_arm_modify_segment_map |
9622 | #define elf_backend_additional_program_headers \ | |
9623 | elf32_arm_additional_program_headers | |
4e617b1e PB |
9624 | #define elf_backend_output_arch_local_syms \ |
9625 | elf32_arm_output_arch_local_syms | |
a4fd1a8e PB |
9626 | #define elf_backend_begin_write_processing \ |
9627 | elf32_arm_begin_write_processing | |
252b5132 | 9628 | |
5e681ec4 | 9629 | #define elf_backend_can_refcount 1 |
252b5132 RH |
9630 | #define elf_backend_can_gc_sections 1 |
9631 | #define elf_backend_plt_readonly 1 | |
9632 | #define elf_backend_want_got_plt 1 | |
9633 | #define elf_backend_want_plt_sym 0 | |
4e7fd91e PB |
9634 | #define elf_backend_may_use_rel_p 1 |
9635 | #define elf_backend_may_use_rela_p 0 | |
9636 | #define elf_backend_default_use_rela_p 0 | |
9637 | #define elf_backend_rela_normal 0 | |
252b5132 | 9638 | |
04f7c78d | 9639 | #define elf_backend_got_header_size 12 |
04f7c78d | 9640 | |
252b5132 | 9641 | #include "elf32-target.h" |
7f266840 | 9642 | |
4e7fd91e PB |
9643 | /* VxWorks Targets */ |
9644 | ||
9645 | #undef TARGET_LITTLE_SYM | |
9646 | #define TARGET_LITTLE_SYM bfd_elf32_littlearm_vxworks_vec | |
9647 | #undef TARGET_LITTLE_NAME | |
9648 | #define TARGET_LITTLE_NAME "elf32-littlearm-vxworks" | |
9649 | #undef TARGET_BIG_SYM | |
9650 | #define TARGET_BIG_SYM bfd_elf32_bigarm_vxworks_vec | |
9651 | #undef TARGET_BIG_NAME | |
9652 | #define TARGET_BIG_NAME "elf32-bigarm-vxworks" | |
9653 | ||
9654 | /* Like elf32_arm_link_hash_table_create -- but overrides | |
9655 | appropriately for VxWorks. */ | |
9656 | static struct bfd_link_hash_table * | |
9657 | elf32_arm_vxworks_link_hash_table_create (bfd *abfd) | |
9658 | { | |
9659 | struct bfd_link_hash_table *ret; | |
9660 | ||
9661 | ret = elf32_arm_link_hash_table_create (abfd); | |
9662 | if (ret) | |
9663 | { | |
9664 | struct elf32_arm_link_hash_table *htab | |
00a97672 | 9665 | = (struct elf32_arm_link_hash_table *) ret; |
4e7fd91e | 9666 | htab->use_rel = 0; |
00a97672 | 9667 | htab->vxworks_p = 1; |
4e7fd91e PB |
9668 | } |
9669 | return ret; | |
9670 | } | |
9671 | ||
00a97672 RS |
9672 | static void |
9673 | elf32_arm_vxworks_final_write_processing (bfd *abfd, bfd_boolean linker) | |
9674 | { | |
9675 | elf32_arm_final_write_processing (abfd, linker); | |
9676 | elf_vxworks_final_write_processing (abfd, linker); | |
9677 | } | |
9678 | ||
4e7fd91e PB |
9679 | #undef elf32_bed |
9680 | #define elf32_bed elf32_arm_vxworks_bed | |
9681 | ||
9682 | #undef bfd_elf32_bfd_link_hash_table_create | |
9683 | #define bfd_elf32_bfd_link_hash_table_create \ | |
9684 | elf32_arm_vxworks_link_hash_table_create | |
00a97672 RS |
9685 | #undef elf_backend_add_symbol_hook |
9686 | #define elf_backend_add_symbol_hook \ | |
9687 | elf_vxworks_add_symbol_hook | |
9688 | #undef elf_backend_final_write_processing | |
9689 | #define elf_backend_final_write_processing \ | |
9690 | elf32_arm_vxworks_final_write_processing | |
9691 | #undef elf_backend_emit_relocs | |
9692 | #define elf_backend_emit_relocs \ | |
9693 | elf_vxworks_emit_relocs | |
4e7fd91e PB |
9694 | |
9695 | #undef elf_backend_may_use_rel_p | |
00a97672 | 9696 | #define elf_backend_may_use_rel_p 0 |
4e7fd91e | 9697 | #undef elf_backend_may_use_rela_p |
00a97672 | 9698 | #define elf_backend_may_use_rela_p 1 |
4e7fd91e | 9699 | #undef elf_backend_default_use_rela_p |
00a97672 | 9700 | #define elf_backend_default_use_rela_p 1 |
4e7fd91e | 9701 | #undef elf_backend_rela_normal |
00a97672 RS |
9702 | #define elf_backend_rela_normal 1 |
9703 | #undef elf_backend_want_plt_sym | |
9704 | #define elf_backend_want_plt_sym 1 | |
9705 | #undef ELF_MAXPAGESIZE | |
9706 | #define ELF_MAXPAGESIZE 0x1000 | |
4e7fd91e PB |
9707 | |
9708 | #include "elf32-target.h" | |
9709 | ||
9710 | ||
7f266840 DJ |
9711 | /* Symbian OS Targets */ |
9712 | ||
9713 | #undef TARGET_LITTLE_SYM | |
9714 | #define TARGET_LITTLE_SYM bfd_elf32_littlearm_symbian_vec | |
9715 | #undef TARGET_LITTLE_NAME | |
9716 | #define TARGET_LITTLE_NAME "elf32-littlearm-symbian" | |
9717 | #undef TARGET_BIG_SYM | |
9718 | #define TARGET_BIG_SYM bfd_elf32_bigarm_symbian_vec | |
9719 | #undef TARGET_BIG_NAME | |
9720 | #define TARGET_BIG_NAME "elf32-bigarm-symbian" | |
9721 | ||
9722 | /* Like elf32_arm_link_hash_table_create -- but overrides | |
9723 | appropriately for Symbian OS. */ | |
9724 | static struct bfd_link_hash_table * | |
9725 | elf32_arm_symbian_link_hash_table_create (bfd *abfd) | |
9726 | { | |
9727 | struct bfd_link_hash_table *ret; | |
9728 | ||
9729 | ret = elf32_arm_link_hash_table_create (abfd); | |
9730 | if (ret) | |
9731 | { | |
9732 | struct elf32_arm_link_hash_table *htab | |
9733 | = (struct elf32_arm_link_hash_table *)ret; | |
9734 | /* There is no PLT header for Symbian OS. */ | |
9735 | htab->plt_header_size = 0; | |
9736 | /* The PLT entries are each three instructions. */ | |
9737 | htab->plt_entry_size = 4 * NUM_ELEM (elf32_arm_symbian_plt_entry); | |
9738 | htab->symbian_p = 1; | |
33bfe774 JB |
9739 | /* Symbian uses armv5t or above, so use_blx is always true. */ |
9740 | htab->use_blx = 1; | |
67687978 | 9741 | htab->root.is_relocatable_executable = 1; |
7f266840 DJ |
9742 | } |
9743 | return ret; | |
9744 | } | |
9745 | ||
b35d266b | 9746 | static const struct bfd_elf_special_section |
551b43fd | 9747 | elf32_arm_symbian_special_sections[] = |
7f266840 | 9748 | { |
5cd3778d MM |
9749 | /* In a BPABI executable, the dynamic linking sections do not go in |
9750 | the loadable read-only segment. The post-linker may wish to | |
9751 | refer to these sections, but they are not part of the final | |
9752 | program image. */ | |
0112cd26 NC |
9753 | { STRING_COMMA_LEN (".dynamic"), 0, SHT_DYNAMIC, 0 }, |
9754 | { STRING_COMMA_LEN (".dynstr"), 0, SHT_STRTAB, 0 }, | |
9755 | { STRING_COMMA_LEN (".dynsym"), 0, SHT_DYNSYM, 0 }, | |
9756 | { STRING_COMMA_LEN (".got"), 0, SHT_PROGBITS, 0 }, | |
9757 | { STRING_COMMA_LEN (".hash"), 0, SHT_HASH, 0 }, | |
5cd3778d MM |
9758 | /* These sections do not need to be writable as the SymbianOS |
9759 | postlinker will arrange things so that no dynamic relocation is | |
9760 | required. */ | |
0112cd26 NC |
9761 | { STRING_COMMA_LEN (".init_array"), 0, SHT_INIT_ARRAY, SHF_ALLOC }, |
9762 | { STRING_COMMA_LEN (".fini_array"), 0, SHT_FINI_ARRAY, SHF_ALLOC }, | |
9763 | { STRING_COMMA_LEN (".preinit_array"), 0, SHT_PREINIT_ARRAY, SHF_ALLOC }, | |
9764 | { NULL, 0, 0, 0, 0 } | |
7f266840 DJ |
9765 | }; |
9766 | ||
c3c76620 | 9767 | static void |
b34af79c | 9768 | elf32_arm_symbian_begin_write_processing (bfd *abfd, |
a4fd1a8e | 9769 | struct bfd_link_info *link_info) |
c3c76620 MM |
9770 | { |
9771 | /* BPABI objects are never loaded directly by an OS kernel; they are | |
9772 | processed by a postlinker first, into an OS-specific format. If | |
9773 | the D_PAGED bit is set on the file, BFD will align segments on | |
9774 | page boundaries, so that an OS can directly map the file. With | |
9775 | BPABI objects, that just results in wasted space. In addition, | |
9776 | because we clear the D_PAGED bit, map_sections_to_segments will | |
9777 | recognize that the program headers should not be mapped into any | |
9778 | loadable segment. */ | |
9779 | abfd->flags &= ~D_PAGED; | |
a4fd1a8e | 9780 | elf32_arm_begin_write_processing(abfd, link_info); |
c3c76620 | 9781 | } |
7f266840 DJ |
9782 | |
9783 | static bfd_boolean | |
b34af79c | 9784 | elf32_arm_symbian_modify_segment_map (bfd *abfd, |
b294bdf8 | 9785 | struct bfd_link_info *info) |
7f266840 DJ |
9786 | { |
9787 | struct elf_segment_map *m; | |
9788 | asection *dynsec; | |
9789 | ||
7f266840 DJ |
9790 | /* BPABI shared libraries and executables should have a PT_DYNAMIC |
9791 | segment. However, because the .dynamic section is not marked | |
9792 | with SEC_LOAD, the generic ELF code will not create such a | |
9793 | segment. */ | |
9794 | dynsec = bfd_get_section_by_name (abfd, ".dynamic"); | |
9795 | if (dynsec) | |
9796 | { | |
8ded5a0f AM |
9797 | for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next) |
9798 | if (m->p_type == PT_DYNAMIC) | |
9799 | break; | |
9800 | ||
9801 | if (m == NULL) | |
9802 | { | |
9803 | m = _bfd_elf_make_dynamic_segment (abfd, dynsec); | |
9804 | m->next = elf_tdata (abfd)->segment_map; | |
9805 | elf_tdata (abfd)->segment_map = m; | |
9806 | } | |
7f266840 DJ |
9807 | } |
9808 | ||
b294bdf8 MM |
9809 | /* Also call the generic arm routine. */ |
9810 | return elf32_arm_modify_segment_map (abfd, info); | |
7f266840 DJ |
9811 | } |
9812 | ||
9813 | #undef elf32_bed | |
9814 | #define elf32_bed elf32_arm_symbian_bed | |
9815 | ||
9816 | /* The dynamic sections are not allocated on SymbianOS; the postlinker | |
9817 | will process them and then discard them. */ | |
9818 | #undef ELF_DYNAMIC_SEC_FLAGS | |
9819 | #define ELF_DYNAMIC_SEC_FLAGS \ | |
9820 | (SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED) | |
9821 | ||
9822 | #undef bfd_elf32_bfd_link_hash_table_create | |
9823 | #define bfd_elf32_bfd_link_hash_table_create \ | |
9824 | elf32_arm_symbian_link_hash_table_create | |
00a97672 | 9825 | #undef elf_backend_add_symbol_hook |
7f266840 | 9826 | |
29ef7005 L |
9827 | #undef elf_backend_special_sections |
9828 | #define elf_backend_special_sections elf32_arm_symbian_special_sections | |
7f266840 | 9829 | |
c3c76620 MM |
9830 | #undef elf_backend_begin_write_processing |
9831 | #define elf_backend_begin_write_processing \ | |
9832 | elf32_arm_symbian_begin_write_processing | |
00a97672 RS |
9833 | #undef elf_backend_final_write_processing |
9834 | #define elf_backend_final_write_processing \ | |
9835 | elf32_arm_final_write_processing | |
9836 | #undef elf_backend_emit_relocs | |
c3c76620 | 9837 | |
7f266840 DJ |
9838 | #undef elf_backend_modify_segment_map |
9839 | #define elf_backend_modify_segment_map elf32_arm_symbian_modify_segment_map | |
9840 | ||
9841 | /* There is no .got section for BPABI objects, and hence no header. */ | |
9842 | #undef elf_backend_got_header_size | |
9843 | #define elf_backend_got_header_size 0 | |
9844 | ||
9845 | /* Similarly, there is no .got.plt section. */ | |
9846 | #undef elf_backend_want_got_plt | |
9847 | #define elf_backend_want_got_plt 0 | |
9848 | ||
4e7fd91e | 9849 | #undef elf_backend_may_use_rel_p |
00a97672 | 9850 | #define elf_backend_may_use_rel_p 1 |
4e7fd91e | 9851 | #undef elf_backend_may_use_rela_p |
00a97672 | 9852 | #define elf_backend_may_use_rela_p 0 |
4e7fd91e | 9853 | #undef elf_backend_default_use_rela_p |
00a97672 | 9854 | #define elf_backend_default_use_rela_p 0 |
4e7fd91e | 9855 | #undef elf_backend_rela_normal |
00a97672 RS |
9856 | #define elf_backend_rela_normal 0 |
9857 | #undef elf_backend_want_plt_sym | |
9858 | #define elf_backend_want_plt_sym 0 | |
9859 | #undef ELF_MAXPAGESIZE | |
9860 | #define ELF_MAXPAGESIZE 0x8000 | |
4e7fd91e | 9861 | |
7f266840 | 9862 | #include "elf32-target.h" |