1 /* 32-bit ELF support for ARM
2 Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
3 2008 Free Software Foundation, Inc.
5 This file is part of BFD, the Binary File Descriptor library.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
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.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
24 #include "libiberty.h"
27 #include "elf-vxworks.h"
31 #define NUM_ELEM(a) (sizeof (a) / (sizeof (a)[0]))
34 /* Return the relocation section associated with NAME. HTAB is the
35 bfd's elf32_arm_link_hash_entry. */
36 #define RELOC_SECTION(HTAB, NAME) \
37 ((HTAB)->use_rel ? ".rel" NAME : ".rela" NAME)
39 /* Return size of a relocation entry. HTAB is the bfd's
40 elf32_arm_link_hash_entry. */
41 #define RELOC_SIZE(HTAB) \
43 ? sizeof (Elf32_External_Rel) \
44 : sizeof (Elf32_External_Rela))
46 /* Return function to swap relocations in. HTAB is the bfd's
47 elf32_arm_link_hash_entry. */
48 #define SWAP_RELOC_IN(HTAB) \
50 ? bfd_elf32_swap_reloc_in \
51 : bfd_elf32_swap_reloca_in)
53 /* Return function to swap relocations out. HTAB is the bfd's
54 elf32_arm_link_hash_entry. */
55 #define SWAP_RELOC_OUT(HTAB) \
57 ? bfd_elf32_swap_reloc_out \
58 : bfd_elf32_swap_reloca_out)
60 #define elf_info_to_howto 0
61 #define elf_info_to_howto_rel elf32_arm_info_to_howto
63 #define ARM_ELF_ABI_VERSION 0
64 #define ARM_ELF_OS_ABI_VERSION ELFOSABI_ARM
66 static struct elf_backend_data elf32_arm_vxworks_bed
;
68 /* Note: code such as elf32_arm_reloc_type_lookup expect to use e.g.
69 R_ARM_PC24 as an index into this, and find the R_ARM_PC24 HOWTO
72 static reloc_howto_type elf32_arm_howto_table_1
[] =
75 HOWTO (R_ARM_NONE
, /* type */
77 0, /* size (0 = byte, 1 = short, 2 = long) */
79 FALSE
, /* pc_relative */
81 complain_overflow_dont
,/* complain_on_overflow */
82 bfd_elf_generic_reloc
, /* special_function */
83 "R_ARM_NONE", /* name */
84 FALSE
, /* partial_inplace */
87 FALSE
), /* pcrel_offset */
89 HOWTO (R_ARM_PC24
, /* type */
91 2, /* size (0 = byte, 1 = short, 2 = long) */
93 TRUE
, /* pc_relative */
95 complain_overflow_signed
,/* complain_on_overflow */
96 bfd_elf_generic_reloc
, /* special_function */
97 "R_ARM_PC24", /* name */
98 FALSE
, /* partial_inplace */
99 0x00ffffff, /* src_mask */
100 0x00ffffff, /* dst_mask */
101 TRUE
), /* pcrel_offset */
103 /* 32 bit absolute */
104 HOWTO (R_ARM_ABS32
, /* type */
106 2, /* size (0 = byte, 1 = short, 2 = long) */
108 FALSE
, /* pc_relative */
110 complain_overflow_bitfield
,/* complain_on_overflow */
111 bfd_elf_generic_reloc
, /* special_function */
112 "R_ARM_ABS32", /* name */
113 FALSE
, /* partial_inplace */
114 0xffffffff, /* src_mask */
115 0xffffffff, /* dst_mask */
116 FALSE
), /* pcrel_offset */
118 /* standard 32bit pc-relative reloc */
119 HOWTO (R_ARM_REL32
, /* type */
121 2, /* size (0 = byte, 1 = short, 2 = long) */
123 TRUE
, /* pc_relative */
125 complain_overflow_bitfield
,/* complain_on_overflow */
126 bfd_elf_generic_reloc
, /* special_function */
127 "R_ARM_REL32", /* name */
128 FALSE
, /* partial_inplace */
129 0xffffffff, /* src_mask */
130 0xffffffff, /* dst_mask */
131 TRUE
), /* pcrel_offset */
133 /* 8 bit absolute - R_ARM_LDR_PC_G0 in AAELF */
134 HOWTO (R_ARM_LDR_PC_G0
, /* type */
136 0, /* size (0 = byte, 1 = short, 2 = long) */
138 TRUE
, /* pc_relative */
140 complain_overflow_dont
,/* complain_on_overflow */
141 bfd_elf_generic_reloc
, /* special_function */
142 "R_ARM_LDR_PC_G0", /* name */
143 FALSE
, /* partial_inplace */
144 0xffffffff, /* src_mask */
145 0xffffffff, /* dst_mask */
146 TRUE
), /* pcrel_offset */
148 /* 16 bit absolute */
149 HOWTO (R_ARM_ABS16
, /* type */
151 1, /* size (0 = byte, 1 = short, 2 = long) */
153 FALSE
, /* pc_relative */
155 complain_overflow_bitfield
,/* complain_on_overflow */
156 bfd_elf_generic_reloc
, /* special_function */
157 "R_ARM_ABS16", /* name */
158 FALSE
, /* partial_inplace */
159 0x0000ffff, /* src_mask */
160 0x0000ffff, /* dst_mask */
161 FALSE
), /* pcrel_offset */
163 /* 12 bit absolute */
164 HOWTO (R_ARM_ABS12
, /* type */
166 2, /* size (0 = byte, 1 = short, 2 = long) */
168 FALSE
, /* pc_relative */
170 complain_overflow_bitfield
,/* complain_on_overflow */
171 bfd_elf_generic_reloc
, /* special_function */
172 "R_ARM_ABS12", /* name */
173 FALSE
, /* partial_inplace */
174 0x00000fff, /* src_mask */
175 0x00000fff, /* dst_mask */
176 FALSE
), /* pcrel_offset */
178 HOWTO (R_ARM_THM_ABS5
, /* type */
180 1, /* size (0 = byte, 1 = short, 2 = long) */
182 FALSE
, /* pc_relative */
184 complain_overflow_bitfield
,/* complain_on_overflow */
185 bfd_elf_generic_reloc
, /* special_function */
186 "R_ARM_THM_ABS5", /* name */
187 FALSE
, /* partial_inplace */
188 0x000007e0, /* src_mask */
189 0x000007e0, /* dst_mask */
190 FALSE
), /* pcrel_offset */
193 HOWTO (R_ARM_ABS8
, /* type */
195 0, /* size (0 = byte, 1 = short, 2 = long) */
197 FALSE
, /* pc_relative */
199 complain_overflow_bitfield
,/* complain_on_overflow */
200 bfd_elf_generic_reloc
, /* special_function */
201 "R_ARM_ABS8", /* name */
202 FALSE
, /* partial_inplace */
203 0x000000ff, /* src_mask */
204 0x000000ff, /* dst_mask */
205 FALSE
), /* pcrel_offset */
207 HOWTO (R_ARM_SBREL32
, /* type */
209 2, /* size (0 = byte, 1 = short, 2 = long) */
211 FALSE
, /* pc_relative */
213 complain_overflow_dont
,/* complain_on_overflow */
214 bfd_elf_generic_reloc
, /* special_function */
215 "R_ARM_SBREL32", /* name */
216 FALSE
, /* partial_inplace */
217 0xffffffff, /* src_mask */
218 0xffffffff, /* dst_mask */
219 FALSE
), /* pcrel_offset */
221 HOWTO (R_ARM_THM_CALL
, /* type */
223 2, /* size (0 = byte, 1 = short, 2 = long) */
225 TRUE
, /* pc_relative */
227 complain_overflow_signed
,/* complain_on_overflow */
228 bfd_elf_generic_reloc
, /* special_function */
229 "R_ARM_THM_CALL", /* name */
230 FALSE
, /* partial_inplace */
231 0x07ff07ff, /* src_mask */
232 0x07ff07ff, /* dst_mask */
233 TRUE
), /* pcrel_offset */
235 HOWTO (R_ARM_THM_PC8
, /* type */
237 1, /* size (0 = byte, 1 = short, 2 = long) */
239 TRUE
, /* pc_relative */
241 complain_overflow_signed
,/* complain_on_overflow */
242 bfd_elf_generic_reloc
, /* special_function */
243 "R_ARM_THM_PC8", /* name */
244 FALSE
, /* partial_inplace */
245 0x000000ff, /* src_mask */
246 0x000000ff, /* dst_mask */
247 TRUE
), /* pcrel_offset */
249 HOWTO (R_ARM_BREL_ADJ
, /* type */
251 1, /* size (0 = byte, 1 = short, 2 = long) */
253 FALSE
, /* pc_relative */
255 complain_overflow_signed
,/* complain_on_overflow */
256 bfd_elf_generic_reloc
, /* special_function */
257 "R_ARM_BREL_ADJ", /* name */
258 FALSE
, /* partial_inplace */
259 0xffffffff, /* src_mask */
260 0xffffffff, /* dst_mask */
261 FALSE
), /* pcrel_offset */
263 HOWTO (R_ARM_SWI24
, /* type */
265 0, /* size (0 = byte, 1 = short, 2 = long) */
267 FALSE
, /* pc_relative */
269 complain_overflow_signed
,/* complain_on_overflow */
270 bfd_elf_generic_reloc
, /* special_function */
271 "R_ARM_SWI24", /* name */
272 FALSE
, /* partial_inplace */
273 0x00000000, /* src_mask */
274 0x00000000, /* dst_mask */
275 FALSE
), /* pcrel_offset */
277 HOWTO (R_ARM_THM_SWI8
, /* type */
279 0, /* size (0 = byte, 1 = short, 2 = long) */
281 FALSE
, /* pc_relative */
283 complain_overflow_signed
,/* complain_on_overflow */
284 bfd_elf_generic_reloc
, /* special_function */
285 "R_ARM_SWI8", /* name */
286 FALSE
, /* partial_inplace */
287 0x00000000, /* src_mask */
288 0x00000000, /* dst_mask */
289 FALSE
), /* pcrel_offset */
291 /* BLX instruction for the ARM. */
292 HOWTO (R_ARM_XPC25
, /* type */
294 2, /* size (0 = byte, 1 = short, 2 = long) */
296 TRUE
, /* pc_relative */
298 complain_overflow_signed
,/* complain_on_overflow */
299 bfd_elf_generic_reloc
, /* special_function */
300 "R_ARM_XPC25", /* name */
301 FALSE
, /* partial_inplace */
302 0x00ffffff, /* src_mask */
303 0x00ffffff, /* dst_mask */
304 TRUE
), /* pcrel_offset */
306 /* BLX instruction for the Thumb. */
307 HOWTO (R_ARM_THM_XPC22
, /* type */
309 2, /* size (0 = byte, 1 = short, 2 = long) */
311 TRUE
, /* pc_relative */
313 complain_overflow_signed
,/* complain_on_overflow */
314 bfd_elf_generic_reloc
, /* special_function */
315 "R_ARM_THM_XPC22", /* name */
316 FALSE
, /* partial_inplace */
317 0x07ff07ff, /* src_mask */
318 0x07ff07ff, /* dst_mask */
319 TRUE
), /* pcrel_offset */
321 /* Dynamic TLS relocations. */
323 HOWTO (R_ARM_TLS_DTPMOD32
, /* type */
325 2, /* size (0 = byte, 1 = short, 2 = long) */
327 FALSE
, /* pc_relative */
329 complain_overflow_bitfield
,/* complain_on_overflow */
330 bfd_elf_generic_reloc
, /* special_function */
331 "R_ARM_TLS_DTPMOD32", /* name */
332 TRUE
, /* partial_inplace */
333 0xffffffff, /* src_mask */
334 0xffffffff, /* dst_mask */
335 FALSE
), /* pcrel_offset */
337 HOWTO (R_ARM_TLS_DTPOFF32
, /* type */
339 2, /* size (0 = byte, 1 = short, 2 = long) */
341 FALSE
, /* pc_relative */
343 complain_overflow_bitfield
,/* complain_on_overflow */
344 bfd_elf_generic_reloc
, /* special_function */
345 "R_ARM_TLS_DTPOFF32", /* name */
346 TRUE
, /* partial_inplace */
347 0xffffffff, /* src_mask */
348 0xffffffff, /* dst_mask */
349 FALSE
), /* pcrel_offset */
351 HOWTO (R_ARM_TLS_TPOFF32
, /* type */
353 2, /* size (0 = byte, 1 = short, 2 = long) */
355 FALSE
, /* pc_relative */
357 complain_overflow_bitfield
,/* complain_on_overflow */
358 bfd_elf_generic_reloc
, /* special_function */
359 "R_ARM_TLS_TPOFF32", /* name */
360 TRUE
, /* partial_inplace */
361 0xffffffff, /* src_mask */
362 0xffffffff, /* dst_mask */
363 FALSE
), /* pcrel_offset */
365 /* Relocs used in ARM Linux */
367 HOWTO (R_ARM_COPY
, /* type */
369 2, /* size (0 = byte, 1 = short, 2 = long) */
371 FALSE
, /* pc_relative */
373 complain_overflow_bitfield
,/* complain_on_overflow */
374 bfd_elf_generic_reloc
, /* special_function */
375 "R_ARM_COPY", /* name */
376 TRUE
, /* partial_inplace */
377 0xffffffff, /* src_mask */
378 0xffffffff, /* dst_mask */
379 FALSE
), /* pcrel_offset */
381 HOWTO (R_ARM_GLOB_DAT
, /* type */
383 2, /* size (0 = byte, 1 = short, 2 = long) */
385 FALSE
, /* pc_relative */
387 complain_overflow_bitfield
,/* complain_on_overflow */
388 bfd_elf_generic_reloc
, /* special_function */
389 "R_ARM_GLOB_DAT", /* name */
390 TRUE
, /* partial_inplace */
391 0xffffffff, /* src_mask */
392 0xffffffff, /* dst_mask */
393 FALSE
), /* pcrel_offset */
395 HOWTO (R_ARM_JUMP_SLOT
, /* type */
397 2, /* size (0 = byte, 1 = short, 2 = long) */
399 FALSE
, /* pc_relative */
401 complain_overflow_bitfield
,/* complain_on_overflow */
402 bfd_elf_generic_reloc
, /* special_function */
403 "R_ARM_JUMP_SLOT", /* name */
404 TRUE
, /* partial_inplace */
405 0xffffffff, /* src_mask */
406 0xffffffff, /* dst_mask */
407 FALSE
), /* pcrel_offset */
409 HOWTO (R_ARM_RELATIVE
, /* type */
411 2, /* size (0 = byte, 1 = short, 2 = long) */
413 FALSE
, /* pc_relative */
415 complain_overflow_bitfield
,/* complain_on_overflow */
416 bfd_elf_generic_reloc
, /* special_function */
417 "R_ARM_RELATIVE", /* name */
418 TRUE
, /* partial_inplace */
419 0xffffffff, /* src_mask */
420 0xffffffff, /* dst_mask */
421 FALSE
), /* pcrel_offset */
423 HOWTO (R_ARM_GOTOFF32
, /* type */
425 2, /* size (0 = byte, 1 = short, 2 = long) */
427 FALSE
, /* pc_relative */
429 complain_overflow_bitfield
,/* complain_on_overflow */
430 bfd_elf_generic_reloc
, /* special_function */
431 "R_ARM_GOTOFF32", /* name */
432 TRUE
, /* partial_inplace */
433 0xffffffff, /* src_mask */
434 0xffffffff, /* dst_mask */
435 FALSE
), /* pcrel_offset */
437 HOWTO (R_ARM_GOTPC
, /* type */
439 2, /* size (0 = byte, 1 = short, 2 = long) */
441 TRUE
, /* pc_relative */
443 complain_overflow_bitfield
,/* complain_on_overflow */
444 bfd_elf_generic_reloc
, /* special_function */
445 "R_ARM_GOTPC", /* name */
446 TRUE
, /* partial_inplace */
447 0xffffffff, /* src_mask */
448 0xffffffff, /* dst_mask */
449 TRUE
), /* pcrel_offset */
451 HOWTO (R_ARM_GOT32
, /* type */
453 2, /* size (0 = byte, 1 = short, 2 = long) */
455 FALSE
, /* pc_relative */
457 complain_overflow_bitfield
,/* complain_on_overflow */
458 bfd_elf_generic_reloc
, /* special_function */
459 "R_ARM_GOT32", /* name */
460 TRUE
, /* partial_inplace */
461 0xffffffff, /* src_mask */
462 0xffffffff, /* dst_mask */
463 FALSE
), /* pcrel_offset */
465 HOWTO (R_ARM_PLT32
, /* type */
467 2, /* size (0 = byte, 1 = short, 2 = long) */
469 TRUE
, /* pc_relative */
471 complain_overflow_bitfield
,/* complain_on_overflow */
472 bfd_elf_generic_reloc
, /* special_function */
473 "R_ARM_PLT32", /* name */
474 FALSE
, /* partial_inplace */
475 0x00ffffff, /* src_mask */
476 0x00ffffff, /* dst_mask */
477 TRUE
), /* pcrel_offset */
479 HOWTO (R_ARM_CALL
, /* type */
481 2, /* size (0 = byte, 1 = short, 2 = long) */
483 TRUE
, /* pc_relative */
485 complain_overflow_signed
,/* complain_on_overflow */
486 bfd_elf_generic_reloc
, /* special_function */
487 "R_ARM_CALL", /* name */
488 FALSE
, /* partial_inplace */
489 0x00ffffff, /* src_mask */
490 0x00ffffff, /* dst_mask */
491 TRUE
), /* pcrel_offset */
493 HOWTO (R_ARM_JUMP24
, /* type */
495 2, /* size (0 = byte, 1 = short, 2 = long) */
497 TRUE
, /* pc_relative */
499 complain_overflow_signed
,/* complain_on_overflow */
500 bfd_elf_generic_reloc
, /* special_function */
501 "R_ARM_JUMP24", /* name */
502 FALSE
, /* partial_inplace */
503 0x00ffffff, /* src_mask */
504 0x00ffffff, /* dst_mask */
505 TRUE
), /* pcrel_offset */
507 HOWTO (R_ARM_THM_JUMP24
, /* type */
509 2, /* size (0 = byte, 1 = short, 2 = long) */
511 TRUE
, /* pc_relative */
513 complain_overflow_signed
,/* complain_on_overflow */
514 bfd_elf_generic_reloc
, /* special_function */
515 "R_ARM_THM_JUMP24", /* name */
516 FALSE
, /* partial_inplace */
517 0x07ff2fff, /* src_mask */
518 0x07ff2fff, /* dst_mask */
519 TRUE
), /* pcrel_offset */
521 HOWTO (R_ARM_BASE_ABS
, /* type */
523 2, /* size (0 = byte, 1 = short, 2 = long) */
525 FALSE
, /* pc_relative */
527 complain_overflow_dont
,/* complain_on_overflow */
528 bfd_elf_generic_reloc
, /* special_function */
529 "R_ARM_BASE_ABS", /* name */
530 FALSE
, /* partial_inplace */
531 0xffffffff, /* src_mask */
532 0xffffffff, /* dst_mask */
533 FALSE
), /* pcrel_offset */
535 HOWTO (R_ARM_ALU_PCREL7_0
, /* type */
537 2, /* size (0 = byte, 1 = short, 2 = long) */
539 TRUE
, /* pc_relative */
541 complain_overflow_dont
,/* complain_on_overflow */
542 bfd_elf_generic_reloc
, /* special_function */
543 "R_ARM_ALU_PCREL_7_0", /* name */
544 FALSE
, /* partial_inplace */
545 0x00000fff, /* src_mask */
546 0x00000fff, /* dst_mask */
547 TRUE
), /* pcrel_offset */
549 HOWTO (R_ARM_ALU_PCREL15_8
, /* type */
551 2, /* size (0 = byte, 1 = short, 2 = long) */
553 TRUE
, /* pc_relative */
555 complain_overflow_dont
,/* complain_on_overflow */
556 bfd_elf_generic_reloc
, /* special_function */
557 "R_ARM_ALU_PCREL_15_8",/* name */
558 FALSE
, /* partial_inplace */
559 0x00000fff, /* src_mask */
560 0x00000fff, /* dst_mask */
561 TRUE
), /* pcrel_offset */
563 HOWTO (R_ARM_ALU_PCREL23_15
, /* type */
565 2, /* size (0 = byte, 1 = short, 2 = long) */
567 TRUE
, /* pc_relative */
569 complain_overflow_dont
,/* complain_on_overflow */
570 bfd_elf_generic_reloc
, /* special_function */
571 "R_ARM_ALU_PCREL_23_15",/* name */
572 FALSE
, /* partial_inplace */
573 0x00000fff, /* src_mask */
574 0x00000fff, /* dst_mask */
575 TRUE
), /* pcrel_offset */
577 HOWTO (R_ARM_LDR_SBREL_11_0
, /* type */
579 2, /* size (0 = byte, 1 = short, 2 = long) */
581 FALSE
, /* pc_relative */
583 complain_overflow_dont
,/* complain_on_overflow */
584 bfd_elf_generic_reloc
, /* special_function */
585 "R_ARM_LDR_SBREL_11_0",/* name */
586 FALSE
, /* partial_inplace */
587 0x00000fff, /* src_mask */
588 0x00000fff, /* dst_mask */
589 FALSE
), /* pcrel_offset */
591 HOWTO (R_ARM_ALU_SBREL_19_12
, /* type */
593 2, /* size (0 = byte, 1 = short, 2 = long) */
595 FALSE
, /* pc_relative */
597 complain_overflow_dont
,/* complain_on_overflow */
598 bfd_elf_generic_reloc
, /* special_function */
599 "R_ARM_ALU_SBREL_19_12",/* name */
600 FALSE
, /* partial_inplace */
601 0x000ff000, /* src_mask */
602 0x000ff000, /* dst_mask */
603 FALSE
), /* pcrel_offset */
605 HOWTO (R_ARM_ALU_SBREL_27_20
, /* type */
607 2, /* size (0 = byte, 1 = short, 2 = long) */
609 FALSE
, /* pc_relative */
611 complain_overflow_dont
,/* complain_on_overflow */
612 bfd_elf_generic_reloc
, /* special_function */
613 "R_ARM_ALU_SBREL_27_20",/* name */
614 FALSE
, /* partial_inplace */
615 0x0ff00000, /* src_mask */
616 0x0ff00000, /* dst_mask */
617 FALSE
), /* pcrel_offset */
619 HOWTO (R_ARM_TARGET1
, /* type */
621 2, /* size (0 = byte, 1 = short, 2 = long) */
623 FALSE
, /* pc_relative */
625 complain_overflow_dont
,/* complain_on_overflow */
626 bfd_elf_generic_reloc
, /* special_function */
627 "R_ARM_TARGET1", /* name */
628 FALSE
, /* partial_inplace */
629 0xffffffff, /* src_mask */
630 0xffffffff, /* dst_mask */
631 FALSE
), /* pcrel_offset */
633 HOWTO (R_ARM_ROSEGREL32
, /* type */
635 2, /* size (0 = byte, 1 = short, 2 = long) */
637 FALSE
, /* pc_relative */
639 complain_overflow_dont
,/* complain_on_overflow */
640 bfd_elf_generic_reloc
, /* special_function */
641 "R_ARM_ROSEGREL32", /* name */
642 FALSE
, /* partial_inplace */
643 0xffffffff, /* src_mask */
644 0xffffffff, /* dst_mask */
645 FALSE
), /* pcrel_offset */
647 HOWTO (R_ARM_V4BX
, /* type */
649 2, /* size (0 = byte, 1 = short, 2 = long) */
651 FALSE
, /* pc_relative */
653 complain_overflow_dont
,/* complain_on_overflow */
654 bfd_elf_generic_reloc
, /* special_function */
655 "R_ARM_V4BX", /* name */
656 FALSE
, /* partial_inplace */
657 0xffffffff, /* src_mask */
658 0xffffffff, /* dst_mask */
659 FALSE
), /* pcrel_offset */
661 HOWTO (R_ARM_TARGET2
, /* type */
663 2, /* size (0 = byte, 1 = short, 2 = long) */
665 FALSE
, /* pc_relative */
667 complain_overflow_signed
,/* complain_on_overflow */
668 bfd_elf_generic_reloc
, /* special_function */
669 "R_ARM_TARGET2", /* name */
670 FALSE
, /* partial_inplace */
671 0xffffffff, /* src_mask */
672 0xffffffff, /* dst_mask */
673 TRUE
), /* pcrel_offset */
675 HOWTO (R_ARM_PREL31
, /* type */
677 2, /* size (0 = byte, 1 = short, 2 = long) */
679 TRUE
, /* pc_relative */
681 complain_overflow_signed
,/* complain_on_overflow */
682 bfd_elf_generic_reloc
, /* special_function */
683 "R_ARM_PREL31", /* name */
684 FALSE
, /* partial_inplace */
685 0x7fffffff, /* src_mask */
686 0x7fffffff, /* dst_mask */
687 TRUE
), /* pcrel_offset */
689 HOWTO (R_ARM_MOVW_ABS_NC
, /* type */
691 2, /* size (0 = byte, 1 = short, 2 = long) */
693 FALSE
, /* pc_relative */
695 complain_overflow_dont
,/* complain_on_overflow */
696 bfd_elf_generic_reloc
, /* special_function */
697 "R_ARM_MOVW_ABS_NC", /* name */
698 FALSE
, /* partial_inplace */
699 0x000f0fff, /* src_mask */
700 0x000f0fff, /* dst_mask */
701 FALSE
), /* pcrel_offset */
703 HOWTO (R_ARM_MOVT_ABS
, /* type */
705 2, /* size (0 = byte, 1 = short, 2 = long) */
707 FALSE
, /* pc_relative */
709 complain_overflow_bitfield
,/* complain_on_overflow */
710 bfd_elf_generic_reloc
, /* special_function */
711 "R_ARM_MOVT_ABS", /* name */
712 FALSE
, /* partial_inplace */
713 0x000f0fff, /* src_mask */
714 0x000f0fff, /* dst_mask */
715 FALSE
), /* pcrel_offset */
717 HOWTO (R_ARM_MOVW_PREL_NC
, /* type */
719 2, /* size (0 = byte, 1 = short, 2 = long) */
721 TRUE
, /* pc_relative */
723 complain_overflow_dont
,/* complain_on_overflow */
724 bfd_elf_generic_reloc
, /* special_function */
725 "R_ARM_MOVW_PREL_NC", /* name */
726 FALSE
, /* partial_inplace */
727 0x000f0fff, /* src_mask */
728 0x000f0fff, /* dst_mask */
729 TRUE
), /* pcrel_offset */
731 HOWTO (R_ARM_MOVT_PREL
, /* type */
733 2, /* size (0 = byte, 1 = short, 2 = long) */
735 TRUE
, /* pc_relative */
737 complain_overflow_bitfield
,/* complain_on_overflow */
738 bfd_elf_generic_reloc
, /* special_function */
739 "R_ARM_MOVT_PREL", /* name */
740 FALSE
, /* partial_inplace */
741 0x000f0fff, /* src_mask */
742 0x000f0fff, /* dst_mask */
743 TRUE
), /* pcrel_offset */
745 HOWTO (R_ARM_THM_MOVW_ABS_NC
, /* type */
747 2, /* size (0 = byte, 1 = short, 2 = long) */
749 FALSE
, /* pc_relative */
751 complain_overflow_dont
,/* complain_on_overflow */
752 bfd_elf_generic_reloc
, /* special_function */
753 "R_ARM_THM_MOVW_ABS_NC",/* name */
754 FALSE
, /* partial_inplace */
755 0x040f70ff, /* src_mask */
756 0x040f70ff, /* dst_mask */
757 FALSE
), /* pcrel_offset */
759 HOWTO (R_ARM_THM_MOVT_ABS
, /* type */
761 2, /* size (0 = byte, 1 = short, 2 = long) */
763 FALSE
, /* pc_relative */
765 complain_overflow_bitfield
,/* complain_on_overflow */
766 bfd_elf_generic_reloc
, /* special_function */
767 "R_ARM_THM_MOVT_ABS", /* name */
768 FALSE
, /* partial_inplace */
769 0x040f70ff, /* src_mask */
770 0x040f70ff, /* dst_mask */
771 FALSE
), /* pcrel_offset */
773 HOWTO (R_ARM_THM_MOVW_PREL_NC
,/* type */
775 2, /* size (0 = byte, 1 = short, 2 = long) */
777 TRUE
, /* pc_relative */
779 complain_overflow_dont
,/* complain_on_overflow */
780 bfd_elf_generic_reloc
, /* special_function */
781 "R_ARM_THM_MOVW_PREL_NC",/* name */
782 FALSE
, /* partial_inplace */
783 0x040f70ff, /* src_mask */
784 0x040f70ff, /* dst_mask */
785 TRUE
), /* pcrel_offset */
787 HOWTO (R_ARM_THM_MOVT_PREL
, /* type */
789 2, /* size (0 = byte, 1 = short, 2 = long) */
791 TRUE
, /* pc_relative */
793 complain_overflow_bitfield
,/* complain_on_overflow */
794 bfd_elf_generic_reloc
, /* special_function */
795 "R_ARM_THM_MOVT_PREL", /* name */
796 FALSE
, /* partial_inplace */
797 0x040f70ff, /* src_mask */
798 0x040f70ff, /* dst_mask */
799 TRUE
), /* pcrel_offset */
801 HOWTO (R_ARM_THM_JUMP19
, /* type */
803 2, /* size (0 = byte, 1 = short, 2 = long) */
805 TRUE
, /* pc_relative */
807 complain_overflow_signed
,/* complain_on_overflow */
808 bfd_elf_generic_reloc
, /* special_function */
809 "R_ARM_THM_JUMP19", /* name */
810 FALSE
, /* partial_inplace */
811 0x043f2fff, /* src_mask */
812 0x043f2fff, /* dst_mask */
813 TRUE
), /* pcrel_offset */
815 HOWTO (R_ARM_THM_JUMP6
, /* type */
817 1, /* size (0 = byte, 1 = short, 2 = long) */
819 TRUE
, /* pc_relative */
821 complain_overflow_unsigned
,/* complain_on_overflow */
822 bfd_elf_generic_reloc
, /* special_function */
823 "R_ARM_THM_JUMP6", /* name */
824 FALSE
, /* partial_inplace */
825 0x02f8, /* src_mask */
826 0x02f8, /* dst_mask */
827 TRUE
), /* pcrel_offset */
829 /* These are declared as 13-bit signed relocations because we can
830 address -4095 .. 4095(base) by altering ADDW to SUBW or vice
832 HOWTO (R_ARM_THM_ALU_PREL_11_0
,/* type */
834 2, /* size (0 = byte, 1 = short, 2 = long) */
836 TRUE
, /* pc_relative */
838 complain_overflow_dont
,/* complain_on_overflow */
839 bfd_elf_generic_reloc
, /* special_function */
840 "R_ARM_THM_ALU_PREL_11_0",/* name */
841 FALSE
, /* partial_inplace */
842 0xffffffff, /* src_mask */
843 0xffffffff, /* dst_mask */
844 TRUE
), /* pcrel_offset */
846 HOWTO (R_ARM_THM_PC12
, /* type */
848 2, /* size (0 = byte, 1 = short, 2 = long) */
850 TRUE
, /* pc_relative */
852 complain_overflow_dont
,/* complain_on_overflow */
853 bfd_elf_generic_reloc
, /* special_function */
854 "R_ARM_THM_PC12", /* name */
855 FALSE
, /* partial_inplace */
856 0xffffffff, /* src_mask */
857 0xffffffff, /* dst_mask */
858 TRUE
), /* pcrel_offset */
860 HOWTO (R_ARM_ABS32_NOI
, /* type */
862 2, /* size (0 = byte, 1 = short, 2 = long) */
864 FALSE
, /* pc_relative */
866 complain_overflow_dont
,/* complain_on_overflow */
867 bfd_elf_generic_reloc
, /* special_function */
868 "R_ARM_ABS32_NOI", /* name */
869 FALSE
, /* partial_inplace */
870 0xffffffff, /* src_mask */
871 0xffffffff, /* dst_mask */
872 FALSE
), /* pcrel_offset */
874 HOWTO (R_ARM_REL32_NOI
, /* type */
876 2, /* size (0 = byte, 1 = short, 2 = long) */
878 TRUE
, /* pc_relative */
880 complain_overflow_dont
,/* complain_on_overflow */
881 bfd_elf_generic_reloc
, /* special_function */
882 "R_ARM_REL32_NOI", /* name */
883 FALSE
, /* partial_inplace */
884 0xffffffff, /* src_mask */
885 0xffffffff, /* dst_mask */
886 FALSE
), /* pcrel_offset */
888 /* Group relocations. */
890 HOWTO (R_ARM_ALU_PC_G0_NC
, /* type */
892 2, /* size (0 = byte, 1 = short, 2 = long) */
894 TRUE
, /* pc_relative */
896 complain_overflow_dont
,/* complain_on_overflow */
897 bfd_elf_generic_reloc
, /* special_function */
898 "R_ARM_ALU_PC_G0_NC", /* name */
899 FALSE
, /* partial_inplace */
900 0xffffffff, /* src_mask */
901 0xffffffff, /* dst_mask */
902 TRUE
), /* pcrel_offset */
904 HOWTO (R_ARM_ALU_PC_G0
, /* type */
906 2, /* size (0 = byte, 1 = short, 2 = long) */
908 TRUE
, /* pc_relative */
910 complain_overflow_dont
,/* complain_on_overflow */
911 bfd_elf_generic_reloc
, /* special_function */
912 "R_ARM_ALU_PC_G0", /* name */
913 FALSE
, /* partial_inplace */
914 0xffffffff, /* src_mask */
915 0xffffffff, /* dst_mask */
916 TRUE
), /* pcrel_offset */
918 HOWTO (R_ARM_ALU_PC_G1_NC
, /* type */
920 2, /* size (0 = byte, 1 = short, 2 = long) */
922 TRUE
, /* pc_relative */
924 complain_overflow_dont
,/* complain_on_overflow */
925 bfd_elf_generic_reloc
, /* special_function */
926 "R_ARM_ALU_PC_G1_NC", /* name */
927 FALSE
, /* partial_inplace */
928 0xffffffff, /* src_mask */
929 0xffffffff, /* dst_mask */
930 TRUE
), /* pcrel_offset */
932 HOWTO (R_ARM_ALU_PC_G1
, /* type */
934 2, /* size (0 = byte, 1 = short, 2 = long) */
936 TRUE
, /* pc_relative */
938 complain_overflow_dont
,/* complain_on_overflow */
939 bfd_elf_generic_reloc
, /* special_function */
940 "R_ARM_ALU_PC_G1", /* name */
941 FALSE
, /* partial_inplace */
942 0xffffffff, /* src_mask */
943 0xffffffff, /* dst_mask */
944 TRUE
), /* pcrel_offset */
946 HOWTO (R_ARM_ALU_PC_G2
, /* type */
948 2, /* size (0 = byte, 1 = short, 2 = long) */
950 TRUE
, /* pc_relative */
952 complain_overflow_dont
,/* complain_on_overflow */
953 bfd_elf_generic_reloc
, /* special_function */
954 "R_ARM_ALU_PC_G2", /* name */
955 FALSE
, /* partial_inplace */
956 0xffffffff, /* src_mask */
957 0xffffffff, /* dst_mask */
958 TRUE
), /* pcrel_offset */
960 HOWTO (R_ARM_LDR_PC_G1
, /* type */
962 2, /* size (0 = byte, 1 = short, 2 = long) */
964 TRUE
, /* pc_relative */
966 complain_overflow_dont
,/* complain_on_overflow */
967 bfd_elf_generic_reloc
, /* special_function */
968 "R_ARM_LDR_PC_G1", /* name */
969 FALSE
, /* partial_inplace */
970 0xffffffff, /* src_mask */
971 0xffffffff, /* dst_mask */
972 TRUE
), /* pcrel_offset */
974 HOWTO (R_ARM_LDR_PC_G2
, /* type */
976 2, /* size (0 = byte, 1 = short, 2 = long) */
978 TRUE
, /* pc_relative */
980 complain_overflow_dont
,/* complain_on_overflow */
981 bfd_elf_generic_reloc
, /* special_function */
982 "R_ARM_LDR_PC_G2", /* name */
983 FALSE
, /* partial_inplace */
984 0xffffffff, /* src_mask */
985 0xffffffff, /* dst_mask */
986 TRUE
), /* pcrel_offset */
988 HOWTO (R_ARM_LDRS_PC_G0
, /* type */
990 2, /* size (0 = byte, 1 = short, 2 = long) */
992 TRUE
, /* pc_relative */
994 complain_overflow_dont
,/* complain_on_overflow */
995 bfd_elf_generic_reloc
, /* special_function */
996 "R_ARM_LDRS_PC_G0", /* name */
997 FALSE
, /* partial_inplace */
998 0xffffffff, /* src_mask */
999 0xffffffff, /* dst_mask */
1000 TRUE
), /* pcrel_offset */
1002 HOWTO (R_ARM_LDRS_PC_G1
, /* type */
1004 2, /* size (0 = byte, 1 = short, 2 = long) */
1006 TRUE
, /* pc_relative */
1008 complain_overflow_dont
,/* complain_on_overflow */
1009 bfd_elf_generic_reloc
, /* special_function */
1010 "R_ARM_LDRS_PC_G1", /* name */
1011 FALSE
, /* partial_inplace */
1012 0xffffffff, /* src_mask */
1013 0xffffffff, /* dst_mask */
1014 TRUE
), /* pcrel_offset */
1016 HOWTO (R_ARM_LDRS_PC_G2
, /* type */
1018 2, /* size (0 = byte, 1 = short, 2 = long) */
1020 TRUE
, /* pc_relative */
1022 complain_overflow_dont
,/* complain_on_overflow */
1023 bfd_elf_generic_reloc
, /* special_function */
1024 "R_ARM_LDRS_PC_G2", /* name */
1025 FALSE
, /* partial_inplace */
1026 0xffffffff, /* src_mask */
1027 0xffffffff, /* dst_mask */
1028 TRUE
), /* pcrel_offset */
1030 HOWTO (R_ARM_LDC_PC_G0
, /* type */
1032 2, /* size (0 = byte, 1 = short, 2 = long) */
1034 TRUE
, /* pc_relative */
1036 complain_overflow_dont
,/* complain_on_overflow */
1037 bfd_elf_generic_reloc
, /* special_function */
1038 "R_ARM_LDC_PC_G0", /* name */
1039 FALSE
, /* partial_inplace */
1040 0xffffffff, /* src_mask */
1041 0xffffffff, /* dst_mask */
1042 TRUE
), /* pcrel_offset */
1044 HOWTO (R_ARM_LDC_PC_G1
, /* type */
1046 2, /* size (0 = byte, 1 = short, 2 = long) */
1048 TRUE
, /* pc_relative */
1050 complain_overflow_dont
,/* complain_on_overflow */
1051 bfd_elf_generic_reloc
, /* special_function */
1052 "R_ARM_LDC_PC_G1", /* name */
1053 FALSE
, /* partial_inplace */
1054 0xffffffff, /* src_mask */
1055 0xffffffff, /* dst_mask */
1056 TRUE
), /* pcrel_offset */
1058 HOWTO (R_ARM_LDC_PC_G2
, /* type */
1060 2, /* size (0 = byte, 1 = short, 2 = long) */
1062 TRUE
, /* pc_relative */
1064 complain_overflow_dont
,/* complain_on_overflow */
1065 bfd_elf_generic_reloc
, /* special_function */
1066 "R_ARM_LDC_PC_G2", /* name */
1067 FALSE
, /* partial_inplace */
1068 0xffffffff, /* src_mask */
1069 0xffffffff, /* dst_mask */
1070 TRUE
), /* pcrel_offset */
1072 HOWTO (R_ARM_ALU_SB_G0_NC
, /* type */
1074 2, /* size (0 = byte, 1 = short, 2 = long) */
1076 TRUE
, /* pc_relative */
1078 complain_overflow_dont
,/* complain_on_overflow */
1079 bfd_elf_generic_reloc
, /* special_function */
1080 "R_ARM_ALU_SB_G0_NC", /* name */
1081 FALSE
, /* partial_inplace */
1082 0xffffffff, /* src_mask */
1083 0xffffffff, /* dst_mask */
1084 TRUE
), /* pcrel_offset */
1086 HOWTO (R_ARM_ALU_SB_G0
, /* type */
1088 2, /* size (0 = byte, 1 = short, 2 = long) */
1090 TRUE
, /* pc_relative */
1092 complain_overflow_dont
,/* complain_on_overflow */
1093 bfd_elf_generic_reloc
, /* special_function */
1094 "R_ARM_ALU_SB_G0", /* name */
1095 FALSE
, /* partial_inplace */
1096 0xffffffff, /* src_mask */
1097 0xffffffff, /* dst_mask */
1098 TRUE
), /* pcrel_offset */
1100 HOWTO (R_ARM_ALU_SB_G1_NC
, /* type */
1102 2, /* size (0 = byte, 1 = short, 2 = long) */
1104 TRUE
, /* pc_relative */
1106 complain_overflow_dont
,/* complain_on_overflow */
1107 bfd_elf_generic_reloc
, /* special_function */
1108 "R_ARM_ALU_SB_G1_NC", /* name */
1109 FALSE
, /* partial_inplace */
1110 0xffffffff, /* src_mask */
1111 0xffffffff, /* dst_mask */
1112 TRUE
), /* pcrel_offset */
1114 HOWTO (R_ARM_ALU_SB_G1
, /* type */
1116 2, /* size (0 = byte, 1 = short, 2 = long) */
1118 TRUE
, /* pc_relative */
1120 complain_overflow_dont
,/* complain_on_overflow */
1121 bfd_elf_generic_reloc
, /* special_function */
1122 "R_ARM_ALU_SB_G1", /* name */
1123 FALSE
, /* partial_inplace */
1124 0xffffffff, /* src_mask */
1125 0xffffffff, /* dst_mask */
1126 TRUE
), /* pcrel_offset */
1128 HOWTO (R_ARM_ALU_SB_G2
, /* type */
1130 2, /* size (0 = byte, 1 = short, 2 = long) */
1132 TRUE
, /* pc_relative */
1134 complain_overflow_dont
,/* complain_on_overflow */
1135 bfd_elf_generic_reloc
, /* special_function */
1136 "R_ARM_ALU_SB_G2", /* name */
1137 FALSE
, /* partial_inplace */
1138 0xffffffff, /* src_mask */
1139 0xffffffff, /* dst_mask */
1140 TRUE
), /* pcrel_offset */
1142 HOWTO (R_ARM_LDR_SB_G0
, /* type */
1144 2, /* size (0 = byte, 1 = short, 2 = long) */
1146 TRUE
, /* pc_relative */
1148 complain_overflow_dont
,/* complain_on_overflow */
1149 bfd_elf_generic_reloc
, /* special_function */
1150 "R_ARM_LDR_SB_G0", /* name */
1151 FALSE
, /* partial_inplace */
1152 0xffffffff, /* src_mask */
1153 0xffffffff, /* dst_mask */
1154 TRUE
), /* pcrel_offset */
1156 HOWTO (R_ARM_LDR_SB_G1
, /* type */
1158 2, /* size (0 = byte, 1 = short, 2 = long) */
1160 TRUE
, /* pc_relative */
1162 complain_overflow_dont
,/* complain_on_overflow */
1163 bfd_elf_generic_reloc
, /* special_function */
1164 "R_ARM_LDR_SB_G1", /* name */
1165 FALSE
, /* partial_inplace */
1166 0xffffffff, /* src_mask */
1167 0xffffffff, /* dst_mask */
1168 TRUE
), /* pcrel_offset */
1170 HOWTO (R_ARM_LDR_SB_G2
, /* type */
1172 2, /* size (0 = byte, 1 = short, 2 = long) */
1174 TRUE
, /* pc_relative */
1176 complain_overflow_dont
,/* complain_on_overflow */
1177 bfd_elf_generic_reloc
, /* special_function */
1178 "R_ARM_LDR_SB_G2", /* name */
1179 FALSE
, /* partial_inplace */
1180 0xffffffff, /* src_mask */
1181 0xffffffff, /* dst_mask */
1182 TRUE
), /* pcrel_offset */
1184 HOWTO (R_ARM_LDRS_SB_G0
, /* type */
1186 2, /* size (0 = byte, 1 = short, 2 = long) */
1188 TRUE
, /* pc_relative */
1190 complain_overflow_dont
,/* complain_on_overflow */
1191 bfd_elf_generic_reloc
, /* special_function */
1192 "R_ARM_LDRS_SB_G0", /* name */
1193 FALSE
, /* partial_inplace */
1194 0xffffffff, /* src_mask */
1195 0xffffffff, /* dst_mask */
1196 TRUE
), /* pcrel_offset */
1198 HOWTO (R_ARM_LDRS_SB_G1
, /* type */
1200 2, /* size (0 = byte, 1 = short, 2 = long) */
1202 TRUE
, /* pc_relative */
1204 complain_overflow_dont
,/* complain_on_overflow */
1205 bfd_elf_generic_reloc
, /* special_function */
1206 "R_ARM_LDRS_SB_G1", /* name */
1207 FALSE
, /* partial_inplace */
1208 0xffffffff, /* src_mask */
1209 0xffffffff, /* dst_mask */
1210 TRUE
), /* pcrel_offset */
1212 HOWTO (R_ARM_LDRS_SB_G2
, /* type */
1214 2, /* size (0 = byte, 1 = short, 2 = long) */
1216 TRUE
, /* pc_relative */
1218 complain_overflow_dont
,/* complain_on_overflow */
1219 bfd_elf_generic_reloc
, /* special_function */
1220 "R_ARM_LDRS_SB_G2", /* name */
1221 FALSE
, /* partial_inplace */
1222 0xffffffff, /* src_mask */
1223 0xffffffff, /* dst_mask */
1224 TRUE
), /* pcrel_offset */
1226 HOWTO (R_ARM_LDC_SB_G0
, /* type */
1228 2, /* size (0 = byte, 1 = short, 2 = long) */
1230 TRUE
, /* pc_relative */
1232 complain_overflow_dont
,/* complain_on_overflow */
1233 bfd_elf_generic_reloc
, /* special_function */
1234 "R_ARM_LDC_SB_G0", /* name */
1235 FALSE
, /* partial_inplace */
1236 0xffffffff, /* src_mask */
1237 0xffffffff, /* dst_mask */
1238 TRUE
), /* pcrel_offset */
1240 HOWTO (R_ARM_LDC_SB_G1
, /* type */
1242 2, /* size (0 = byte, 1 = short, 2 = long) */
1244 TRUE
, /* pc_relative */
1246 complain_overflow_dont
,/* complain_on_overflow */
1247 bfd_elf_generic_reloc
, /* special_function */
1248 "R_ARM_LDC_SB_G1", /* name */
1249 FALSE
, /* partial_inplace */
1250 0xffffffff, /* src_mask */
1251 0xffffffff, /* dst_mask */
1252 TRUE
), /* pcrel_offset */
1254 HOWTO (R_ARM_LDC_SB_G2
, /* type */
1256 2, /* size (0 = byte, 1 = short, 2 = long) */
1258 TRUE
, /* pc_relative */
1260 complain_overflow_dont
,/* complain_on_overflow */
1261 bfd_elf_generic_reloc
, /* special_function */
1262 "R_ARM_LDC_SB_G2", /* name */
1263 FALSE
, /* partial_inplace */
1264 0xffffffff, /* src_mask */
1265 0xffffffff, /* dst_mask */
1266 TRUE
), /* pcrel_offset */
1268 /* End of group relocations. */
1270 HOWTO (R_ARM_MOVW_BREL_NC
, /* type */
1272 2, /* size (0 = byte, 1 = short, 2 = long) */
1274 FALSE
, /* pc_relative */
1276 complain_overflow_dont
,/* complain_on_overflow */
1277 bfd_elf_generic_reloc
, /* special_function */
1278 "R_ARM_MOVW_BREL_NC", /* name */
1279 FALSE
, /* partial_inplace */
1280 0x0000ffff, /* src_mask */
1281 0x0000ffff, /* dst_mask */
1282 FALSE
), /* pcrel_offset */
1284 HOWTO (R_ARM_MOVT_BREL
, /* type */
1286 2, /* size (0 = byte, 1 = short, 2 = long) */
1288 FALSE
, /* pc_relative */
1290 complain_overflow_bitfield
,/* complain_on_overflow */
1291 bfd_elf_generic_reloc
, /* special_function */
1292 "R_ARM_MOVT_BREL", /* name */
1293 FALSE
, /* partial_inplace */
1294 0x0000ffff, /* src_mask */
1295 0x0000ffff, /* dst_mask */
1296 FALSE
), /* pcrel_offset */
1298 HOWTO (R_ARM_MOVW_BREL
, /* type */
1300 2, /* size (0 = byte, 1 = short, 2 = long) */
1302 FALSE
, /* pc_relative */
1304 complain_overflow_dont
,/* complain_on_overflow */
1305 bfd_elf_generic_reloc
, /* special_function */
1306 "R_ARM_MOVW_BREL", /* name */
1307 FALSE
, /* partial_inplace */
1308 0x0000ffff, /* src_mask */
1309 0x0000ffff, /* dst_mask */
1310 FALSE
), /* pcrel_offset */
1312 HOWTO (R_ARM_THM_MOVW_BREL_NC
,/* type */
1314 2, /* size (0 = byte, 1 = short, 2 = long) */
1316 FALSE
, /* pc_relative */
1318 complain_overflow_dont
,/* complain_on_overflow */
1319 bfd_elf_generic_reloc
, /* special_function */
1320 "R_ARM_THM_MOVW_BREL_NC",/* name */
1321 FALSE
, /* partial_inplace */
1322 0x040f70ff, /* src_mask */
1323 0x040f70ff, /* dst_mask */
1324 FALSE
), /* pcrel_offset */
1326 HOWTO (R_ARM_THM_MOVT_BREL
, /* type */
1328 2, /* size (0 = byte, 1 = short, 2 = long) */
1330 FALSE
, /* pc_relative */
1332 complain_overflow_bitfield
,/* complain_on_overflow */
1333 bfd_elf_generic_reloc
, /* special_function */
1334 "R_ARM_THM_MOVT_BREL", /* name */
1335 FALSE
, /* partial_inplace */
1336 0x040f70ff, /* src_mask */
1337 0x040f70ff, /* dst_mask */
1338 FALSE
), /* pcrel_offset */
1340 HOWTO (R_ARM_THM_MOVW_BREL
, /* type */
1342 2, /* size (0 = byte, 1 = short, 2 = long) */
1344 FALSE
, /* pc_relative */
1346 complain_overflow_dont
,/* complain_on_overflow */
1347 bfd_elf_generic_reloc
, /* special_function */
1348 "R_ARM_THM_MOVW_BREL", /* name */
1349 FALSE
, /* partial_inplace */
1350 0x040f70ff, /* src_mask */
1351 0x040f70ff, /* dst_mask */
1352 FALSE
), /* pcrel_offset */
1354 EMPTY_HOWTO (90), /* unallocated */
1359 HOWTO (R_ARM_PLT32_ABS
, /* type */
1361 2, /* size (0 = byte, 1 = short, 2 = long) */
1363 FALSE
, /* pc_relative */
1365 complain_overflow_dont
,/* complain_on_overflow */
1366 bfd_elf_generic_reloc
, /* special_function */
1367 "R_ARM_PLT32_ABS", /* name */
1368 FALSE
, /* partial_inplace */
1369 0xffffffff, /* src_mask */
1370 0xffffffff, /* dst_mask */
1371 FALSE
), /* pcrel_offset */
1373 HOWTO (R_ARM_GOT_ABS
, /* type */
1375 2, /* size (0 = byte, 1 = short, 2 = long) */
1377 FALSE
, /* pc_relative */
1379 complain_overflow_dont
,/* complain_on_overflow */
1380 bfd_elf_generic_reloc
, /* special_function */
1381 "R_ARM_GOT_ABS", /* name */
1382 FALSE
, /* partial_inplace */
1383 0xffffffff, /* src_mask */
1384 0xffffffff, /* dst_mask */
1385 FALSE
), /* pcrel_offset */
1387 HOWTO (R_ARM_GOT_PREL
, /* type */
1389 2, /* size (0 = byte, 1 = short, 2 = long) */
1391 TRUE
, /* pc_relative */
1393 complain_overflow_dont
, /* complain_on_overflow */
1394 bfd_elf_generic_reloc
, /* special_function */
1395 "R_ARM_GOT_PREL", /* name */
1396 FALSE
, /* partial_inplace */
1397 0xffffffff, /* src_mask */
1398 0xffffffff, /* dst_mask */
1399 TRUE
), /* pcrel_offset */
1401 HOWTO (R_ARM_GOT_BREL12
, /* type */
1403 2, /* size (0 = byte, 1 = short, 2 = long) */
1405 FALSE
, /* pc_relative */
1407 complain_overflow_bitfield
,/* complain_on_overflow */
1408 bfd_elf_generic_reloc
, /* special_function */
1409 "R_ARM_GOT_BREL12", /* name */
1410 FALSE
, /* partial_inplace */
1411 0x00000fff, /* src_mask */
1412 0x00000fff, /* dst_mask */
1413 FALSE
), /* pcrel_offset */
1415 HOWTO (R_ARM_GOTOFF12
, /* type */
1417 2, /* size (0 = byte, 1 = short, 2 = long) */
1419 FALSE
, /* pc_relative */
1421 complain_overflow_bitfield
,/* complain_on_overflow */
1422 bfd_elf_generic_reloc
, /* special_function */
1423 "R_ARM_GOTOFF12", /* name */
1424 FALSE
, /* partial_inplace */
1425 0x00000fff, /* src_mask */
1426 0x00000fff, /* dst_mask */
1427 FALSE
), /* pcrel_offset */
1429 EMPTY_HOWTO (R_ARM_GOTRELAX
), /* reserved for future GOT-load optimizations */
1431 /* GNU extension to record C++ vtable member usage */
1432 HOWTO (R_ARM_GNU_VTENTRY
, /* type */
1434 2, /* size (0 = byte, 1 = short, 2 = long) */
1436 FALSE
, /* pc_relative */
1438 complain_overflow_dont
, /* complain_on_overflow */
1439 _bfd_elf_rel_vtable_reloc_fn
, /* special_function */
1440 "R_ARM_GNU_VTENTRY", /* name */
1441 FALSE
, /* partial_inplace */
1444 FALSE
), /* pcrel_offset */
1446 /* GNU extension to record C++ vtable hierarchy */
1447 HOWTO (R_ARM_GNU_VTINHERIT
, /* type */
1449 2, /* size (0 = byte, 1 = short, 2 = long) */
1451 FALSE
, /* pc_relative */
1453 complain_overflow_dont
, /* complain_on_overflow */
1454 NULL
, /* special_function */
1455 "R_ARM_GNU_VTINHERIT", /* name */
1456 FALSE
, /* partial_inplace */
1459 FALSE
), /* pcrel_offset */
1461 HOWTO (R_ARM_THM_JUMP11
, /* type */
1463 1, /* size (0 = byte, 1 = short, 2 = long) */
1465 TRUE
, /* pc_relative */
1467 complain_overflow_signed
, /* complain_on_overflow */
1468 bfd_elf_generic_reloc
, /* special_function */
1469 "R_ARM_THM_JUMP11", /* name */
1470 FALSE
, /* partial_inplace */
1471 0x000007ff, /* src_mask */
1472 0x000007ff, /* dst_mask */
1473 TRUE
), /* pcrel_offset */
1475 HOWTO (R_ARM_THM_JUMP8
, /* type */
1477 1, /* size (0 = byte, 1 = short, 2 = long) */
1479 TRUE
, /* pc_relative */
1481 complain_overflow_signed
, /* complain_on_overflow */
1482 bfd_elf_generic_reloc
, /* special_function */
1483 "R_ARM_THM_JUMP8", /* name */
1484 FALSE
, /* partial_inplace */
1485 0x000000ff, /* src_mask */
1486 0x000000ff, /* dst_mask */
1487 TRUE
), /* pcrel_offset */
1489 /* TLS relocations */
1490 HOWTO (R_ARM_TLS_GD32
, /* type */
1492 2, /* size (0 = byte, 1 = short, 2 = long) */
1494 FALSE
, /* pc_relative */
1496 complain_overflow_bitfield
,/* complain_on_overflow */
1497 NULL
, /* special_function */
1498 "R_ARM_TLS_GD32", /* name */
1499 TRUE
, /* partial_inplace */
1500 0xffffffff, /* src_mask */
1501 0xffffffff, /* dst_mask */
1502 FALSE
), /* pcrel_offset */
1504 HOWTO (R_ARM_TLS_LDM32
, /* type */
1506 2, /* size (0 = byte, 1 = short, 2 = long) */
1508 FALSE
, /* pc_relative */
1510 complain_overflow_bitfield
,/* complain_on_overflow */
1511 bfd_elf_generic_reloc
, /* special_function */
1512 "R_ARM_TLS_LDM32", /* name */
1513 TRUE
, /* partial_inplace */
1514 0xffffffff, /* src_mask */
1515 0xffffffff, /* dst_mask */
1516 FALSE
), /* pcrel_offset */
1518 HOWTO (R_ARM_TLS_LDO32
, /* type */
1520 2, /* size (0 = byte, 1 = short, 2 = long) */
1522 FALSE
, /* pc_relative */
1524 complain_overflow_bitfield
,/* complain_on_overflow */
1525 bfd_elf_generic_reloc
, /* special_function */
1526 "R_ARM_TLS_LDO32", /* name */
1527 TRUE
, /* partial_inplace */
1528 0xffffffff, /* src_mask */
1529 0xffffffff, /* dst_mask */
1530 FALSE
), /* pcrel_offset */
1532 HOWTO (R_ARM_TLS_IE32
, /* type */
1534 2, /* size (0 = byte, 1 = short, 2 = long) */
1536 FALSE
, /* pc_relative */
1538 complain_overflow_bitfield
,/* complain_on_overflow */
1539 NULL
, /* special_function */
1540 "R_ARM_TLS_IE32", /* name */
1541 TRUE
, /* partial_inplace */
1542 0xffffffff, /* src_mask */
1543 0xffffffff, /* dst_mask */
1544 FALSE
), /* pcrel_offset */
1546 HOWTO (R_ARM_TLS_LE32
, /* type */
1548 2, /* size (0 = byte, 1 = short, 2 = long) */
1550 FALSE
, /* pc_relative */
1552 complain_overflow_bitfield
,/* complain_on_overflow */
1553 bfd_elf_generic_reloc
, /* special_function */
1554 "R_ARM_TLS_LE32", /* name */
1555 TRUE
, /* partial_inplace */
1556 0xffffffff, /* src_mask */
1557 0xffffffff, /* dst_mask */
1558 FALSE
), /* pcrel_offset */
1560 HOWTO (R_ARM_TLS_LDO12
, /* type */
1562 2, /* size (0 = byte, 1 = short, 2 = long) */
1564 FALSE
, /* pc_relative */
1566 complain_overflow_bitfield
,/* complain_on_overflow */
1567 bfd_elf_generic_reloc
, /* special_function */
1568 "R_ARM_TLS_LDO12", /* name */
1569 FALSE
, /* partial_inplace */
1570 0x00000fff, /* src_mask */
1571 0x00000fff, /* dst_mask */
1572 FALSE
), /* pcrel_offset */
1574 HOWTO (R_ARM_TLS_LE12
, /* type */
1576 2, /* size (0 = byte, 1 = short, 2 = long) */
1578 FALSE
, /* pc_relative */
1580 complain_overflow_bitfield
,/* complain_on_overflow */
1581 bfd_elf_generic_reloc
, /* special_function */
1582 "R_ARM_TLS_LE12", /* name */
1583 FALSE
, /* partial_inplace */
1584 0x00000fff, /* src_mask */
1585 0x00000fff, /* dst_mask */
1586 FALSE
), /* pcrel_offset */
1588 HOWTO (R_ARM_TLS_IE12GP
, /* type */
1590 2, /* size (0 = byte, 1 = short, 2 = long) */
1592 FALSE
, /* pc_relative */
1594 complain_overflow_bitfield
,/* complain_on_overflow */
1595 bfd_elf_generic_reloc
, /* special_function */
1596 "R_ARM_TLS_IE12GP", /* name */
1597 FALSE
, /* partial_inplace */
1598 0x00000fff, /* src_mask */
1599 0x00000fff, /* dst_mask */
1600 FALSE
), /* pcrel_offset */
1603 /* 112-127 private relocations
1604 128 R_ARM_ME_TOO, obsolete
1605 129-255 unallocated in AAELF.
1607 249-255 extended, currently unused, relocations: */
1609 static reloc_howto_type elf32_arm_howto_table_2
[4] =
1611 HOWTO (R_ARM_RREL32
, /* type */
1613 0, /* size (0 = byte, 1 = short, 2 = long) */
1615 FALSE
, /* pc_relative */
1617 complain_overflow_dont
,/* complain_on_overflow */
1618 bfd_elf_generic_reloc
, /* special_function */
1619 "R_ARM_RREL32", /* name */
1620 FALSE
, /* partial_inplace */
1623 FALSE
), /* pcrel_offset */
1625 HOWTO (R_ARM_RABS32
, /* type */
1627 0, /* size (0 = byte, 1 = short, 2 = long) */
1629 FALSE
, /* pc_relative */
1631 complain_overflow_dont
,/* complain_on_overflow */
1632 bfd_elf_generic_reloc
, /* special_function */
1633 "R_ARM_RABS32", /* name */
1634 FALSE
, /* partial_inplace */
1637 FALSE
), /* pcrel_offset */
1639 HOWTO (R_ARM_RPC24
, /* type */
1641 0, /* size (0 = byte, 1 = short, 2 = long) */
1643 FALSE
, /* pc_relative */
1645 complain_overflow_dont
,/* complain_on_overflow */
1646 bfd_elf_generic_reloc
, /* special_function */
1647 "R_ARM_RPC24", /* name */
1648 FALSE
, /* partial_inplace */
1651 FALSE
), /* pcrel_offset */
1653 HOWTO (R_ARM_RBASE
, /* type */
1655 0, /* size (0 = byte, 1 = short, 2 = long) */
1657 FALSE
, /* pc_relative */
1659 complain_overflow_dont
,/* complain_on_overflow */
1660 bfd_elf_generic_reloc
, /* special_function */
1661 "R_ARM_RBASE", /* name */
1662 FALSE
, /* partial_inplace */
1665 FALSE
) /* pcrel_offset */
1668 static reloc_howto_type
*
1669 elf32_arm_howto_from_type (unsigned int r_type
)
1671 if (r_type
< NUM_ELEM (elf32_arm_howto_table_1
))
1672 return &elf32_arm_howto_table_1
[r_type
];
1674 if (r_type
>= R_ARM_RREL32
1675 && r_type
< R_ARM_RREL32
+ NUM_ELEM (elf32_arm_howto_table_2
))
1676 return &elf32_arm_howto_table_2
[r_type
- R_ARM_RREL32
];
1682 elf32_arm_info_to_howto (bfd
* abfd ATTRIBUTE_UNUSED
, arelent
* bfd_reloc
,
1683 Elf_Internal_Rela
* elf_reloc
)
1685 unsigned int r_type
;
1687 r_type
= ELF32_R_TYPE (elf_reloc
->r_info
);
1688 bfd_reloc
->howto
= elf32_arm_howto_from_type (r_type
);
1691 struct elf32_arm_reloc_map
1693 bfd_reloc_code_real_type bfd_reloc_val
;
1694 unsigned char elf_reloc_val
;
1697 /* All entries in this list must also be present in elf32_arm_howto_table. */
1698 static const struct elf32_arm_reloc_map elf32_arm_reloc_map
[] =
1700 {BFD_RELOC_NONE
, R_ARM_NONE
},
1701 {BFD_RELOC_ARM_PCREL_BRANCH
, R_ARM_PC24
},
1702 {BFD_RELOC_ARM_PCREL_CALL
, R_ARM_CALL
},
1703 {BFD_RELOC_ARM_PCREL_JUMP
, R_ARM_JUMP24
},
1704 {BFD_RELOC_ARM_PCREL_BLX
, R_ARM_XPC25
},
1705 {BFD_RELOC_THUMB_PCREL_BLX
, R_ARM_THM_XPC22
},
1706 {BFD_RELOC_32
, R_ARM_ABS32
},
1707 {BFD_RELOC_32_PCREL
, R_ARM_REL32
},
1708 {BFD_RELOC_8
, R_ARM_ABS8
},
1709 {BFD_RELOC_16
, R_ARM_ABS16
},
1710 {BFD_RELOC_ARM_OFFSET_IMM
, R_ARM_ABS12
},
1711 {BFD_RELOC_ARM_THUMB_OFFSET
, R_ARM_THM_ABS5
},
1712 {BFD_RELOC_THUMB_PCREL_BRANCH25
, R_ARM_THM_JUMP24
},
1713 {BFD_RELOC_THUMB_PCREL_BRANCH23
, R_ARM_THM_CALL
},
1714 {BFD_RELOC_THUMB_PCREL_BRANCH12
, R_ARM_THM_JUMP11
},
1715 {BFD_RELOC_THUMB_PCREL_BRANCH20
, R_ARM_THM_JUMP19
},
1716 {BFD_RELOC_THUMB_PCREL_BRANCH9
, R_ARM_THM_JUMP8
},
1717 {BFD_RELOC_THUMB_PCREL_BRANCH7
, R_ARM_THM_JUMP6
},
1718 {BFD_RELOC_ARM_GLOB_DAT
, R_ARM_GLOB_DAT
},
1719 {BFD_RELOC_ARM_JUMP_SLOT
, R_ARM_JUMP_SLOT
},
1720 {BFD_RELOC_ARM_RELATIVE
, R_ARM_RELATIVE
},
1721 {BFD_RELOC_ARM_GOTOFF
, R_ARM_GOTOFF32
},
1722 {BFD_RELOC_ARM_GOTPC
, R_ARM_GOTPC
},
1723 {BFD_RELOC_ARM_GOT32
, R_ARM_GOT32
},
1724 {BFD_RELOC_ARM_PLT32
, R_ARM_PLT32
},
1725 {BFD_RELOC_ARM_TARGET1
, R_ARM_TARGET1
},
1726 {BFD_RELOC_ARM_ROSEGREL32
, R_ARM_ROSEGREL32
},
1727 {BFD_RELOC_ARM_SBREL32
, R_ARM_SBREL32
},
1728 {BFD_RELOC_ARM_PREL31
, R_ARM_PREL31
},
1729 {BFD_RELOC_ARM_TARGET2
, R_ARM_TARGET2
},
1730 {BFD_RELOC_ARM_PLT32
, R_ARM_PLT32
},
1731 {BFD_RELOC_ARM_TLS_GD32
, R_ARM_TLS_GD32
},
1732 {BFD_RELOC_ARM_TLS_LDO32
, R_ARM_TLS_LDO32
},
1733 {BFD_RELOC_ARM_TLS_LDM32
, R_ARM_TLS_LDM32
},
1734 {BFD_RELOC_ARM_TLS_DTPMOD32
, R_ARM_TLS_DTPMOD32
},
1735 {BFD_RELOC_ARM_TLS_DTPOFF32
, R_ARM_TLS_DTPOFF32
},
1736 {BFD_RELOC_ARM_TLS_TPOFF32
, R_ARM_TLS_TPOFF32
},
1737 {BFD_RELOC_ARM_TLS_IE32
, R_ARM_TLS_IE32
},
1738 {BFD_RELOC_ARM_TLS_LE32
, R_ARM_TLS_LE32
},
1739 {BFD_RELOC_VTABLE_INHERIT
, R_ARM_GNU_VTINHERIT
},
1740 {BFD_RELOC_VTABLE_ENTRY
, R_ARM_GNU_VTENTRY
},
1741 {BFD_RELOC_ARM_MOVW
, R_ARM_MOVW_ABS_NC
},
1742 {BFD_RELOC_ARM_MOVT
, R_ARM_MOVT_ABS
},
1743 {BFD_RELOC_ARM_MOVW_PCREL
, R_ARM_MOVW_PREL_NC
},
1744 {BFD_RELOC_ARM_MOVT_PCREL
, R_ARM_MOVT_PREL
},
1745 {BFD_RELOC_ARM_THUMB_MOVW
, R_ARM_THM_MOVW_ABS_NC
},
1746 {BFD_RELOC_ARM_THUMB_MOVT
, R_ARM_THM_MOVT_ABS
},
1747 {BFD_RELOC_ARM_THUMB_MOVW_PCREL
, R_ARM_THM_MOVW_PREL_NC
},
1748 {BFD_RELOC_ARM_THUMB_MOVT_PCREL
, R_ARM_THM_MOVT_PREL
},
1749 {BFD_RELOC_ARM_ALU_PC_G0_NC
, R_ARM_ALU_PC_G0_NC
},
1750 {BFD_RELOC_ARM_ALU_PC_G0
, R_ARM_ALU_PC_G0
},
1751 {BFD_RELOC_ARM_ALU_PC_G1_NC
, R_ARM_ALU_PC_G1_NC
},
1752 {BFD_RELOC_ARM_ALU_PC_G1
, R_ARM_ALU_PC_G1
},
1753 {BFD_RELOC_ARM_ALU_PC_G2
, R_ARM_ALU_PC_G2
},
1754 {BFD_RELOC_ARM_LDR_PC_G0
, R_ARM_LDR_PC_G0
},
1755 {BFD_RELOC_ARM_LDR_PC_G1
, R_ARM_LDR_PC_G1
},
1756 {BFD_RELOC_ARM_LDR_PC_G2
, R_ARM_LDR_PC_G2
},
1757 {BFD_RELOC_ARM_LDRS_PC_G0
, R_ARM_LDRS_PC_G0
},
1758 {BFD_RELOC_ARM_LDRS_PC_G1
, R_ARM_LDRS_PC_G1
},
1759 {BFD_RELOC_ARM_LDRS_PC_G2
, R_ARM_LDRS_PC_G2
},
1760 {BFD_RELOC_ARM_LDC_PC_G0
, R_ARM_LDC_PC_G0
},
1761 {BFD_RELOC_ARM_LDC_PC_G1
, R_ARM_LDC_PC_G1
},
1762 {BFD_RELOC_ARM_LDC_PC_G2
, R_ARM_LDC_PC_G2
},
1763 {BFD_RELOC_ARM_ALU_SB_G0_NC
, R_ARM_ALU_SB_G0_NC
},
1764 {BFD_RELOC_ARM_ALU_SB_G0
, R_ARM_ALU_SB_G0
},
1765 {BFD_RELOC_ARM_ALU_SB_G1_NC
, R_ARM_ALU_SB_G1_NC
},
1766 {BFD_RELOC_ARM_ALU_SB_G1
, R_ARM_ALU_SB_G1
},
1767 {BFD_RELOC_ARM_ALU_SB_G2
, R_ARM_ALU_SB_G2
},
1768 {BFD_RELOC_ARM_LDR_SB_G0
, R_ARM_LDR_SB_G0
},
1769 {BFD_RELOC_ARM_LDR_SB_G1
, R_ARM_LDR_SB_G1
},
1770 {BFD_RELOC_ARM_LDR_SB_G2
, R_ARM_LDR_SB_G2
},
1771 {BFD_RELOC_ARM_LDRS_SB_G0
, R_ARM_LDRS_SB_G0
},
1772 {BFD_RELOC_ARM_LDRS_SB_G1
, R_ARM_LDRS_SB_G1
},
1773 {BFD_RELOC_ARM_LDRS_SB_G2
, R_ARM_LDRS_SB_G2
},
1774 {BFD_RELOC_ARM_LDC_SB_G0
, R_ARM_LDC_SB_G0
},
1775 {BFD_RELOC_ARM_LDC_SB_G1
, R_ARM_LDC_SB_G1
},
1776 {BFD_RELOC_ARM_LDC_SB_G2
, R_ARM_LDC_SB_G2
},
1777 {BFD_RELOC_ARM_V4BX
, R_ARM_V4BX
}
1780 static reloc_howto_type
*
1781 elf32_arm_reloc_type_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
1782 bfd_reloc_code_real_type code
)
1785 for (i
= 0; i
< NUM_ELEM (elf32_arm_reloc_map
); i
++)
1786 if (elf32_arm_reloc_map
[i
].bfd_reloc_val
== code
)
1787 return elf32_arm_howto_from_type (elf32_arm_reloc_map
[i
].elf_reloc_val
);
1792 static reloc_howto_type
*
1793 elf32_arm_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
1799 i
< (sizeof (elf32_arm_howto_table_1
)
1800 / sizeof (elf32_arm_howto_table_1
[0]));
1802 if (elf32_arm_howto_table_1
[i
].name
!= NULL
1803 && strcasecmp (elf32_arm_howto_table_1
[i
].name
, r_name
) == 0)
1804 return &elf32_arm_howto_table_1
[i
];
1807 i
< (sizeof (elf32_arm_howto_table_2
)
1808 / sizeof (elf32_arm_howto_table_2
[0]));
1810 if (elf32_arm_howto_table_2
[i
].name
!= NULL
1811 && strcasecmp (elf32_arm_howto_table_2
[i
].name
, r_name
) == 0)
1812 return &elf32_arm_howto_table_2
[i
];
1817 /* Support for core dump NOTE sections */
1819 elf32_arm_nabi_grok_prstatus (bfd
*abfd
, Elf_Internal_Note
*note
)
1824 switch (note
->descsz
)
1829 case 148: /* Linux/ARM 32-bit*/
1831 elf_tdata (abfd
)->core_signal
= bfd_get_16 (abfd
, note
->descdata
+ 12);
1834 elf_tdata (abfd
)->core_pid
= bfd_get_32 (abfd
, note
->descdata
+ 24);
1843 /* Make a ".reg/999" section. */
1844 return _bfd_elfcore_make_pseudosection (abfd
, ".reg",
1845 size
, note
->descpos
+ offset
);
1849 elf32_arm_nabi_grok_psinfo (bfd
*abfd
, Elf_Internal_Note
*note
)
1851 switch (note
->descsz
)
1856 case 124: /* Linux/ARM elf_prpsinfo */
1857 elf_tdata (abfd
)->core_program
1858 = _bfd_elfcore_strndup (abfd
, note
->descdata
+ 28, 16);
1859 elf_tdata (abfd
)->core_command
1860 = _bfd_elfcore_strndup (abfd
, note
->descdata
+ 44, 80);
1863 /* Note that for some reason, a spurious space is tacked
1864 onto the end of the args in some (at least one anyway)
1865 implementations, so strip it off if it exists. */
1868 char *command
= elf_tdata (abfd
)->core_command
;
1869 int n
= strlen (command
);
1871 if (0 < n
&& command
[n
- 1] == ' ')
1872 command
[n
- 1] = '\0';
1878 #define TARGET_LITTLE_SYM bfd_elf32_littlearm_vec
1879 #define TARGET_LITTLE_NAME "elf32-littlearm"
1880 #define TARGET_BIG_SYM bfd_elf32_bigarm_vec
1881 #define TARGET_BIG_NAME "elf32-bigarm"
1883 #define elf_backend_grok_prstatus elf32_arm_nabi_grok_prstatus
1884 #define elf_backend_grok_psinfo elf32_arm_nabi_grok_psinfo
1886 typedef unsigned long int insn32
;
1887 typedef unsigned short int insn16
;
1889 /* In lieu of proper flags, assume all EABIv4 or later objects are
1891 #define INTERWORK_FLAG(abfd) \
1892 (EF_ARM_EABI_VERSION (elf_elfheader (abfd)->e_flags) >= EF_ARM_EABI_VER4 \
1893 || (elf_elfheader (abfd)->e_flags & EF_ARM_INTERWORK))
1895 /* The linker script knows the section names for placement.
1896 The entry_names are used to do simple name mangling on the stubs.
1897 Given a function name, and its type, the stub can be found. The
1898 name can be changed. The only requirement is the %s be present. */
1899 #define THUMB2ARM_GLUE_SECTION_NAME ".glue_7t"
1900 #define THUMB2ARM_GLUE_ENTRY_NAME "__%s_from_thumb"
1902 #define ARM2THUMB_GLUE_SECTION_NAME ".glue_7"
1903 #define ARM2THUMB_GLUE_ENTRY_NAME "__%s_from_arm"
1905 #define VFP11_ERRATUM_VENEER_SECTION_NAME ".vfp11_veneer"
1906 #define VFP11_ERRATUM_VENEER_ENTRY_NAME "__vfp11_veneer_%x"
1908 #define ARM_BX_GLUE_SECTION_NAME ".v4_bx"
1909 #define ARM_BX_GLUE_ENTRY_NAME "__bx_r%d"
1911 /* The name of the dynamic interpreter. This is put in the .interp
1913 #define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1"
1915 #ifdef FOUR_WORD_PLT
1917 /* The first entry in a procedure linkage table looks like
1918 this. It is set up so that any shared library function that is
1919 called before the relocation has been set up calls the dynamic
1921 static const bfd_vma elf32_arm_plt0_entry
[] =
1923 0xe52de004, /* str lr, [sp, #-4]! */
1924 0xe59fe010, /* ldr lr, [pc, #16] */
1925 0xe08fe00e, /* add lr, pc, lr */
1926 0xe5bef008, /* ldr pc, [lr, #8]! */
1929 /* Subsequent entries in a procedure linkage table look like
1931 static const bfd_vma elf32_arm_plt_entry
[] =
1933 0xe28fc600, /* add ip, pc, #NN */
1934 0xe28cca00, /* add ip, ip, #NN */
1935 0xe5bcf000, /* ldr pc, [ip, #NN]! */
1936 0x00000000, /* unused */
1941 /* The first entry in a procedure linkage table looks like
1942 this. It is set up so that any shared library function that is
1943 called before the relocation has been set up calls the dynamic
1945 static const bfd_vma elf32_arm_plt0_entry
[] =
1947 0xe52de004, /* str lr, [sp, #-4]! */
1948 0xe59fe004, /* ldr lr, [pc, #4] */
1949 0xe08fe00e, /* add lr, pc, lr */
1950 0xe5bef008, /* ldr pc, [lr, #8]! */
1951 0x00000000, /* &GOT[0] - . */
1954 /* Subsequent entries in a procedure linkage table look like
1956 static const bfd_vma elf32_arm_plt_entry
[] =
1958 0xe28fc600, /* add ip, pc, #0xNN00000 */
1959 0xe28cca00, /* add ip, ip, #0xNN000 */
1960 0xe5bcf000, /* ldr pc, [ip, #0xNNN]! */
1965 /* The format of the first entry in the procedure linkage table
1966 for a VxWorks executable. */
1967 static const bfd_vma elf32_arm_vxworks_exec_plt0_entry
[] =
1969 0xe52dc008, /* str ip,[sp,#-8]! */
1970 0xe59fc000, /* ldr ip,[pc] */
1971 0xe59cf008, /* ldr pc,[ip,#8] */
1972 0x00000000, /* .long _GLOBAL_OFFSET_TABLE_ */
1975 /* The format of subsequent entries in a VxWorks executable. */
1976 static const bfd_vma elf32_arm_vxworks_exec_plt_entry
[] =
1978 0xe59fc000, /* ldr ip,[pc] */
1979 0xe59cf000, /* ldr pc,[ip] */
1980 0x00000000, /* .long @got */
1981 0xe59fc000, /* ldr ip,[pc] */
1982 0xea000000, /* b _PLT */
1983 0x00000000, /* .long @pltindex*sizeof(Elf32_Rela) */
1986 /* The format of entries in a VxWorks shared library. */
1987 static const bfd_vma elf32_arm_vxworks_shared_plt_entry
[] =
1989 0xe59fc000, /* ldr ip,[pc] */
1990 0xe79cf009, /* ldr pc,[ip,r9] */
1991 0x00000000, /* .long @got */
1992 0xe59fc000, /* ldr ip,[pc] */
1993 0xe599f008, /* ldr pc,[r9,#8] */
1994 0x00000000, /* .long @pltindex*sizeof(Elf32_Rela) */
1997 /* An initial stub used if the PLT entry is referenced from Thumb code. */
1998 #define PLT_THUMB_STUB_SIZE 4
1999 static const bfd_vma elf32_arm_plt_thumb_stub
[] =
2005 /* The entries in a PLT when using a DLL-based target with multiple
2007 static const bfd_vma elf32_arm_symbian_plt_entry
[] =
2009 0xe51ff004, /* ldr pc, [pc, #-4] */
2010 0x00000000, /* dcd R_ARM_GLOB_DAT(X) */
2013 /* Used to build a map of a section. This is required for mixed-endian
2016 typedef struct elf32_elf_section_map
2021 elf32_arm_section_map
;
2023 /* Information about a VFP11 erratum veneer, or a branch to such a veneer. */
2027 VFP11_ERRATUM_BRANCH_TO_ARM_VENEER
,
2028 VFP11_ERRATUM_BRANCH_TO_THUMB_VENEER
,
2029 VFP11_ERRATUM_ARM_VENEER
,
2030 VFP11_ERRATUM_THUMB_VENEER
2032 elf32_vfp11_erratum_type
;
2034 typedef struct elf32_vfp11_erratum_list
2036 struct elf32_vfp11_erratum_list
*next
;
2042 struct elf32_vfp11_erratum_list
*veneer
;
2043 unsigned int vfp_insn
;
2047 struct elf32_vfp11_erratum_list
*branch
;
2051 elf32_vfp11_erratum_type type
;
2053 elf32_vfp11_erratum_list
;
2055 typedef struct _arm_elf_section_data
2057 struct bfd_elf_section_data elf
;
2058 unsigned int mapcount
;
2059 unsigned int mapsize
;
2060 elf32_arm_section_map
*map
;
2061 unsigned int erratumcount
;
2062 elf32_vfp11_erratum_list
*erratumlist
;
2064 _arm_elf_section_data
;
2066 #define elf32_arm_section_data(sec) \
2067 ((_arm_elf_section_data *) elf_section_data (sec))
2069 /* The size of the thread control block. */
2072 struct elf_arm_obj_tdata
2074 struct elf_obj_tdata root
;
2076 /* tls_type for each local got entry. */
2077 char *local_got_tls_type
;
2079 /* Zero to warn when linking objects with incompatible enum sizes. */
2080 int no_enum_size_warning
;
2083 #define elf_arm_tdata(bfd) \
2084 ((struct elf_arm_obj_tdata *) (bfd)->tdata.any)
2086 #define elf32_arm_local_got_tls_type(bfd) \
2087 (elf_arm_tdata (bfd)->local_got_tls_type)
2089 #define is_arm_elf(bfd) \
2090 (bfd_get_flavour (bfd) == bfd_target_elf_flavour \
2091 && elf_tdata (bfd) != NULL \
2092 && elf_object_id (bfd) == ARM_ELF_TDATA)
2095 elf32_arm_mkobject (bfd
*abfd
)
2097 return bfd_elf_allocate_object (abfd
, sizeof (struct elf_arm_obj_tdata
),
2101 /* The ARM linker needs to keep track of the number of relocs that it
2102 decides to copy in check_relocs for each symbol. This is so that
2103 it can discard PC relative relocs if it doesn't need them when
2104 linking with -Bsymbolic. We store the information in a field
2105 extending the regular ELF linker hash table. */
2107 /* This structure keeps track of the number of relocs we have copied
2108 for a given symbol. */
2109 struct elf32_arm_relocs_copied
2112 struct elf32_arm_relocs_copied
* next
;
2113 /* A section in dynobj. */
2115 /* Number of relocs copied in this section. */
2116 bfd_size_type count
;
2117 /* Number of PC-relative relocs copied in this section. */
2118 bfd_size_type pc_count
;
2121 #define elf32_arm_hash_entry(ent) ((struct elf32_arm_link_hash_entry *)(ent))
2123 /* Arm ELF linker hash entry. */
2124 struct elf32_arm_link_hash_entry
2126 struct elf_link_hash_entry root
;
2128 /* Number of PC relative relocs copied for this symbol. */
2129 struct elf32_arm_relocs_copied
* relocs_copied
;
2131 /* We reference count Thumb references to a PLT entry separately,
2132 so that we can emit the Thumb trampoline only if needed. */
2133 bfd_signed_vma plt_thumb_refcount
;
2135 /* Some references from Thumb code may be eliminated by BL->BLX
2136 conversion, so record them separately. */
2137 bfd_signed_vma plt_maybe_thumb_refcount
;
2139 /* Since PLT entries have variable size if the Thumb prologue is
2140 used, we need to record the index into .got.plt instead of
2141 recomputing it from the PLT offset. */
2142 bfd_signed_vma plt_got_offset
;
2144 #define GOT_UNKNOWN 0
2145 #define GOT_NORMAL 1
2146 #define GOT_TLS_GD 2
2147 #define GOT_TLS_IE 4
2148 unsigned char tls_type
;
2150 /* The symbol marking the real symbol location for exported thumb
2151 symbols with Arm stubs. */
2152 struct elf_link_hash_entry
*export_glue
;
2155 /* Traverse an arm ELF linker hash table. */
2156 #define elf32_arm_link_hash_traverse(table, func, info) \
2157 (elf_link_hash_traverse \
2159 (bfd_boolean (*) (struct elf_link_hash_entry *, void *)) (func), \
2162 /* Get the ARM elf linker hash table from a link_info structure. */
2163 #define elf32_arm_hash_table(info) \
2164 ((struct elf32_arm_link_hash_table *) ((info)->hash))
2166 /* ARM ELF linker hash table. */
2167 struct elf32_arm_link_hash_table
2169 /* The main hash table. */
2170 struct elf_link_hash_table root
;
2172 /* The size in bytes of the section containing the Thumb-to-ARM glue. */
2173 bfd_size_type thumb_glue_size
;
2175 /* The size in bytes of the section containing the ARM-to-Thumb glue. */
2176 bfd_size_type arm_glue_size
;
2178 /* The size in bytes of section containing the ARMv4 BX veneers. */
2179 bfd_size_type bx_glue_size
;
2181 /* Offsets of ARMv4 BX veneers. Bit1 set if present, and Bit0 set when
2182 veneer has been populated. */
2183 bfd_vma bx_glue_offset
[15];
2185 /* The size in bytes of the section containing glue for VFP11 erratum
2187 bfd_size_type vfp11_erratum_glue_size
;
2189 /* An arbitrary input BFD chosen to hold the glue sections. */
2190 bfd
* bfd_of_glue_owner
;
2192 /* Nonzero to output a BE8 image. */
2195 /* Zero if R_ARM_TARGET1 means R_ARM_ABS32.
2196 Nonzero if R_ARM_TARGET1 means R_ARM_REL32. */
2199 /* The relocation to use for R_ARM_TARGET2 relocations. */
2202 /* 0 = Ignore R_ARM_V4BX.
2203 1 = Convert BX to MOV PC.
2204 2 = Generate v4 interworing stubs. */
2207 /* Nonzero if the ARM/Thumb BLX instructions are available for use. */
2210 /* What sort of code sequences we should look for which may trigger the
2211 VFP11 denorm erratum. */
2212 bfd_arm_vfp11_fix vfp11_fix
;
2214 /* Global counter for the number of fixes we have emitted. */
2215 int num_vfp11_fixes
;
2217 /* Nonzero to force PIC branch veneers. */
2220 /* The number of bytes in the initial entry in the PLT. */
2221 bfd_size_type plt_header_size
;
2223 /* The number of bytes in the subsequent PLT etries. */
2224 bfd_size_type plt_entry_size
;
2226 /* True if the target system is VxWorks. */
2229 /* True if the target system is Symbian OS. */
2232 /* True if the target uses REL relocations. */
2235 /* Short-cuts to get to dynamic linker sections. */
2244 /* The (unloaded but important) VxWorks .rela.plt.unloaded section. */
2247 /* Data for R_ARM_TLS_LDM32 relocations. */
2249 bfd_signed_vma refcount
;
2253 /* Small local sym to section mapping cache. */
2254 struct sym_sec_cache sym_sec
;
2256 /* For convenience in allocate_dynrelocs. */
2260 /* Create an entry in an ARM ELF linker hash table. */
2262 static struct bfd_hash_entry
*
2263 elf32_arm_link_hash_newfunc (struct bfd_hash_entry
* entry
,
2264 struct bfd_hash_table
* table
,
2265 const char * string
)
2267 struct elf32_arm_link_hash_entry
* ret
=
2268 (struct elf32_arm_link_hash_entry
*) entry
;
2270 /* Allocate the structure if it has not already been allocated by a
2272 if (ret
== (struct elf32_arm_link_hash_entry
*) NULL
)
2273 ret
= bfd_hash_allocate (table
, sizeof (struct elf32_arm_link_hash_entry
));
2275 return (struct bfd_hash_entry
*) ret
;
2277 /* Call the allocation method of the superclass. */
2278 ret
= ((struct elf32_arm_link_hash_entry
*)
2279 _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry
*) ret
,
2283 ret
->relocs_copied
= NULL
;
2284 ret
->tls_type
= GOT_UNKNOWN
;
2285 ret
->plt_thumb_refcount
= 0;
2286 ret
->plt_maybe_thumb_refcount
= 0;
2287 ret
->plt_got_offset
= -1;
2288 ret
->export_glue
= NULL
;
2291 return (struct bfd_hash_entry
*) ret
;
2294 /* Return true if NAME is the name of the relocation section associated
2298 reloc_section_p (struct elf32_arm_link_hash_table
*htab
,
2299 const char *name
, asection
*s
)
2302 return CONST_STRNEQ (name
, ".rel") && strcmp (s
->name
, name
+ 4) == 0;
2304 return CONST_STRNEQ (name
, ".rela") && strcmp (s
->name
, name
+ 5) == 0;
2307 /* Create .got, .gotplt, and .rel(a).got sections in DYNOBJ, and set up
2308 shortcuts to them in our hash table. */
2311 create_got_section (bfd
*dynobj
, struct bfd_link_info
*info
)
2313 struct elf32_arm_link_hash_table
*htab
;
2315 htab
= elf32_arm_hash_table (info
);
2316 /* BPABI objects never have a GOT, or associated sections. */
2317 if (htab
->symbian_p
)
2320 if (! _bfd_elf_create_got_section (dynobj
, info
))
2323 htab
->sgot
= bfd_get_section_by_name (dynobj
, ".got");
2324 htab
->sgotplt
= bfd_get_section_by_name (dynobj
, ".got.plt");
2325 if (!htab
->sgot
|| !htab
->sgotplt
)
2328 htab
->srelgot
= bfd_make_section_with_flags (dynobj
,
2329 RELOC_SECTION (htab
, ".got"),
2330 (SEC_ALLOC
| SEC_LOAD
2333 | SEC_LINKER_CREATED
2335 if (htab
->srelgot
== NULL
2336 || ! bfd_set_section_alignment (dynobj
, htab
->srelgot
, 2))
2341 /* Create .plt, .rel(a).plt, .got, .got.plt, .rel(a).got, .dynbss, and
2342 .rel(a).bss sections in DYNOBJ, and set up shortcuts to them in our
2346 elf32_arm_create_dynamic_sections (bfd
*dynobj
, struct bfd_link_info
*info
)
2348 struct elf32_arm_link_hash_table
*htab
;
2350 htab
= elf32_arm_hash_table (info
);
2351 if (!htab
->sgot
&& !create_got_section (dynobj
, info
))
2354 if (!_bfd_elf_create_dynamic_sections (dynobj
, info
))
2357 htab
->splt
= bfd_get_section_by_name (dynobj
, ".plt");
2358 htab
->srelplt
= bfd_get_section_by_name (dynobj
,
2359 RELOC_SECTION (htab
, ".plt"));
2360 htab
->sdynbss
= bfd_get_section_by_name (dynobj
, ".dynbss");
2362 htab
->srelbss
= bfd_get_section_by_name (dynobj
,
2363 RELOC_SECTION (htab
, ".bss"));
2365 if (htab
->vxworks_p
)
2367 if (!elf_vxworks_create_dynamic_sections (dynobj
, info
, &htab
->srelplt2
))
2372 htab
->plt_header_size
= 0;
2373 htab
->plt_entry_size
2374 = 4 * ARRAY_SIZE (elf32_arm_vxworks_shared_plt_entry
);
2378 htab
->plt_header_size
2379 = 4 * ARRAY_SIZE (elf32_arm_vxworks_exec_plt0_entry
);
2380 htab
->plt_entry_size
2381 = 4 * ARRAY_SIZE (elf32_arm_vxworks_exec_plt_entry
);
2388 || (!info
->shared
&& !htab
->srelbss
))
2394 /* Copy the extra info we tack onto an elf_link_hash_entry. */
2397 elf32_arm_copy_indirect_symbol (struct bfd_link_info
*info
,
2398 struct elf_link_hash_entry
*dir
,
2399 struct elf_link_hash_entry
*ind
)
2401 struct elf32_arm_link_hash_entry
*edir
, *eind
;
2403 edir
= (struct elf32_arm_link_hash_entry
*) dir
;
2404 eind
= (struct elf32_arm_link_hash_entry
*) ind
;
2406 if (eind
->relocs_copied
!= NULL
)
2408 if (edir
->relocs_copied
!= NULL
)
2410 struct elf32_arm_relocs_copied
**pp
;
2411 struct elf32_arm_relocs_copied
*p
;
2413 /* Add reloc counts against the indirect sym to the direct sym
2414 list. Merge any entries against the same section. */
2415 for (pp
= &eind
->relocs_copied
; (p
= *pp
) != NULL
; )
2417 struct elf32_arm_relocs_copied
*q
;
2419 for (q
= edir
->relocs_copied
; q
!= NULL
; q
= q
->next
)
2420 if (q
->section
== p
->section
)
2422 q
->pc_count
+= p
->pc_count
;
2423 q
->count
+= p
->count
;
2430 *pp
= edir
->relocs_copied
;
2433 edir
->relocs_copied
= eind
->relocs_copied
;
2434 eind
->relocs_copied
= NULL
;
2437 if (ind
->root
.type
== bfd_link_hash_indirect
)
2439 /* Copy over PLT info. */
2440 edir
->plt_thumb_refcount
+= eind
->plt_thumb_refcount
;
2441 eind
->plt_thumb_refcount
= 0;
2442 edir
->plt_maybe_thumb_refcount
+= eind
->plt_maybe_thumb_refcount
;
2443 eind
->plt_maybe_thumb_refcount
= 0;
2445 if (dir
->got
.refcount
<= 0)
2447 edir
->tls_type
= eind
->tls_type
;
2448 eind
->tls_type
= GOT_UNKNOWN
;
2452 _bfd_elf_link_hash_copy_indirect (info
, dir
, ind
);
2455 /* Create an ARM elf linker hash table. */
2457 static struct bfd_link_hash_table
*
2458 elf32_arm_link_hash_table_create (bfd
*abfd
)
2460 struct elf32_arm_link_hash_table
*ret
;
2461 bfd_size_type amt
= sizeof (struct elf32_arm_link_hash_table
);
2463 ret
= bfd_malloc (amt
);
2467 if (!_bfd_elf_link_hash_table_init (& ret
->root
, abfd
,
2468 elf32_arm_link_hash_newfunc
,
2469 sizeof (struct elf32_arm_link_hash_entry
)))
2476 ret
->sgotplt
= NULL
;
2477 ret
->srelgot
= NULL
;
2479 ret
->srelplt
= NULL
;
2480 ret
->sdynbss
= NULL
;
2481 ret
->srelbss
= NULL
;
2482 ret
->srelplt2
= NULL
;
2483 ret
->thumb_glue_size
= 0;
2484 ret
->arm_glue_size
= 0;
2485 ret
->bx_glue_size
= 0;
2486 memset (ret
->bx_glue_offset
, 0, sizeof(ret
->bx_glue_offset
));
2487 ret
->vfp11_fix
= BFD_ARM_VFP11_FIX_NONE
;
2488 ret
->vfp11_erratum_glue_size
= 0;
2489 ret
->num_vfp11_fixes
= 0;
2490 ret
->bfd_of_glue_owner
= NULL
;
2491 ret
->byteswap_code
= 0;
2492 ret
->target1_is_rel
= 0;
2493 ret
->target2_reloc
= R_ARM_NONE
;
2494 #ifdef FOUR_WORD_PLT
2495 ret
->plt_header_size
= 16;
2496 ret
->plt_entry_size
= 16;
2498 ret
->plt_header_size
= 20;
2499 ret
->plt_entry_size
= 12;
2506 ret
->sym_sec
.abfd
= NULL
;
2508 ret
->tls_ldm_got
.refcount
= 0;
2510 return &ret
->root
.root
;
2513 /* Locate the Thumb encoded calling stub for NAME. */
2515 static struct elf_link_hash_entry
*
2516 find_thumb_glue (struct bfd_link_info
*link_info
,
2518 char **error_message
)
2521 struct elf_link_hash_entry
*hash
;
2522 struct elf32_arm_link_hash_table
*hash_table
;
2524 /* We need a pointer to the armelf specific hash table. */
2525 hash_table
= elf32_arm_hash_table (link_info
);
2527 tmp_name
= bfd_malloc ((bfd_size_type
) strlen (name
)
2528 + strlen (THUMB2ARM_GLUE_ENTRY_NAME
) + 1);
2530 BFD_ASSERT (tmp_name
);
2532 sprintf (tmp_name
, THUMB2ARM_GLUE_ENTRY_NAME
, name
);
2534 hash
= elf_link_hash_lookup
2535 (&(hash_table
)->root
, tmp_name
, FALSE
, FALSE
, TRUE
);
2538 && asprintf (error_message
, _("unable to find THUMB glue '%s' for '%s'"),
2539 tmp_name
, name
) == -1)
2540 *error_message
= (char *) bfd_errmsg (bfd_error_system_call
);
2547 /* Locate the ARM encoded calling stub for NAME. */
2549 static struct elf_link_hash_entry
*
2550 find_arm_glue (struct bfd_link_info
*link_info
,
2552 char **error_message
)
2555 struct elf_link_hash_entry
*myh
;
2556 struct elf32_arm_link_hash_table
*hash_table
;
2558 /* We need a pointer to the elfarm specific hash table. */
2559 hash_table
= elf32_arm_hash_table (link_info
);
2561 tmp_name
= bfd_malloc ((bfd_size_type
) strlen (name
)
2562 + strlen (ARM2THUMB_GLUE_ENTRY_NAME
) + 1);
2564 BFD_ASSERT (tmp_name
);
2566 sprintf (tmp_name
, ARM2THUMB_GLUE_ENTRY_NAME
, name
);
2568 myh
= elf_link_hash_lookup
2569 (&(hash_table
)->root
, tmp_name
, FALSE
, FALSE
, TRUE
);
2572 && asprintf (error_message
, _("unable to find ARM glue '%s' for '%s'"),
2573 tmp_name
, name
) == -1)
2574 *error_message
= (char *) bfd_errmsg (bfd_error_system_call
);
2581 /* ARM->Thumb glue (static images):
2585 ldr r12, __func_addr
2588 .word func @ behave as if you saw a ARM_32 reloc.
2595 .word func @ behave as if you saw a ARM_32 reloc.
2597 (relocatable images)
2600 ldr r12, __func_offset
2607 #define ARM2THUMB_STATIC_GLUE_SIZE 12
2608 static const insn32 a2t1_ldr_insn
= 0xe59fc000;
2609 static const insn32 a2t2_bx_r12_insn
= 0xe12fff1c;
2610 static const insn32 a2t3_func_addr_insn
= 0x00000001;
2612 #define ARM2THUMB_V5_STATIC_GLUE_SIZE 8
2613 static const insn32 a2t1v5_ldr_insn
= 0xe51ff004;
2614 static const insn32 a2t2v5_func_addr_insn
= 0x00000001;
2616 #define ARM2THUMB_PIC_GLUE_SIZE 16
2617 static const insn32 a2t1p_ldr_insn
= 0xe59fc004;
2618 static const insn32 a2t2p_add_pc_insn
= 0xe08cc00f;
2619 static const insn32 a2t3p_bx_r12_insn
= 0xe12fff1c;
2621 /* Thumb->ARM: Thumb->(non-interworking aware) ARM
2625 __func_from_thumb: __func_from_thumb:
2627 nop ldr r6, __func_addr
2629 __func_change_to_arm: bx r6
2631 __func_back_to_thumb:
2637 #define THUMB2ARM_GLUE_SIZE 8
2638 static const insn16 t2a1_bx_pc_insn
= 0x4778;
2639 static const insn16 t2a2_noop_insn
= 0x46c0;
2640 static const insn32 t2a3_b_insn
= 0xea000000;
2642 #define VFP11_ERRATUM_VENEER_SIZE 8
2644 #define ARM_BX_VENEER_SIZE 12
2645 static const insn32 armbx1_tst_insn
= 0xe3100001;
2646 static const insn32 armbx2_moveq_insn
= 0x01a0f000;
2647 static const insn32 armbx3_bx_insn
= 0xe12fff10;
2649 #ifndef ELFARM_NABI_C_INCLUDED
2651 bfd_elf32_arm_allocate_interworking_sections (struct bfd_link_info
* info
)
2655 struct elf32_arm_link_hash_table
* globals
;
2657 globals
= elf32_arm_hash_table (info
);
2659 BFD_ASSERT (globals
!= NULL
);
2661 if (globals
->arm_glue_size
!= 0)
2663 BFD_ASSERT (globals
->bfd_of_glue_owner
!= NULL
);
2665 s
= bfd_get_section_by_name (globals
->bfd_of_glue_owner
,
2666 ARM2THUMB_GLUE_SECTION_NAME
);
2668 BFD_ASSERT (s
!= NULL
);
2670 foo
= bfd_alloc (globals
->bfd_of_glue_owner
, globals
->arm_glue_size
);
2672 BFD_ASSERT (s
->size
== globals
->arm_glue_size
);
2676 if (globals
->thumb_glue_size
!= 0)
2678 BFD_ASSERT (globals
->bfd_of_glue_owner
!= NULL
);
2680 s
= bfd_get_section_by_name
2681 (globals
->bfd_of_glue_owner
, THUMB2ARM_GLUE_SECTION_NAME
);
2683 BFD_ASSERT (s
!= NULL
);
2685 foo
= bfd_alloc (globals
->bfd_of_glue_owner
, globals
->thumb_glue_size
);
2687 BFD_ASSERT (s
->size
== globals
->thumb_glue_size
);
2691 if (globals
->vfp11_erratum_glue_size
!= 0)
2693 BFD_ASSERT (globals
->bfd_of_glue_owner
!= NULL
);
2695 s
= bfd_get_section_by_name
2696 (globals
->bfd_of_glue_owner
, VFP11_ERRATUM_VENEER_SECTION_NAME
);
2698 BFD_ASSERT (s
!= NULL
);
2700 foo
= bfd_alloc (globals
->bfd_of_glue_owner
,
2701 globals
->vfp11_erratum_glue_size
);
2703 BFD_ASSERT (s
->size
== globals
->vfp11_erratum_glue_size
);
2707 if (globals
->bx_glue_size
!= 0)
2709 BFD_ASSERT (globals
->bfd_of_glue_owner
!= NULL
);
2711 s
= bfd_get_section_by_name (globals
->bfd_of_glue_owner
,
2712 ARM_BX_GLUE_SECTION_NAME
);
2714 BFD_ASSERT (s
!= NULL
);
2716 foo
= bfd_alloc (globals
->bfd_of_glue_owner
, globals
->bx_glue_size
);
2718 BFD_ASSERT (s
->size
== globals
->bx_glue_size
);
2725 /* Allocate space and symbols for calling a Thumb function from Arm mode.
2726 returns the symbol identifying teh stub. */
2727 static struct elf_link_hash_entry
*
2728 record_arm_to_thumb_glue (struct bfd_link_info
* link_info
,
2729 struct elf_link_hash_entry
* h
)
2731 const char * name
= h
->root
.root
.string
;
2734 struct elf_link_hash_entry
* myh
;
2735 struct bfd_link_hash_entry
* bh
;
2736 struct elf32_arm_link_hash_table
* globals
;
2740 globals
= elf32_arm_hash_table (link_info
);
2742 BFD_ASSERT (globals
!= NULL
);
2743 BFD_ASSERT (globals
->bfd_of_glue_owner
!= NULL
);
2745 s
= bfd_get_section_by_name
2746 (globals
->bfd_of_glue_owner
, ARM2THUMB_GLUE_SECTION_NAME
);
2748 BFD_ASSERT (s
!= NULL
);
2750 tmp_name
= bfd_malloc ((bfd_size_type
) strlen (name
) + strlen (ARM2THUMB_GLUE_ENTRY_NAME
) + 1);
2752 BFD_ASSERT (tmp_name
);
2754 sprintf (tmp_name
, ARM2THUMB_GLUE_ENTRY_NAME
, name
);
2756 myh
= elf_link_hash_lookup
2757 (&(globals
)->root
, tmp_name
, FALSE
, FALSE
, TRUE
);
2761 /* We've already seen this guy. */
2766 /* The only trick here is using hash_table->arm_glue_size as the value.
2767 Even though the section isn't allocated yet, this is where we will be
2770 val
= globals
->arm_glue_size
+ 1;
2771 _bfd_generic_link_add_one_symbol (link_info
, globals
->bfd_of_glue_owner
,
2772 tmp_name
, BSF_GLOBAL
, s
, val
,
2773 NULL
, TRUE
, FALSE
, &bh
);
2775 myh
= (struct elf_link_hash_entry
*) bh
;
2776 myh
->type
= ELF_ST_INFO (STB_LOCAL
, STT_FUNC
);
2777 myh
->forced_local
= 1;
2781 if (link_info
->shared
|| globals
->root
.is_relocatable_executable
2782 || globals
->pic_veneer
)
2783 size
= ARM2THUMB_PIC_GLUE_SIZE
;
2784 else if (globals
->use_blx
)
2785 size
= ARM2THUMB_V5_STATIC_GLUE_SIZE
;
2787 size
= ARM2THUMB_STATIC_GLUE_SIZE
;
2790 globals
->arm_glue_size
+= size
;
2796 record_thumb_to_arm_glue (struct bfd_link_info
*link_info
,
2797 struct elf_link_hash_entry
*h
)
2799 const char *name
= h
->root
.root
.string
;
2802 struct elf_link_hash_entry
*myh
;
2803 struct bfd_link_hash_entry
*bh
;
2804 struct elf32_arm_link_hash_table
*hash_table
;
2807 hash_table
= elf32_arm_hash_table (link_info
);
2809 BFD_ASSERT (hash_table
!= NULL
);
2810 BFD_ASSERT (hash_table
->bfd_of_glue_owner
!= NULL
);
2812 s
= bfd_get_section_by_name
2813 (hash_table
->bfd_of_glue_owner
, THUMB2ARM_GLUE_SECTION_NAME
);
2815 BFD_ASSERT (s
!= NULL
);
2817 tmp_name
= bfd_malloc ((bfd_size_type
) strlen (name
)
2818 + strlen (THUMB2ARM_GLUE_ENTRY_NAME
) + 1);
2820 BFD_ASSERT (tmp_name
);
2822 sprintf (tmp_name
, THUMB2ARM_GLUE_ENTRY_NAME
, name
);
2824 myh
= elf_link_hash_lookup
2825 (&(hash_table
)->root
, tmp_name
, FALSE
, FALSE
, TRUE
);
2829 /* We've already seen this guy. */
2835 val
= hash_table
->thumb_glue_size
+ 1;
2836 _bfd_generic_link_add_one_symbol (link_info
, hash_table
->bfd_of_glue_owner
,
2837 tmp_name
, BSF_GLOBAL
, s
, val
,
2838 NULL
, TRUE
, FALSE
, &bh
);
2840 /* If we mark it 'Thumb', the disassembler will do a better job. */
2841 myh
= (struct elf_link_hash_entry
*) bh
;
2842 myh
->type
= ELF_ST_INFO (STB_LOCAL
, STT_ARM_TFUNC
);
2843 myh
->forced_local
= 1;
2847 #define CHANGE_TO_ARM "__%s_change_to_arm"
2848 #define BACK_FROM_ARM "__%s_back_from_arm"
2850 /* Allocate another symbol to mark where we switch to Arm mode. */
2851 tmp_name
= bfd_malloc ((bfd_size_type
) strlen (name
)
2852 + strlen (CHANGE_TO_ARM
) + 1);
2854 BFD_ASSERT (tmp_name
);
2856 sprintf (tmp_name
, CHANGE_TO_ARM
, name
);
2859 val
= hash_table
->thumb_glue_size
+ 4,
2860 _bfd_generic_link_add_one_symbol (link_info
, hash_table
->bfd_of_glue_owner
,
2861 tmp_name
, BSF_LOCAL
, s
, val
,
2862 NULL
, TRUE
, FALSE
, &bh
);
2866 s
->size
+= THUMB2ARM_GLUE_SIZE
;
2867 hash_table
->thumb_glue_size
+= THUMB2ARM_GLUE_SIZE
;
2873 /* Allocate space for ARMv4 BX veneers. */
2876 record_arm_bx_glue (struct bfd_link_info
* link_info
, int reg
)
2879 struct elf32_arm_link_hash_table
*globals
;
2881 struct elf_link_hash_entry
*myh
;
2882 struct bfd_link_hash_entry
*bh
;
2885 /* BX PC does not need a veneer. */
2889 globals
= elf32_arm_hash_table (link_info
);
2891 BFD_ASSERT (globals
!= NULL
);
2892 BFD_ASSERT (globals
->bfd_of_glue_owner
!= NULL
);
2894 /* Check if this veneer has already been allocated. */
2895 if (globals
->bx_glue_offset
[reg
])
2898 s
= bfd_get_section_by_name
2899 (globals
->bfd_of_glue_owner
, ARM_BX_GLUE_SECTION_NAME
);
2901 BFD_ASSERT (s
!= NULL
);
2903 /* Add symbol for veneer. */
2904 tmp_name
= bfd_malloc ((bfd_size_type
) strlen (ARM_BX_GLUE_ENTRY_NAME
) + 1);
2906 BFD_ASSERT (tmp_name
);
2908 sprintf (tmp_name
, ARM_BX_GLUE_ENTRY_NAME
, reg
);
2910 myh
= elf_link_hash_lookup
2911 (&(globals
)->root
, tmp_name
, FALSE
, FALSE
, FALSE
);
2913 BFD_ASSERT (myh
== NULL
);
2916 val
= globals
->bx_glue_size
;
2917 _bfd_generic_link_add_one_symbol (link_info
, globals
->bfd_of_glue_owner
,
2918 tmp_name
, BSF_FUNCTION
| BSF_LOCAL
, s
, val
,
2919 NULL
, TRUE
, FALSE
, &bh
);
2921 myh
= (struct elf_link_hash_entry
*) bh
;
2922 myh
->type
= ELF_ST_INFO (STB_LOCAL
, STT_FUNC
);
2923 myh
->forced_local
= 1;
2925 s
->size
+= ARM_BX_VENEER_SIZE
;
2926 globals
->bx_glue_offset
[reg
] = globals
->bx_glue_size
| 2;
2927 globals
->bx_glue_size
+= ARM_BX_VENEER_SIZE
;
2931 /* Add an entry to the code/data map for section SEC. */
2934 elf32_arm_section_map_add (asection
*sec
, char type
, bfd_vma vma
)
2936 struct _arm_elf_section_data
*sec_data
= elf32_arm_section_data (sec
);
2937 unsigned int newidx
;
2939 if (sec_data
->map
== NULL
)
2941 sec_data
->map
= bfd_malloc (sizeof (elf32_arm_section_map
));
2942 sec_data
->mapcount
= 0;
2943 sec_data
->mapsize
= 1;
2946 newidx
= sec_data
->mapcount
++;
2948 if (sec_data
->mapcount
> sec_data
->mapsize
)
2950 sec_data
->mapsize
*= 2;
2951 sec_data
->map
= bfd_realloc_or_free (sec_data
->map
, sec_data
->mapsize
2952 * sizeof (elf32_arm_section_map
));
2957 sec_data
->map
[newidx
].vma
= vma
;
2958 sec_data
->map
[newidx
].type
= type
;
2963 /* Record information about a VFP11 denorm-erratum veneer. Only ARM-mode
2964 veneers are handled for now. */
2967 record_vfp11_erratum_veneer (struct bfd_link_info
*link_info
,
2968 elf32_vfp11_erratum_list
*branch
,
2970 asection
*branch_sec
,
2971 unsigned int offset
)
2974 struct elf32_arm_link_hash_table
*hash_table
;
2976 struct elf_link_hash_entry
*myh
;
2977 struct bfd_link_hash_entry
*bh
;
2979 struct _arm_elf_section_data
*sec_data
;
2981 elf32_vfp11_erratum_list
*newerr
;
2983 hash_table
= elf32_arm_hash_table (link_info
);
2985 BFD_ASSERT (hash_table
!= NULL
);
2986 BFD_ASSERT (hash_table
->bfd_of_glue_owner
!= NULL
);
2988 s
= bfd_get_section_by_name
2989 (hash_table
->bfd_of_glue_owner
, VFP11_ERRATUM_VENEER_SECTION_NAME
);
2991 sec_data
= elf32_arm_section_data (s
);
2993 BFD_ASSERT (s
!= NULL
);
2995 tmp_name
= bfd_malloc ((bfd_size_type
) strlen
2996 (VFP11_ERRATUM_VENEER_ENTRY_NAME
) + 10);
2998 BFD_ASSERT (tmp_name
);
3000 sprintf (tmp_name
, VFP11_ERRATUM_VENEER_ENTRY_NAME
,
3001 hash_table
->num_vfp11_fixes
);
3003 myh
= elf_link_hash_lookup
3004 (&(hash_table
)->root
, tmp_name
, FALSE
, FALSE
, FALSE
);
3006 BFD_ASSERT (myh
== NULL
);
3009 val
= hash_table
->vfp11_erratum_glue_size
;
3010 _bfd_generic_link_add_one_symbol (link_info
, hash_table
->bfd_of_glue_owner
,
3011 tmp_name
, BSF_FUNCTION
| BSF_LOCAL
, s
, val
,
3012 NULL
, TRUE
, FALSE
, &bh
);
3014 myh
= (struct elf_link_hash_entry
*) bh
;
3015 myh
->type
= ELF_ST_INFO (STB_LOCAL
, STT_FUNC
);
3016 myh
->forced_local
= 1;
3018 /* Link veneer back to calling location. */
3019 errcount
= ++(sec_data
->erratumcount
);
3020 newerr
= bfd_zmalloc (sizeof (elf32_vfp11_erratum_list
));
3022 newerr
->type
= VFP11_ERRATUM_ARM_VENEER
;
3024 newerr
->u
.v
.branch
= branch
;
3025 newerr
->u
.v
.id
= hash_table
->num_vfp11_fixes
;
3026 branch
->u
.b
.veneer
= newerr
;
3028 newerr
->next
= sec_data
->erratumlist
;
3029 sec_data
->erratumlist
= newerr
;
3031 /* A symbol for the return from the veneer. */
3032 sprintf (tmp_name
, VFP11_ERRATUM_VENEER_ENTRY_NAME
"_r",
3033 hash_table
->num_vfp11_fixes
);
3035 myh
= elf_link_hash_lookup
3036 (&(hash_table
)->root
, tmp_name
, FALSE
, FALSE
, FALSE
);
3043 _bfd_generic_link_add_one_symbol (link_info
, branch_bfd
, tmp_name
, BSF_LOCAL
,
3044 branch_sec
, val
, NULL
, TRUE
, FALSE
, &bh
);
3046 myh
= (struct elf_link_hash_entry
*) bh
;
3047 myh
->type
= ELF_ST_INFO (STB_LOCAL
, STT_FUNC
);
3048 myh
->forced_local
= 1;
3052 /* Generate a mapping symbol for the veneer section, and explicitly add an
3053 entry for that symbol to the code/data map for the section. */
3054 if (hash_table
->vfp11_erratum_glue_size
== 0)
3057 /* FIXME: Creates an ARM symbol. Thumb mode will need attention if it
3058 ever requires this erratum fix. */
3059 _bfd_generic_link_add_one_symbol (link_info
,
3060 hash_table
->bfd_of_glue_owner
, "$a",
3061 BSF_LOCAL
, s
, 0, NULL
,
3064 myh
= (struct elf_link_hash_entry
*) bh
;
3065 myh
->type
= ELF_ST_INFO (STB_LOCAL
, STT_NOTYPE
);
3066 myh
->forced_local
= 1;
3068 /* The elf32_arm_init_maps function only cares about symbols from input
3069 BFDs. We must make a note of this generated mapping symbol
3070 ourselves so that code byteswapping works properly in
3071 elf32_arm_write_section. */
3072 elf32_arm_section_map_add (s
, 'a', 0);
3075 s
->size
+= VFP11_ERRATUM_VENEER_SIZE
;
3076 hash_table
->vfp11_erratum_glue_size
+= VFP11_ERRATUM_VENEER_SIZE
;
3077 hash_table
->num_vfp11_fixes
++;
3079 /* The offset of the veneer. */
3083 /* Add the glue sections to ABFD. This function is called from the
3084 linker scripts in ld/emultempl/{armelf}.em. */
3087 bfd_elf32_arm_add_glue_sections_to_bfd (bfd
*abfd
,
3088 struct bfd_link_info
*info
)
3093 /* If we are only performing a partial
3094 link do not bother adding the glue. */
3095 if (info
->relocatable
)
3098 sec
= bfd_get_section_by_name (abfd
, ARM2THUMB_GLUE_SECTION_NAME
);
3102 /* Note: we do not include the flag SEC_LINKER_CREATED, as this
3103 will prevent elf_link_input_bfd() from processing the contents
3105 flags
= (SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_IN_MEMORY
3106 | SEC_CODE
| SEC_READONLY
);
3108 sec
= bfd_make_section_with_flags (abfd
,
3109 ARM2THUMB_GLUE_SECTION_NAME
,
3113 || !bfd_set_section_alignment (abfd
, sec
, 2))
3116 /* Set the gc mark to prevent the section from being removed by garbage
3117 collection, despite the fact that no relocs refer to this section. */
3121 sec
= bfd_get_section_by_name (abfd
, THUMB2ARM_GLUE_SECTION_NAME
);
3125 flags
= (SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_IN_MEMORY
3126 | SEC_CODE
| SEC_READONLY
);
3128 sec
= bfd_make_section_with_flags (abfd
,
3129 THUMB2ARM_GLUE_SECTION_NAME
,
3133 || !bfd_set_section_alignment (abfd
, sec
, 2))
3139 sec
= bfd_get_section_by_name (abfd
, VFP11_ERRATUM_VENEER_SECTION_NAME
);
3143 flags
= (SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_IN_MEMORY
3144 | SEC_CODE
| SEC_READONLY
);
3146 sec
= bfd_make_section_with_flags (abfd
,
3147 VFP11_ERRATUM_VENEER_SECTION_NAME
,
3151 || !bfd_set_section_alignment (abfd
, sec
, 2))
3157 sec
= bfd_get_section_by_name (abfd
, ARM_BX_GLUE_SECTION_NAME
);
3161 flags
= (SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_IN_MEMORY
3162 | SEC_CODE
| SEC_READONLY
);
3164 sec
= bfd_make_section_with_flags (abfd
,
3165 ARM_BX_GLUE_SECTION_NAME
,
3169 || !bfd_set_section_alignment (abfd
, sec
, 2))
3178 /* Select a BFD to be used to hold the sections used by the glue code.
3179 This function is called from the linker scripts in ld/emultempl/
3183 bfd_elf32_arm_get_bfd_for_interworking (bfd
*abfd
, struct bfd_link_info
*info
)
3185 struct elf32_arm_link_hash_table
*globals
;
3187 /* If we are only performing a partial link
3188 do not bother getting a bfd to hold the glue. */
3189 if (info
->relocatable
)
3192 /* Make sure we don't attach the glue sections to a dynamic object. */
3193 BFD_ASSERT (!(abfd
->flags
& DYNAMIC
));
3195 globals
= elf32_arm_hash_table (info
);
3197 BFD_ASSERT (globals
!= NULL
);
3199 if (globals
->bfd_of_glue_owner
!= NULL
)
3202 /* Save the bfd for later use. */
3203 globals
->bfd_of_glue_owner
= abfd
;
3208 static void check_use_blx(struct elf32_arm_link_hash_table
*globals
)
3210 if (bfd_elf_get_obj_attr_int (globals
->obfd
, OBJ_ATTR_PROC
,
3212 globals
->use_blx
= 1;
3216 bfd_elf32_arm_process_before_allocation (bfd
*abfd
,
3217 struct bfd_link_info
*link_info
)
3219 Elf_Internal_Shdr
*symtab_hdr
;
3220 Elf_Internal_Rela
*internal_relocs
= NULL
;
3221 Elf_Internal_Rela
*irel
, *irelend
;
3222 bfd_byte
*contents
= NULL
;
3225 struct elf32_arm_link_hash_table
*globals
;
3227 /* If we are only performing a partial link do not bother
3228 to construct any glue. */
3229 if (link_info
->relocatable
)
3232 /* Here we have a bfd that is to be included on the link. We have a
3233 hook to do reloc rummaging, before section sizes are nailed down. */
3234 globals
= elf32_arm_hash_table (link_info
);
3236 BFD_ASSERT (globals
!= NULL
);
3238 check_use_blx (globals
);
3240 if (globals
->byteswap_code
&& !bfd_big_endian (abfd
))
3242 _bfd_error_handler (_("%B: BE8 images only valid in big-endian mode."),
3247 /* PR 5398: If we have not decided to include any loadable sections in
3248 the output then we will not have a glue owner bfd. This is OK, it
3249 just means that there is nothing else for us to do here. */
3250 if (globals
->bfd_of_glue_owner
== NULL
)
3253 /* Rummage around all the relocs and map the glue vectors. */
3254 sec
= abfd
->sections
;
3259 for (; sec
!= NULL
; sec
= sec
->next
)
3261 if (sec
->reloc_count
== 0)
3264 if ((sec
->flags
& SEC_EXCLUDE
) != 0)
3267 symtab_hdr
= & elf_symtab_hdr (abfd
);
3269 /* Load the relocs. */
3271 = _bfd_elf_link_read_relocs (abfd
, sec
, (void *) NULL
,
3272 (Elf_Internal_Rela
*) NULL
, FALSE
);
3274 if (internal_relocs
== NULL
)
3277 irelend
= internal_relocs
+ sec
->reloc_count
;
3278 for (irel
= internal_relocs
; irel
< irelend
; irel
++)
3281 unsigned long r_index
;
3283 struct elf_link_hash_entry
*h
;
3285 r_type
= ELF32_R_TYPE (irel
->r_info
);
3286 r_index
= ELF32_R_SYM (irel
->r_info
);
3288 /* These are the only relocation types we care about. */
3289 if ( r_type
!= R_ARM_PC24
3290 && r_type
!= R_ARM_PLT32
3291 && r_type
!= R_ARM_CALL
3292 && r_type
!= R_ARM_JUMP24
3293 && r_type
!= R_ARM_THM_CALL
3294 && r_type
!= R_ARM_THM_JUMP24
3295 && (r_type
!= R_ARM_V4BX
|| globals
->fix_v4bx
< 2))
3298 /* Get the section contents if we haven't done so already. */
3299 if (contents
== NULL
)
3301 /* Get cached copy if it exists. */
3302 if (elf_section_data (sec
)->this_hdr
.contents
!= NULL
)
3303 contents
= elf_section_data (sec
)->this_hdr
.contents
;
3306 /* Go get them off disk. */
3307 if (! bfd_malloc_and_get_section (abfd
, sec
, &contents
))
3312 if (r_type
== R_ARM_V4BX
)
3316 reg
= bfd_get_32 (abfd
, contents
+ irel
->r_offset
) & 0xf;
3317 record_arm_bx_glue (link_info
, reg
);
3321 /* If the relocation is not against a symbol it cannot concern us. */
3324 /* We don't care about local symbols. */
3325 if (r_index
< symtab_hdr
->sh_info
)
3328 /* This is an external symbol. */
3329 r_index
-= symtab_hdr
->sh_info
;
3330 h
= (struct elf_link_hash_entry
*)
3331 elf_sym_hashes (abfd
)[r_index
];
3333 /* If the relocation is against a static symbol it must be within
3334 the current section and so cannot be a cross ARM/Thumb relocation. */
3338 /* If the call will go through a PLT entry then we do not need
3340 if (globals
->splt
!= NULL
&& h
->plt
.offset
!= (bfd_vma
) -1)
3349 /* This one is a call from arm code. We need to look up
3350 the target of the call. If it is a thumb target, we
3352 if (ELF_ST_TYPE(h
->type
) == STT_ARM_TFUNC
3353 && !(r_type
== R_ARM_CALL
&& globals
->use_blx
))
3354 record_arm_to_thumb_glue (link_info
, h
);
3357 case R_ARM_THM_CALL
:
3358 case R_ARM_THM_JUMP24
:
3359 /* This one is a call from thumb code. We look
3360 up the target of the call. If it is not a thumb
3361 target, we insert glue. */
3362 if (ELF_ST_TYPE (h
->type
) != STT_ARM_TFUNC
3363 && !(globals
->use_blx
&& r_type
== R_ARM_THM_CALL
)
3364 && h
->root
.type
!= bfd_link_hash_undefweak
)
3365 record_thumb_to_arm_glue (link_info
, h
);
3373 if (contents
!= NULL
3374 && elf_section_data (sec
)->this_hdr
.contents
!= contents
)
3378 if (internal_relocs
!= NULL
3379 && elf_section_data (sec
)->relocs
!= internal_relocs
)
3380 free (internal_relocs
);
3381 internal_relocs
= NULL
;
3387 if (contents
!= NULL
3388 && elf_section_data (sec
)->this_hdr
.contents
!= contents
)
3390 if (internal_relocs
!= NULL
3391 && elf_section_data (sec
)->relocs
!= internal_relocs
)
3392 free (internal_relocs
);
3399 /* Initialise maps of ARM/Thumb/data for input BFDs. */
3402 bfd_elf32_arm_init_maps (bfd
*abfd
)
3404 Elf_Internal_Sym
*isymbuf
;
3405 Elf_Internal_Shdr
*hdr
;
3406 unsigned int i
, localsyms
;
3408 if ((abfd
->flags
& DYNAMIC
) != 0)
3411 hdr
= & elf_symtab_hdr (abfd
);
3412 localsyms
= hdr
->sh_info
;
3414 /* Obtain a buffer full of symbols for this BFD. The hdr->sh_info field
3415 should contain the number of local symbols, which should come before any
3416 global symbols. Mapping symbols are always local. */
3417 isymbuf
= bfd_elf_get_elf_syms (abfd
, hdr
, localsyms
, 0, NULL
, NULL
,
3420 /* No internal symbols read? Skip this BFD. */
3421 if (isymbuf
== NULL
)
3424 for (i
= 0; i
< localsyms
; i
++)
3426 Elf_Internal_Sym
*isym
= &isymbuf
[i
];
3427 asection
*sec
= bfd_section_from_elf_index (abfd
, isym
->st_shndx
);
3431 && ELF_ST_BIND (isym
->st_info
) == STB_LOCAL
)
3433 name
= bfd_elf_string_from_elf_section (abfd
,
3434 hdr
->sh_link
, isym
->st_name
);
3436 if (bfd_is_arm_special_symbol_name (name
,
3437 BFD_ARM_SPECIAL_SYM_TYPE_MAP
))
3438 elf32_arm_section_map_add (sec
, name
[1], isym
->st_value
);
3445 bfd_elf32_arm_set_vfp11_fix (bfd
*obfd
, struct bfd_link_info
*link_info
)
3447 struct elf32_arm_link_hash_table
*globals
= elf32_arm_hash_table (link_info
);
3448 obj_attribute
*out_attr
= elf_known_obj_attributes_proc (obfd
);
3450 /* We assume that ARMv7+ does not need the VFP11 denorm erratum fix. */
3451 if (out_attr
[Tag_CPU_arch
].i
>= TAG_CPU_ARCH_V7
)
3453 switch (globals
->vfp11_fix
)
3455 case BFD_ARM_VFP11_FIX_DEFAULT
:
3456 case BFD_ARM_VFP11_FIX_NONE
:
3457 globals
->vfp11_fix
= BFD_ARM_VFP11_FIX_NONE
;
3461 /* Give a warning, but do as the user requests anyway. */
3462 (*_bfd_error_handler
) (_("%B: warning: selected VFP11 erratum "
3463 "workaround is not necessary for target architecture"), obfd
);
3466 else if (globals
->vfp11_fix
== BFD_ARM_VFP11_FIX_DEFAULT
)
3467 /* For earlier architectures, we might need the workaround, but do not
3468 enable it by default. If users is running with broken hardware, they
3469 must enable the erratum fix explicitly. */
3470 globals
->vfp11_fix
= BFD_ARM_VFP11_FIX_NONE
;
3474 enum bfd_arm_vfp11_pipe
{
3481 /* Return a VFP register number. This is encoded as RX:X for single-precision
3482 registers, or X:RX for double-precision registers, where RX is the group of
3483 four bits in the instruction encoding and X is the single extension bit.
3484 RX and X fields are specified using their lowest (starting) bit. The return
3487 0...31: single-precision registers s0...s31
3488 32...63: double-precision registers d0...d31.
3490 Although X should be zero for VFP11 (encoding d0...d15 only), we might
3491 encounter VFP3 instructions, so we allow the full range for DP registers. */
3494 bfd_arm_vfp11_regno (unsigned int insn
, bfd_boolean is_double
, unsigned int rx
,
3498 return (((insn
>> rx
) & 0xf) | (((insn
>> x
) & 1) << 4)) + 32;
3500 return (((insn
>> rx
) & 0xf) << 1) | ((insn
>> x
) & 1);
3503 /* Set bits in *WMASK according to a register number REG as encoded by
3504 bfd_arm_vfp11_regno(). Ignore d16-d31. */
3507 bfd_arm_vfp11_write_mask (unsigned int *wmask
, unsigned int reg
)
3512 *wmask
|= 3 << ((reg
- 32) * 2);
3515 /* Return TRUE if WMASK overwrites anything in REGS. */
3518 bfd_arm_vfp11_antidependency (unsigned int wmask
, int *regs
, int numregs
)
3522 for (i
= 0; i
< numregs
; i
++)
3524 unsigned int reg
= regs
[i
];
3526 if (reg
< 32 && (wmask
& (1 << reg
)) != 0)
3534 if ((wmask
& (3 << (reg
* 2))) != 0)
3541 /* In this function, we're interested in two things: finding input registers
3542 for VFP data-processing instructions, and finding the set of registers which
3543 arbitrary VFP instructions may write to. We use a 32-bit unsigned int to
3544 hold the written set, so FLDM etc. are easy to deal with (we're only
3545 interested in 32 SP registers or 16 dp registers, due to the VFP version
3546 implemented by the chip in question). DP registers are marked by setting
3547 both SP registers in the write mask). */
3549 static enum bfd_arm_vfp11_pipe
3550 bfd_arm_vfp11_insn_decode (unsigned int insn
, unsigned int *destmask
, int *regs
,
3553 enum bfd_arm_vfp11_pipe pipe
= VFP11_BAD
;
3554 bfd_boolean is_double
= ((insn
& 0xf00) == 0xb00) ? 1 : 0;
3556 if ((insn
& 0x0f000e10) == 0x0e000a00) /* A data-processing insn. */
3559 unsigned int fd
= bfd_arm_vfp11_regno (insn
, is_double
, 12, 22);
3560 unsigned int fm
= bfd_arm_vfp11_regno (insn
, is_double
, 0, 5);
3562 pqrs
= ((insn
& 0x00800000) >> 20)
3563 | ((insn
& 0x00300000) >> 19)
3564 | ((insn
& 0x00000040) >> 6);
3568 case 0: /* fmac[sd]. */
3569 case 1: /* fnmac[sd]. */
3570 case 2: /* fmsc[sd]. */
3571 case 3: /* fnmsc[sd]. */
3573 bfd_arm_vfp11_write_mask (destmask
, fd
);
3575 regs
[1] = bfd_arm_vfp11_regno (insn
, is_double
, 16, 7); /* Fn. */
3580 case 4: /* fmul[sd]. */
3581 case 5: /* fnmul[sd]. */
3582 case 6: /* fadd[sd]. */
3583 case 7: /* fsub[sd]. */
3587 case 8: /* fdiv[sd]. */
3590 bfd_arm_vfp11_write_mask (destmask
, fd
);
3591 regs
[0] = bfd_arm_vfp11_regno (insn
, is_double
, 16, 7); /* Fn. */
3596 case 15: /* extended opcode. */
3598 unsigned int extn
= ((insn
>> 15) & 0x1e)
3599 | ((insn
>> 7) & 1);
3603 case 0: /* fcpy[sd]. */
3604 case 1: /* fabs[sd]. */
3605 case 2: /* fneg[sd]. */
3606 case 8: /* fcmp[sd]. */
3607 case 9: /* fcmpe[sd]. */
3608 case 10: /* fcmpz[sd]. */
3609 case 11: /* fcmpez[sd]. */
3610 case 16: /* fuito[sd]. */
3611 case 17: /* fsito[sd]. */
3612 case 24: /* ftoui[sd]. */
3613 case 25: /* ftouiz[sd]. */
3614 case 26: /* ftosi[sd]. */
3615 case 27: /* ftosiz[sd]. */
3616 /* These instructions will not bounce due to underflow. */
3621 case 3: /* fsqrt[sd]. */
3622 /* fsqrt cannot underflow, but it can (perhaps) overwrite
3623 registers to cause the erratum in previous instructions. */
3624 bfd_arm_vfp11_write_mask (destmask
, fd
);
3628 case 15: /* fcvt{ds,sd}. */
3632 bfd_arm_vfp11_write_mask (destmask
, fd
);
3634 /* Only FCVTSD can underflow. */
3635 if ((insn
& 0x100) != 0)
3654 /* Two-register transfer. */
3655 else if ((insn
& 0x0fe00ed0) == 0x0c400a10)
3657 unsigned int fm
= bfd_arm_vfp11_regno (insn
, is_double
, 0, 5);
3659 if ((insn
& 0x100000) == 0)
3662 bfd_arm_vfp11_write_mask (destmask
, fm
);
3665 bfd_arm_vfp11_write_mask (destmask
, fm
);
3666 bfd_arm_vfp11_write_mask (destmask
, fm
+ 1);
3672 else if ((insn
& 0x0e100e00) == 0x0c100a00) /* A load insn. */
3674 int fd
= bfd_arm_vfp11_regno (insn
, is_double
, 12, 22);
3675 unsigned int puw
= ((insn
>> 21) & 0x1) | (((insn
>> 23) & 3) << 1);
3679 case 0: /* Two-reg transfer. We should catch these above. */
3682 case 2: /* fldm[sdx]. */
3686 unsigned int i
, offset
= insn
& 0xff;
3691 for (i
= fd
; i
< fd
+ offset
; i
++)
3692 bfd_arm_vfp11_write_mask (destmask
, i
);
3696 case 4: /* fld[sd]. */
3698 bfd_arm_vfp11_write_mask (destmask
, fd
);
3707 /* Single-register transfer. Note L==0. */
3708 else if ((insn
& 0x0f100e10) == 0x0e000a10)
3710 unsigned int opcode
= (insn
>> 21) & 7;
3711 unsigned int fn
= bfd_arm_vfp11_regno (insn
, is_double
, 16, 7);
3715 case 0: /* fmsr/fmdlr. */
3716 case 1: /* fmdhr. */
3717 /* Mark fmdhr and fmdlr as writing to the whole of the DP
3718 destination register. I don't know if this is exactly right,
3719 but it is the conservative choice. */
3720 bfd_arm_vfp11_write_mask (destmask
, fn
);
3734 static int elf32_arm_compare_mapping (const void * a
, const void * b
);
3737 /* Look for potentially-troublesome code sequences which might trigger the
3738 VFP11 denormal/antidependency erratum. See, e.g., the ARM1136 errata sheet
3739 (available from ARM) for details of the erratum. A short version is
3740 described in ld.texinfo. */
3743 bfd_elf32_arm_vfp11_erratum_scan (bfd
*abfd
, struct bfd_link_info
*link_info
)
3746 bfd_byte
*contents
= NULL
;
3748 int regs
[3], numregs
= 0;
3749 struct elf32_arm_link_hash_table
*globals
= elf32_arm_hash_table (link_info
);
3750 int use_vector
= (globals
->vfp11_fix
== BFD_ARM_VFP11_FIX_VECTOR
);
3752 /* We use a simple FSM to match troublesome VFP11 instruction sequences.
3753 The states transition as follows:
3755 0 -> 1 (vector) or 0 -> 2 (scalar)
3756 A VFP FMAC-pipeline instruction has been seen. Fill
3757 regs[0]..regs[numregs-1] with its input operands. Remember this
3758 instruction in 'first_fmac'.
3761 Any instruction, except for a VFP instruction which overwrites
3766 A VFP instruction has been seen which overwrites any of regs[*].
3767 We must make a veneer! Reset state to 0 before examining next
3771 If we fail to match anything in state 2, reset to state 0 and reset
3772 the instruction pointer to the instruction after 'first_fmac'.
3774 If the VFP11 vector mode is in use, there must be at least two unrelated
3775 instructions between anti-dependent VFP11 instructions to properly avoid
3776 triggering the erratum, hence the use of the extra state 1.
3779 /* If we are only performing a partial link do not bother
3780 to construct any glue. */
3781 if (link_info
->relocatable
)
3784 /* Skip if this bfd does not correspond to an ELF image. */
3785 if (! is_arm_elf (abfd
))
3788 /* We should have chosen a fix type by the time we get here. */
3789 BFD_ASSERT (globals
->vfp11_fix
!= BFD_ARM_VFP11_FIX_DEFAULT
);
3791 if (globals
->vfp11_fix
== BFD_ARM_VFP11_FIX_NONE
)
3794 for (sec
= abfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
3796 unsigned int i
, span
, first_fmac
= 0, veneer_of_insn
= 0;
3797 struct _arm_elf_section_data
*sec_data
;
3799 /* If we don't have executable progbits, we're not interested in this
3800 section. Also skip if section is to be excluded. */
3801 if (elf_section_type (sec
) != SHT_PROGBITS
3802 || (elf_section_flags (sec
) & SHF_EXECINSTR
) == 0
3803 || (sec
->flags
& SEC_EXCLUDE
) != 0
3804 || strcmp (sec
->name
, VFP11_ERRATUM_VENEER_SECTION_NAME
) == 0)
3807 sec_data
= elf32_arm_section_data (sec
);
3809 if (sec_data
->mapcount
== 0)
3812 if (elf_section_data (sec
)->this_hdr
.contents
!= NULL
)
3813 contents
= elf_section_data (sec
)->this_hdr
.contents
;
3814 else if (! bfd_malloc_and_get_section (abfd
, sec
, &contents
))
3817 qsort (sec_data
->map
, sec_data
->mapcount
, sizeof (elf32_arm_section_map
),
3818 elf32_arm_compare_mapping
);
3820 for (span
= 0; span
< sec_data
->mapcount
; span
++)
3822 unsigned int span_start
= sec_data
->map
[span
].vma
;
3823 unsigned int span_end
= (span
== sec_data
->mapcount
- 1)
3824 ? sec
->size
: sec_data
->map
[span
+ 1].vma
;
3825 char span_type
= sec_data
->map
[span
].type
;
3827 /* FIXME: Only ARM mode is supported at present. We may need to
3828 support Thumb-2 mode also at some point. */
3829 if (span_type
!= 'a')
3832 for (i
= span_start
; i
< span_end
;)
3834 unsigned int next_i
= i
+ 4;
3835 unsigned int insn
= bfd_big_endian (abfd
)
3836 ? (contents
[i
] << 24)
3837 | (contents
[i
+ 1] << 16)
3838 | (contents
[i
+ 2] << 8)
3840 : (contents
[i
+ 3] << 24)
3841 | (contents
[i
+ 2] << 16)
3842 | (contents
[i
+ 1] << 8)
3844 unsigned int writemask
= 0;
3845 enum bfd_arm_vfp11_pipe pipe
;
3850 pipe
= bfd_arm_vfp11_insn_decode (insn
, &writemask
, regs
,
3852 /* I'm assuming the VFP11 erratum can trigger with denorm
3853 operands on either the FMAC or the DS pipeline. This might
3854 lead to slightly overenthusiastic veneer insertion. */
3855 if (pipe
== VFP11_FMAC
|| pipe
== VFP11_DS
)
3857 state
= use_vector
? 1 : 2;
3859 veneer_of_insn
= insn
;
3865 int other_regs
[3], other_numregs
;
3866 pipe
= bfd_arm_vfp11_insn_decode (insn
, &writemask
,
3869 if (pipe
!= VFP11_BAD
3870 && bfd_arm_vfp11_antidependency (writemask
, regs
,
3880 int other_regs
[3], other_numregs
;
3881 pipe
= bfd_arm_vfp11_insn_decode (insn
, &writemask
,
3884 if (pipe
!= VFP11_BAD
3885 && bfd_arm_vfp11_antidependency (writemask
, regs
,
3891 next_i
= first_fmac
+ 4;
3897 abort (); /* Should be unreachable. */
3902 elf32_vfp11_erratum_list
*newerr
3903 = bfd_zmalloc (sizeof (elf32_vfp11_erratum_list
));
3906 errcount
= ++(elf32_arm_section_data (sec
)->erratumcount
);
3908 newerr
->u
.b
.vfp_insn
= veneer_of_insn
;
3913 newerr
->type
= VFP11_ERRATUM_BRANCH_TO_ARM_VENEER
;
3920 record_vfp11_erratum_veneer (link_info
, newerr
, abfd
, sec
,
3925 newerr
->next
= sec_data
->erratumlist
;
3926 sec_data
->erratumlist
= newerr
;
3935 if (contents
!= NULL
3936 && elf_section_data (sec
)->this_hdr
.contents
!= contents
)
3944 if (contents
!= NULL
3945 && elf_section_data (sec
)->this_hdr
.contents
!= contents
)
3951 /* Find virtual-memory addresses for VFP11 erratum veneers and return locations
3952 after sections have been laid out, using specially-named symbols. */
3955 bfd_elf32_arm_vfp11_fix_veneer_locations (bfd
*abfd
,
3956 struct bfd_link_info
*link_info
)
3959 struct elf32_arm_link_hash_table
*globals
;
3962 if (link_info
->relocatable
)
3965 /* Skip if this bfd does not correspond to an ELF image. */
3966 if (! is_arm_elf (abfd
))
3969 globals
= elf32_arm_hash_table (link_info
);
3971 tmp_name
= bfd_malloc ((bfd_size_type
) strlen
3972 (VFP11_ERRATUM_VENEER_ENTRY_NAME
) + 10);
3974 for (sec
= abfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
3976 struct _arm_elf_section_data
*sec_data
= elf32_arm_section_data (sec
);
3977 elf32_vfp11_erratum_list
*errnode
= sec_data
->erratumlist
;
3979 for (; errnode
!= NULL
; errnode
= errnode
->next
)
3981 struct elf_link_hash_entry
*myh
;
3984 switch (errnode
->type
)
3986 case VFP11_ERRATUM_BRANCH_TO_ARM_VENEER
:
3987 case VFP11_ERRATUM_BRANCH_TO_THUMB_VENEER
:
3988 /* Find veneer symbol. */
3989 sprintf (tmp_name
, VFP11_ERRATUM_VENEER_ENTRY_NAME
,
3990 errnode
->u
.b
.veneer
->u
.v
.id
);
3992 myh
= elf_link_hash_lookup
3993 (&(globals
)->root
, tmp_name
, FALSE
, FALSE
, TRUE
);
3996 (*_bfd_error_handler
) (_("%B: unable to find VFP11 veneer "
3997 "`%s'"), abfd
, tmp_name
);
3999 vma
= myh
->root
.u
.def
.section
->output_section
->vma
4000 + myh
->root
.u
.def
.section
->output_offset
4001 + myh
->root
.u
.def
.value
;
4003 errnode
->u
.b
.veneer
->vma
= vma
;
4006 case VFP11_ERRATUM_ARM_VENEER
:
4007 case VFP11_ERRATUM_THUMB_VENEER
:
4008 /* Find return location. */
4009 sprintf (tmp_name
, VFP11_ERRATUM_VENEER_ENTRY_NAME
"_r",
4012 myh
= elf_link_hash_lookup
4013 (&(globals
)->root
, tmp_name
, FALSE
, FALSE
, TRUE
);
4016 (*_bfd_error_handler
) (_("%B: unable to find VFP11 veneer "
4017 "`%s'"), abfd
, tmp_name
);
4019 vma
= myh
->root
.u
.def
.section
->output_section
->vma
4020 + myh
->root
.u
.def
.section
->output_offset
4021 + myh
->root
.u
.def
.value
;
4023 errnode
->u
.v
.branch
->vma
= vma
;
4036 /* Set target relocation values needed during linking. */
4039 bfd_elf32_arm_set_target_relocs (struct bfd
*output_bfd
,
4040 struct bfd_link_info
*link_info
,
4042 char * target2_type
,
4045 bfd_arm_vfp11_fix vfp11_fix
,
4046 int no_enum_warn
, int pic_veneer
)
4048 struct elf32_arm_link_hash_table
*globals
;
4050 globals
= elf32_arm_hash_table (link_info
);
4052 globals
->target1_is_rel
= target1_is_rel
;
4053 if (strcmp (target2_type
, "rel") == 0)
4054 globals
->target2_reloc
= R_ARM_REL32
;
4055 else if (strcmp (target2_type
, "abs") == 0)
4056 globals
->target2_reloc
= R_ARM_ABS32
;
4057 else if (strcmp (target2_type
, "got-rel") == 0)
4058 globals
->target2_reloc
= R_ARM_GOT_PREL
;
4061 _bfd_error_handler (_("Invalid TARGET2 relocation type '%s'."),
4064 globals
->fix_v4bx
= fix_v4bx
;
4065 globals
->use_blx
|= use_blx
;
4066 globals
->vfp11_fix
= vfp11_fix
;
4067 globals
->pic_veneer
= pic_veneer
;
4069 BFD_ASSERT (is_arm_elf (output_bfd
));
4070 elf_arm_tdata (output_bfd
)->no_enum_size_warning
= no_enum_warn
;
4073 /* Replace the target offset of a Thumb bl or b.w instruction. */
4076 insert_thumb_branch (bfd
*abfd
, long int offset
, bfd_byte
*insn
)
4082 BFD_ASSERT ((offset
& 1) == 0);
4084 upper
= bfd_get_16 (abfd
, insn
);
4085 lower
= bfd_get_16 (abfd
, insn
+ 2);
4086 reloc_sign
= (offset
< 0) ? 1 : 0;
4087 upper
= (upper
& ~(bfd_vma
) 0x7ff)
4088 | ((offset
>> 12) & 0x3ff)
4089 | (reloc_sign
<< 10);
4090 lower
= (lower
& ~(bfd_vma
) 0x2fff)
4091 | (((!((offset
>> 23) & 1)) ^ reloc_sign
) << 13)
4092 | (((!((offset
>> 22) & 1)) ^ reloc_sign
) << 11)
4093 | ((offset
>> 1) & 0x7ff);
4094 bfd_put_16 (abfd
, upper
, insn
);
4095 bfd_put_16 (abfd
, lower
, insn
+ 2);
4099 /* Store an Arm insn into an output section not processed by
4100 elf32_arm_write_section. */
4103 put_arm_insn (struct elf32_arm_link_hash_table
*htab
,
4104 bfd
* output_bfd
, bfd_vma val
, void * ptr
)
4106 if (htab
->byteswap_code
!= bfd_little_endian (output_bfd
))
4107 bfd_putl32 (val
, ptr
);
4109 bfd_putb32 (val
, ptr
);
4113 /* Store a 16-bit Thumb insn into an output section not processed by
4114 elf32_arm_write_section. */
4117 put_thumb_insn (struct elf32_arm_link_hash_table
*htab
,
4118 bfd
* output_bfd
, bfd_vma val
, void * ptr
)
4120 if (htab
->byteswap_code
!= bfd_little_endian (output_bfd
))
4121 bfd_putl16 (val
, ptr
);
4123 bfd_putb16 (val
, ptr
);
4127 /* Thumb code calling an ARM function. */
4130 elf32_thumb_to_arm_stub (struct bfd_link_info
* info
,
4134 asection
* input_section
,
4135 bfd_byte
* hit_data
,
4138 bfd_signed_vma addend
,
4140 char **error_message
)
4144 long int ret_offset
;
4145 struct elf_link_hash_entry
* myh
;
4146 struct elf32_arm_link_hash_table
* globals
;
4148 myh
= find_thumb_glue (info
, name
, error_message
);
4152 globals
= elf32_arm_hash_table (info
);
4154 BFD_ASSERT (globals
!= NULL
);
4155 BFD_ASSERT (globals
->bfd_of_glue_owner
!= NULL
);
4157 my_offset
= myh
->root
.u
.def
.value
;
4159 s
= bfd_get_section_by_name (globals
->bfd_of_glue_owner
,
4160 THUMB2ARM_GLUE_SECTION_NAME
);
4162 BFD_ASSERT (s
!= NULL
);
4163 BFD_ASSERT (s
->contents
!= NULL
);
4164 BFD_ASSERT (s
->output_section
!= NULL
);
4166 if ((my_offset
& 0x01) == 0x01)
4169 && sym_sec
->owner
!= NULL
4170 && !INTERWORK_FLAG (sym_sec
->owner
))
4172 (*_bfd_error_handler
)
4173 (_("%B(%s): warning: interworking not enabled.\n"
4174 " first occurrence: %B: thumb call to arm"),
4175 sym_sec
->owner
, input_bfd
, name
);
4181 myh
->root
.u
.def
.value
= my_offset
;
4183 put_thumb_insn (globals
, output_bfd
, (bfd_vma
) t2a1_bx_pc_insn
,
4184 s
->contents
+ my_offset
);
4186 put_thumb_insn (globals
, output_bfd
, (bfd_vma
) t2a2_noop_insn
,
4187 s
->contents
+ my_offset
+ 2);
4190 /* Address of destination of the stub. */
4191 ((bfd_signed_vma
) val
)
4193 /* Offset from the start of the current section
4194 to the start of the stubs. */
4196 /* Offset of the start of this stub from the start of the stubs. */
4198 /* Address of the start of the current section. */
4199 + s
->output_section
->vma
)
4200 /* The branch instruction is 4 bytes into the stub. */
4202 /* ARM branches work from the pc of the instruction + 8. */
4205 put_arm_insn (globals
, output_bfd
,
4206 (bfd_vma
) t2a3_b_insn
| ((ret_offset
>> 2) & 0x00FFFFFF),
4207 s
->contents
+ my_offset
+ 4);
4210 BFD_ASSERT (my_offset
<= globals
->thumb_glue_size
);
4212 /* Now go back and fix up the original BL insn to point to here. */
4214 /* Address of where the stub is located. */
4215 (s
->output_section
->vma
+ s
->output_offset
+ my_offset
)
4216 /* Address of where the BL is located. */
4217 - (input_section
->output_section
->vma
+ input_section
->output_offset
4219 /* Addend in the relocation. */
4221 /* Biassing for PC-relative addressing. */
4224 insert_thumb_branch (input_bfd
, ret_offset
, hit_data
- input_section
->vma
);
4229 /* Populate an Arm to Thumb stub. Returns the stub symbol. */
4231 static struct elf_link_hash_entry
*
4232 elf32_arm_create_thumb_stub (struct bfd_link_info
* info
,
4239 char **error_message
)
4242 long int ret_offset
;
4243 struct elf_link_hash_entry
* myh
;
4244 struct elf32_arm_link_hash_table
* globals
;
4246 myh
= find_arm_glue (info
, name
, error_message
);
4250 globals
= elf32_arm_hash_table (info
);
4252 BFD_ASSERT (globals
!= NULL
);
4253 BFD_ASSERT (globals
->bfd_of_glue_owner
!= NULL
);
4255 my_offset
= myh
->root
.u
.def
.value
;
4257 if ((my_offset
& 0x01) == 0x01)
4260 && sym_sec
->owner
!= NULL
4261 && !INTERWORK_FLAG (sym_sec
->owner
))
4263 (*_bfd_error_handler
)
4264 (_("%B(%s): warning: interworking not enabled.\n"
4265 " first occurrence: %B: arm call to thumb"),
4266 sym_sec
->owner
, input_bfd
, name
);
4270 myh
->root
.u
.def
.value
= my_offset
;
4272 if (info
->shared
|| globals
->root
.is_relocatable_executable
4273 || globals
->pic_veneer
)
4275 /* For relocatable objects we can't use absolute addresses,
4276 so construct the address from a relative offset. */
4277 /* TODO: If the offset is small it's probably worth
4278 constructing the address with adds. */
4279 put_arm_insn (globals
, output_bfd
, (bfd_vma
) a2t1p_ldr_insn
,
4280 s
->contents
+ my_offset
);
4281 put_arm_insn (globals
, output_bfd
, (bfd_vma
) a2t2p_add_pc_insn
,
4282 s
->contents
+ my_offset
+ 4);
4283 put_arm_insn (globals
, output_bfd
, (bfd_vma
) a2t3p_bx_r12_insn
,
4284 s
->contents
+ my_offset
+ 8);
4285 /* Adjust the offset by 4 for the position of the add,
4286 and 8 for the pipeline offset. */
4287 ret_offset
= (val
- (s
->output_offset
4288 + s
->output_section
->vma
4291 bfd_put_32 (output_bfd
, ret_offset
,
4292 s
->contents
+ my_offset
+ 12);
4294 else if (globals
->use_blx
)
4296 put_arm_insn (globals
, output_bfd
, (bfd_vma
) a2t1v5_ldr_insn
,
4297 s
->contents
+ my_offset
);
4299 /* It's a thumb address. Add the low order bit. */
4300 bfd_put_32 (output_bfd
, val
| a2t2v5_func_addr_insn
,
4301 s
->contents
+ my_offset
+ 4);
4305 put_arm_insn (globals
, output_bfd
, (bfd_vma
) a2t1_ldr_insn
,
4306 s
->contents
+ my_offset
);
4308 put_arm_insn (globals
, output_bfd
, (bfd_vma
) a2t2_bx_r12_insn
,
4309 s
->contents
+ my_offset
+ 4);
4311 /* It's a thumb address. Add the low order bit. */
4312 bfd_put_32 (output_bfd
, val
| a2t3_func_addr_insn
,
4313 s
->contents
+ my_offset
+ 8);
4317 BFD_ASSERT (my_offset
<= globals
->arm_glue_size
);
4322 /* Arm code calling a Thumb function. */
4325 elf32_arm_to_thumb_stub (struct bfd_link_info
* info
,
4329 asection
* input_section
,
4330 bfd_byte
* hit_data
,
4333 bfd_signed_vma addend
,
4335 char **error_message
)
4337 unsigned long int tmp
;
4340 long int ret_offset
;
4341 struct elf_link_hash_entry
* myh
;
4342 struct elf32_arm_link_hash_table
* globals
;
4344 globals
= elf32_arm_hash_table (info
);
4346 BFD_ASSERT (globals
!= NULL
);
4347 BFD_ASSERT (globals
->bfd_of_glue_owner
!= NULL
);
4349 s
= bfd_get_section_by_name (globals
->bfd_of_glue_owner
,
4350 ARM2THUMB_GLUE_SECTION_NAME
);
4351 BFD_ASSERT (s
!= NULL
);
4352 BFD_ASSERT (s
->contents
!= NULL
);
4353 BFD_ASSERT (s
->output_section
!= NULL
);
4355 myh
= elf32_arm_create_thumb_stub (info
, name
, input_bfd
, output_bfd
,
4356 sym_sec
, val
, s
, error_message
);
4360 my_offset
= myh
->root
.u
.def
.value
;
4361 tmp
= bfd_get_32 (input_bfd
, hit_data
);
4362 tmp
= tmp
& 0xFF000000;
4364 /* Somehow these are both 4 too far, so subtract 8. */
4365 ret_offset
= (s
->output_offset
4367 + s
->output_section
->vma
4368 - (input_section
->output_offset
4369 + input_section
->output_section
->vma
4373 tmp
= tmp
| ((ret_offset
>> 2) & 0x00FFFFFF);
4375 bfd_put_32 (output_bfd
, (bfd_vma
) tmp
, hit_data
- input_section
->vma
);
4380 /* Populate Arm stub for an exported Thumb function. */
4383 elf32_arm_to_thumb_export_stub (struct elf_link_hash_entry
*h
, void * inf
)
4385 struct bfd_link_info
* info
= (struct bfd_link_info
*) inf
;
4387 struct elf_link_hash_entry
* myh
;
4388 struct elf32_arm_link_hash_entry
*eh
;
4389 struct elf32_arm_link_hash_table
* globals
;
4392 char *error_message
;
4394 eh
= elf32_arm_hash_entry(h
);
4395 /* Allocate stubs for exported Thumb functions on v4t. */
4396 if (eh
->export_glue
== NULL
)
4399 globals
= elf32_arm_hash_table (info
);
4401 BFD_ASSERT (globals
!= NULL
);
4402 BFD_ASSERT (globals
->bfd_of_glue_owner
!= NULL
);
4404 s
= bfd_get_section_by_name (globals
->bfd_of_glue_owner
,
4405 ARM2THUMB_GLUE_SECTION_NAME
);
4406 BFD_ASSERT (s
!= NULL
);
4407 BFD_ASSERT (s
->contents
!= NULL
);
4408 BFD_ASSERT (s
->output_section
!= NULL
);
4410 sec
= eh
->export_glue
->root
.u
.def
.section
;
4412 BFD_ASSERT (sec
->output_section
!= NULL
);
4414 val
= eh
->export_glue
->root
.u
.def
.value
+ sec
->output_offset
4415 + sec
->output_section
->vma
;
4416 myh
= elf32_arm_create_thumb_stub (info
, h
->root
.root
.string
,
4417 h
->root
.u
.def
.section
->owner
,
4418 globals
->obfd
, sec
, val
, s
,
4424 /* Populate ARMv4 BX veneers. Returns the absolute adress of the veneer. */
4427 elf32_arm_bx_glue (struct bfd_link_info
* info
, int reg
)
4432 struct elf32_arm_link_hash_table
*globals
;
4434 globals
= elf32_arm_hash_table (info
);
4436 BFD_ASSERT (globals
!= NULL
);
4437 BFD_ASSERT (globals
->bfd_of_glue_owner
!= NULL
);
4439 s
= bfd_get_section_by_name (globals
->bfd_of_glue_owner
,
4440 ARM_BX_GLUE_SECTION_NAME
);
4441 BFD_ASSERT (s
!= NULL
);
4442 BFD_ASSERT (s
->contents
!= NULL
);
4443 BFD_ASSERT (s
->output_section
!= NULL
);
4445 BFD_ASSERT (globals
->bx_glue_offset
[reg
] & 2);
4447 glue_addr
= globals
->bx_glue_offset
[reg
] & ~(bfd_vma
)3;
4449 if ((globals
->bx_glue_offset
[reg
] & 1) == 0)
4451 p
= s
->contents
+ glue_addr
;
4452 bfd_put_32 (globals
->obfd
, armbx1_tst_insn
+ (reg
<< 16), p
);
4453 bfd_put_32 (globals
->obfd
, armbx2_moveq_insn
+ reg
, p
+ 4);
4454 bfd_put_32 (globals
->obfd
, armbx3_bx_insn
+ reg
, p
+ 8);
4455 globals
->bx_glue_offset
[reg
] |= 1;
4458 return glue_addr
+ s
->output_section
->vma
+ s
->output_offset
;
4461 /* Generate Arm stubs for exported Thumb symbols. */
4463 elf32_arm_begin_write_processing (bfd
*abfd ATTRIBUTE_UNUSED
,
4464 struct bfd_link_info
*link_info
)
4466 struct elf32_arm_link_hash_table
* globals
;
4471 globals
= elf32_arm_hash_table (link_info
);
4472 /* If blx is available then exported Thumb symbols are OK and there is
4474 if (globals
->use_blx
)
4477 elf_link_hash_traverse (&globals
->root
, elf32_arm_to_thumb_export_stub
,
4481 /* Some relocations map to different relocations depending on the
4482 target. Return the real relocation. */
4484 arm_real_reloc_type (struct elf32_arm_link_hash_table
* globals
,
4490 if (globals
->target1_is_rel
)
4496 return globals
->target2_reloc
;
4503 /* Return the base VMA address which should be subtracted from real addresses
4504 when resolving @dtpoff relocation.
4505 This is PT_TLS segment p_vaddr. */
4508 dtpoff_base (struct bfd_link_info
*info
)
4510 /* If tls_sec is NULL, we should have signalled an error already. */
4511 if (elf_hash_table (info
)->tls_sec
== NULL
)
4513 return elf_hash_table (info
)->tls_sec
->vma
;
4516 /* Return the relocation value for @tpoff relocation
4517 if STT_TLS virtual address is ADDRESS. */
4520 tpoff (struct bfd_link_info
*info
, bfd_vma address
)
4522 struct elf_link_hash_table
*htab
= elf_hash_table (info
);
4525 /* If tls_sec is NULL, we should have signalled an error already. */
4526 if (htab
->tls_sec
== NULL
)
4528 base
= align_power ((bfd_vma
) TCB_SIZE
, htab
->tls_sec
->alignment_power
);
4529 return address
- htab
->tls_sec
->vma
+ base
;
4532 /* Perform an R_ARM_ABS12 relocation on the field pointed to by DATA.
4533 VALUE is the relocation value. */
4535 static bfd_reloc_status_type
4536 elf32_arm_abs12_reloc (bfd
*abfd
, void *data
, bfd_vma value
)
4539 return bfd_reloc_overflow
;
4541 value
|= bfd_get_32 (abfd
, data
) & 0xfffff000;
4542 bfd_put_32 (abfd
, value
, data
);
4543 return bfd_reloc_ok
;
4546 /* For a given value of n, calculate the value of G_n as required to
4547 deal with group relocations. We return it in the form of an
4548 encoded constant-and-rotation, together with the final residual. If n is
4549 specified as less than zero, then final_residual is filled with the
4550 input value and no further action is performed. */
4553 calculate_group_reloc_mask (bfd_vma value
, int n
, bfd_vma
*final_residual
)
4557 bfd_vma encoded_g_n
= 0;
4558 bfd_vma residual
= value
; /* Also known as Y_n. */
4560 for (current_n
= 0; current_n
<= n
; current_n
++)
4564 /* Calculate which part of the value to mask. */
4571 /* Determine the most significant bit in the residual and
4572 align the resulting value to a 2-bit boundary. */
4573 for (msb
= 30; msb
>= 0; msb
-= 2)
4574 if (residual
& (3 << msb
))
4577 /* The desired shift is now (msb - 6), or zero, whichever
4584 /* Calculate g_n in 32-bit as well as encoded constant+rotation form. */
4585 g_n
= residual
& (0xff << shift
);
4586 encoded_g_n
= (g_n
>> shift
)
4587 | ((g_n
<= 0xff ? 0 : (32 - shift
) / 2) << 8);
4589 /* Calculate the residual for the next time around. */
4593 *final_residual
= residual
;
4598 /* Given an ARM instruction, determine whether it is an ADD or a SUB.
4599 Returns 1 if it is an ADD, -1 if it is a SUB, and 0 otherwise. */
4601 identify_add_or_sub(bfd_vma insn
)
4603 int opcode
= insn
& 0x1e00000;
4605 if (opcode
== 1 << 23) /* ADD */
4608 if (opcode
== 1 << 22) /* SUB */
4614 /* Determine if we're dealing with a Thumb-2 object. */
4616 static int using_thumb2 (struct elf32_arm_link_hash_table
*globals
)
4618 int arch
= bfd_elf_get_obj_attr_int (globals
->obfd
, OBJ_ATTR_PROC
,
4620 return arch
== TAG_CPU_ARCH_V6T2
|| arch
>= TAG_CPU_ARCH_V7
;
4623 /* Perform a relocation as part of a final link. */
4625 static bfd_reloc_status_type
4626 elf32_arm_final_link_relocate (reloc_howto_type
* howto
,
4629 asection
* input_section
,
4630 bfd_byte
* contents
,
4631 Elf_Internal_Rela
* rel
,
4633 struct bfd_link_info
* info
,
4635 const char * sym_name
,
4637 struct elf_link_hash_entry
* h
,
4638 bfd_boolean
* unresolved_reloc_p
,
4639 char **error_message
)
4641 unsigned long r_type
= howto
->type
;
4642 unsigned long r_symndx
;
4643 bfd_byte
* hit_data
= contents
+ rel
->r_offset
;
4644 bfd
* dynobj
= NULL
;
4645 Elf_Internal_Shdr
* symtab_hdr
;
4646 struct elf_link_hash_entry
** sym_hashes
;
4647 bfd_vma
* local_got_offsets
;
4648 asection
* sgot
= NULL
;
4649 asection
* splt
= NULL
;
4650 asection
* sreloc
= NULL
;
4652 bfd_signed_vma signed_addend
;
4653 struct elf32_arm_link_hash_table
* globals
;
4655 globals
= elf32_arm_hash_table (info
);
4657 BFD_ASSERT (is_arm_elf (input_bfd
));
4659 /* Some relocation types map to different relocations depending on the
4660 target. We pick the right one here. */
4661 r_type
= arm_real_reloc_type (globals
, r_type
);
4662 if (r_type
!= howto
->type
)
4663 howto
= elf32_arm_howto_from_type (r_type
);
4665 /* If the start address has been set, then set the EF_ARM_HASENTRY
4666 flag. Setting this more than once is redundant, but the cost is
4667 not too high, and it keeps the code simple.
4669 The test is done here, rather than somewhere else, because the
4670 start address is only set just before the final link commences.
4672 Note - if the user deliberately sets a start address of 0, the
4673 flag will not be set. */
4674 if (bfd_get_start_address (output_bfd
) != 0)
4675 elf_elfheader (output_bfd
)->e_flags
|= EF_ARM_HASENTRY
;
4677 dynobj
= elf_hash_table (info
)->dynobj
;
4680 sgot
= bfd_get_section_by_name (dynobj
, ".got");
4681 splt
= bfd_get_section_by_name (dynobj
, ".plt");
4683 symtab_hdr
= & elf_symtab_hdr (input_bfd
);
4684 sym_hashes
= elf_sym_hashes (input_bfd
);
4685 local_got_offsets
= elf_local_got_offsets (input_bfd
);
4686 r_symndx
= ELF32_R_SYM (rel
->r_info
);
4688 if (globals
->use_rel
)
4690 addend
= bfd_get_32 (input_bfd
, hit_data
) & howto
->src_mask
;
4692 if (addend
& ((howto
->src_mask
+ 1) >> 1))
4695 signed_addend
&= ~ howto
->src_mask
;
4696 signed_addend
|= addend
;
4699 signed_addend
= addend
;
4702 addend
= signed_addend
= rel
->r_addend
;
4707 /* We don't need to find a value for this symbol. It's just a
4709 *unresolved_reloc_p
= FALSE
;
4710 return bfd_reloc_ok
;
4713 if (!globals
->vxworks_p
)
4714 return elf32_arm_abs12_reloc (input_bfd
, hit_data
, value
+ addend
);
4718 case R_ARM_ABS32_NOI
:
4720 case R_ARM_REL32_NOI
:
4726 /* Handle relocations which should use the PLT entry. ABS32/REL32
4727 will use the symbol's value, which may point to a PLT entry, but we
4728 don't need to handle that here. If we created a PLT entry, all
4729 branches in this object should go to it. */
4730 if ((r_type
!= R_ARM_ABS32
&& r_type
!= R_ARM_REL32
4731 && r_type
!= R_ARM_ABS32_NOI
&& r_type
!= R_ARM_REL32_NOI
)
4734 && h
->plt
.offset
!= (bfd_vma
) -1)
4736 /* If we've created a .plt section, and assigned a PLT entry to
4737 this function, it should not be known to bind locally. If
4738 it were, we would have cleared the PLT entry. */
4739 BFD_ASSERT (!SYMBOL_CALLS_LOCAL (info
, h
));
4741 value
= (splt
->output_section
->vma
4742 + splt
->output_offset
4744 *unresolved_reloc_p
= FALSE
;
4745 return _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
4746 contents
, rel
->r_offset
, value
,
4750 /* When generating a shared object or relocatable executable, these
4751 relocations are copied into the output file to be resolved at
4753 if ((info
->shared
|| globals
->root
.is_relocatable_executable
)
4754 && (input_section
->flags
& SEC_ALLOC
)
4755 && ((r_type
!= R_ARM_REL32
&& r_type
!= R_ARM_REL32_NOI
)
4756 || !SYMBOL_CALLS_LOCAL (info
, h
))
4758 || ELF_ST_VISIBILITY (h
->other
) == STV_DEFAULT
4759 || h
->root
.type
!= bfd_link_hash_undefweak
)
4760 && r_type
!= R_ARM_PC24
4761 && r_type
!= R_ARM_CALL
4762 && r_type
!= R_ARM_JUMP24
4763 && r_type
!= R_ARM_PREL31
4764 && r_type
!= R_ARM_PLT32
)
4766 Elf_Internal_Rela outrel
;
4768 bfd_boolean skip
, relocate
;
4770 *unresolved_reloc_p
= FALSE
;
4776 name
= (bfd_elf_string_from_elf_section
4778 elf_elfheader (input_bfd
)->e_shstrndx
,
4779 elf_section_data (input_section
)->rel_hdr
.sh_name
));
4781 return bfd_reloc_notsupported
;
4783 BFD_ASSERT (reloc_section_p (globals
, name
, input_section
));
4785 sreloc
= bfd_get_section_by_name (dynobj
, name
);
4786 BFD_ASSERT (sreloc
!= NULL
);
4792 outrel
.r_addend
= addend
;
4794 _bfd_elf_section_offset (output_bfd
, info
, input_section
,
4796 if (outrel
.r_offset
== (bfd_vma
) -1)
4798 else if (outrel
.r_offset
== (bfd_vma
) -2)
4799 skip
= TRUE
, relocate
= TRUE
;
4800 outrel
.r_offset
+= (input_section
->output_section
->vma
4801 + input_section
->output_offset
);
4804 memset (&outrel
, 0, sizeof outrel
);
4809 || !h
->def_regular
))
4810 outrel
.r_info
= ELF32_R_INFO (h
->dynindx
, r_type
);
4815 /* This symbol is local, or marked to become local. */
4816 if (sym_flags
== STT_ARM_TFUNC
)
4818 if (globals
->symbian_p
)
4822 /* On Symbian OS, the data segment and text segement
4823 can be relocated independently. Therefore, we
4824 must indicate the segment to which this
4825 relocation is relative. The BPABI allows us to
4826 use any symbol in the right segment; we just use
4827 the section symbol as it is convenient. (We
4828 cannot use the symbol given by "h" directly as it
4829 will not appear in the dynamic symbol table.)
4831 Note that the dynamic linker ignores the section
4832 symbol value, so we don't subtract osec->vma
4833 from the emitted reloc addend. */
4835 osec
= sym_sec
->output_section
;
4837 osec
= input_section
->output_section
;
4838 symbol
= elf_section_data (osec
)->dynindx
;
4841 struct elf_link_hash_table
*htab
= elf_hash_table (info
);
4843 if ((osec
->flags
& SEC_READONLY
) == 0
4844 && htab
->data_index_section
!= NULL
)
4845 osec
= htab
->data_index_section
;
4847 osec
= htab
->text_index_section
;
4848 symbol
= elf_section_data (osec
)->dynindx
;
4850 BFD_ASSERT (symbol
!= 0);
4853 /* On SVR4-ish systems, the dynamic loader cannot
4854 relocate the text and data segments independently,
4855 so the symbol does not matter. */
4857 outrel
.r_info
= ELF32_R_INFO (symbol
, R_ARM_RELATIVE
);
4858 if (globals
->use_rel
)
4861 outrel
.r_addend
+= value
;
4864 loc
= sreloc
->contents
;
4865 loc
+= sreloc
->reloc_count
++ * RELOC_SIZE (globals
);
4866 SWAP_RELOC_OUT (globals
) (output_bfd
, &outrel
, loc
);
4868 /* If this reloc is against an external symbol, we do not want to
4869 fiddle with the addend. Otherwise, we need to include the symbol
4870 value so that it becomes an addend for the dynamic reloc. */
4872 return bfd_reloc_ok
;
4874 return _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
4875 contents
, rel
->r_offset
, value
,
4878 else switch (r_type
)
4881 return elf32_arm_abs12_reloc (input_bfd
, hit_data
, value
+ addend
);
4883 case R_ARM_XPC25
: /* Arm BLX instruction. */
4886 case R_ARM_PC24
: /* Arm B/BL instruction */
4888 if (r_type
== R_ARM_XPC25
)
4890 /* Check for Arm calling Arm function. */
4891 /* FIXME: Should we translate the instruction into a BL
4892 instruction instead ? */
4893 if (sym_flags
!= STT_ARM_TFUNC
)
4894 (*_bfd_error_handler
)
4895 (_("\%B: Warning: Arm BLX instruction targets Arm function '%s'."),
4897 h
? h
->root
.root
.string
: "(local)");
4899 else if (r_type
!= R_ARM_CALL
|| !globals
->use_blx
)
4901 /* Check for Arm calling Thumb function. */
4902 if (sym_flags
== STT_ARM_TFUNC
)
4904 if (elf32_arm_to_thumb_stub (info
, sym_name
, input_bfd
,
4905 output_bfd
, input_section
,
4906 hit_data
, sym_sec
, rel
->r_offset
,
4907 signed_addend
, value
,
4909 return bfd_reloc_ok
;
4911 return bfd_reloc_dangerous
;
4915 /* The ARM ELF ABI says that this reloc is computed as: S - P + A
4917 S is the address of the symbol in the relocation.
4918 P is address of the instruction being relocated.
4919 A is the addend (extracted from the instruction) in bytes.
4921 S is held in 'value'.
4922 P is the base address of the section containing the
4923 instruction plus the offset of the reloc into that
4925 (input_section->output_section->vma +
4926 input_section->output_offset +
4928 A is the addend, converted into bytes, ie:
4931 Note: None of these operations have knowledge of the pipeline
4932 size of the processor, thus it is up to the assembler to
4933 encode this information into the addend. */
4934 value
-= (input_section
->output_section
->vma
4935 + input_section
->output_offset
);
4936 value
-= rel
->r_offset
;
4937 if (globals
->use_rel
)
4938 value
+= (signed_addend
<< howto
->size
);
4940 /* RELA addends do not have to be adjusted by howto->size. */
4941 value
+= signed_addend
;
4943 signed_addend
= value
;
4944 signed_addend
>>= howto
->rightshift
;
4946 /* A branch to an undefined weak symbol is turned into a jump to
4947 the next instruction. */
4948 if (h
&& h
->root
.type
== bfd_link_hash_undefweak
)
4950 value
= (bfd_get_32 (input_bfd
, hit_data
) & 0xf0000000)
4955 /* Perform a signed range check. */
4956 if ( signed_addend
> ((bfd_signed_vma
) (howto
->dst_mask
>> 1))
4957 || signed_addend
< - ((bfd_signed_vma
) ((howto
->dst_mask
+ 1) >> 1)))
4958 return bfd_reloc_overflow
;
4960 addend
= (value
& 2);
4962 value
= (signed_addend
& howto
->dst_mask
)
4963 | (bfd_get_32 (input_bfd
, hit_data
) & (~ howto
->dst_mask
));
4965 /* Set the H bit in the BLX instruction. */
4966 if (sym_flags
== STT_ARM_TFUNC
)
4971 value
&= ~(bfd_vma
)(1 << 24);
4973 if (r_type
== R_ARM_CALL
)
4975 /* Select the correct instruction (BL or BLX). */
4976 if (sym_flags
== STT_ARM_TFUNC
)
4980 value
&= ~(bfd_vma
)(1 << 28);
4989 if (sym_flags
== STT_ARM_TFUNC
)
4993 case R_ARM_ABS32_NOI
:
4999 if (sym_flags
== STT_ARM_TFUNC
)
5001 value
-= (input_section
->output_section
->vma
5002 + input_section
->output_offset
+ rel
->r_offset
);
5005 case R_ARM_REL32_NOI
:
5007 value
-= (input_section
->output_section
->vma
5008 + input_section
->output_offset
+ rel
->r_offset
);
5012 value
-= (input_section
->output_section
->vma
5013 + input_section
->output_offset
+ rel
->r_offset
);
5014 value
+= signed_addend
;
5015 if (! h
|| h
->root
.type
!= bfd_link_hash_undefweak
)
5017 /* Check for overflow */
5018 if ((value
^ (value
>> 1)) & (1 << 30))
5019 return bfd_reloc_overflow
;
5021 value
&= 0x7fffffff;
5022 value
|= (bfd_get_32 (input_bfd
, hit_data
) & 0x80000000);
5023 if (sym_flags
== STT_ARM_TFUNC
)
5028 bfd_put_32 (input_bfd
, value
, hit_data
);
5029 return bfd_reloc_ok
;
5033 if ((long) value
> 0x7f || (long) value
< -0x80)
5034 return bfd_reloc_overflow
;
5036 bfd_put_8 (input_bfd
, value
, hit_data
);
5037 return bfd_reloc_ok
;
5042 if ((long) value
> 0x7fff || (long) value
< -0x8000)
5043 return bfd_reloc_overflow
;
5045 bfd_put_16 (input_bfd
, value
, hit_data
);
5046 return bfd_reloc_ok
;
5048 case R_ARM_THM_ABS5
:
5049 /* Support ldr and str instructions for the thumb. */
5050 if (globals
->use_rel
)
5052 /* Need to refetch addend. */
5053 addend
= bfd_get_16 (input_bfd
, hit_data
) & howto
->src_mask
;
5054 /* ??? Need to determine shift amount from operand size. */
5055 addend
>>= howto
->rightshift
;
5059 /* ??? Isn't value unsigned? */
5060 if ((long) value
> 0x1f || (long) value
< -0x10)
5061 return bfd_reloc_overflow
;
5063 /* ??? Value needs to be properly shifted into place first. */
5064 value
|= bfd_get_16 (input_bfd
, hit_data
) & 0xf83f;
5065 bfd_put_16 (input_bfd
, value
, hit_data
);
5066 return bfd_reloc_ok
;
5068 case R_ARM_THM_ALU_PREL_11_0
:
5069 /* Corresponds to: addw.w reg, pc, #offset (and similarly for subw). */
5072 bfd_signed_vma relocation
;
5074 insn
= (bfd_get_16 (input_bfd
, hit_data
) << 16)
5075 | bfd_get_16 (input_bfd
, hit_data
+ 2);
5077 if (globals
->use_rel
)
5079 signed_addend
= (insn
& 0xff) | ((insn
& 0x7000) >> 4)
5080 | ((insn
& (1 << 26)) >> 15);
5081 if (insn
& 0xf00000)
5082 signed_addend
= -signed_addend
;
5085 relocation
= value
+ signed_addend
;
5086 relocation
-= (input_section
->output_section
->vma
5087 + input_section
->output_offset
5090 value
= abs (relocation
);
5092 if (value
>= 0x1000)
5093 return bfd_reloc_overflow
;
5095 insn
= (insn
& 0xfb0f8f00) | (value
& 0xff)
5096 | ((value
& 0x700) << 4)
5097 | ((value
& 0x800) << 15);
5101 bfd_put_16 (input_bfd
, insn
>> 16, hit_data
);
5102 bfd_put_16 (input_bfd
, insn
& 0xffff, hit_data
+ 2);
5104 return bfd_reloc_ok
;
5107 case R_ARM_THM_PC12
:
5108 /* Corresponds to: ldr.w reg, [pc, #offset]. */
5111 bfd_signed_vma relocation
;
5113 insn
= (bfd_get_16 (input_bfd
, hit_data
) << 16)
5114 | bfd_get_16 (input_bfd
, hit_data
+ 2);
5116 if (globals
->use_rel
)
5118 signed_addend
= insn
& 0xfff;
5119 if (!(insn
& (1 << 23)))
5120 signed_addend
= -signed_addend
;
5123 relocation
= value
+ signed_addend
;
5124 relocation
-= (input_section
->output_section
->vma
5125 + input_section
->output_offset
5128 value
= abs (relocation
);
5130 if (value
>= 0x1000)
5131 return bfd_reloc_overflow
;
5133 insn
= (insn
& 0xff7ff000) | value
;
5134 if (relocation
>= 0)
5137 bfd_put_16 (input_bfd
, insn
>> 16, hit_data
);
5138 bfd_put_16 (input_bfd
, insn
& 0xffff, hit_data
+ 2);
5140 return bfd_reloc_ok
;
5143 case R_ARM_THM_XPC22
:
5144 case R_ARM_THM_CALL
:
5145 case R_ARM_THM_JUMP24
:
5146 /* Thumb BL (branch long instruction). */
5150 bfd_boolean overflow
= FALSE
;
5151 bfd_vma upper_insn
= bfd_get_16 (input_bfd
, hit_data
);
5152 bfd_vma lower_insn
= bfd_get_16 (input_bfd
, hit_data
+ 2);
5153 bfd_signed_vma reloc_signed_max
;
5154 bfd_signed_vma reloc_signed_min
;
5156 bfd_signed_vma signed_check
;
5158 int thumb2
= using_thumb2 (globals
);
5160 /* A branch to an undefined weak symbol is turned into a jump to
5161 the next instruction. */
5162 if (h
&& h
->root
.type
== bfd_link_hash_undefweak
)
5164 bfd_put_16 (input_bfd
, 0xe000, hit_data
);
5165 bfd_put_16 (input_bfd
, 0xbf00, hit_data
+ 2);
5166 return bfd_reloc_ok
;
5169 /* Fetch the addend. We use the Thumb-2 encoding (backwards compatible
5170 with Thumb-1) involving the J1 and J2 bits. */
5171 if (globals
->use_rel
)
5173 bfd_vma s
= (upper_insn
& (1 << 10)) >> 10;
5174 bfd_vma upper
= upper_insn
& 0x3ff;
5175 bfd_vma lower
= lower_insn
& 0x7ff;
5176 bfd_vma j1
= (lower_insn
& (1 << 13)) >> 13;
5177 bfd_vma j2
= (lower_insn
& (1 << 11)) >> 11;
5178 bfd_vma i1
= j1
^ s
? 0 : 1;
5179 bfd_vma i2
= j2
^ s
? 0 : 1;
5181 addend
= (i1
<< 23) | (i2
<< 22) | (upper
<< 12) | (lower
<< 1);
5183 addend
= (addend
| ((s
? 0 : 1) << 24)) - (1 << 24);
5185 signed_addend
= addend
;
5188 if (r_type
== R_ARM_THM_XPC22
)
5190 /* Check for Thumb to Thumb call. */
5191 /* FIXME: Should we translate the instruction into a BL
5192 instruction instead ? */
5193 if (sym_flags
== STT_ARM_TFUNC
)
5194 (*_bfd_error_handler
)
5195 (_("%B: Warning: Thumb BLX instruction targets thumb function '%s'."),
5197 h
? h
->root
.root
.string
: "(local)");
5201 /* If it is not a call to Thumb, assume call to Arm.
5202 If it is a call relative to a section name, then it is not a
5203 function call at all, but rather a long jump. Calls through
5204 the PLT do not require stubs. */
5205 if (sym_flags
!= STT_ARM_TFUNC
&& sym_flags
!= STT_SECTION
5206 && (h
== NULL
|| splt
== NULL
5207 || h
->plt
.offset
== (bfd_vma
) -1))
5209 if (globals
->use_blx
&& r_type
== R_ARM_THM_CALL
)
5211 /* Convert BL to BLX. */
5212 lower_insn
= (lower_insn
& ~0x1000) | 0x0800;
5214 else if (elf32_thumb_to_arm_stub
5215 (info
, sym_name
, input_bfd
, output_bfd
, input_section
,
5216 hit_data
, sym_sec
, rel
->r_offset
, signed_addend
, value
,
5218 return bfd_reloc_ok
;
5220 return bfd_reloc_dangerous
;
5222 else if (sym_flags
== STT_ARM_TFUNC
&& globals
->use_blx
5223 && r_type
== R_ARM_THM_CALL
)
5225 /* Make sure this is a BL. */
5226 lower_insn
|= 0x1800;
5230 /* Handle calls via the PLT. */
5231 if (h
!= NULL
&& splt
!= NULL
&& h
->plt
.offset
!= (bfd_vma
) -1)
5233 value
= (splt
->output_section
->vma
5234 + splt
->output_offset
5236 if (globals
->use_blx
&& r_type
== R_ARM_THM_CALL
)
5238 /* If the Thumb BLX instruction is available, convert the
5239 BL to a BLX instruction to call the ARM-mode PLT entry. */
5240 lower_insn
= (lower_insn
& ~0x1000) | 0x0800;
5243 /* Target the Thumb stub before the ARM PLT entry. */
5244 value
-= PLT_THUMB_STUB_SIZE
;
5245 *unresolved_reloc_p
= FALSE
;
5248 relocation
= value
+ signed_addend
;
5250 relocation
-= (input_section
->output_section
->vma
5251 + input_section
->output_offset
5254 check
= relocation
>> howto
->rightshift
;
5256 /* If this is a signed value, the rightshift just dropped
5257 leading 1 bits (assuming twos complement). */
5258 if ((bfd_signed_vma
) relocation
>= 0)
5259 signed_check
= check
;
5261 signed_check
= check
| ~((bfd_vma
) -1 >> howto
->rightshift
);
5263 /* Calculate the permissable maximum and minimum values for
5264 this relocation according to whether we're relocating for
5266 bitsize
= howto
->bitsize
;
5269 reloc_signed_max
= ((1 << (bitsize
- 1)) - 1) >> howto
->rightshift
;
5270 reloc_signed_min
= ~reloc_signed_max
;
5272 /* Assumes two's complement. */
5273 if (signed_check
> reloc_signed_max
|| signed_check
< reloc_signed_min
)
5276 if ((lower_insn
& 0x5000) == 0x4000)
5277 /* For a BLX instruction, make sure that the relocation is rounded up
5278 to a word boundary. This follows the semantics of the instruction
5279 which specifies that bit 1 of the target address will come from bit
5280 1 of the base address. */
5281 relocation
= (relocation
+ 2) & ~ 3;
5283 /* Put RELOCATION back into the insn. Assumes two's complement.
5284 We use the Thumb-2 encoding, which is safe even if dealing with
5285 a Thumb-1 instruction by virtue of our overflow check above. */
5286 reloc_sign
= (signed_check
< 0) ? 1 : 0;
5287 upper_insn
= (upper_insn
& ~(bfd_vma
) 0x7ff)
5288 | ((relocation
>> 12) & 0x3ff)
5289 | (reloc_sign
<< 10);
5290 lower_insn
= (lower_insn
& ~(bfd_vma
) 0x2fff)
5291 | (((!((relocation
>> 23) & 1)) ^ reloc_sign
) << 13)
5292 | (((!((relocation
>> 22) & 1)) ^ reloc_sign
) << 11)
5293 | ((relocation
>> 1) & 0x7ff);
5295 /* Put the relocated value back in the object file: */
5296 bfd_put_16 (input_bfd
, upper_insn
, hit_data
);
5297 bfd_put_16 (input_bfd
, lower_insn
, hit_data
+ 2);
5299 return (overflow
? bfd_reloc_overflow
: bfd_reloc_ok
);
5303 case R_ARM_THM_JUMP19
:
5304 /* Thumb32 conditional branch instruction. */
5307 bfd_boolean overflow
= FALSE
;
5308 bfd_vma upper_insn
= bfd_get_16 (input_bfd
, hit_data
);
5309 bfd_vma lower_insn
= bfd_get_16 (input_bfd
, hit_data
+ 2);
5310 bfd_signed_vma reloc_signed_max
= 0xffffe;
5311 bfd_signed_vma reloc_signed_min
= -0x100000;
5312 bfd_signed_vma signed_check
;
5314 /* Need to refetch the addend, reconstruct the top three bits,
5315 and squish the two 11 bit pieces together. */
5316 if (globals
->use_rel
)
5318 bfd_vma S
= (upper_insn
& 0x0400) >> 10;
5319 bfd_vma upper
= (upper_insn
& 0x003f);
5320 bfd_vma J1
= (lower_insn
& 0x2000) >> 13;
5321 bfd_vma J2
= (lower_insn
& 0x0800) >> 11;
5322 bfd_vma lower
= (lower_insn
& 0x07ff);
5327 upper
-= 0x0100; /* Sign extend. */
5329 addend
= (upper
<< 12) | (lower
<< 1);
5330 signed_addend
= addend
;
5333 /* Handle calls via the PLT. */
5334 if (h
!= NULL
&& splt
!= NULL
&& h
->plt
.offset
!= (bfd_vma
) -1)
5336 value
= (splt
->output_section
->vma
5337 + splt
->output_offset
5339 /* Target the Thumb stub before the ARM PLT entry. */
5340 value
-= PLT_THUMB_STUB_SIZE
;
5341 *unresolved_reloc_p
= FALSE
;
5344 /* ??? Should handle interworking? GCC might someday try to
5345 use this for tail calls. */
5347 relocation
= value
+ signed_addend
;
5348 relocation
-= (input_section
->output_section
->vma
5349 + input_section
->output_offset
5351 signed_check
= (bfd_signed_vma
) relocation
;
5353 if (signed_check
> reloc_signed_max
|| signed_check
< reloc_signed_min
)
5356 /* Put RELOCATION back into the insn. */
5358 bfd_vma S
= (relocation
& 0x00100000) >> 20;
5359 bfd_vma J2
= (relocation
& 0x00080000) >> 19;
5360 bfd_vma J1
= (relocation
& 0x00040000) >> 18;
5361 bfd_vma hi
= (relocation
& 0x0003f000) >> 12;
5362 bfd_vma lo
= (relocation
& 0x00000ffe) >> 1;
5364 upper_insn
= (upper_insn
& 0xfbc0) | (S
<< 10) | hi
;
5365 lower_insn
= (lower_insn
& 0xd000) | (J1
<< 13) | (J2
<< 11) | lo
;
5368 /* Put the relocated value back in the object file: */
5369 bfd_put_16 (input_bfd
, upper_insn
, hit_data
);
5370 bfd_put_16 (input_bfd
, lower_insn
, hit_data
+ 2);
5372 return (overflow
? bfd_reloc_overflow
: bfd_reloc_ok
);
5375 case R_ARM_THM_JUMP11
:
5376 case R_ARM_THM_JUMP8
:
5377 case R_ARM_THM_JUMP6
:
5378 /* Thumb B (branch) instruction). */
5380 bfd_signed_vma relocation
;
5381 bfd_signed_vma reloc_signed_max
= (1 << (howto
->bitsize
- 1)) - 1;
5382 bfd_signed_vma reloc_signed_min
= ~ reloc_signed_max
;
5383 bfd_signed_vma signed_check
;
5385 /* CZB cannot jump backward. */
5386 if (r_type
== R_ARM_THM_JUMP6
)
5387 reloc_signed_min
= 0;
5389 if (globals
->use_rel
)
5391 /* Need to refetch addend. */
5392 addend
= bfd_get_16 (input_bfd
, hit_data
) & howto
->src_mask
;
5393 if (addend
& ((howto
->src_mask
+ 1) >> 1))
5396 signed_addend
&= ~ howto
->src_mask
;
5397 signed_addend
|= addend
;
5400 signed_addend
= addend
;
5401 /* The value in the insn has been right shifted. We need to
5402 undo this, so that we can perform the address calculation
5403 in terms of bytes. */
5404 signed_addend
<<= howto
->rightshift
;
5406 relocation
= value
+ signed_addend
;
5408 relocation
-= (input_section
->output_section
->vma
5409 + input_section
->output_offset
5412 relocation
>>= howto
->rightshift
;
5413 signed_check
= relocation
;
5415 if (r_type
== R_ARM_THM_JUMP6
)
5416 relocation
= ((relocation
& 0x0020) << 4) | ((relocation
& 0x001f) << 3);
5418 relocation
&= howto
->dst_mask
;
5419 relocation
|= (bfd_get_16 (input_bfd
, hit_data
) & (~ howto
->dst_mask
));
5421 bfd_put_16 (input_bfd
, relocation
, hit_data
);
5423 /* Assumes two's complement. */
5424 if (signed_check
> reloc_signed_max
|| signed_check
< reloc_signed_min
)
5425 return bfd_reloc_overflow
;
5427 return bfd_reloc_ok
;
5430 case R_ARM_ALU_PCREL7_0
:
5431 case R_ARM_ALU_PCREL15_8
:
5432 case R_ARM_ALU_PCREL23_15
:
5437 insn
= bfd_get_32 (input_bfd
, hit_data
);
5438 if (globals
->use_rel
)
5440 /* Extract the addend. */
5441 addend
= (insn
& 0xff) << ((insn
& 0xf00) >> 7);
5442 signed_addend
= addend
;
5444 relocation
= value
+ signed_addend
;
5446 relocation
-= (input_section
->output_section
->vma
5447 + input_section
->output_offset
5449 insn
= (insn
& ~0xfff)
5450 | ((howto
->bitpos
<< 7) & 0xf00)
5451 | ((relocation
>> howto
->bitpos
) & 0xff);
5452 bfd_put_32 (input_bfd
, value
, hit_data
);
5454 return bfd_reloc_ok
;
5456 case R_ARM_GNU_VTINHERIT
:
5457 case R_ARM_GNU_VTENTRY
:
5458 return bfd_reloc_ok
;
5460 case R_ARM_GOTOFF32
:
5461 /* Relocation is relative to the start of the
5462 global offset table. */
5464 BFD_ASSERT (sgot
!= NULL
);
5466 return bfd_reloc_notsupported
;
5468 /* If we are addressing a Thumb function, we need to adjust the
5469 address by one, so that attempts to call the function pointer will
5470 correctly interpret it as Thumb code. */
5471 if (sym_flags
== STT_ARM_TFUNC
)
5474 /* Note that sgot->output_offset is not involved in this
5475 calculation. We always want the start of .got. If we
5476 define _GLOBAL_OFFSET_TABLE in a different way, as is
5477 permitted by the ABI, we might have to change this
5479 value
-= sgot
->output_section
->vma
;
5480 return _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
5481 contents
, rel
->r_offset
, value
,
5485 /* Use global offset table as symbol value. */
5486 BFD_ASSERT (sgot
!= NULL
);
5489 return bfd_reloc_notsupported
;
5491 *unresolved_reloc_p
= FALSE
;
5492 value
= sgot
->output_section
->vma
;
5493 return _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
5494 contents
, rel
->r_offset
, value
,
5498 case R_ARM_GOT_PREL
:
5499 /* Relocation is to the entry for this symbol in the
5500 global offset table. */
5502 return bfd_reloc_notsupported
;
5509 off
= h
->got
.offset
;
5510 BFD_ASSERT (off
!= (bfd_vma
) -1);
5511 dyn
= globals
->root
.dynamic_sections_created
;
5513 if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn
, info
->shared
, h
)
5515 && SYMBOL_REFERENCES_LOCAL (info
, h
))
5516 || (ELF_ST_VISIBILITY (h
->other
)
5517 && h
->root
.type
== bfd_link_hash_undefweak
))
5519 /* This is actually a static link, or it is a -Bsymbolic link
5520 and the symbol is defined locally. We must initialize this
5521 entry in the global offset table. Since the offset must
5522 always be a multiple of 4, we use the least significant bit
5523 to record whether we have initialized it already.
5525 When doing a dynamic link, we create a .rel(a).got relocation
5526 entry to initialize the value. This is done in the
5527 finish_dynamic_symbol routine. */
5532 /* If we are addressing a Thumb function, we need to
5533 adjust the address by one, so that attempts to
5534 call the function pointer will correctly
5535 interpret it as Thumb code. */
5536 if (sym_flags
== STT_ARM_TFUNC
)
5539 bfd_put_32 (output_bfd
, value
, sgot
->contents
+ off
);
5544 *unresolved_reloc_p
= FALSE
;
5546 value
= sgot
->output_offset
+ off
;
5552 BFD_ASSERT (local_got_offsets
!= NULL
&&
5553 local_got_offsets
[r_symndx
] != (bfd_vma
) -1);
5555 off
= local_got_offsets
[r_symndx
];
5557 /* The offset must always be a multiple of 4. We use the
5558 least significant bit to record whether we have already
5559 generated the necessary reloc. */
5564 /* If we are addressing a Thumb function, we need to
5565 adjust the address by one, so that attempts to
5566 call the function pointer will correctly
5567 interpret it as Thumb code. */
5568 if (sym_flags
== STT_ARM_TFUNC
)
5571 if (globals
->use_rel
)
5572 bfd_put_32 (output_bfd
, value
, sgot
->contents
+ off
);
5577 Elf_Internal_Rela outrel
;
5580 srelgot
= (bfd_get_section_by_name
5581 (dynobj
, RELOC_SECTION (globals
, ".got")));
5582 BFD_ASSERT (srelgot
!= NULL
);
5584 outrel
.r_addend
= addend
+ value
;
5585 outrel
.r_offset
= (sgot
->output_section
->vma
5586 + sgot
->output_offset
5588 outrel
.r_info
= ELF32_R_INFO (0, R_ARM_RELATIVE
);
5589 loc
= srelgot
->contents
;
5590 loc
+= srelgot
->reloc_count
++ * RELOC_SIZE (globals
);
5591 SWAP_RELOC_OUT (globals
) (output_bfd
, &outrel
, loc
);
5594 local_got_offsets
[r_symndx
] |= 1;
5597 value
= sgot
->output_offset
+ off
;
5599 if (r_type
!= R_ARM_GOT32
)
5600 value
+= sgot
->output_section
->vma
;
5602 return _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
5603 contents
, rel
->r_offset
, value
,
5606 case R_ARM_TLS_LDO32
:
5607 value
= value
- dtpoff_base (info
);
5609 return _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
5610 contents
, rel
->r_offset
, value
,
5613 case R_ARM_TLS_LDM32
:
5617 if (globals
->sgot
== NULL
)
5620 off
= globals
->tls_ldm_got
.offset
;
5626 /* If we don't know the module number, create a relocation
5630 Elf_Internal_Rela outrel
;
5633 if (globals
->srelgot
== NULL
)
5636 outrel
.r_addend
= 0;
5637 outrel
.r_offset
= (globals
->sgot
->output_section
->vma
5638 + globals
->sgot
->output_offset
+ off
);
5639 outrel
.r_info
= ELF32_R_INFO (0, R_ARM_TLS_DTPMOD32
);
5641 if (globals
->use_rel
)
5642 bfd_put_32 (output_bfd
, outrel
.r_addend
,
5643 globals
->sgot
->contents
+ off
);
5645 loc
= globals
->srelgot
->contents
;
5646 loc
+= globals
->srelgot
->reloc_count
++ * RELOC_SIZE (globals
);
5647 SWAP_RELOC_OUT (globals
) (output_bfd
, &outrel
, loc
);
5650 bfd_put_32 (output_bfd
, 1, globals
->sgot
->contents
+ off
);
5652 globals
->tls_ldm_got
.offset
|= 1;
5655 value
= globals
->sgot
->output_section
->vma
+ globals
->sgot
->output_offset
+ off
5656 - (input_section
->output_section
->vma
+ input_section
->output_offset
+ rel
->r_offset
);
5658 return _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
5659 contents
, rel
->r_offset
, value
,
5663 case R_ARM_TLS_GD32
:
5664 case R_ARM_TLS_IE32
:
5670 if (globals
->sgot
== NULL
)
5677 dyn
= globals
->root
.dynamic_sections_created
;
5678 if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn
, info
->shared
, h
)
5680 || !SYMBOL_REFERENCES_LOCAL (info
, h
)))
5682 *unresolved_reloc_p
= FALSE
;
5685 off
= h
->got
.offset
;
5686 tls_type
= ((struct elf32_arm_link_hash_entry
*) h
)->tls_type
;
5690 if (local_got_offsets
== NULL
)
5692 off
= local_got_offsets
[r_symndx
];
5693 tls_type
= elf32_arm_local_got_tls_type (input_bfd
)[r_symndx
];
5696 if (tls_type
== GOT_UNKNOWN
)
5703 bfd_boolean need_relocs
= FALSE
;
5704 Elf_Internal_Rela outrel
;
5705 bfd_byte
*loc
= NULL
;
5708 /* The GOT entries have not been initialized yet. Do it
5709 now, and emit any relocations. If both an IE GOT and a
5710 GD GOT are necessary, we emit the GD first. */
5712 if ((info
->shared
|| indx
!= 0)
5714 || ELF_ST_VISIBILITY (h
->other
) == STV_DEFAULT
5715 || h
->root
.type
!= bfd_link_hash_undefweak
))
5718 if (globals
->srelgot
== NULL
)
5720 loc
= globals
->srelgot
->contents
;
5721 loc
+= globals
->srelgot
->reloc_count
* RELOC_SIZE (globals
);
5724 if (tls_type
& GOT_TLS_GD
)
5728 outrel
.r_addend
= 0;
5729 outrel
.r_offset
= (globals
->sgot
->output_section
->vma
5730 + globals
->sgot
->output_offset
5732 outrel
.r_info
= ELF32_R_INFO (indx
, R_ARM_TLS_DTPMOD32
);
5734 if (globals
->use_rel
)
5735 bfd_put_32 (output_bfd
, outrel
.r_addend
,
5736 globals
->sgot
->contents
+ cur_off
);
5738 SWAP_RELOC_OUT (globals
) (output_bfd
, &outrel
, loc
);
5739 globals
->srelgot
->reloc_count
++;
5740 loc
+= RELOC_SIZE (globals
);
5743 bfd_put_32 (output_bfd
, value
- dtpoff_base (info
),
5744 globals
->sgot
->contents
+ cur_off
+ 4);
5747 outrel
.r_addend
= 0;
5748 outrel
.r_info
= ELF32_R_INFO (indx
,
5749 R_ARM_TLS_DTPOFF32
);
5750 outrel
.r_offset
+= 4;
5752 if (globals
->use_rel
)
5753 bfd_put_32 (output_bfd
, outrel
.r_addend
,
5754 globals
->sgot
->contents
+ cur_off
+ 4);
5757 SWAP_RELOC_OUT (globals
) (output_bfd
, &outrel
, loc
);
5758 globals
->srelgot
->reloc_count
++;
5759 loc
+= RELOC_SIZE (globals
);
5764 /* If we are not emitting relocations for a
5765 general dynamic reference, then we must be in a
5766 static link or an executable link with the
5767 symbol binding locally. Mark it as belonging
5768 to module 1, the executable. */
5769 bfd_put_32 (output_bfd
, 1,
5770 globals
->sgot
->contents
+ cur_off
);
5771 bfd_put_32 (output_bfd
, value
- dtpoff_base (info
),
5772 globals
->sgot
->contents
+ cur_off
+ 4);
5778 if (tls_type
& GOT_TLS_IE
)
5783 outrel
.r_addend
= value
- dtpoff_base (info
);
5785 outrel
.r_addend
= 0;
5786 outrel
.r_offset
= (globals
->sgot
->output_section
->vma
5787 + globals
->sgot
->output_offset
5789 outrel
.r_info
= ELF32_R_INFO (indx
, R_ARM_TLS_TPOFF32
);
5791 if (globals
->use_rel
)
5792 bfd_put_32 (output_bfd
, outrel
.r_addend
,
5793 globals
->sgot
->contents
+ cur_off
);
5795 SWAP_RELOC_OUT (globals
) (output_bfd
, &outrel
, loc
);
5796 globals
->srelgot
->reloc_count
++;
5797 loc
+= RELOC_SIZE (globals
);
5800 bfd_put_32 (output_bfd
, tpoff (info
, value
),
5801 globals
->sgot
->contents
+ cur_off
);
5808 local_got_offsets
[r_symndx
] |= 1;
5811 if ((tls_type
& GOT_TLS_GD
) && r_type
!= R_ARM_TLS_GD32
)
5813 value
= globals
->sgot
->output_section
->vma
+ globals
->sgot
->output_offset
+ off
5814 - (input_section
->output_section
->vma
+ input_section
->output_offset
+ rel
->r_offset
);
5816 return _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
5817 contents
, rel
->r_offset
, value
,
5821 case R_ARM_TLS_LE32
:
5824 (*_bfd_error_handler
)
5825 (_("%B(%A+0x%lx): R_ARM_TLS_LE32 relocation not permitted in shared object"),
5826 input_bfd
, input_section
,
5827 (long) rel
->r_offset
, howto
->name
);
5831 value
= tpoff (info
, value
);
5833 return _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
5834 contents
, rel
->r_offset
, value
,
5838 if (globals
->fix_v4bx
)
5840 bfd_vma insn
= bfd_get_32 (input_bfd
, hit_data
);
5842 /* Ensure that we have a BX instruction. */
5843 BFD_ASSERT ((insn
& 0x0ffffff0) == 0x012fff10);
5845 if (globals
->fix_v4bx
== 2 && (insn
& 0xf) != 0xf)
5847 /* Branch to veneer. */
5849 glue_addr
= elf32_arm_bx_glue (info
, insn
& 0xf);
5850 glue_addr
-= input_section
->output_section
->vma
5851 + input_section
->output_offset
5852 + rel
->r_offset
+ 8;
5853 insn
= (insn
& 0xf0000000) | 0x0a000000
5854 | ((glue_addr
>> 2) & 0x00ffffff);
5858 /* Preserve Rm (lowest four bits) and the condition code
5859 (highest four bits). Other bits encode MOV PC,Rm. */
5860 insn
= (insn
& 0xf000000f) | 0x01a0f000;
5863 bfd_put_32 (input_bfd
, insn
, hit_data
);
5865 return bfd_reloc_ok
;
5867 case R_ARM_MOVW_ABS_NC
:
5868 case R_ARM_MOVT_ABS
:
5869 case R_ARM_MOVW_PREL_NC
:
5870 case R_ARM_MOVT_PREL
:
5871 /* Until we properly support segment-base-relative addressing then
5872 we assume the segment base to be zero, as for the group relocations.
5873 Thus R_ARM_MOVW_BREL_NC has the same semantics as R_ARM_MOVW_ABS_NC
5874 and R_ARM_MOVT_BREL has the same semantics as R_ARM_MOVT_ABS. */
5875 case R_ARM_MOVW_BREL_NC
:
5876 case R_ARM_MOVW_BREL
:
5877 case R_ARM_MOVT_BREL
:
5879 bfd_vma insn
= bfd_get_32 (input_bfd
, hit_data
);
5881 if (globals
->use_rel
)
5883 addend
= ((insn
>> 4) & 0xf000) | (insn
& 0xfff);
5884 signed_addend
= (addend
^ 0x8000) - 0x8000;
5887 value
+= signed_addend
;
5889 if (r_type
== R_ARM_MOVW_PREL_NC
|| r_type
== R_ARM_MOVT_PREL
)
5890 value
-= (input_section
->output_section
->vma
5891 + input_section
->output_offset
+ rel
->r_offset
);
5893 if (r_type
== R_ARM_MOVW_BREL
&& value
>= 0x10000)
5894 return bfd_reloc_overflow
;
5896 if (sym_flags
== STT_ARM_TFUNC
)
5899 if (r_type
== R_ARM_MOVT_ABS
|| r_type
== R_ARM_MOVT_PREL
5900 || r_type
== R_ARM_MOVT_BREL
)
5904 insn
|= value
& 0xfff;
5905 insn
|= (value
& 0xf000) << 4;
5906 bfd_put_32 (input_bfd
, insn
, hit_data
);
5908 return bfd_reloc_ok
;
5910 case R_ARM_THM_MOVW_ABS_NC
:
5911 case R_ARM_THM_MOVT_ABS
:
5912 case R_ARM_THM_MOVW_PREL_NC
:
5913 case R_ARM_THM_MOVT_PREL
:
5914 /* Until we properly support segment-base-relative addressing then
5915 we assume the segment base to be zero, as for the above relocations.
5916 Thus R_ARM_THM_MOVW_BREL_NC has the same semantics as
5917 R_ARM_THM_MOVW_ABS_NC and R_ARM_THM_MOVT_BREL has the same semantics
5918 as R_ARM_THM_MOVT_ABS. */
5919 case R_ARM_THM_MOVW_BREL_NC
:
5920 case R_ARM_THM_MOVW_BREL
:
5921 case R_ARM_THM_MOVT_BREL
:
5925 insn
= bfd_get_16 (input_bfd
, hit_data
) << 16;
5926 insn
|= bfd_get_16 (input_bfd
, hit_data
+ 2);
5928 if (globals
->use_rel
)
5930 addend
= ((insn
>> 4) & 0xf000)
5931 | ((insn
>> 15) & 0x0800)
5932 | ((insn
>> 4) & 0x0700)
5934 signed_addend
= (addend
^ 0x8000) - 0x8000;
5937 value
+= signed_addend
;
5939 if (r_type
== R_ARM_THM_MOVW_PREL_NC
|| r_type
== R_ARM_THM_MOVT_PREL
)
5940 value
-= (input_section
->output_section
->vma
5941 + input_section
->output_offset
+ rel
->r_offset
);
5943 if (r_type
== R_ARM_THM_MOVW_BREL
&& value
>= 0x10000)
5944 return bfd_reloc_overflow
;
5946 if (sym_flags
== STT_ARM_TFUNC
)
5949 if (r_type
== R_ARM_THM_MOVT_ABS
|| r_type
== R_ARM_THM_MOVT_PREL
5950 || r_type
== R_ARM_THM_MOVT_BREL
)
5954 insn
|= (value
& 0xf000) << 4;
5955 insn
|= (value
& 0x0800) << 15;
5956 insn
|= (value
& 0x0700) << 4;
5957 insn
|= (value
& 0x00ff);
5959 bfd_put_16 (input_bfd
, insn
>> 16, hit_data
);
5960 bfd_put_16 (input_bfd
, insn
& 0xffff, hit_data
+ 2);
5962 return bfd_reloc_ok
;
5964 case R_ARM_ALU_PC_G0_NC
:
5965 case R_ARM_ALU_PC_G1_NC
:
5966 case R_ARM_ALU_PC_G0
:
5967 case R_ARM_ALU_PC_G1
:
5968 case R_ARM_ALU_PC_G2
:
5969 case R_ARM_ALU_SB_G0_NC
:
5970 case R_ARM_ALU_SB_G1_NC
:
5971 case R_ARM_ALU_SB_G0
:
5972 case R_ARM_ALU_SB_G1
:
5973 case R_ARM_ALU_SB_G2
:
5975 bfd_vma insn
= bfd_get_32 (input_bfd
, hit_data
);
5976 bfd_vma pc
= input_section
->output_section
->vma
5977 + input_section
->output_offset
+ rel
->r_offset
;
5978 /* sb should be the origin of the *segment* containing the symbol.
5979 It is not clear how to obtain this OS-dependent value, so we
5980 make an arbitrary choice of zero. */
5984 bfd_signed_vma signed_value
;
5987 /* Determine which group of bits to select. */
5990 case R_ARM_ALU_PC_G0_NC
:
5991 case R_ARM_ALU_PC_G0
:
5992 case R_ARM_ALU_SB_G0_NC
:
5993 case R_ARM_ALU_SB_G0
:
5997 case R_ARM_ALU_PC_G1_NC
:
5998 case R_ARM_ALU_PC_G1
:
5999 case R_ARM_ALU_SB_G1_NC
:
6000 case R_ARM_ALU_SB_G1
:
6004 case R_ARM_ALU_PC_G2
:
6005 case R_ARM_ALU_SB_G2
:
6013 /* If REL, extract the addend from the insn. If RELA, it will
6014 have already been fetched for us. */
6015 if (globals
->use_rel
)
6018 bfd_vma constant
= insn
& 0xff;
6019 bfd_vma rotation
= (insn
& 0xf00) >> 8;
6022 signed_addend
= constant
;
6025 /* Compensate for the fact that in the instruction, the
6026 rotation is stored in multiples of 2 bits. */
6029 /* Rotate "constant" right by "rotation" bits. */
6030 signed_addend
= (constant
>> rotation
) |
6031 (constant
<< (8 * sizeof (bfd_vma
) - rotation
));
6034 /* Determine if the instruction is an ADD or a SUB.
6035 (For REL, this determines the sign of the addend.) */
6036 negative
= identify_add_or_sub (insn
);
6039 (*_bfd_error_handler
)
6040 (_("%B(%A+0x%lx): Only ADD or SUB instructions are allowed for ALU group relocations"),
6041 input_bfd
, input_section
,
6042 (long) rel
->r_offset
, howto
->name
);
6043 return bfd_reloc_overflow
;
6046 signed_addend
*= negative
;
6049 /* Compute the value (X) to go in the place. */
6050 if (r_type
== R_ARM_ALU_PC_G0_NC
6051 || r_type
== R_ARM_ALU_PC_G1_NC
6052 || r_type
== R_ARM_ALU_PC_G0
6053 || r_type
== R_ARM_ALU_PC_G1
6054 || r_type
== R_ARM_ALU_PC_G2
)
6056 signed_value
= value
- pc
+ signed_addend
;
6058 /* Section base relative. */
6059 signed_value
= value
- sb
+ signed_addend
;
6061 /* If the target symbol is a Thumb function, then set the
6062 Thumb bit in the address. */
6063 if (sym_flags
== STT_ARM_TFUNC
)
6066 /* Calculate the value of the relevant G_n, in encoded
6067 constant-with-rotation format. */
6068 g_n
= calculate_group_reloc_mask (abs (signed_value
), group
,
6071 /* Check for overflow if required. */
6072 if ((r_type
== R_ARM_ALU_PC_G0
6073 || r_type
== R_ARM_ALU_PC_G1
6074 || r_type
== R_ARM_ALU_PC_G2
6075 || r_type
== R_ARM_ALU_SB_G0
6076 || r_type
== R_ARM_ALU_SB_G1
6077 || r_type
== R_ARM_ALU_SB_G2
) && residual
!= 0)
6079 (*_bfd_error_handler
)
6080 (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"),
6081 input_bfd
, input_section
,
6082 (long) rel
->r_offset
, abs (signed_value
), howto
->name
);
6083 return bfd_reloc_overflow
;
6086 /* Mask out the value and the ADD/SUB part of the opcode; take care
6087 not to destroy the S bit. */
6090 /* Set the opcode according to whether the value to go in the
6091 place is negative. */
6092 if (signed_value
< 0)
6097 /* Encode the offset. */
6100 bfd_put_32 (input_bfd
, insn
, hit_data
);
6102 return bfd_reloc_ok
;
6104 case R_ARM_LDR_PC_G0
:
6105 case R_ARM_LDR_PC_G1
:
6106 case R_ARM_LDR_PC_G2
:
6107 case R_ARM_LDR_SB_G0
:
6108 case R_ARM_LDR_SB_G1
:
6109 case R_ARM_LDR_SB_G2
:
6111 bfd_vma insn
= bfd_get_32 (input_bfd
, hit_data
);
6112 bfd_vma pc
= input_section
->output_section
->vma
6113 + input_section
->output_offset
+ rel
->r_offset
;
6114 bfd_vma sb
= 0; /* See note above. */
6116 bfd_signed_vma signed_value
;
6119 /* Determine which groups of bits to calculate. */
6122 case R_ARM_LDR_PC_G0
:
6123 case R_ARM_LDR_SB_G0
:
6127 case R_ARM_LDR_PC_G1
:
6128 case R_ARM_LDR_SB_G1
:
6132 case R_ARM_LDR_PC_G2
:
6133 case R_ARM_LDR_SB_G2
:
6141 /* If REL, extract the addend from the insn. If RELA, it will
6142 have already been fetched for us. */
6143 if (globals
->use_rel
)
6145 int negative
= (insn
& (1 << 23)) ? 1 : -1;
6146 signed_addend
= negative
* (insn
& 0xfff);
6149 /* Compute the value (X) to go in the place. */
6150 if (r_type
== R_ARM_LDR_PC_G0
6151 || r_type
== R_ARM_LDR_PC_G1
6152 || r_type
== R_ARM_LDR_PC_G2
)
6154 signed_value
= value
- pc
+ signed_addend
;
6156 /* Section base relative. */
6157 signed_value
= value
- sb
+ signed_addend
;
6159 /* Calculate the value of the relevant G_{n-1} to obtain
6160 the residual at that stage. */
6161 calculate_group_reloc_mask (abs (signed_value
), group
- 1, &residual
);
6163 /* Check for overflow. */
6164 if (residual
>= 0x1000)
6166 (*_bfd_error_handler
)
6167 (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"),
6168 input_bfd
, input_section
,
6169 (long) rel
->r_offset
, abs (signed_value
), howto
->name
);
6170 return bfd_reloc_overflow
;
6173 /* Mask out the value and U bit. */
6176 /* Set the U bit if the value to go in the place is non-negative. */
6177 if (signed_value
>= 0)
6180 /* Encode the offset. */
6183 bfd_put_32 (input_bfd
, insn
, hit_data
);
6185 return bfd_reloc_ok
;
6187 case R_ARM_LDRS_PC_G0
:
6188 case R_ARM_LDRS_PC_G1
:
6189 case R_ARM_LDRS_PC_G2
:
6190 case R_ARM_LDRS_SB_G0
:
6191 case R_ARM_LDRS_SB_G1
:
6192 case R_ARM_LDRS_SB_G2
:
6194 bfd_vma insn
= bfd_get_32 (input_bfd
, hit_data
);
6195 bfd_vma pc
= input_section
->output_section
->vma
6196 + input_section
->output_offset
+ rel
->r_offset
;
6197 bfd_vma sb
= 0; /* See note above. */
6199 bfd_signed_vma signed_value
;
6202 /* Determine which groups of bits to calculate. */
6205 case R_ARM_LDRS_PC_G0
:
6206 case R_ARM_LDRS_SB_G0
:
6210 case R_ARM_LDRS_PC_G1
:
6211 case R_ARM_LDRS_SB_G1
:
6215 case R_ARM_LDRS_PC_G2
:
6216 case R_ARM_LDRS_SB_G2
:
6224 /* If REL, extract the addend from the insn. If RELA, it will
6225 have already been fetched for us. */
6226 if (globals
->use_rel
)
6228 int negative
= (insn
& (1 << 23)) ? 1 : -1;
6229 signed_addend
= negative
* (((insn
& 0xf00) >> 4) + (insn
& 0xf));
6232 /* Compute the value (X) to go in the place. */
6233 if (r_type
== R_ARM_LDRS_PC_G0
6234 || r_type
== R_ARM_LDRS_PC_G1
6235 || r_type
== R_ARM_LDRS_PC_G2
)
6237 signed_value
= value
- pc
+ signed_addend
;
6239 /* Section base relative. */
6240 signed_value
= value
- sb
+ signed_addend
;
6242 /* Calculate the value of the relevant G_{n-1} to obtain
6243 the residual at that stage. */
6244 calculate_group_reloc_mask (abs (signed_value
), group
- 1, &residual
);
6246 /* Check for overflow. */
6247 if (residual
>= 0x100)
6249 (*_bfd_error_handler
)
6250 (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"),
6251 input_bfd
, input_section
,
6252 (long) rel
->r_offset
, abs (signed_value
), howto
->name
);
6253 return bfd_reloc_overflow
;
6256 /* Mask out the value and U bit. */
6259 /* Set the U bit if the value to go in the place is non-negative. */
6260 if (signed_value
>= 0)
6263 /* Encode the offset. */
6264 insn
|= ((residual
& 0xf0) << 4) | (residual
& 0xf);
6266 bfd_put_32 (input_bfd
, insn
, hit_data
);
6268 return bfd_reloc_ok
;
6270 case R_ARM_LDC_PC_G0
:
6271 case R_ARM_LDC_PC_G1
:
6272 case R_ARM_LDC_PC_G2
:
6273 case R_ARM_LDC_SB_G0
:
6274 case R_ARM_LDC_SB_G1
:
6275 case R_ARM_LDC_SB_G2
:
6277 bfd_vma insn
= bfd_get_32 (input_bfd
, hit_data
);
6278 bfd_vma pc
= input_section
->output_section
->vma
6279 + input_section
->output_offset
+ rel
->r_offset
;
6280 bfd_vma sb
= 0; /* See note above. */
6282 bfd_signed_vma signed_value
;
6285 /* Determine which groups of bits to calculate. */
6288 case R_ARM_LDC_PC_G0
:
6289 case R_ARM_LDC_SB_G0
:
6293 case R_ARM_LDC_PC_G1
:
6294 case R_ARM_LDC_SB_G1
:
6298 case R_ARM_LDC_PC_G2
:
6299 case R_ARM_LDC_SB_G2
:
6307 /* If REL, extract the addend from the insn. If RELA, it will
6308 have already been fetched for us. */
6309 if (globals
->use_rel
)
6311 int negative
= (insn
& (1 << 23)) ? 1 : -1;
6312 signed_addend
= negative
* ((insn
& 0xff) << 2);
6315 /* Compute the value (X) to go in the place. */
6316 if (r_type
== R_ARM_LDC_PC_G0
6317 || r_type
== R_ARM_LDC_PC_G1
6318 || r_type
== R_ARM_LDC_PC_G2
)
6320 signed_value
= value
- pc
+ signed_addend
;
6322 /* Section base relative. */
6323 signed_value
= value
- sb
+ signed_addend
;
6325 /* Calculate the value of the relevant G_{n-1} to obtain
6326 the residual at that stage. */
6327 calculate_group_reloc_mask (abs (signed_value
), group
- 1, &residual
);
6329 /* Check for overflow. (The absolute value to go in the place must be
6330 divisible by four and, after having been divided by four, must
6331 fit in eight bits.) */
6332 if ((residual
& 0x3) != 0 || residual
>= 0x400)
6334 (*_bfd_error_handler
)
6335 (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"),
6336 input_bfd
, input_section
,
6337 (long) rel
->r_offset
, abs (signed_value
), howto
->name
);
6338 return bfd_reloc_overflow
;
6341 /* Mask out the value and U bit. */
6344 /* Set the U bit if the value to go in the place is non-negative. */
6345 if (signed_value
>= 0)
6348 /* Encode the offset. */
6349 insn
|= residual
>> 2;
6351 bfd_put_32 (input_bfd
, insn
, hit_data
);
6353 return bfd_reloc_ok
;
6356 return bfd_reloc_notsupported
;
6360 /* Add INCREMENT to the reloc (of type HOWTO) at ADDRESS. */
6362 arm_add_to_rel (bfd
* abfd
,
6364 reloc_howto_type
* howto
,
6365 bfd_signed_vma increment
)
6367 bfd_signed_vma addend
;
6369 if (howto
->type
== R_ARM_THM_CALL
6370 || howto
->type
== R_ARM_THM_JUMP24
)
6372 int upper_insn
, lower_insn
;
6375 upper_insn
= bfd_get_16 (abfd
, address
);
6376 lower_insn
= bfd_get_16 (abfd
, address
+ 2);
6377 upper
= upper_insn
& 0x7ff;
6378 lower
= lower_insn
& 0x7ff;
6380 addend
= (upper
<< 12) | (lower
<< 1);
6381 addend
+= increment
;
6384 upper_insn
= (upper_insn
& 0xf800) | ((addend
>> 11) & 0x7ff);
6385 lower_insn
= (lower_insn
& 0xf800) | (addend
& 0x7ff);
6387 bfd_put_16 (abfd
, (bfd_vma
) upper_insn
, address
);
6388 bfd_put_16 (abfd
, (bfd_vma
) lower_insn
, address
+ 2);
6394 contents
= bfd_get_32 (abfd
, address
);
6396 /* Get the (signed) value from the instruction. */
6397 addend
= contents
& howto
->src_mask
;
6398 if (addend
& ((howto
->src_mask
+ 1) >> 1))
6400 bfd_signed_vma mask
;
6403 mask
&= ~ howto
->src_mask
;
6407 /* Add in the increment, (which is a byte value). */
6408 switch (howto
->type
)
6411 addend
+= increment
;
6418 addend
<<= howto
->size
;
6419 addend
+= increment
;
6421 /* Should we check for overflow here ? */
6423 /* Drop any undesired bits. */
6424 addend
>>= howto
->rightshift
;
6428 contents
= (contents
& ~ howto
->dst_mask
) | (addend
& howto
->dst_mask
);
6430 bfd_put_32 (abfd
, contents
, address
);
6434 #define IS_ARM_TLS_RELOC(R_TYPE) \
6435 ((R_TYPE) == R_ARM_TLS_GD32 \
6436 || (R_TYPE) == R_ARM_TLS_LDO32 \
6437 || (R_TYPE) == R_ARM_TLS_LDM32 \
6438 || (R_TYPE) == R_ARM_TLS_DTPOFF32 \
6439 || (R_TYPE) == R_ARM_TLS_DTPMOD32 \
6440 || (R_TYPE) == R_ARM_TLS_TPOFF32 \
6441 || (R_TYPE) == R_ARM_TLS_LE32 \
6442 || (R_TYPE) == R_ARM_TLS_IE32)
6444 /* Relocate an ARM ELF section. */
6446 elf32_arm_relocate_section (bfd
* output_bfd
,
6447 struct bfd_link_info
* info
,
6449 asection
* input_section
,
6450 bfd_byte
* contents
,
6451 Elf_Internal_Rela
* relocs
,
6452 Elf_Internal_Sym
* local_syms
,
6453 asection
** local_sections
)
6455 Elf_Internal_Shdr
*symtab_hdr
;
6456 struct elf_link_hash_entry
**sym_hashes
;
6457 Elf_Internal_Rela
*rel
;
6458 Elf_Internal_Rela
*relend
;
6460 struct elf32_arm_link_hash_table
* globals
;
6462 globals
= elf32_arm_hash_table (info
);
6464 symtab_hdr
= & elf_symtab_hdr (input_bfd
);
6465 sym_hashes
= elf_sym_hashes (input_bfd
);
6468 relend
= relocs
+ input_section
->reloc_count
;
6469 for (; rel
< relend
; rel
++)
6472 reloc_howto_type
* howto
;
6473 unsigned long r_symndx
;
6474 Elf_Internal_Sym
* sym
;
6476 struct elf_link_hash_entry
* h
;
6478 bfd_reloc_status_type r
;
6481 bfd_boolean unresolved_reloc
= FALSE
;
6482 char *error_message
= NULL
;
6484 r_symndx
= ELF32_R_SYM (rel
->r_info
);
6485 r_type
= ELF32_R_TYPE (rel
->r_info
);
6486 r_type
= arm_real_reloc_type (globals
, r_type
);
6488 if ( r_type
== R_ARM_GNU_VTENTRY
6489 || r_type
== R_ARM_GNU_VTINHERIT
)
6492 bfd_reloc
.howto
= elf32_arm_howto_from_type (r_type
);
6493 howto
= bfd_reloc
.howto
;
6499 if (r_symndx
< symtab_hdr
->sh_info
)
6501 sym
= local_syms
+ r_symndx
;
6502 sym_type
= ELF32_ST_TYPE (sym
->st_info
);
6503 sec
= local_sections
[r_symndx
];
6504 if (globals
->use_rel
)
6506 relocation
= (sec
->output_section
->vma
6507 + sec
->output_offset
6509 if (!info
->relocatable
6510 && (sec
->flags
& SEC_MERGE
)
6511 && ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
)
6514 bfd_vma addend
, value
;
6518 case R_ARM_MOVW_ABS_NC
:
6519 case R_ARM_MOVT_ABS
:
6520 value
= bfd_get_32 (input_bfd
, contents
+ rel
->r_offset
);
6521 addend
= ((value
& 0xf0000) >> 4) | (value
& 0xfff);
6522 addend
= (addend
^ 0x8000) - 0x8000;
6525 case R_ARM_THM_MOVW_ABS_NC
:
6526 case R_ARM_THM_MOVT_ABS
:
6527 value
= bfd_get_16 (input_bfd
, contents
+ rel
->r_offset
)
6529 value
|= bfd_get_16 (input_bfd
,
6530 contents
+ rel
->r_offset
+ 2);
6531 addend
= ((value
& 0xf7000) >> 4) | (value
& 0xff)
6532 | ((value
& 0x04000000) >> 15);
6533 addend
= (addend
^ 0x8000) - 0x8000;
6537 if (howto
->rightshift
6538 || (howto
->src_mask
& (howto
->src_mask
+ 1)))
6540 (*_bfd_error_handler
)
6541 (_("%B(%A+0x%lx): %s relocation against SEC_MERGE section"),
6542 input_bfd
, input_section
,
6543 (long) rel
->r_offset
, howto
->name
);
6547 value
= bfd_get_32 (input_bfd
, contents
+ rel
->r_offset
);
6549 /* Get the (signed) value from the instruction. */
6550 addend
= value
& howto
->src_mask
;
6551 if (addend
& ((howto
->src_mask
+ 1) >> 1))
6553 bfd_signed_vma mask
;
6556 mask
&= ~ howto
->src_mask
;
6564 _bfd_elf_rel_local_sym (output_bfd
, sym
, &msec
, addend
)
6566 addend
+= msec
->output_section
->vma
+ msec
->output_offset
;
6568 /* Cases here must match those in the preceeding
6569 switch statement. */
6572 case R_ARM_MOVW_ABS_NC
:
6573 case R_ARM_MOVT_ABS
:
6574 value
= (value
& 0xfff0f000) | ((addend
& 0xf000) << 4)
6576 bfd_put_32 (input_bfd
, value
, contents
+ rel
->r_offset
);
6579 case R_ARM_THM_MOVW_ABS_NC
:
6580 case R_ARM_THM_MOVT_ABS
:
6581 value
= (value
& 0xfbf08f00) | ((addend
& 0xf700) << 4)
6582 | (addend
& 0xff) | ((addend
& 0x0800) << 15);
6583 bfd_put_16 (input_bfd
, value
>> 16,
6584 contents
+ rel
->r_offset
);
6585 bfd_put_16 (input_bfd
, value
,
6586 contents
+ rel
->r_offset
+ 2);
6590 value
= (value
& ~ howto
->dst_mask
)
6591 | (addend
& howto
->dst_mask
);
6592 bfd_put_32 (input_bfd
, value
, contents
+ rel
->r_offset
);
6598 relocation
= _bfd_elf_rela_local_sym (output_bfd
, sym
, &sec
, rel
);
6604 RELOC_FOR_GLOBAL_SYMBOL (info
, input_bfd
, input_section
, rel
,
6605 r_symndx
, symtab_hdr
, sym_hashes
,
6607 unresolved_reloc
, warned
);
6612 if (sec
!= NULL
&& elf_discarded_section (sec
))
6614 /* For relocs against symbols from removed linkonce sections,
6615 or sections discarded by a linker script, we just want the
6616 section contents zeroed. Avoid any special processing. */
6617 _bfd_clear_contents (howto
, input_bfd
, contents
+ rel
->r_offset
);
6623 if (info
->relocatable
)
6625 /* This is a relocatable link. We don't have to change
6626 anything, unless the reloc is against a section symbol,
6627 in which case we have to adjust according to where the
6628 section symbol winds up in the output section. */
6629 if (sym
!= NULL
&& ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
)
6631 if (globals
->use_rel
)
6632 arm_add_to_rel (input_bfd
, contents
+ rel
->r_offset
,
6633 howto
, (bfd_signed_vma
) sec
->output_offset
);
6635 rel
->r_addend
+= sec
->output_offset
;
6641 name
= h
->root
.root
.string
;
6644 name
= (bfd_elf_string_from_elf_section
6645 (input_bfd
, symtab_hdr
->sh_link
, sym
->st_name
));
6646 if (name
== NULL
|| *name
== '\0')
6647 name
= bfd_section_name (input_bfd
, sec
);
6651 && r_type
!= R_ARM_NONE
6653 || h
->root
.type
== bfd_link_hash_defined
6654 || h
->root
.type
== bfd_link_hash_defweak
)
6655 && IS_ARM_TLS_RELOC (r_type
) != (sym_type
== STT_TLS
))
6657 (*_bfd_error_handler
)
6658 ((sym_type
== STT_TLS
6659 ? _("%B(%A+0x%lx): %s used with TLS symbol %s")
6660 : _("%B(%A+0x%lx): %s used with non-TLS symbol %s")),
6663 (long) rel
->r_offset
,
6668 r
= elf32_arm_final_link_relocate (howto
, input_bfd
, output_bfd
,
6669 input_section
, contents
, rel
,
6670 relocation
, info
, sec
, name
,
6671 (h
? ELF_ST_TYPE (h
->type
) :
6672 ELF_ST_TYPE (sym
->st_info
)), h
,
6673 &unresolved_reloc
, &error_message
);
6675 /* Dynamic relocs are not propagated for SEC_DEBUGGING sections
6676 because such sections are not SEC_ALLOC and thus ld.so will
6677 not process them. */
6678 if (unresolved_reloc
6679 && !((input_section
->flags
& SEC_DEBUGGING
) != 0
6682 (*_bfd_error_handler
)
6683 (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
6686 (long) rel
->r_offset
,
6688 h
->root
.root
.string
);
6692 if (r
!= bfd_reloc_ok
)
6696 case bfd_reloc_overflow
:
6697 /* If the overflowing reloc was to an undefined symbol,
6698 we have already printed one error message and there
6699 is no point complaining again. */
6701 h
->root
.type
!= bfd_link_hash_undefined
)
6702 && (!((*info
->callbacks
->reloc_overflow
)
6703 (info
, (h
? &h
->root
: NULL
), name
, howto
->name
,
6704 (bfd_vma
) 0, input_bfd
, input_section
,
6709 case bfd_reloc_undefined
:
6710 if (!((*info
->callbacks
->undefined_symbol
)
6711 (info
, name
, input_bfd
, input_section
,
6712 rel
->r_offset
, TRUE
)))
6716 case bfd_reloc_outofrange
:
6717 error_message
= _("out of range");
6720 case bfd_reloc_notsupported
:
6721 error_message
= _("unsupported relocation");
6724 case bfd_reloc_dangerous
:
6725 /* error_message should already be set. */
6729 error_message
= _("unknown error");
6733 BFD_ASSERT (error_message
!= NULL
);
6734 if (!((*info
->callbacks
->reloc_dangerous
)
6735 (info
, error_message
, input_bfd
, input_section
,
6746 /* Set the right machine number. */
6749 elf32_arm_object_p (bfd
*abfd
)
6753 mach
= bfd_arm_get_mach_from_notes (abfd
, ARM_NOTE_SECTION
);
6755 if (mach
!= bfd_mach_arm_unknown
)
6756 bfd_default_set_arch_mach (abfd
, bfd_arch_arm
, mach
);
6758 else if (elf_elfheader (abfd
)->e_flags
& EF_ARM_MAVERICK_FLOAT
)
6759 bfd_default_set_arch_mach (abfd
, bfd_arch_arm
, bfd_mach_arm_ep9312
);
6762 bfd_default_set_arch_mach (abfd
, bfd_arch_arm
, mach
);
6767 /* Function to keep ARM specific flags in the ELF header. */
6770 elf32_arm_set_private_flags (bfd
*abfd
, flagword flags
)
6772 if (elf_flags_init (abfd
)
6773 && elf_elfheader (abfd
)->e_flags
!= flags
)
6775 if (EF_ARM_EABI_VERSION (flags
) == EF_ARM_EABI_UNKNOWN
)
6777 if (flags
& EF_ARM_INTERWORK
)
6778 (*_bfd_error_handler
)
6779 (_("Warning: Not setting interworking flag of %B since it has already been specified as non-interworking"),
6783 (_("Warning: Clearing the interworking flag of %B due to outside request"),
6789 elf_elfheader (abfd
)->e_flags
= flags
;
6790 elf_flags_init (abfd
) = TRUE
;
6796 /* Copy backend specific data from one object module to another. */
6799 elf32_arm_copy_private_bfd_data (bfd
*ibfd
, bfd
*obfd
)
6804 if (! is_arm_elf (ibfd
) || ! is_arm_elf (obfd
))
6807 in_flags
= elf_elfheader (ibfd
)->e_flags
;
6808 out_flags
= elf_elfheader (obfd
)->e_flags
;
6810 if (elf_flags_init (obfd
)
6811 && EF_ARM_EABI_VERSION (out_flags
) == EF_ARM_EABI_UNKNOWN
6812 && in_flags
!= out_flags
)
6814 /* Cannot mix APCS26 and APCS32 code. */
6815 if ((in_flags
& EF_ARM_APCS_26
) != (out_flags
& EF_ARM_APCS_26
))
6818 /* Cannot mix float APCS and non-float APCS code. */
6819 if ((in_flags
& EF_ARM_APCS_FLOAT
) != (out_flags
& EF_ARM_APCS_FLOAT
))
6822 /* If the src and dest have different interworking flags
6823 then turn off the interworking bit. */
6824 if ((in_flags
& EF_ARM_INTERWORK
) != (out_flags
& EF_ARM_INTERWORK
))
6826 if (out_flags
& EF_ARM_INTERWORK
)
6828 (_("Warning: Clearing the interworking flag of %B because non-interworking code in %B has been linked with it"),
6831 in_flags
&= ~EF_ARM_INTERWORK
;
6834 /* Likewise for PIC, though don't warn for this case. */
6835 if ((in_flags
& EF_ARM_PIC
) != (out_flags
& EF_ARM_PIC
))
6836 in_flags
&= ~EF_ARM_PIC
;
6839 elf_elfheader (obfd
)->e_flags
= in_flags
;
6840 elf_flags_init (obfd
) = TRUE
;
6842 /* Also copy the EI_OSABI field. */
6843 elf_elfheader (obfd
)->e_ident
[EI_OSABI
] =
6844 elf_elfheader (ibfd
)->e_ident
[EI_OSABI
];
6846 /* Copy object attributes. */
6847 _bfd_elf_copy_obj_attributes (ibfd
, obfd
);
6852 /* Values for Tag_ABI_PCS_R9_use. */
6861 /* Values for Tag_ABI_PCS_RW_data. */
6864 AEABI_PCS_RW_data_absolute
,
6865 AEABI_PCS_RW_data_PCrel
,
6866 AEABI_PCS_RW_data_SBrel
,
6867 AEABI_PCS_RW_data_unused
6870 /* Values for Tag_ABI_enum_size. */
6876 AEABI_enum_forced_wide
6879 /* Determine whether an object attribute tag takes an integer, a
6882 elf32_arm_obj_attrs_arg_type (int tag
)
6884 if (tag
== Tag_compatibility
)
6886 else if (tag
== 4 || tag
== 5)
6891 return (tag
& 1) != 0 ? 2 : 1;
6894 /* Merge EABI object attributes from IBFD into OBFD. Raise an error if there
6895 are conflicting attributes. */
6897 elf32_arm_merge_eabi_attributes (bfd
*ibfd
, bfd
*obfd
)
6899 obj_attribute
*in_attr
;
6900 obj_attribute
*out_attr
;
6901 obj_attribute_list
*in_list
;
6902 /* Some tags have 0 = don't care, 1 = strong requirement,
6903 2 = weak requirement. */
6904 static const int order_312
[3] = {3, 1, 2};
6907 if (!elf_known_obj_attributes_proc (obfd
)[0].i
)
6909 /* This is the first object. Copy the attributes. */
6910 _bfd_elf_copy_obj_attributes (ibfd
, obfd
);
6912 /* Use the Tag_null value to indicate the attributes have been
6914 elf_known_obj_attributes_proc (obfd
)[0].i
= 1;
6919 in_attr
= elf_known_obj_attributes_proc (ibfd
);
6920 out_attr
= elf_known_obj_attributes_proc (obfd
);
6921 /* This needs to happen before Tag_ABI_FP_number_model is merged. */
6922 if (in_attr
[Tag_ABI_VFP_args
].i
!= out_attr
[Tag_ABI_VFP_args
].i
)
6924 /* Ignore mismatches if teh object doesn't use floating point. */
6925 if (out_attr
[Tag_ABI_FP_number_model
].i
== 0)
6926 out_attr
[Tag_ABI_VFP_args
].i
= in_attr
[Tag_ABI_VFP_args
].i
;
6927 else if (in_attr
[Tag_ABI_FP_number_model
].i
!= 0)
6930 (_("ERROR: %B uses VFP register arguments, %B does not"),
6936 for (i
= 4; i
< NUM_KNOWN_OBJ_ATTRIBUTES
; i
++)
6938 /* Merge this attribute with existing attributes. */
6941 case Tag_CPU_raw_name
:
6943 /* Use whichever has the greatest architecture requirements. We
6944 won't necessarily have both the above tags, so make sure input
6945 name is non-NULL. */
6946 if (in_attr
[Tag_CPU_arch
].i
> out_attr
[Tag_CPU_arch
].i
6948 out_attr
[i
].s
= _bfd_elf_attr_strdup (obfd
, in_attr
[i
].s
);
6951 case Tag_ABI_optimization_goals
:
6952 case Tag_ABI_FP_optimization_goals
:
6953 /* Use the first value seen. */
6957 case Tag_ARM_ISA_use
:
6958 case Tag_THUMB_ISA_use
:
6962 /* ??? Do NEON and WMMX conflict? */
6963 case Tag_ABI_FP_rounding
:
6964 case Tag_ABI_FP_denormal
:
6965 case Tag_ABI_FP_exceptions
:
6966 case Tag_ABI_FP_user_exceptions
:
6967 case Tag_ABI_FP_number_model
:
6968 case Tag_ABI_align8_preserved
:
6969 case Tag_ABI_HardFP_use
:
6970 /* Use the largest value specified. */
6971 if (in_attr
[i
].i
> out_attr
[i
].i
)
6972 out_attr
[i
].i
= in_attr
[i
].i
;
6975 case Tag_CPU_arch_profile
:
6976 /* Warn if conflicting architecture profiles used. */
6977 if (out_attr
[i
].i
&& in_attr
[i
].i
&& in_attr
[i
].i
!= out_attr
[i
].i
)
6980 (_("ERROR: %B: Conflicting architecture profiles %c/%c"),
6981 ibfd
, in_attr
[i
].i
, out_attr
[i
].i
);
6985 out_attr
[i
].i
= in_attr
[i
].i
;
6987 case Tag_PCS_config
:
6988 if (out_attr
[i
].i
== 0)
6989 out_attr
[i
].i
= in_attr
[i
].i
;
6990 else if (in_attr
[i
].i
!= 0 && out_attr
[i
].i
!= 0)
6992 /* It's sometimes ok to mix different configs, so this is only
6995 (_("Warning: %B: Conflicting platform configuration"), ibfd
);
6998 case Tag_ABI_PCS_R9_use
:
6999 if (in_attr
[i
].i
!= out_attr
[i
].i
7000 && out_attr
[i
].i
!= AEABI_R9_unused
7001 && in_attr
[i
].i
!= AEABI_R9_unused
)
7004 (_("ERROR: %B: Conflicting use of R9"), ibfd
);
7007 if (out_attr
[i
].i
== AEABI_R9_unused
)
7008 out_attr
[i
].i
= in_attr
[i
].i
;
7010 case Tag_ABI_PCS_RW_data
:
7011 if (in_attr
[i
].i
== AEABI_PCS_RW_data_SBrel
7012 && out_attr
[Tag_ABI_PCS_R9_use
].i
!= AEABI_R9_SB
7013 && out_attr
[Tag_ABI_PCS_R9_use
].i
!= AEABI_R9_unused
)
7016 (_("ERROR: %B: SB relative addressing conflicts with use of R9"),
7020 /* Use the smallest value specified. */
7021 if (in_attr
[i
].i
< out_attr
[i
].i
)
7022 out_attr
[i
].i
= in_attr
[i
].i
;
7024 case Tag_ABI_PCS_RO_data
:
7025 /* Use the smallest value specified. */
7026 if (in_attr
[i
].i
< out_attr
[i
].i
)
7027 out_attr
[i
].i
= in_attr
[i
].i
;
7029 case Tag_ABI_PCS_GOT_use
:
7030 if (in_attr
[i
].i
> 2 || out_attr
[i
].i
> 2
7031 || order_312
[in_attr
[i
].i
] < order_312
[out_attr
[i
].i
])
7032 out_attr
[i
].i
= in_attr
[i
].i
;
7034 case Tag_ABI_PCS_wchar_t
:
7035 if (out_attr
[i
].i
&& in_attr
[i
].i
&& out_attr
[i
].i
!= in_attr
[i
].i
)
7038 (_("ERROR: %B: Conflicting definitions of wchar_t"), ibfd
);
7042 out_attr
[i
].i
= in_attr
[i
].i
;
7044 case Tag_ABI_align8_needed
:
7045 /* ??? Check against Tag_ABI_align8_preserved. */
7046 if (in_attr
[i
].i
> 2 || out_attr
[i
].i
> 2
7047 || order_312
[in_attr
[i
].i
] < order_312
[out_attr
[i
].i
])
7048 out_attr
[i
].i
= in_attr
[i
].i
;
7050 case Tag_ABI_enum_size
:
7051 if (in_attr
[i
].i
!= AEABI_enum_unused
)
7053 if (out_attr
[i
].i
== AEABI_enum_unused
7054 || out_attr
[i
].i
== AEABI_enum_forced_wide
)
7056 /* The existing object is compatible with anything.
7057 Use whatever requirements the new object has. */
7058 out_attr
[i
].i
= in_attr
[i
].i
;
7060 else if (in_attr
[i
].i
!= AEABI_enum_forced_wide
7061 && out_attr
[i
].i
!= in_attr
[i
].i
7062 && !elf_arm_tdata (obfd
)->no_enum_size_warning
)
7064 const char *aeabi_enum_names
[] =
7065 { "", "variable-size", "32-bit", "" };
7067 (_("warning: %B uses %s enums yet the output is to use %s enums; use of enum values across objects may fail"),
7068 ibfd
, aeabi_enum_names
[in_attr
[i
].i
],
7069 aeabi_enum_names
[out_attr
[i
].i
]);
7073 case Tag_ABI_VFP_args
:
7076 case Tag_ABI_WMMX_args
:
7077 if (in_attr
[i
].i
!= out_attr
[i
].i
)
7080 (_("ERROR: %B uses iWMMXt register arguments, %B does not"),
7085 default: /* All known attributes should be explicitly covered. */
7089 if (in_attr
[i
].type
&& !out_attr
[i
].type
)
7090 switch (in_attr
[i
].type
)
7094 out_attr
[i
].type
= 1;
7099 out_attr
[i
].type
= 2;
7107 /* Merge Tag_compatibility attributes and any common GNU ones. */
7108 _bfd_elf_merge_object_attributes (ibfd
, obfd
);
7110 /* Check for any attributes not known on ARM. */
7111 in_list
= elf_other_obj_attributes_proc (ibfd
);
7112 while (in_list
&& in_list
->tag
== Tag_compatibility
)
7113 in_list
= in_list
->next
;
7115 for (; in_list
; in_list
= in_list
->next
)
7117 if ((in_list
->tag
& 128) < 64)
7120 (_("Warning: %B: Unknown EABI object attribute %d"),
7121 ibfd
, in_list
->tag
);
7129 /* Return TRUE if the two EABI versions are incompatible. */
7132 elf32_arm_versions_compatible (unsigned iver
, unsigned over
)
7134 /* v4 and v5 are the same spec before and after it was released,
7135 so allow mixing them. */
7136 if ((iver
== EF_ARM_EABI_VER4
&& over
== EF_ARM_EABI_VER5
)
7137 || (iver
== EF_ARM_EABI_VER5
&& over
== EF_ARM_EABI_VER4
))
7140 return (iver
== over
);
7143 /* Merge backend specific data from an object file to the output
7144 object file when linking. */
7147 elf32_arm_merge_private_bfd_data (bfd
* ibfd
, bfd
* obfd
)
7151 bfd_boolean flags_compatible
= TRUE
;
7154 /* Check if we have the same endianess. */
7155 if (! _bfd_generic_verify_endian_match (ibfd
, obfd
))
7158 if (! is_arm_elf (ibfd
) || ! is_arm_elf (obfd
))
7161 if (!elf32_arm_merge_eabi_attributes (ibfd
, obfd
))
7164 /* The input BFD must have had its flags initialised. */
7165 /* The following seems bogus to me -- The flags are initialized in
7166 the assembler but I don't think an elf_flags_init field is
7167 written into the object. */
7168 /* BFD_ASSERT (elf_flags_init (ibfd)); */
7170 in_flags
= elf_elfheader (ibfd
)->e_flags
;
7171 out_flags
= elf_elfheader (obfd
)->e_flags
;
7173 if (!elf_flags_init (obfd
))
7175 /* If the input is the default architecture and had the default
7176 flags then do not bother setting the flags for the output
7177 architecture, instead allow future merges to do this. If no
7178 future merges ever set these flags then they will retain their
7179 uninitialised values, which surprise surprise, correspond
7180 to the default values. */
7181 if (bfd_get_arch_info (ibfd
)->the_default
7182 && elf_elfheader (ibfd
)->e_flags
== 0)
7185 elf_flags_init (obfd
) = TRUE
;
7186 elf_elfheader (obfd
)->e_flags
= in_flags
;
7188 if (bfd_get_arch (obfd
) == bfd_get_arch (ibfd
)
7189 && bfd_get_arch_info (obfd
)->the_default
)
7190 return bfd_set_arch_mach (obfd
, bfd_get_arch (ibfd
), bfd_get_mach (ibfd
));
7195 /* Determine what should happen if the input ARM architecture
7196 does not match the output ARM architecture. */
7197 if (! bfd_arm_merge_machines (ibfd
, obfd
))
7200 /* Identical flags must be compatible. */
7201 if (in_flags
== out_flags
)
7204 /* Check to see if the input BFD actually contains any sections. If
7205 not, its flags may not have been initialised either, but it
7206 cannot actually cause any incompatiblity. Do not short-circuit
7207 dynamic objects; their section list may be emptied by
7208 elf_link_add_object_symbols.
7210 Also check to see if there are no code sections in the input.
7211 In this case there is no need to check for code specific flags.
7212 XXX - do we need to worry about floating-point format compatability
7213 in data sections ? */
7214 if (!(ibfd
->flags
& DYNAMIC
))
7216 bfd_boolean null_input_bfd
= TRUE
;
7217 bfd_boolean only_data_sections
= TRUE
;
7219 for (sec
= ibfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
7221 /* Ignore synthetic glue sections. */
7222 if (strcmp (sec
->name
, ".glue_7")
7223 && strcmp (sec
->name
, ".glue_7t"))
7225 if ((bfd_get_section_flags (ibfd
, sec
)
7226 & (SEC_LOAD
| SEC_CODE
| SEC_HAS_CONTENTS
))
7227 == (SEC_LOAD
| SEC_CODE
| SEC_HAS_CONTENTS
))
7228 only_data_sections
= FALSE
;
7230 null_input_bfd
= FALSE
;
7235 if (null_input_bfd
|| only_data_sections
)
7239 /* Complain about various flag mismatches. */
7240 if (!elf32_arm_versions_compatible (EF_ARM_EABI_VERSION (in_flags
),
7241 EF_ARM_EABI_VERSION (out_flags
)))
7244 (_("ERROR: Source object %B has EABI version %d, but target %B has EABI version %d"),
7246 (in_flags
& EF_ARM_EABIMASK
) >> 24,
7247 (out_flags
& EF_ARM_EABIMASK
) >> 24);
7251 /* Not sure what needs to be checked for EABI versions >= 1. */
7252 /* VxWorks libraries do not use these flags. */
7253 if (get_elf_backend_data (obfd
) != &elf32_arm_vxworks_bed
7254 && get_elf_backend_data (ibfd
) != &elf32_arm_vxworks_bed
7255 && EF_ARM_EABI_VERSION (in_flags
) == EF_ARM_EABI_UNKNOWN
)
7257 if ((in_flags
& EF_ARM_APCS_26
) != (out_flags
& EF_ARM_APCS_26
))
7260 (_("ERROR: %B is compiled for APCS-%d, whereas target %B uses APCS-%d"),
7262 in_flags
& EF_ARM_APCS_26
? 26 : 32,
7263 out_flags
& EF_ARM_APCS_26
? 26 : 32);
7264 flags_compatible
= FALSE
;
7267 if ((in_flags
& EF_ARM_APCS_FLOAT
) != (out_flags
& EF_ARM_APCS_FLOAT
))
7269 if (in_flags
& EF_ARM_APCS_FLOAT
)
7271 (_("ERROR: %B passes floats in float registers, whereas %B passes them in integer registers"),
7275 (_("ERROR: %B passes floats in integer registers, whereas %B passes them in float registers"),
7278 flags_compatible
= FALSE
;
7281 if ((in_flags
& EF_ARM_VFP_FLOAT
) != (out_flags
& EF_ARM_VFP_FLOAT
))
7283 if (in_flags
& EF_ARM_VFP_FLOAT
)
7285 (_("ERROR: %B uses VFP instructions, whereas %B does not"),
7289 (_("ERROR: %B uses FPA instructions, whereas %B does not"),
7292 flags_compatible
= FALSE
;
7295 if ((in_flags
& EF_ARM_MAVERICK_FLOAT
) != (out_flags
& EF_ARM_MAVERICK_FLOAT
))
7297 if (in_flags
& EF_ARM_MAVERICK_FLOAT
)
7299 (_("ERROR: %B uses Maverick instructions, whereas %B does not"),
7303 (_("ERROR: %B does not use Maverick instructions, whereas %B does"),
7306 flags_compatible
= FALSE
;
7309 #ifdef EF_ARM_SOFT_FLOAT
7310 if ((in_flags
& EF_ARM_SOFT_FLOAT
) != (out_flags
& EF_ARM_SOFT_FLOAT
))
7312 /* We can allow interworking between code that is VFP format
7313 layout, and uses either soft float or integer regs for
7314 passing floating point arguments and results. We already
7315 know that the APCS_FLOAT flags match; similarly for VFP
7317 if ((in_flags
& EF_ARM_APCS_FLOAT
) != 0
7318 || (in_flags
& EF_ARM_VFP_FLOAT
) == 0)
7320 if (in_flags
& EF_ARM_SOFT_FLOAT
)
7322 (_("ERROR: %B uses software FP, whereas %B uses hardware FP"),
7326 (_("ERROR: %B uses hardware FP, whereas %B uses software FP"),
7329 flags_compatible
= FALSE
;
7334 /* Interworking mismatch is only a warning. */
7335 if ((in_flags
& EF_ARM_INTERWORK
) != (out_flags
& EF_ARM_INTERWORK
))
7337 if (in_flags
& EF_ARM_INTERWORK
)
7340 (_("Warning: %B supports interworking, whereas %B does not"),
7346 (_("Warning: %B does not support interworking, whereas %B does"),
7352 return flags_compatible
;
7355 /* Display the flags field. */
7358 elf32_arm_print_private_bfd_data (bfd
*abfd
, void * ptr
)
7360 FILE * file
= (FILE *) ptr
;
7361 unsigned long flags
;
7363 BFD_ASSERT (abfd
!= NULL
&& ptr
!= NULL
);
7365 /* Print normal ELF private data. */
7366 _bfd_elf_print_private_bfd_data (abfd
, ptr
);
7368 flags
= elf_elfheader (abfd
)->e_flags
;
7369 /* Ignore init flag - it may not be set, despite the flags field
7370 containing valid data. */
7372 /* xgettext:c-format */
7373 fprintf (file
, _("private flags = %lx:"), elf_elfheader (abfd
)->e_flags
);
7375 switch (EF_ARM_EABI_VERSION (flags
))
7377 case EF_ARM_EABI_UNKNOWN
:
7378 /* The following flag bits are GNU extensions and not part of the
7379 official ARM ELF extended ABI. Hence they are only decoded if
7380 the EABI version is not set. */
7381 if (flags
& EF_ARM_INTERWORK
)
7382 fprintf (file
, _(" [interworking enabled]"));
7384 if (flags
& EF_ARM_APCS_26
)
7385 fprintf (file
, " [APCS-26]");
7387 fprintf (file
, " [APCS-32]");
7389 if (flags
& EF_ARM_VFP_FLOAT
)
7390 fprintf (file
, _(" [VFP float format]"));
7391 else if (flags
& EF_ARM_MAVERICK_FLOAT
)
7392 fprintf (file
, _(" [Maverick float format]"));
7394 fprintf (file
, _(" [FPA float format]"));
7396 if (flags
& EF_ARM_APCS_FLOAT
)
7397 fprintf (file
, _(" [floats passed in float registers]"));
7399 if (flags
& EF_ARM_PIC
)
7400 fprintf (file
, _(" [position independent]"));
7402 if (flags
& EF_ARM_NEW_ABI
)
7403 fprintf (file
, _(" [new ABI]"));
7405 if (flags
& EF_ARM_OLD_ABI
)
7406 fprintf (file
, _(" [old ABI]"));
7408 if (flags
& EF_ARM_SOFT_FLOAT
)
7409 fprintf (file
, _(" [software FP]"));
7411 flags
&= ~(EF_ARM_INTERWORK
| EF_ARM_APCS_26
| EF_ARM_APCS_FLOAT
7412 | EF_ARM_PIC
| EF_ARM_NEW_ABI
| EF_ARM_OLD_ABI
7413 | EF_ARM_SOFT_FLOAT
| EF_ARM_VFP_FLOAT
7414 | EF_ARM_MAVERICK_FLOAT
);
7417 case EF_ARM_EABI_VER1
:
7418 fprintf (file
, _(" [Version1 EABI]"));
7420 if (flags
& EF_ARM_SYMSARESORTED
)
7421 fprintf (file
, _(" [sorted symbol table]"));
7423 fprintf (file
, _(" [unsorted symbol table]"));
7425 flags
&= ~ EF_ARM_SYMSARESORTED
;
7428 case EF_ARM_EABI_VER2
:
7429 fprintf (file
, _(" [Version2 EABI]"));
7431 if (flags
& EF_ARM_SYMSARESORTED
)
7432 fprintf (file
, _(" [sorted symbol table]"));
7434 fprintf (file
, _(" [unsorted symbol table]"));
7436 if (flags
& EF_ARM_DYNSYMSUSESEGIDX
)
7437 fprintf (file
, _(" [dynamic symbols use segment index]"));
7439 if (flags
& EF_ARM_MAPSYMSFIRST
)
7440 fprintf (file
, _(" [mapping symbols precede others]"));
7442 flags
&= ~(EF_ARM_SYMSARESORTED
| EF_ARM_DYNSYMSUSESEGIDX
7443 | EF_ARM_MAPSYMSFIRST
);
7446 case EF_ARM_EABI_VER3
:
7447 fprintf (file
, _(" [Version3 EABI]"));
7450 case EF_ARM_EABI_VER4
:
7451 fprintf (file
, _(" [Version4 EABI]"));
7454 case EF_ARM_EABI_VER5
:
7455 fprintf (file
, _(" [Version5 EABI]"));
7457 if (flags
& EF_ARM_BE8
)
7458 fprintf (file
, _(" [BE8]"));
7460 if (flags
& EF_ARM_LE8
)
7461 fprintf (file
, _(" [LE8]"));
7463 flags
&= ~(EF_ARM_LE8
| EF_ARM_BE8
);
7467 fprintf (file
, _(" <EABI version unrecognised>"));
7471 flags
&= ~ EF_ARM_EABIMASK
;
7473 if (flags
& EF_ARM_RELEXEC
)
7474 fprintf (file
, _(" [relocatable executable]"));
7476 if (flags
& EF_ARM_HASENTRY
)
7477 fprintf (file
, _(" [has entry point]"));
7479 flags
&= ~ (EF_ARM_RELEXEC
| EF_ARM_HASENTRY
);
7482 fprintf (file
, _("<Unrecognised flag bits set>"));
7490 elf32_arm_get_symbol_type (Elf_Internal_Sym
* elf_sym
, int type
)
7492 switch (ELF_ST_TYPE (elf_sym
->st_info
))
7495 return ELF_ST_TYPE (elf_sym
->st_info
);
7498 /* If the symbol is not an object, return the STT_ARM_16BIT flag.
7499 This allows us to distinguish between data used by Thumb instructions
7500 and non-data (which is probably code) inside Thumb regions of an
7502 if (type
!= STT_OBJECT
&& type
!= STT_TLS
)
7503 return ELF_ST_TYPE (elf_sym
->st_info
);
7514 elf32_arm_gc_mark_hook (asection
*sec
,
7515 struct bfd_link_info
*info
,
7516 Elf_Internal_Rela
*rel
,
7517 struct elf_link_hash_entry
*h
,
7518 Elf_Internal_Sym
*sym
)
7521 switch (ELF32_R_TYPE (rel
->r_info
))
7523 case R_ARM_GNU_VTINHERIT
:
7524 case R_ARM_GNU_VTENTRY
:
7528 return _bfd_elf_gc_mark_hook (sec
, info
, rel
, h
, sym
);
7531 /* Update the got entry reference counts for the section being removed. */
7534 elf32_arm_gc_sweep_hook (bfd
* abfd
,
7535 struct bfd_link_info
* info
,
7537 const Elf_Internal_Rela
* relocs
)
7539 Elf_Internal_Shdr
*symtab_hdr
;
7540 struct elf_link_hash_entry
**sym_hashes
;
7541 bfd_signed_vma
*local_got_refcounts
;
7542 const Elf_Internal_Rela
*rel
, *relend
;
7543 struct elf32_arm_link_hash_table
* globals
;
7545 if (info
->relocatable
)
7548 globals
= elf32_arm_hash_table (info
);
7550 elf_section_data (sec
)->local_dynrel
= NULL
;
7552 symtab_hdr
= & elf_symtab_hdr (abfd
);
7553 sym_hashes
= elf_sym_hashes (abfd
);
7554 local_got_refcounts
= elf_local_got_refcounts (abfd
);
7556 check_use_blx(globals
);
7558 relend
= relocs
+ sec
->reloc_count
;
7559 for (rel
= relocs
; rel
< relend
; rel
++)
7561 unsigned long r_symndx
;
7562 struct elf_link_hash_entry
*h
= NULL
;
7565 r_symndx
= ELF32_R_SYM (rel
->r_info
);
7566 if (r_symndx
>= symtab_hdr
->sh_info
)
7568 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
7569 while (h
->root
.type
== bfd_link_hash_indirect
7570 || h
->root
.type
== bfd_link_hash_warning
)
7571 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
7574 r_type
= ELF32_R_TYPE (rel
->r_info
);
7575 r_type
= arm_real_reloc_type (globals
, r_type
);
7579 case R_ARM_GOT_PREL
:
7580 case R_ARM_TLS_GD32
:
7581 case R_ARM_TLS_IE32
:
7584 if (h
->got
.refcount
> 0)
7585 h
->got
.refcount
-= 1;
7587 else if (local_got_refcounts
!= NULL
)
7589 if (local_got_refcounts
[r_symndx
] > 0)
7590 local_got_refcounts
[r_symndx
] -= 1;
7594 case R_ARM_TLS_LDM32
:
7595 elf32_arm_hash_table (info
)->tls_ldm_got
.refcount
-= 1;
7599 case R_ARM_ABS32_NOI
:
7601 case R_ARM_REL32_NOI
:
7607 case R_ARM_THM_CALL
:
7608 case R_ARM_THM_JUMP24
:
7609 case R_ARM_THM_JUMP19
:
7610 case R_ARM_MOVW_ABS_NC
:
7611 case R_ARM_MOVT_ABS
:
7612 case R_ARM_MOVW_PREL_NC
:
7613 case R_ARM_MOVT_PREL
:
7614 case R_ARM_THM_MOVW_ABS_NC
:
7615 case R_ARM_THM_MOVT_ABS
:
7616 case R_ARM_THM_MOVW_PREL_NC
:
7617 case R_ARM_THM_MOVT_PREL
:
7618 /* Should the interworking branches be here also? */
7622 struct elf32_arm_link_hash_entry
*eh
;
7623 struct elf32_arm_relocs_copied
**pp
;
7624 struct elf32_arm_relocs_copied
*p
;
7626 eh
= (struct elf32_arm_link_hash_entry
*) h
;
7628 if (h
->plt
.refcount
> 0)
7630 h
->plt
.refcount
-= 1;
7631 if (r_type
== R_ARM_THM_CALL
)
7632 eh
->plt_maybe_thumb_refcount
--;
7634 if (r_type
== R_ARM_THM_JUMP24
7635 || r_type
== R_ARM_THM_JUMP19
)
7636 eh
->plt_thumb_refcount
--;
7639 if (r_type
== R_ARM_ABS32
7640 || r_type
== R_ARM_REL32
7641 || r_type
== R_ARM_ABS32_NOI
7642 || r_type
== R_ARM_REL32_NOI
)
7644 for (pp
= &eh
->relocs_copied
; (p
= *pp
) != NULL
;
7646 if (p
->section
== sec
)
7649 if (ELF32_R_TYPE (rel
->r_info
) == R_ARM_REL32
7650 || ELF32_R_TYPE (rel
->r_info
) == R_ARM_REL32_NOI
)
7668 /* Look through the relocs for a section during the first phase. */
7671 elf32_arm_check_relocs (bfd
*abfd
, struct bfd_link_info
*info
,
7672 asection
*sec
, const Elf_Internal_Rela
*relocs
)
7674 Elf_Internal_Shdr
*symtab_hdr
;
7675 struct elf_link_hash_entry
**sym_hashes
;
7676 const Elf_Internal_Rela
*rel
;
7677 const Elf_Internal_Rela
*rel_end
;
7680 bfd_vma
*local_got_offsets
;
7681 struct elf32_arm_link_hash_table
*htab
;
7682 bfd_boolean needs_plt
;
7684 if (info
->relocatable
)
7687 BFD_ASSERT (is_arm_elf (abfd
));
7689 htab
= elf32_arm_hash_table (info
);
7692 /* Create dynamic sections for relocatable executables so that we can
7693 copy relocations. */
7694 if (htab
->root
.is_relocatable_executable
7695 && ! htab
->root
.dynamic_sections_created
)
7697 if (! _bfd_elf_link_create_dynamic_sections (abfd
, info
))
7701 dynobj
= elf_hash_table (info
)->dynobj
;
7702 local_got_offsets
= elf_local_got_offsets (abfd
);
7704 symtab_hdr
= & elf_symtab_hdr (abfd
);
7705 sym_hashes
= elf_sym_hashes (abfd
);
7707 rel_end
= relocs
+ sec
->reloc_count
;
7708 for (rel
= relocs
; rel
< rel_end
; rel
++)
7710 struct elf_link_hash_entry
*h
;
7711 struct elf32_arm_link_hash_entry
*eh
;
7712 unsigned long r_symndx
;
7715 r_symndx
= ELF32_R_SYM (rel
->r_info
);
7716 r_type
= ELF32_R_TYPE (rel
->r_info
);
7717 r_type
= arm_real_reloc_type (htab
, r_type
);
7719 if (r_symndx
>= NUM_SHDR_ENTRIES (symtab_hdr
))
7721 (*_bfd_error_handler
) (_("%B: bad symbol index: %d"), abfd
,
7726 if (r_symndx
< symtab_hdr
->sh_info
)
7730 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
7731 while (h
->root
.type
== bfd_link_hash_indirect
7732 || h
->root
.type
== bfd_link_hash_warning
)
7733 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
7736 eh
= (struct elf32_arm_link_hash_entry
*) h
;
7741 case R_ARM_GOT_PREL
:
7742 case R_ARM_TLS_GD32
:
7743 case R_ARM_TLS_IE32
:
7744 /* This symbol requires a global offset table entry. */
7746 int tls_type
, old_tls_type
;
7750 case R_ARM_TLS_GD32
: tls_type
= GOT_TLS_GD
; break;
7751 case R_ARM_TLS_IE32
: tls_type
= GOT_TLS_IE
; break;
7752 default: tls_type
= GOT_NORMAL
; break;
7758 old_tls_type
= elf32_arm_hash_entry (h
)->tls_type
;
7762 bfd_signed_vma
*local_got_refcounts
;
7764 /* This is a global offset table entry for a local symbol. */
7765 local_got_refcounts
= elf_local_got_refcounts (abfd
);
7766 if (local_got_refcounts
== NULL
)
7770 size
= symtab_hdr
->sh_info
;
7771 size
*= (sizeof (bfd_signed_vma
) + sizeof(char));
7772 local_got_refcounts
= bfd_zalloc (abfd
, size
);
7773 if (local_got_refcounts
== NULL
)
7775 elf_local_got_refcounts (abfd
) = local_got_refcounts
;
7776 elf32_arm_local_got_tls_type (abfd
)
7777 = (char *) (local_got_refcounts
+ symtab_hdr
->sh_info
);
7779 local_got_refcounts
[r_symndx
] += 1;
7780 old_tls_type
= elf32_arm_local_got_tls_type (abfd
) [r_symndx
];
7783 /* We will already have issued an error message if there is a
7784 TLS / non-TLS mismatch, based on the symbol type. We don't
7785 support any linker relaxations. So just combine any TLS
7787 if (old_tls_type
!= GOT_UNKNOWN
&& old_tls_type
!= GOT_NORMAL
7788 && tls_type
!= GOT_NORMAL
)
7789 tls_type
|= old_tls_type
;
7791 if (old_tls_type
!= tls_type
)
7794 elf32_arm_hash_entry (h
)->tls_type
= tls_type
;
7796 elf32_arm_local_got_tls_type (abfd
) [r_symndx
] = tls_type
;
7801 case R_ARM_TLS_LDM32
:
7802 if (r_type
== R_ARM_TLS_LDM32
)
7803 htab
->tls_ldm_got
.refcount
++;
7806 case R_ARM_GOTOFF32
:
7808 if (htab
->sgot
== NULL
)
7810 if (htab
->root
.dynobj
== NULL
)
7811 htab
->root
.dynobj
= abfd
;
7812 if (!create_got_section (htab
->root
.dynobj
, info
))
7818 /* VxWorks uses dynamic R_ARM_ABS12 relocations for
7819 ldr __GOTT_INDEX__ offsets. */
7820 if (!htab
->vxworks_p
)
7829 case R_ARM_THM_CALL
:
7830 case R_ARM_THM_JUMP24
:
7831 case R_ARM_THM_JUMP19
:
7836 case R_ARM_ABS32_NOI
:
7838 case R_ARM_REL32_NOI
:
7839 case R_ARM_MOVW_ABS_NC
:
7840 case R_ARM_MOVT_ABS
:
7841 case R_ARM_MOVW_PREL_NC
:
7842 case R_ARM_MOVT_PREL
:
7843 case R_ARM_THM_MOVW_ABS_NC
:
7844 case R_ARM_THM_MOVT_ABS
:
7845 case R_ARM_THM_MOVW_PREL_NC
:
7846 case R_ARM_THM_MOVT_PREL
:
7850 /* Should the interworking branches be listed here? */
7853 /* If this reloc is in a read-only section, we might
7854 need a copy reloc. We can't check reliably at this
7855 stage whether the section is read-only, as input
7856 sections have not yet been mapped to output sections.
7857 Tentatively set the flag for now, and correct in
7858 adjust_dynamic_symbol. */
7862 /* We may need a .plt entry if the function this reloc
7863 refers to is in a different object. We can't tell for
7864 sure yet, because something later might force the
7869 /* If we create a PLT entry, this relocation will reference
7870 it, even if it's an ABS32 relocation. */
7871 h
->plt
.refcount
+= 1;
7873 /* It's too early to use htab->use_blx here, so we have to
7874 record possible blx references separately from
7875 relocs that definitely need a thumb stub. */
7877 if (r_type
== R_ARM_THM_CALL
)
7878 eh
->plt_maybe_thumb_refcount
+= 1;
7880 if (r_type
== R_ARM_THM_JUMP24
7881 || r_type
== R_ARM_THM_JUMP19
)
7882 eh
->plt_thumb_refcount
+= 1;
7885 /* If we are creating a shared library or relocatable executable,
7886 and this is a reloc against a global symbol, or a non PC
7887 relative reloc against a local symbol, then we need to copy
7888 the reloc into the shared library. However, if we are linking
7889 with -Bsymbolic, we do not need to copy a reloc against a
7890 global symbol which is defined in an object we are
7891 including in the link (i.e., DEF_REGULAR is set). At
7892 this point we have not seen all the input files, so it is
7893 possible that DEF_REGULAR is not set now but will be set
7894 later (it is never cleared). We account for that
7895 possibility below by storing information in the
7896 relocs_copied field of the hash table entry. */
7897 if ((info
->shared
|| htab
->root
.is_relocatable_executable
)
7898 && (sec
->flags
& SEC_ALLOC
) != 0
7899 && ((r_type
== R_ARM_ABS32
|| r_type
== R_ARM_ABS32_NOI
)
7900 || (h
!= NULL
&& ! h
->needs_plt
7901 && (! info
->symbolic
|| ! h
->def_regular
))))
7903 struct elf32_arm_relocs_copied
*p
, **head
;
7905 /* When creating a shared object, we must copy these
7906 reloc types into the output file. We create a reloc
7907 section in dynobj and make room for this reloc. */
7912 name
= (bfd_elf_string_from_elf_section
7914 elf_elfheader (abfd
)->e_shstrndx
,
7915 elf_section_data (sec
)->rel_hdr
.sh_name
));
7919 BFD_ASSERT (reloc_section_p (htab
, name
, sec
));
7921 sreloc
= bfd_get_section_by_name (dynobj
, name
);
7926 flags
= (SEC_HAS_CONTENTS
| SEC_READONLY
7927 | SEC_IN_MEMORY
| SEC_LINKER_CREATED
);
7928 if ((sec
->flags
& SEC_ALLOC
) != 0
7929 /* BPABI objects never have dynamic
7930 relocations mapped. */
7931 && !htab
->symbian_p
)
7932 flags
|= SEC_ALLOC
| SEC_LOAD
;
7933 sreloc
= bfd_make_section_with_flags (dynobj
,
7937 || ! bfd_set_section_alignment (dynobj
, sreloc
, 2))
7941 elf_section_data (sec
)->sreloc
= sreloc
;
7944 /* If this is a global symbol, we count the number of
7945 relocations we need for this symbol. */
7948 head
= &((struct elf32_arm_link_hash_entry
*) h
)->relocs_copied
;
7952 /* Track dynamic relocs needed for local syms too.
7953 We really need local syms available to do this
7959 s
= bfd_section_from_r_symndx (abfd
, &htab
->sym_sec
,
7964 vpp
= &elf_section_data (s
)->local_dynrel
;
7965 head
= (struct elf32_arm_relocs_copied
**) vpp
;
7969 if (p
== NULL
|| p
->section
!= sec
)
7971 bfd_size_type amt
= sizeof *p
;
7973 p
= bfd_alloc (htab
->root
.dynobj
, amt
);
7983 if (r_type
== R_ARM_REL32
|| r_type
== R_ARM_REL32_NOI
)
7989 /* This relocation describes the C++ object vtable hierarchy.
7990 Reconstruct it for later use during GC. */
7991 case R_ARM_GNU_VTINHERIT
:
7992 if (!bfd_elf_gc_record_vtinherit (abfd
, sec
, h
, rel
->r_offset
))
7996 /* This relocation describes which C++ vtable entries are actually
7997 used. Record for later use during GC. */
7998 case R_ARM_GNU_VTENTRY
:
7999 BFD_ASSERT (h
!= NULL
);
8001 && !bfd_elf_gc_record_vtentry (abfd
, sec
, h
, rel
->r_offset
))
8010 /* Unwinding tables are not referenced directly. This pass marks them as
8011 required if the corresponding code section is marked. */
8014 elf32_arm_gc_mark_extra_sections(struct bfd_link_info
*info
,
8015 elf_gc_mark_hook_fn gc_mark_hook
)
8018 Elf_Internal_Shdr
**elf_shdrp
;
8021 /* Marking EH data may cause additional code sections to be marked,
8022 requiring multiple passes. */
8027 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link_next
)
8031 if (! is_arm_elf (sub
))
8034 elf_shdrp
= elf_elfsections (sub
);
8035 for (o
= sub
->sections
; o
!= NULL
; o
= o
->next
)
8037 Elf_Internal_Shdr
*hdr
;
8039 hdr
= &elf_section_data (o
)->this_hdr
;
8040 if (hdr
->sh_type
== SHT_ARM_EXIDX
&& hdr
->sh_link
8042 && elf_shdrp
[hdr
->sh_link
]->bfd_section
->gc_mark
)
8045 if (!_bfd_elf_gc_mark (info
, o
, gc_mark_hook
))
8055 /* Treat mapping symbols as special target symbols. */
8058 elf32_arm_is_target_special_symbol (bfd
* abfd ATTRIBUTE_UNUSED
, asymbol
* sym
)
8060 return bfd_is_arm_special_symbol_name (sym
->name
,
8061 BFD_ARM_SPECIAL_SYM_TYPE_ANY
);
8064 /* This is a copy of elf_find_function() from elf.c except that
8065 ARM mapping symbols are ignored when looking for function names
8066 and STT_ARM_TFUNC is considered to a function type. */
8069 arm_elf_find_function (bfd
* abfd ATTRIBUTE_UNUSED
,
8073 const char ** filename_ptr
,
8074 const char ** functionname_ptr
)
8076 const char * filename
= NULL
;
8077 asymbol
* func
= NULL
;
8078 bfd_vma low_func
= 0;
8081 for (p
= symbols
; *p
!= NULL
; p
++)
8085 q
= (elf_symbol_type
*) *p
;
8087 switch (ELF_ST_TYPE (q
->internal_elf_sym
.st_info
))
8092 filename
= bfd_asymbol_name (&q
->symbol
);
8097 /* Skip mapping symbols. */
8098 if ((q
->symbol
.flags
& BSF_LOCAL
)
8099 && bfd_is_arm_special_symbol_name (q
->symbol
.name
,
8100 BFD_ARM_SPECIAL_SYM_TYPE_ANY
))
8103 if (bfd_get_section (&q
->symbol
) == section
8104 && q
->symbol
.value
>= low_func
8105 && q
->symbol
.value
<= offset
)
8107 func
= (asymbol
*) q
;
8108 low_func
= q
->symbol
.value
;
8118 *filename_ptr
= filename
;
8119 if (functionname_ptr
)
8120 *functionname_ptr
= bfd_asymbol_name (func
);
8126 /* Find the nearest line to a particular section and offset, for error
8127 reporting. This code is a duplicate of the code in elf.c, except
8128 that it uses arm_elf_find_function. */
8131 elf32_arm_find_nearest_line (bfd
* abfd
,
8135 const char ** filename_ptr
,
8136 const char ** functionname_ptr
,
8137 unsigned int * line_ptr
)
8139 bfd_boolean found
= FALSE
;
8141 /* We skip _bfd_dwarf1_find_nearest_line since no known ARM toolchain uses it. */
8143 if (_bfd_dwarf2_find_nearest_line (abfd
, section
, symbols
, offset
,
8144 filename_ptr
, functionname_ptr
,
8146 & elf_tdata (abfd
)->dwarf2_find_line_info
))
8148 if (!*functionname_ptr
)
8149 arm_elf_find_function (abfd
, section
, symbols
, offset
,
8150 *filename_ptr
? NULL
: filename_ptr
,
8156 if (! _bfd_stab_section_find_nearest_line (abfd
, symbols
, section
, offset
,
8157 & found
, filename_ptr
,
8158 functionname_ptr
, line_ptr
,
8159 & elf_tdata (abfd
)->line_info
))
8162 if (found
&& (*functionname_ptr
|| *line_ptr
))
8165 if (symbols
== NULL
)
8168 if (! arm_elf_find_function (abfd
, section
, symbols
, offset
,
8169 filename_ptr
, functionname_ptr
))
8177 elf32_arm_find_inliner_info (bfd
* abfd
,
8178 const char ** filename_ptr
,
8179 const char ** functionname_ptr
,
8180 unsigned int * line_ptr
)
8183 found
= _bfd_dwarf2_find_inliner_info (abfd
, filename_ptr
,
8184 functionname_ptr
, line_ptr
,
8185 & elf_tdata (abfd
)->dwarf2_find_line_info
);
8189 /* Adjust a symbol defined by a dynamic object and referenced by a
8190 regular object. The current definition is in some section of the
8191 dynamic object, but we're not including those sections. We have to
8192 change the definition to something the rest of the link can
8196 elf32_arm_adjust_dynamic_symbol (struct bfd_link_info
* info
,
8197 struct elf_link_hash_entry
* h
)
8201 struct elf32_arm_link_hash_entry
* eh
;
8202 struct elf32_arm_link_hash_table
*globals
;
8204 globals
= elf32_arm_hash_table (info
);
8205 dynobj
= elf_hash_table (info
)->dynobj
;
8207 /* Make sure we know what is going on here. */
8208 BFD_ASSERT (dynobj
!= NULL
8210 || h
->u
.weakdef
!= NULL
8213 && !h
->def_regular
)));
8215 eh
= (struct elf32_arm_link_hash_entry
*) h
;
8217 /* If this is a function, put it in the procedure linkage table. We
8218 will fill in the contents of the procedure linkage table later,
8219 when we know the address of the .got section. */
8220 if (h
->type
== STT_FUNC
|| h
->type
== STT_ARM_TFUNC
8223 if (h
->plt
.refcount
<= 0
8224 || SYMBOL_CALLS_LOCAL (info
, h
)
8225 || (ELF_ST_VISIBILITY (h
->other
) != STV_DEFAULT
8226 && h
->root
.type
== bfd_link_hash_undefweak
))
8228 /* This case can occur if we saw a PLT32 reloc in an input
8229 file, but the symbol was never referred to by a dynamic
8230 object, or if all references were garbage collected. In
8231 such a case, we don't actually need to build a procedure
8232 linkage table, and we can just do a PC24 reloc instead. */
8233 h
->plt
.offset
= (bfd_vma
) -1;
8234 eh
->plt_thumb_refcount
= 0;
8235 eh
->plt_maybe_thumb_refcount
= 0;
8243 /* It's possible that we incorrectly decided a .plt reloc was
8244 needed for an R_ARM_PC24 or similar reloc to a non-function sym
8245 in check_relocs. We can't decide accurately between function
8246 and non-function syms in check-relocs; Objects loaded later in
8247 the link may change h->type. So fix it now. */
8248 h
->plt
.offset
= (bfd_vma
) -1;
8249 eh
->plt_thumb_refcount
= 0;
8250 eh
->plt_maybe_thumb_refcount
= 0;
8253 /* If this is a weak symbol, and there is a real definition, the
8254 processor independent code will have arranged for us to see the
8255 real definition first, and we can just use the same value. */
8256 if (h
->u
.weakdef
!= NULL
)
8258 BFD_ASSERT (h
->u
.weakdef
->root
.type
== bfd_link_hash_defined
8259 || h
->u
.weakdef
->root
.type
== bfd_link_hash_defweak
);
8260 h
->root
.u
.def
.section
= h
->u
.weakdef
->root
.u
.def
.section
;
8261 h
->root
.u
.def
.value
= h
->u
.weakdef
->root
.u
.def
.value
;
8265 /* If there are no non-GOT references, we do not need a copy
8267 if (!h
->non_got_ref
)
8270 /* This is a reference to a symbol defined by a dynamic object which
8271 is not a function. */
8273 /* If we are creating a shared library, we must presume that the
8274 only references to the symbol are via the global offset table.
8275 For such cases we need not do anything here; the relocations will
8276 be handled correctly by relocate_section. Relocatable executables
8277 can reference data in shared objects directly, so we don't need to
8278 do anything here. */
8279 if (info
->shared
|| globals
->root
.is_relocatable_executable
)
8284 (*_bfd_error_handler
) (_("dynamic variable `%s' is zero size"),
8285 h
->root
.root
.string
);
8289 /* We must allocate the symbol in our .dynbss section, which will
8290 become part of the .bss section of the executable. There will be
8291 an entry for this symbol in the .dynsym section. The dynamic
8292 object will contain position independent code, so all references
8293 from the dynamic object to this symbol will go through the global
8294 offset table. The dynamic linker will use the .dynsym entry to
8295 determine the address it must put in the global offset table, so
8296 both the dynamic object and the regular object will refer to the
8297 same memory location for the variable. */
8298 s
= bfd_get_section_by_name (dynobj
, ".dynbss");
8299 BFD_ASSERT (s
!= NULL
);
8301 /* We must generate a R_ARM_COPY reloc to tell the dynamic linker to
8302 copy the initial value out of the dynamic object and into the
8303 runtime process image. We need to remember the offset into the
8304 .rel(a).bss section we are going to use. */
8305 if ((h
->root
.u
.def
.section
->flags
& SEC_ALLOC
) != 0)
8309 srel
= bfd_get_section_by_name (dynobj
, RELOC_SECTION (globals
, ".bss"));
8310 BFD_ASSERT (srel
!= NULL
);
8311 srel
->size
+= RELOC_SIZE (globals
);
8315 return _bfd_elf_adjust_dynamic_copy (h
, s
);
8318 /* Allocate space in .plt, .got and associated reloc sections for
8322 allocate_dynrelocs (struct elf_link_hash_entry
*h
, void * inf
)
8324 struct bfd_link_info
*info
;
8325 struct elf32_arm_link_hash_table
*htab
;
8326 struct elf32_arm_link_hash_entry
*eh
;
8327 struct elf32_arm_relocs_copied
*p
;
8328 bfd_signed_vma thumb_refs
;
8330 eh
= (struct elf32_arm_link_hash_entry
*) h
;
8332 if (h
->root
.type
== bfd_link_hash_indirect
)
8335 if (h
->root
.type
== bfd_link_hash_warning
)
8336 /* When warning symbols are created, they **replace** the "real"
8337 entry in the hash table, thus we never get to see the real
8338 symbol in a hash traversal. So look at it now. */
8339 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
8341 info
= (struct bfd_link_info
*) inf
;
8342 htab
= elf32_arm_hash_table (info
);
8344 if (htab
->root
.dynamic_sections_created
8345 && h
->plt
.refcount
> 0)
8347 /* Make sure this symbol is output as a dynamic symbol.
8348 Undefined weak syms won't yet be marked as dynamic. */
8349 if (h
->dynindx
== -1
8350 && !h
->forced_local
)
8352 if (! bfd_elf_link_record_dynamic_symbol (info
, h
))
8357 || WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, 0, h
))
8359 asection
*s
= htab
->splt
;
8361 /* If this is the first .plt entry, make room for the special
8364 s
->size
+= htab
->plt_header_size
;
8366 h
->plt
.offset
= s
->size
;
8368 /* If we will insert a Thumb trampoline before this PLT, leave room
8370 thumb_refs
= eh
->plt_thumb_refcount
;
8372 thumb_refs
+= eh
->plt_maybe_thumb_refcount
;
8376 h
->plt
.offset
+= PLT_THUMB_STUB_SIZE
;
8377 s
->size
+= PLT_THUMB_STUB_SIZE
;
8380 /* If this symbol is not defined in a regular file, and we are
8381 not generating a shared library, then set the symbol to this
8382 location in the .plt. This is required to make function
8383 pointers compare as equal between the normal executable and
8384 the shared library. */
8388 h
->root
.u
.def
.section
= s
;
8389 h
->root
.u
.def
.value
= h
->plt
.offset
;
8391 /* Make sure the function is not marked as Thumb, in case
8392 it is the target of an ABS32 relocation, which will
8393 point to the PLT entry. */
8394 if (ELF_ST_TYPE (h
->type
) == STT_ARM_TFUNC
)
8395 h
->type
= ELF_ST_INFO (ELF_ST_BIND (h
->type
), STT_FUNC
);
8398 /* Make room for this entry. */
8399 s
->size
+= htab
->plt_entry_size
;
8401 if (!htab
->symbian_p
)
8403 /* We also need to make an entry in the .got.plt section, which
8404 will be placed in the .got section by the linker script. */
8405 eh
->plt_got_offset
= htab
->sgotplt
->size
;
8406 htab
->sgotplt
->size
+= 4;
8409 /* We also need to make an entry in the .rel(a).plt section. */
8410 htab
->srelplt
->size
+= RELOC_SIZE (htab
);
8412 /* VxWorks executables have a second set of relocations for
8413 each PLT entry. They go in a separate relocation section,
8414 which is processed by the kernel loader. */
8415 if (htab
->vxworks_p
&& !info
->shared
)
8417 /* There is a relocation for the initial PLT entry:
8418 an R_ARM_32 relocation for _GLOBAL_OFFSET_TABLE_. */
8419 if (h
->plt
.offset
== htab
->plt_header_size
)
8420 htab
->srelplt2
->size
+= RELOC_SIZE (htab
);
8422 /* There are two extra relocations for each subsequent
8423 PLT entry: an R_ARM_32 relocation for the GOT entry,
8424 and an R_ARM_32 relocation for the PLT entry. */
8425 htab
->srelplt2
->size
+= RELOC_SIZE (htab
) * 2;
8430 h
->plt
.offset
= (bfd_vma
) -1;
8436 h
->plt
.offset
= (bfd_vma
) -1;
8440 if (h
->got
.refcount
> 0)
8444 int tls_type
= elf32_arm_hash_entry (h
)->tls_type
;
8447 /* Make sure this symbol is output as a dynamic symbol.
8448 Undefined weak syms won't yet be marked as dynamic. */
8449 if (h
->dynindx
== -1
8450 && !h
->forced_local
)
8452 if (! bfd_elf_link_record_dynamic_symbol (info
, h
))
8456 if (!htab
->symbian_p
)
8459 h
->got
.offset
= s
->size
;
8461 if (tls_type
== GOT_UNKNOWN
)
8464 if (tls_type
== GOT_NORMAL
)
8465 /* Non-TLS symbols need one GOT slot. */
8469 if (tls_type
& GOT_TLS_GD
)
8470 /* R_ARM_TLS_GD32 needs 2 consecutive GOT slots. */
8472 if (tls_type
& GOT_TLS_IE
)
8473 /* R_ARM_TLS_IE32 needs one GOT slot. */
8477 dyn
= htab
->root
.dynamic_sections_created
;
8480 if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn
, info
->shared
, h
)
8482 || !SYMBOL_REFERENCES_LOCAL (info
, h
)))
8485 if (tls_type
!= GOT_NORMAL
8486 && (info
->shared
|| indx
!= 0)
8487 && (ELF_ST_VISIBILITY (h
->other
) == STV_DEFAULT
8488 || h
->root
.type
!= bfd_link_hash_undefweak
))
8490 if (tls_type
& GOT_TLS_IE
)
8491 htab
->srelgot
->size
+= RELOC_SIZE (htab
);
8493 if (tls_type
& GOT_TLS_GD
)
8494 htab
->srelgot
->size
+= RELOC_SIZE (htab
);
8496 if ((tls_type
& GOT_TLS_GD
) && indx
!= 0)
8497 htab
->srelgot
->size
+= RELOC_SIZE (htab
);
8499 else if ((ELF_ST_VISIBILITY (h
->other
) == STV_DEFAULT
8500 || h
->root
.type
!= bfd_link_hash_undefweak
)
8502 || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn
, 0, h
)))
8503 htab
->srelgot
->size
+= RELOC_SIZE (htab
);
8507 h
->got
.offset
= (bfd_vma
) -1;
8509 /* Allocate stubs for exported Thumb functions on v4t. */
8510 if (!htab
->use_blx
&& h
->dynindx
!= -1
8512 && ELF_ST_TYPE (h
->type
) == STT_ARM_TFUNC
8513 && ELF_ST_VISIBILITY (h
->other
) == STV_DEFAULT
)
8515 struct elf_link_hash_entry
* th
;
8516 struct bfd_link_hash_entry
* bh
;
8517 struct elf_link_hash_entry
* myh
;
8521 /* Create a new symbol to regist the real location of the function. */
8522 s
= h
->root
.u
.def
.section
;
8523 sprintf(name
, "__real_%s", h
->root
.root
.string
);
8524 _bfd_generic_link_add_one_symbol (info
, s
->owner
,
8525 name
, BSF_GLOBAL
, s
,
8526 h
->root
.u
.def
.value
,
8527 NULL
, TRUE
, FALSE
, &bh
);
8529 myh
= (struct elf_link_hash_entry
*) bh
;
8530 myh
->type
= ELF_ST_INFO (STB_LOCAL
, STT_ARM_TFUNC
);
8531 myh
->forced_local
= 1;
8532 eh
->export_glue
= myh
;
8533 th
= record_arm_to_thumb_glue (info
, h
);
8534 /* Point the symbol at the stub. */
8535 h
->type
= ELF_ST_INFO (ELF_ST_BIND (h
->type
), STT_FUNC
);
8536 h
->root
.u
.def
.section
= th
->root
.u
.def
.section
;
8537 h
->root
.u
.def
.value
= th
->root
.u
.def
.value
& ~1;
8540 if (eh
->relocs_copied
== NULL
)
8543 /* In the shared -Bsymbolic case, discard space allocated for
8544 dynamic pc-relative relocs against symbols which turn out to be
8545 defined in regular objects. For the normal shared case, discard
8546 space for pc-relative relocs that have become local due to symbol
8547 visibility changes. */
8549 if (info
->shared
|| htab
->root
.is_relocatable_executable
)
8551 /* The only relocs that use pc_count are R_ARM_REL32 and
8552 R_ARM_REL32_NOI, which will appear on something like
8553 ".long foo - .". We want calls to protected symbols to resolve
8554 directly to the function rather than going via the plt. If people
8555 want function pointer comparisons to work as expected then they
8556 should avoid writing assembly like ".long foo - .". */
8557 if (SYMBOL_CALLS_LOCAL (info
, h
))
8559 struct elf32_arm_relocs_copied
**pp
;
8561 for (pp
= &eh
->relocs_copied
; (p
= *pp
) != NULL
; )
8563 p
->count
-= p
->pc_count
;
8572 /* Also discard relocs on undefined weak syms with non-default
8574 if (eh
->relocs_copied
!= NULL
8575 && h
->root
.type
== bfd_link_hash_undefweak
)
8577 if (ELF_ST_VISIBILITY (h
->other
) != STV_DEFAULT
)
8578 eh
->relocs_copied
= NULL
;
8580 /* Make sure undefined weak symbols are output as a dynamic
8582 else if (h
->dynindx
== -1
8583 && !h
->forced_local
)
8585 if (! bfd_elf_link_record_dynamic_symbol (info
, h
))
8590 else if (htab
->root
.is_relocatable_executable
&& h
->dynindx
== -1
8591 && h
->root
.type
== bfd_link_hash_new
)
8593 /* Output absolute symbols so that we can create relocations
8594 against them. For normal symbols we output a relocation
8595 against the section that contains them. */
8596 if (! bfd_elf_link_record_dynamic_symbol (info
, h
))
8603 /* For the non-shared case, discard space for relocs against
8604 symbols which turn out to need copy relocs or are not
8610 || (htab
->root
.dynamic_sections_created
8611 && (h
->root
.type
== bfd_link_hash_undefweak
8612 || h
->root
.type
== bfd_link_hash_undefined
))))
8614 /* Make sure this symbol is output as a dynamic symbol.
8615 Undefined weak syms won't yet be marked as dynamic. */
8616 if (h
->dynindx
== -1
8617 && !h
->forced_local
)
8619 if (! bfd_elf_link_record_dynamic_symbol (info
, h
))
8623 /* If that succeeded, we know we'll be keeping all the
8625 if (h
->dynindx
!= -1)
8629 eh
->relocs_copied
= NULL
;
8634 /* Finally, allocate space. */
8635 for (p
= eh
->relocs_copied
; p
!= NULL
; p
= p
->next
)
8637 asection
*sreloc
= elf_section_data (p
->section
)->sreloc
;
8638 sreloc
->size
+= p
->count
* RELOC_SIZE (htab
);
8644 /* Find any dynamic relocs that apply to read-only sections. */
8647 elf32_arm_readonly_dynrelocs (struct elf_link_hash_entry
*h
, PTR inf
)
8649 struct elf32_arm_link_hash_entry
*eh
;
8650 struct elf32_arm_relocs_copied
*p
;
8652 if (h
->root
.type
== bfd_link_hash_warning
)
8653 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
8655 eh
= (struct elf32_arm_link_hash_entry
*) h
;
8656 for (p
= eh
->relocs_copied
; p
!= NULL
; p
= p
->next
)
8658 asection
*s
= p
->section
;
8660 if (s
!= NULL
&& (s
->flags
& SEC_READONLY
) != 0)
8662 struct bfd_link_info
*info
= (struct bfd_link_info
*) inf
;
8664 info
->flags
|= DF_TEXTREL
;
8666 /* Not an error, just cut short the traversal. */
8674 bfd_elf32_arm_set_byteswap_code (struct bfd_link_info
*info
,
8677 struct elf32_arm_link_hash_table
*globals
;
8679 globals
= elf32_arm_hash_table (info
);
8680 globals
->byteswap_code
= byteswap_code
;
8683 /* Set the sizes of the dynamic sections. */
8686 elf32_arm_size_dynamic_sections (bfd
* output_bfd ATTRIBUTE_UNUSED
,
8687 struct bfd_link_info
* info
)
8694 struct elf32_arm_link_hash_table
*htab
;
8696 htab
= elf32_arm_hash_table (info
);
8697 dynobj
= elf_hash_table (info
)->dynobj
;
8698 BFD_ASSERT (dynobj
!= NULL
);
8699 check_use_blx (htab
);
8701 if (elf_hash_table (info
)->dynamic_sections_created
)
8703 /* Set the contents of the .interp section to the interpreter. */
8704 if (info
->executable
)
8706 s
= bfd_get_section_by_name (dynobj
, ".interp");
8707 BFD_ASSERT (s
!= NULL
);
8708 s
->size
= sizeof ELF_DYNAMIC_INTERPRETER
;
8709 s
->contents
= (unsigned char *) ELF_DYNAMIC_INTERPRETER
;
8713 /* Set up .got offsets for local syms, and space for local dynamic
8715 for (ibfd
= info
->input_bfds
; ibfd
!= NULL
; ibfd
= ibfd
->link_next
)
8717 bfd_signed_vma
*local_got
;
8718 bfd_signed_vma
*end_local_got
;
8719 char *local_tls_type
;
8720 bfd_size_type locsymcount
;
8721 Elf_Internal_Shdr
*symtab_hdr
;
8724 if (! is_arm_elf (ibfd
))
8727 for (s
= ibfd
->sections
; s
!= NULL
; s
= s
->next
)
8729 struct elf32_arm_relocs_copied
*p
;
8731 for (p
= elf_section_data (s
)->local_dynrel
; p
!= NULL
; p
= p
->next
)
8733 if (!bfd_is_abs_section (p
->section
)
8734 && bfd_is_abs_section (p
->section
->output_section
))
8736 /* Input section has been discarded, either because
8737 it is a copy of a linkonce section or due to
8738 linker script /DISCARD/, so we'll be discarding
8741 else if (p
->count
!= 0)
8743 srel
= elf_section_data (p
->section
)->sreloc
;
8744 srel
->size
+= p
->count
* RELOC_SIZE (htab
);
8745 if ((p
->section
->output_section
->flags
& SEC_READONLY
) != 0)
8746 info
->flags
|= DF_TEXTREL
;
8751 local_got
= elf_local_got_refcounts (ibfd
);
8755 symtab_hdr
= & elf_symtab_hdr (ibfd
);
8756 locsymcount
= symtab_hdr
->sh_info
;
8757 end_local_got
= local_got
+ locsymcount
;
8758 local_tls_type
= elf32_arm_local_got_tls_type (ibfd
);
8760 srel
= htab
->srelgot
;
8761 for (; local_got
< end_local_got
; ++local_got
, ++local_tls_type
)
8765 *local_got
= s
->size
;
8766 if (*local_tls_type
& GOT_TLS_GD
)
8767 /* TLS_GD relocs need an 8-byte structure in the GOT. */
8769 if (*local_tls_type
& GOT_TLS_IE
)
8771 if (*local_tls_type
== GOT_NORMAL
)
8774 if (info
->shared
|| *local_tls_type
== GOT_TLS_GD
)
8775 srel
->size
+= RELOC_SIZE (htab
);
8778 *local_got
= (bfd_vma
) -1;
8782 if (htab
->tls_ldm_got
.refcount
> 0)
8784 /* Allocate two GOT entries and one dynamic relocation (if necessary)
8785 for R_ARM_TLS_LDM32 relocations. */
8786 htab
->tls_ldm_got
.offset
= htab
->sgot
->size
;
8787 htab
->sgot
->size
+= 8;
8789 htab
->srelgot
->size
+= RELOC_SIZE (htab
);
8792 htab
->tls_ldm_got
.offset
= -1;
8794 /* Allocate global sym .plt and .got entries, and space for global
8795 sym dynamic relocs. */
8796 elf_link_hash_traverse (& htab
->root
, allocate_dynrelocs
, info
);
8798 /* Here we rummage through the found bfds to collect glue information. */
8799 for (ibfd
= info
->input_bfds
; ibfd
!= NULL
; ibfd
= ibfd
->link_next
)
8801 if (! is_arm_elf (ibfd
))
8804 /* Initialise mapping tables for code/data. */
8805 bfd_elf32_arm_init_maps (ibfd
);
8807 if (!bfd_elf32_arm_process_before_allocation (ibfd
, info
)
8808 || !bfd_elf32_arm_vfp11_erratum_scan (ibfd
, info
))
8809 /* xgettext:c-format */
8810 _bfd_error_handler (_("Errors encountered processing file %s"),
8814 /* The check_relocs and adjust_dynamic_symbol entry points have
8815 determined the sizes of the various dynamic sections. Allocate
8819 for (s
= dynobj
->sections
; s
!= NULL
; s
= s
->next
)
8823 if ((s
->flags
& SEC_LINKER_CREATED
) == 0)
8826 /* It's OK to base decisions on the section name, because none
8827 of the dynobj section names depend upon the input files. */
8828 name
= bfd_get_section_name (dynobj
, s
);
8830 if (strcmp (name
, ".plt") == 0)
8832 /* Remember whether there is a PLT. */
8835 else if (CONST_STRNEQ (name
, ".rel"))
8839 /* Remember whether there are any reloc sections other
8840 than .rel(a).plt and .rela.plt.unloaded. */
8841 if (s
!= htab
->srelplt
&& s
!= htab
->srelplt2
)
8844 /* We use the reloc_count field as a counter if we need
8845 to copy relocs into the output file. */
8849 else if (! CONST_STRNEQ (name
, ".got")
8850 && strcmp (name
, ".dynbss") != 0)
8852 /* It's not one of our sections, so don't allocate space. */
8858 /* If we don't need this section, strip it from the
8859 output file. This is mostly to handle .rel(a).bss and
8860 .rel(a).plt. We must create both sections in
8861 create_dynamic_sections, because they must be created
8862 before the linker maps input sections to output
8863 sections. The linker does that before
8864 adjust_dynamic_symbol is called, and it is that
8865 function which decides whether anything needs to go
8866 into these sections. */
8867 s
->flags
|= SEC_EXCLUDE
;
8871 if ((s
->flags
& SEC_HAS_CONTENTS
) == 0)
8874 /* Allocate memory for the section contents. */
8875 s
->contents
= (bfd_byte
*) bfd_zalloc (dynobj
, s
->size
);
8876 if (s
->contents
== NULL
)
8880 if (elf_hash_table (info
)->dynamic_sections_created
)
8882 /* Add some entries to the .dynamic section. We fill in the
8883 values later, in elf32_arm_finish_dynamic_sections, but we
8884 must add the entries now so that we get the correct size for
8885 the .dynamic section. The DT_DEBUG entry is filled in by the
8886 dynamic linker and used by the debugger. */
8887 #define add_dynamic_entry(TAG, VAL) \
8888 _bfd_elf_add_dynamic_entry (info, TAG, VAL)
8890 if (info
->executable
)
8892 if (!add_dynamic_entry (DT_DEBUG
, 0))
8898 if ( !add_dynamic_entry (DT_PLTGOT
, 0)
8899 || !add_dynamic_entry (DT_PLTRELSZ
, 0)
8900 || !add_dynamic_entry (DT_PLTREL
,
8901 htab
->use_rel
? DT_REL
: DT_RELA
)
8902 || !add_dynamic_entry (DT_JMPREL
, 0))
8910 if (!add_dynamic_entry (DT_REL
, 0)
8911 || !add_dynamic_entry (DT_RELSZ
, 0)
8912 || !add_dynamic_entry (DT_RELENT
, RELOC_SIZE (htab
)))
8917 if (!add_dynamic_entry (DT_RELA
, 0)
8918 || !add_dynamic_entry (DT_RELASZ
, 0)
8919 || !add_dynamic_entry (DT_RELAENT
, RELOC_SIZE (htab
)))
8924 /* If any dynamic relocs apply to a read-only section,
8925 then we need a DT_TEXTREL entry. */
8926 if ((info
->flags
& DF_TEXTREL
) == 0)
8927 elf_link_hash_traverse (&htab
->root
, elf32_arm_readonly_dynrelocs
,
8930 if ((info
->flags
& DF_TEXTREL
) != 0)
8932 if (!add_dynamic_entry (DT_TEXTREL
, 0))
8936 && !elf_vxworks_add_dynamic_entries (output_bfd
, info
))
8939 #undef add_dynamic_entry
8944 /* Finish up dynamic symbol handling. We set the contents of various
8945 dynamic sections here. */
8948 elf32_arm_finish_dynamic_symbol (bfd
* output_bfd
, struct bfd_link_info
* info
,
8949 struct elf_link_hash_entry
* h
, Elf_Internal_Sym
* sym
)
8952 struct elf32_arm_link_hash_table
*htab
;
8953 struct elf32_arm_link_hash_entry
*eh
;
8955 dynobj
= elf_hash_table (info
)->dynobj
;
8956 htab
= elf32_arm_hash_table (info
);
8957 eh
= (struct elf32_arm_link_hash_entry
*) h
;
8959 if (h
->plt
.offset
!= (bfd_vma
) -1)
8965 Elf_Internal_Rela rel
;
8967 /* This symbol has an entry in the procedure linkage table. Set
8970 BFD_ASSERT (h
->dynindx
!= -1);
8972 splt
= bfd_get_section_by_name (dynobj
, ".plt");
8973 srel
= bfd_get_section_by_name (dynobj
, RELOC_SECTION (htab
, ".plt"));
8974 BFD_ASSERT (splt
!= NULL
&& srel
!= NULL
);
8976 /* Fill in the entry in the procedure linkage table. */
8977 if (htab
->symbian_p
)
8979 put_arm_insn (htab
, output_bfd
,
8980 elf32_arm_symbian_plt_entry
[0],
8981 splt
->contents
+ h
->plt
.offset
);
8982 bfd_put_32 (output_bfd
,
8983 elf32_arm_symbian_plt_entry
[1],
8984 splt
->contents
+ h
->plt
.offset
+ 4);
8986 /* Fill in the entry in the .rel.plt section. */
8987 rel
.r_offset
= (splt
->output_section
->vma
8988 + splt
->output_offset
8989 + h
->plt
.offset
+ 4);
8990 rel
.r_info
= ELF32_R_INFO (h
->dynindx
, R_ARM_GLOB_DAT
);
8992 /* Get the index in the procedure linkage table which
8993 corresponds to this symbol. This is the index of this symbol
8994 in all the symbols for which we are making plt entries. The
8995 first entry in the procedure linkage table is reserved. */
8996 plt_index
= ((h
->plt
.offset
- htab
->plt_header_size
)
8997 / htab
->plt_entry_size
);
9001 bfd_vma got_offset
, got_address
, plt_address
;
9002 bfd_vma got_displacement
;
9006 sgot
= bfd_get_section_by_name (dynobj
, ".got.plt");
9007 BFD_ASSERT (sgot
!= NULL
);
9009 /* Get the offset into the .got.plt table of the entry that
9010 corresponds to this function. */
9011 got_offset
= eh
->plt_got_offset
;
9013 /* Get the index in the procedure linkage table which
9014 corresponds to this symbol. This is the index of this symbol
9015 in all the symbols for which we are making plt entries. The
9016 first three entries in .got.plt are reserved; after that
9017 symbols appear in the same order as in .plt. */
9018 plt_index
= (got_offset
- 12) / 4;
9020 /* Calculate the address of the GOT entry. */
9021 got_address
= (sgot
->output_section
->vma
9022 + sgot
->output_offset
9025 /* ...and the address of the PLT entry. */
9026 plt_address
= (splt
->output_section
->vma
9027 + splt
->output_offset
9030 ptr
= htab
->splt
->contents
+ h
->plt
.offset
;
9031 if (htab
->vxworks_p
&& info
->shared
)
9036 for (i
= 0; i
!= htab
->plt_entry_size
/ 4; i
++, ptr
+= 4)
9038 val
= elf32_arm_vxworks_shared_plt_entry
[i
];
9040 val
|= got_address
- sgot
->output_section
->vma
;
9042 val
|= plt_index
* RELOC_SIZE (htab
);
9043 if (i
== 2 || i
== 5)
9044 bfd_put_32 (output_bfd
, val
, ptr
);
9046 put_arm_insn (htab
, output_bfd
, val
, ptr
);
9049 else if (htab
->vxworks_p
)
9054 for (i
= 0; i
!= htab
->plt_entry_size
/ 4; i
++, ptr
+= 4)
9056 val
= elf32_arm_vxworks_exec_plt_entry
[i
];
9060 val
|= 0xffffff & -((h
->plt
.offset
+ i
* 4 + 8) >> 2);
9062 val
|= plt_index
* RELOC_SIZE (htab
);
9063 if (i
== 2 || i
== 5)
9064 bfd_put_32 (output_bfd
, val
, ptr
);
9066 put_arm_insn (htab
, output_bfd
, val
, ptr
);
9069 loc
= (htab
->srelplt2
->contents
9070 + (plt_index
* 2 + 1) * RELOC_SIZE (htab
));
9072 /* Create the .rela.plt.unloaded R_ARM_ABS32 relocation
9073 referencing the GOT for this PLT entry. */
9074 rel
.r_offset
= plt_address
+ 8;
9075 rel
.r_info
= ELF32_R_INFO (htab
->root
.hgot
->indx
, R_ARM_ABS32
);
9076 rel
.r_addend
= got_offset
;
9077 SWAP_RELOC_OUT (htab
) (output_bfd
, &rel
, loc
);
9078 loc
+= RELOC_SIZE (htab
);
9080 /* Create the R_ARM_ABS32 relocation referencing the
9081 beginning of the PLT for this GOT entry. */
9082 rel
.r_offset
= got_address
;
9083 rel
.r_info
= ELF32_R_INFO (htab
->root
.hplt
->indx
, R_ARM_ABS32
);
9085 SWAP_RELOC_OUT (htab
) (output_bfd
, &rel
, loc
);
9089 bfd_signed_vma thumb_refs
;
9090 /* Calculate the displacement between the PLT slot and the
9091 entry in the GOT. The eight-byte offset accounts for the
9092 value produced by adding to pc in the first instruction
9094 got_displacement
= got_address
- (plt_address
+ 8);
9096 BFD_ASSERT ((got_displacement
& 0xf0000000) == 0);
9098 thumb_refs
= eh
->plt_thumb_refcount
;
9100 thumb_refs
+= eh
->plt_maybe_thumb_refcount
;
9104 put_thumb_insn (htab
, output_bfd
,
9105 elf32_arm_plt_thumb_stub
[0], ptr
- 4);
9106 put_thumb_insn (htab
, output_bfd
,
9107 elf32_arm_plt_thumb_stub
[1], ptr
- 2);
9110 put_arm_insn (htab
, output_bfd
,
9111 elf32_arm_plt_entry
[0]
9112 | ((got_displacement
& 0x0ff00000) >> 20),
9114 put_arm_insn (htab
, output_bfd
,
9115 elf32_arm_plt_entry
[1]
9116 | ((got_displacement
& 0x000ff000) >> 12),
9118 put_arm_insn (htab
, output_bfd
,
9119 elf32_arm_plt_entry
[2]
9120 | (got_displacement
& 0x00000fff),
9122 #ifdef FOUR_WORD_PLT
9123 bfd_put_32 (output_bfd
, elf32_arm_plt_entry
[3], ptr
+ 12);
9127 /* Fill in the entry in the global offset table. */
9128 bfd_put_32 (output_bfd
,
9129 (splt
->output_section
->vma
9130 + splt
->output_offset
),
9131 sgot
->contents
+ got_offset
);
9133 /* Fill in the entry in the .rel(a).plt section. */
9135 rel
.r_offset
= got_address
;
9136 rel
.r_info
= ELF32_R_INFO (h
->dynindx
, R_ARM_JUMP_SLOT
);
9139 loc
= srel
->contents
+ plt_index
* RELOC_SIZE (htab
);
9140 SWAP_RELOC_OUT (htab
) (output_bfd
, &rel
, loc
);
9142 if (!h
->def_regular
)
9144 /* Mark the symbol as undefined, rather than as defined in
9145 the .plt section. Leave the value alone. */
9146 sym
->st_shndx
= SHN_UNDEF
;
9147 /* If the symbol is weak, we do need to clear the value.
9148 Otherwise, the PLT entry would provide a definition for
9149 the symbol even if the symbol wasn't defined anywhere,
9150 and so the symbol would never be NULL. */
9151 if (!h
->ref_regular_nonweak
)
9156 if (h
->got
.offset
!= (bfd_vma
) -1
9157 && (elf32_arm_hash_entry (h
)->tls_type
& GOT_TLS_GD
) == 0
9158 && (elf32_arm_hash_entry (h
)->tls_type
& GOT_TLS_IE
) == 0)
9162 Elf_Internal_Rela rel
;
9166 /* This symbol has an entry in the global offset table. Set it
9168 sgot
= bfd_get_section_by_name (dynobj
, ".got");
9169 srel
= bfd_get_section_by_name (dynobj
, RELOC_SECTION (htab
, ".got"));
9170 BFD_ASSERT (sgot
!= NULL
&& srel
!= NULL
);
9172 offset
= (h
->got
.offset
& ~(bfd_vma
) 1);
9174 rel
.r_offset
= (sgot
->output_section
->vma
9175 + sgot
->output_offset
9178 /* If this is a static link, or it is a -Bsymbolic link and the
9179 symbol is defined locally or was forced to be local because
9180 of a version file, we just want to emit a RELATIVE reloc.
9181 The entry in the global offset table will already have been
9182 initialized in the relocate_section function. */
9184 && SYMBOL_REFERENCES_LOCAL (info
, h
))
9186 BFD_ASSERT((h
->got
.offset
& 1) != 0);
9187 rel
.r_info
= ELF32_R_INFO (0, R_ARM_RELATIVE
);
9190 rel
.r_addend
= bfd_get_32 (output_bfd
, sgot
->contents
+ offset
);
9191 bfd_put_32 (output_bfd
, (bfd_vma
) 0, sgot
->contents
+ offset
);
9196 BFD_ASSERT((h
->got
.offset
& 1) == 0);
9197 bfd_put_32 (output_bfd
, (bfd_vma
) 0, sgot
->contents
+ offset
);
9198 rel
.r_info
= ELF32_R_INFO (h
->dynindx
, R_ARM_GLOB_DAT
);
9201 loc
= srel
->contents
+ srel
->reloc_count
++ * RELOC_SIZE (htab
);
9202 SWAP_RELOC_OUT (htab
) (output_bfd
, &rel
, loc
);
9208 Elf_Internal_Rela rel
;
9211 /* This symbol needs a copy reloc. Set it up. */
9212 BFD_ASSERT (h
->dynindx
!= -1
9213 && (h
->root
.type
== bfd_link_hash_defined
9214 || h
->root
.type
== bfd_link_hash_defweak
));
9216 s
= bfd_get_section_by_name (h
->root
.u
.def
.section
->owner
,
9217 RELOC_SECTION (htab
, ".bss"));
9218 BFD_ASSERT (s
!= NULL
);
9221 rel
.r_offset
= (h
->root
.u
.def
.value
9222 + h
->root
.u
.def
.section
->output_section
->vma
9223 + h
->root
.u
.def
.section
->output_offset
);
9224 rel
.r_info
= ELF32_R_INFO (h
->dynindx
, R_ARM_COPY
);
9225 loc
= s
->contents
+ s
->reloc_count
++ * RELOC_SIZE (htab
);
9226 SWAP_RELOC_OUT (htab
) (output_bfd
, &rel
, loc
);
9229 /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. On VxWorks,
9230 the _GLOBAL_OFFSET_TABLE_ symbol is not absolute: it is relative
9231 to the ".got" section. */
9232 if (strcmp (h
->root
.root
.string
, "_DYNAMIC") == 0
9233 || (!htab
->vxworks_p
&& h
== htab
->root
.hgot
))
9234 sym
->st_shndx
= SHN_ABS
;
9239 /* Finish up the dynamic sections. */
9242 elf32_arm_finish_dynamic_sections (bfd
* output_bfd
, struct bfd_link_info
* info
)
9248 dynobj
= elf_hash_table (info
)->dynobj
;
9250 sgot
= bfd_get_section_by_name (dynobj
, ".got.plt");
9251 BFD_ASSERT (elf32_arm_hash_table (info
)->symbian_p
|| sgot
!= NULL
);
9252 sdyn
= bfd_get_section_by_name (dynobj
, ".dynamic");
9254 if (elf_hash_table (info
)->dynamic_sections_created
)
9257 Elf32_External_Dyn
*dyncon
, *dynconend
;
9258 struct elf32_arm_link_hash_table
*htab
;
9260 htab
= elf32_arm_hash_table (info
);
9261 splt
= bfd_get_section_by_name (dynobj
, ".plt");
9262 BFD_ASSERT (splt
!= NULL
&& sdyn
!= NULL
);
9264 dyncon
= (Elf32_External_Dyn
*) sdyn
->contents
;
9265 dynconend
= (Elf32_External_Dyn
*) (sdyn
->contents
+ sdyn
->size
);
9267 for (; dyncon
< dynconend
; dyncon
++)
9269 Elf_Internal_Dyn dyn
;
9273 bfd_elf32_swap_dyn_in (dynobj
, dyncon
, &dyn
);
9281 && elf_vxworks_finish_dynamic_entry (output_bfd
, &dyn
))
9282 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
9287 goto get_vma_if_bpabi
;
9290 goto get_vma_if_bpabi
;
9293 goto get_vma_if_bpabi
;
9295 name
= ".gnu.version";
9296 goto get_vma_if_bpabi
;
9298 name
= ".gnu.version_d";
9299 goto get_vma_if_bpabi
;
9301 name
= ".gnu.version_r";
9302 goto get_vma_if_bpabi
;
9308 name
= RELOC_SECTION (htab
, ".plt");
9310 s
= bfd_get_section_by_name (output_bfd
, name
);
9311 BFD_ASSERT (s
!= NULL
);
9312 if (!htab
->symbian_p
)
9313 dyn
.d_un
.d_ptr
= s
->vma
;
9315 /* In the BPABI, tags in the PT_DYNAMIC section point
9316 at the file offset, not the memory address, for the
9317 convenience of the post linker. */
9318 dyn
.d_un
.d_ptr
= s
->filepos
;
9319 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
9323 if (htab
->symbian_p
)
9328 s
= bfd_get_section_by_name (output_bfd
,
9329 RELOC_SECTION (htab
, ".plt"));
9330 BFD_ASSERT (s
!= NULL
);
9331 dyn
.d_un
.d_val
= s
->size
;
9332 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
9337 if (!htab
->symbian_p
)
9339 /* My reading of the SVR4 ABI indicates that the
9340 procedure linkage table relocs (DT_JMPREL) should be
9341 included in the overall relocs (DT_REL). This is
9342 what Solaris does. However, UnixWare can not handle
9343 that case. Therefore, we override the DT_RELSZ entry
9344 here to make it not include the JMPREL relocs. Since
9345 the linker script arranges for .rel(a).plt to follow all
9346 other relocation sections, we don't have to worry
9347 about changing the DT_REL entry. */
9348 s
= bfd_get_section_by_name (output_bfd
,
9349 RELOC_SECTION (htab
, ".plt"));
9351 dyn
.d_un
.d_val
-= s
->size
;
9352 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
9359 /* In the BPABI, the DT_REL tag must point at the file
9360 offset, not the VMA, of the first relocation
9361 section. So, we use code similar to that in
9362 elflink.c, but do not check for SHF_ALLOC on the
9363 relcoation section, since relocations sections are
9364 never allocated under the BPABI. The comments above
9365 about Unixware notwithstanding, we include all of the
9366 relocations here. */
9367 if (htab
->symbian_p
)
9370 type
= ((dyn
.d_tag
== DT_REL
|| dyn
.d_tag
== DT_RELSZ
)
9371 ? SHT_REL
: SHT_RELA
);
9373 for (i
= 1; i
< elf_numsections (output_bfd
); i
++)
9375 Elf_Internal_Shdr
*hdr
9376 = elf_elfsections (output_bfd
)[i
];
9377 if (hdr
->sh_type
== type
)
9379 if (dyn
.d_tag
== DT_RELSZ
9380 || dyn
.d_tag
== DT_RELASZ
)
9381 dyn
.d_un
.d_val
+= hdr
->sh_size
;
9382 else if ((ufile_ptr
) hdr
->sh_offset
9383 <= dyn
.d_un
.d_val
- 1)
9384 dyn
.d_un
.d_val
= hdr
->sh_offset
;
9387 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
9391 /* Set the bottom bit of DT_INIT/FINI if the
9392 corresponding function is Thumb. */
9394 name
= info
->init_function
;
9397 name
= info
->fini_function
;
9399 /* If it wasn't set by elf_bfd_final_link
9400 then there is nothing to adjust. */
9401 if (dyn
.d_un
.d_val
!= 0)
9403 struct elf_link_hash_entry
* eh
;
9405 eh
= elf_link_hash_lookup (elf_hash_table (info
), name
,
9406 FALSE
, FALSE
, TRUE
);
9407 if (eh
!= (struct elf_link_hash_entry
*) NULL
9408 && ELF_ST_TYPE (eh
->type
) == STT_ARM_TFUNC
)
9410 dyn
.d_un
.d_val
|= 1;
9411 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
9418 /* Fill in the first entry in the procedure linkage table. */
9419 if (splt
->size
> 0 && elf32_arm_hash_table (info
)->plt_header_size
)
9421 const bfd_vma
*plt0_entry
;
9422 bfd_vma got_address
, plt_address
, got_displacement
;
9424 /* Calculate the addresses of the GOT and PLT. */
9425 got_address
= sgot
->output_section
->vma
+ sgot
->output_offset
;
9426 plt_address
= splt
->output_section
->vma
+ splt
->output_offset
;
9428 if (htab
->vxworks_p
)
9430 /* The VxWorks GOT is relocated by the dynamic linker.
9431 Therefore, we must emit relocations rather than simply
9432 computing the values now. */
9433 Elf_Internal_Rela rel
;
9435 plt0_entry
= elf32_arm_vxworks_exec_plt0_entry
;
9436 put_arm_insn (htab
, output_bfd
, plt0_entry
[0],
9437 splt
->contents
+ 0);
9438 put_arm_insn (htab
, output_bfd
, plt0_entry
[1],
9439 splt
->contents
+ 4);
9440 put_arm_insn (htab
, output_bfd
, plt0_entry
[2],
9441 splt
->contents
+ 8);
9442 bfd_put_32 (output_bfd
, got_address
, splt
->contents
+ 12);
9444 /* Generate a relocation for _GLOBAL_OFFSET_TABLE_. */
9445 rel
.r_offset
= plt_address
+ 12;
9446 rel
.r_info
= ELF32_R_INFO (htab
->root
.hgot
->indx
, R_ARM_ABS32
);
9448 SWAP_RELOC_OUT (htab
) (output_bfd
, &rel
,
9449 htab
->srelplt2
->contents
);
9453 got_displacement
= got_address
- (plt_address
+ 16);
9455 plt0_entry
= elf32_arm_plt0_entry
;
9456 put_arm_insn (htab
, output_bfd
, plt0_entry
[0],
9457 splt
->contents
+ 0);
9458 put_arm_insn (htab
, output_bfd
, plt0_entry
[1],
9459 splt
->contents
+ 4);
9460 put_arm_insn (htab
, output_bfd
, plt0_entry
[2],
9461 splt
->contents
+ 8);
9462 put_arm_insn (htab
, output_bfd
, plt0_entry
[3],
9463 splt
->contents
+ 12);
9465 #ifdef FOUR_WORD_PLT
9466 /* The displacement value goes in the otherwise-unused
9467 last word of the second entry. */
9468 bfd_put_32 (output_bfd
, got_displacement
, splt
->contents
+ 28);
9470 bfd_put_32 (output_bfd
, got_displacement
, splt
->contents
+ 16);
9475 /* UnixWare sets the entsize of .plt to 4, although that doesn't
9476 really seem like the right value. */
9477 if (splt
->output_section
->owner
== output_bfd
)
9478 elf_section_data (splt
->output_section
)->this_hdr
.sh_entsize
= 4;
9480 if (htab
->vxworks_p
&& !info
->shared
&& htab
->splt
->size
> 0)
9482 /* Correct the .rel(a).plt.unloaded relocations. They will have
9483 incorrect symbol indexes. */
9487 num_plts
= ((htab
->splt
->size
- htab
->plt_header_size
)
9488 / htab
->plt_entry_size
);
9489 p
= htab
->srelplt2
->contents
+ RELOC_SIZE (htab
);
9491 for (; num_plts
; num_plts
--)
9493 Elf_Internal_Rela rel
;
9495 SWAP_RELOC_IN (htab
) (output_bfd
, p
, &rel
);
9496 rel
.r_info
= ELF32_R_INFO (htab
->root
.hgot
->indx
, R_ARM_ABS32
);
9497 SWAP_RELOC_OUT (htab
) (output_bfd
, &rel
, p
);
9498 p
+= RELOC_SIZE (htab
);
9500 SWAP_RELOC_IN (htab
) (output_bfd
, p
, &rel
);
9501 rel
.r_info
= ELF32_R_INFO (htab
->root
.hplt
->indx
, R_ARM_ABS32
);
9502 SWAP_RELOC_OUT (htab
) (output_bfd
, &rel
, p
);
9503 p
+= RELOC_SIZE (htab
);
9508 /* Fill in the first three entries in the global offset table. */
9514 bfd_put_32 (output_bfd
, (bfd_vma
) 0, sgot
->contents
);
9516 bfd_put_32 (output_bfd
,
9517 sdyn
->output_section
->vma
+ sdyn
->output_offset
,
9519 bfd_put_32 (output_bfd
, (bfd_vma
) 0, sgot
->contents
+ 4);
9520 bfd_put_32 (output_bfd
, (bfd_vma
) 0, sgot
->contents
+ 8);
9523 elf_section_data (sgot
->output_section
)->this_hdr
.sh_entsize
= 4;
9530 elf32_arm_post_process_headers (bfd
* abfd
, struct bfd_link_info
* link_info ATTRIBUTE_UNUSED
)
9532 Elf_Internal_Ehdr
* i_ehdrp
; /* ELF file header, internal form. */
9533 struct elf32_arm_link_hash_table
*globals
;
9535 i_ehdrp
= elf_elfheader (abfd
);
9537 if (EF_ARM_EABI_VERSION (i_ehdrp
->e_flags
) == EF_ARM_EABI_UNKNOWN
)
9538 i_ehdrp
->e_ident
[EI_OSABI
] = ELFOSABI_ARM
;
9540 i_ehdrp
->e_ident
[EI_OSABI
] = 0;
9541 i_ehdrp
->e_ident
[EI_ABIVERSION
] = ARM_ELF_ABI_VERSION
;
9545 globals
= elf32_arm_hash_table (link_info
);
9546 if (globals
->byteswap_code
)
9547 i_ehdrp
->e_flags
|= EF_ARM_BE8
;
9551 static enum elf_reloc_type_class
9552 elf32_arm_reloc_type_class (const Elf_Internal_Rela
*rela
)
9554 switch ((int) ELF32_R_TYPE (rela
->r_info
))
9556 case R_ARM_RELATIVE
:
9557 return reloc_class_relative
;
9558 case R_ARM_JUMP_SLOT
:
9559 return reloc_class_plt
;
9561 return reloc_class_copy
;
9563 return reloc_class_normal
;
9567 /* Set the right machine number for an Arm ELF file. */
9570 elf32_arm_section_flags (flagword
*flags
, const Elf_Internal_Shdr
*hdr
)
9572 if (hdr
->sh_type
== SHT_NOTE
)
9573 *flags
|= SEC_LINK_ONCE
| SEC_LINK_DUPLICATES_SAME_CONTENTS
;
9579 elf32_arm_final_write_processing (bfd
*abfd
, bfd_boolean linker ATTRIBUTE_UNUSED
)
9581 bfd_arm_update_notes (abfd
, ARM_NOTE_SECTION
);
9584 /* Return TRUE if this is an unwinding table entry. */
9587 is_arm_elf_unwind_section_name (bfd
* abfd ATTRIBUTE_UNUSED
, const char * name
)
9589 return (CONST_STRNEQ (name
, ELF_STRING_ARM_unwind
)
9590 || CONST_STRNEQ (name
, ELF_STRING_ARM_unwind_once
));
9594 /* Set the type and flags for an ARM section. We do this by
9595 the section name, which is a hack, but ought to work. */
9598 elf32_arm_fake_sections (bfd
* abfd
, Elf_Internal_Shdr
* hdr
, asection
* sec
)
9602 name
= bfd_get_section_name (abfd
, sec
);
9604 if (is_arm_elf_unwind_section_name (abfd
, name
))
9606 hdr
->sh_type
= SHT_ARM_EXIDX
;
9607 hdr
->sh_flags
|= SHF_LINK_ORDER
;
9612 /* Handle an ARM specific section when reading an object file. This is
9613 called when bfd_section_from_shdr finds a section with an unknown
9617 elf32_arm_section_from_shdr (bfd
*abfd
,
9618 Elf_Internal_Shdr
* hdr
,
9622 /* There ought to be a place to keep ELF backend specific flags, but
9623 at the moment there isn't one. We just keep track of the
9624 sections by their name, instead. Fortunately, the ABI gives
9625 names for all the ARM specific sections, so we will probably get
9627 switch (hdr
->sh_type
)
9630 case SHT_ARM_PREEMPTMAP
:
9631 case SHT_ARM_ATTRIBUTES
:
9638 if (! _bfd_elf_make_section_from_shdr (abfd
, hdr
, name
, shindex
))
9644 /* A structure used to record a list of sections, independently
9645 of the next and prev fields in the asection structure. */
9646 typedef struct section_list
9649 struct section_list
* next
;
9650 struct section_list
* prev
;
9654 /* Unfortunately we need to keep a list of sections for which
9655 an _arm_elf_section_data structure has been allocated. This
9656 is because it is possible for functions like elf32_arm_write_section
9657 to be called on a section which has had an elf_data_structure
9658 allocated for it (and so the used_by_bfd field is valid) but
9659 for which the ARM extended version of this structure - the
9660 _arm_elf_section_data structure - has not been allocated. */
9661 static section_list
* sections_with_arm_elf_section_data
= NULL
;
9664 record_section_with_arm_elf_section_data (asection
* sec
)
9666 struct section_list
* entry
;
9668 entry
= bfd_malloc (sizeof (* entry
));
9672 entry
->next
= sections_with_arm_elf_section_data
;
9674 if (entry
->next
!= NULL
)
9675 entry
->next
->prev
= entry
;
9676 sections_with_arm_elf_section_data
= entry
;
9679 static struct section_list
*
9680 find_arm_elf_section_entry (asection
* sec
)
9682 struct section_list
* entry
;
9683 static struct section_list
* last_entry
= NULL
;
9685 /* This is a short cut for the typical case where the sections are added
9686 to the sections_with_arm_elf_section_data list in forward order and
9687 then looked up here in backwards order. This makes a real difference
9688 to the ld-srec/sec64k.exp linker test. */
9689 entry
= sections_with_arm_elf_section_data
;
9690 if (last_entry
!= NULL
)
9692 if (last_entry
->sec
== sec
)
9694 else if (last_entry
->next
!= NULL
9695 && last_entry
->next
->sec
== sec
)
9696 entry
= last_entry
->next
;
9699 for (; entry
; entry
= entry
->next
)
9700 if (entry
->sec
== sec
)
9704 /* Record the entry prior to this one - it is the entry we are most
9705 likely to want to locate next time. Also this way if we have been
9706 called from unrecord_section_with_arm_elf_section_data() we will not
9707 be caching a pointer that is about to be freed. */
9708 last_entry
= entry
->prev
;
9713 static _arm_elf_section_data
*
9714 get_arm_elf_section_data (asection
* sec
)
9716 struct section_list
* entry
;
9718 entry
= find_arm_elf_section_entry (sec
);
9721 return elf32_arm_section_data (entry
->sec
);
9727 unrecord_section_with_arm_elf_section_data (asection
* sec
)
9729 struct section_list
* entry
;
9731 entry
= find_arm_elf_section_entry (sec
);
9735 if (entry
->prev
!= NULL
)
9736 entry
->prev
->next
= entry
->next
;
9737 if (entry
->next
!= NULL
)
9738 entry
->next
->prev
= entry
->prev
;
9739 if (entry
== sections_with_arm_elf_section_data
)
9740 sections_with_arm_elf_section_data
= entry
->next
;
9749 struct bfd_link_info
*info
;
9752 bfd_boolean (*func
) (void *, const char *, Elf_Internal_Sym
*,
9753 asection
*, struct elf_link_hash_entry
*);
9754 } output_arch_syminfo
;
9756 enum map_symbol_type
9764 /* Output a single PLT mapping symbol. */
9767 elf32_arm_ouput_plt_map_sym (output_arch_syminfo
*osi
,
9768 enum map_symbol_type type
,
9771 static const char *names
[3] = {"$a", "$t", "$d"};
9772 struct elf32_arm_link_hash_table
*htab
;
9773 Elf_Internal_Sym sym
;
9775 htab
= elf32_arm_hash_table (osi
->info
);
9776 sym
.st_value
= osi
->sec
->output_section
->vma
9777 + osi
->sec
->output_offset
9781 sym
.st_info
= ELF_ST_INFO (STB_LOCAL
, STT_NOTYPE
);
9782 sym
.st_shndx
= osi
->sec_shndx
;
9783 if (!osi
->func (osi
->finfo
, names
[type
], &sym
, osi
->sec
, NULL
))
9789 /* Output mapping symbols for PLT entries associated with H. */
9792 elf32_arm_output_plt_map (struct elf_link_hash_entry
*h
, void *inf
)
9794 output_arch_syminfo
*osi
= (output_arch_syminfo
*) inf
;
9795 struct elf32_arm_link_hash_table
*htab
;
9796 struct elf32_arm_link_hash_entry
*eh
;
9799 htab
= elf32_arm_hash_table (osi
->info
);
9801 if (h
->root
.type
== bfd_link_hash_indirect
)
9804 if (h
->root
.type
== bfd_link_hash_warning
)
9805 /* When warning symbols are created, they **replace** the "real"
9806 entry in the hash table, thus we never get to see the real
9807 symbol in a hash traversal. So look at it now. */
9808 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
9810 if (h
->plt
.offset
== (bfd_vma
) -1)
9813 eh
= (struct elf32_arm_link_hash_entry
*) h
;
9814 addr
= h
->plt
.offset
;
9815 if (htab
->symbian_p
)
9817 if (!elf32_arm_ouput_plt_map_sym (osi
, ARM_MAP_ARM
, addr
))
9819 if (!elf32_arm_ouput_plt_map_sym (osi
, ARM_MAP_DATA
, addr
+ 4))
9822 else if (htab
->vxworks_p
)
9824 if (!elf32_arm_ouput_plt_map_sym (osi
, ARM_MAP_ARM
, addr
))
9826 if (!elf32_arm_ouput_plt_map_sym (osi
, ARM_MAP_DATA
, addr
+ 8))
9828 if (!elf32_arm_ouput_plt_map_sym (osi
, ARM_MAP_ARM
, addr
+ 12))
9830 if (!elf32_arm_ouput_plt_map_sym (osi
, ARM_MAP_DATA
, addr
+ 20))
9835 bfd_signed_vma thumb_refs
;
9837 thumb_refs
= eh
->plt_thumb_refcount
;
9839 thumb_refs
+= eh
->plt_maybe_thumb_refcount
;
9843 if (!elf32_arm_ouput_plt_map_sym (osi
, ARM_MAP_THUMB
, addr
- 4))
9846 #ifdef FOUR_WORD_PLT
9847 if (!elf32_arm_ouput_plt_map_sym (osi
, ARM_MAP_ARM
, addr
))
9849 if (!elf32_arm_ouput_plt_map_sym (osi
, ARM_MAP_DATA
, addr
+ 12))
9852 /* A three-word PLT with no Thumb thunk contains only Arm code,
9853 so only need to output a mapping symbol for the first PLT entry and
9854 entries with thumb thunks. */
9855 if (thumb_refs
> 0 || addr
== 20)
9857 if (!elf32_arm_ouput_plt_map_sym (osi
, ARM_MAP_ARM
, addr
))
9867 /* Output mapping symbols for linker generated sections. */
9870 elf32_arm_output_arch_local_syms (bfd
*output_bfd
,
9871 struct bfd_link_info
*info
,
9872 void *finfo
, bfd_boolean (*func
) (void *, const char *,
9875 struct elf_link_hash_entry
*))
9877 output_arch_syminfo osi
;
9878 struct elf32_arm_link_hash_table
*htab
;
9882 htab
= elf32_arm_hash_table (info
);
9883 check_use_blx(htab
);
9889 /* ARM->Thumb glue. */
9890 if (htab
->arm_glue_size
> 0)
9892 osi
.sec
= bfd_get_section_by_name (htab
->bfd_of_glue_owner
,
9893 ARM2THUMB_GLUE_SECTION_NAME
);
9895 osi
.sec_shndx
= _bfd_elf_section_from_bfd_section
9896 (output_bfd
, osi
.sec
->output_section
);
9897 if (info
->shared
|| htab
->root
.is_relocatable_executable
9898 || htab
->pic_veneer
)
9899 size
= ARM2THUMB_PIC_GLUE_SIZE
;
9900 else if (htab
->use_blx
)
9901 size
= ARM2THUMB_V5_STATIC_GLUE_SIZE
;
9903 size
= ARM2THUMB_STATIC_GLUE_SIZE
;
9905 for (offset
= 0; offset
< htab
->arm_glue_size
; offset
+= size
)
9907 elf32_arm_ouput_plt_map_sym (&osi
, ARM_MAP_ARM
, offset
);
9908 elf32_arm_ouput_plt_map_sym (&osi
, ARM_MAP_DATA
, offset
+ size
- 4);
9912 /* Thumb->ARM glue. */
9913 if (htab
->thumb_glue_size
> 0)
9915 osi
.sec
= bfd_get_section_by_name (htab
->bfd_of_glue_owner
,
9916 THUMB2ARM_GLUE_SECTION_NAME
);
9918 osi
.sec_shndx
= _bfd_elf_section_from_bfd_section
9919 (output_bfd
, osi
.sec
->output_section
);
9920 size
= THUMB2ARM_GLUE_SIZE
;
9922 for (offset
= 0; offset
< htab
->thumb_glue_size
; offset
+= size
)
9924 elf32_arm_ouput_plt_map_sym (&osi
, ARM_MAP_THUMB
, offset
);
9925 elf32_arm_ouput_plt_map_sym (&osi
, ARM_MAP_ARM
, offset
+ 4);
9929 /* ARMv4 BX veneers. */
9930 if (htab
->bx_glue_size
> 0)
9932 osi
.sec
= bfd_get_section_by_name (htab
->bfd_of_glue_owner
,
9933 ARM_BX_GLUE_SECTION_NAME
);
9935 osi
.sec_shndx
= _bfd_elf_section_from_bfd_section
9936 (output_bfd
, osi
.sec
->output_section
);
9938 elf32_arm_ouput_plt_map_sym (&osi
, ARM_MAP_ARM
, 0);
9941 /* Finally, output mapping symbols for the PLT. */
9942 if (!htab
->splt
|| htab
->splt
->size
== 0)
9945 osi
.sec_shndx
= _bfd_elf_section_from_bfd_section (output_bfd
,
9946 htab
->splt
->output_section
);
9947 osi
.sec
= htab
->splt
;
9948 /* Output mapping symbols for the plt header. SymbianOS does not have a
9950 if (htab
->vxworks_p
)
9952 /* VxWorks shared libraries have no PLT header. */
9955 if (!elf32_arm_ouput_plt_map_sym (&osi
, ARM_MAP_ARM
, 0))
9957 if (!elf32_arm_ouput_plt_map_sym (&osi
, ARM_MAP_DATA
, 12))
9961 else if (!htab
->symbian_p
)
9963 if (!elf32_arm_ouput_plt_map_sym (&osi
, ARM_MAP_ARM
, 0))
9965 #ifndef FOUR_WORD_PLT
9966 if (!elf32_arm_ouput_plt_map_sym (&osi
, ARM_MAP_DATA
, 16))
9971 elf_link_hash_traverse (&htab
->root
, elf32_arm_output_plt_map
, (void *) &osi
);
9975 /* Allocate target specific section data. */
9978 elf32_arm_new_section_hook (bfd
*abfd
, asection
*sec
)
9980 if (!sec
->used_by_bfd
)
9982 _arm_elf_section_data
*sdata
;
9983 bfd_size_type amt
= sizeof (*sdata
);
9985 sdata
= bfd_zalloc (abfd
, amt
);
9988 sec
->used_by_bfd
= sdata
;
9991 record_section_with_arm_elf_section_data (sec
);
9993 return _bfd_elf_new_section_hook (abfd
, sec
);
9997 /* Used to order a list of mapping symbols by address. */
10000 elf32_arm_compare_mapping (const void * a
, const void * b
)
10002 const elf32_arm_section_map
*amap
= (const elf32_arm_section_map
*) a
;
10003 const elf32_arm_section_map
*bmap
= (const elf32_arm_section_map
*) b
;
10005 if (amap
->vma
> bmap
->vma
)
10007 else if (amap
->vma
< bmap
->vma
)
10009 else if (amap
->type
> bmap
->type
)
10010 /* Ensure results do not depend on the host qsort for objects with
10011 multiple mapping symbols at the same address by sorting on type
10014 else if (amap
->type
< bmap
->type
)
10021 /* Do code byteswapping. Return FALSE afterwards so that the section is
10022 written out as normal. */
10025 elf32_arm_write_section (bfd
*output_bfd
,
10026 struct bfd_link_info
*link_info
, asection
*sec
,
10027 bfd_byte
*contents
)
10029 int mapcount
, errcount
;
10030 _arm_elf_section_data
*arm_data
;
10031 struct elf32_arm_link_hash_table
*globals
= elf32_arm_hash_table (link_info
);
10032 elf32_arm_section_map
*map
;
10033 elf32_vfp11_erratum_list
*errnode
;
10036 bfd_vma offset
= sec
->output_section
->vma
+ sec
->output_offset
;
10040 /* If this section has not been allocated an _arm_elf_section_data
10041 structure then we cannot record anything. */
10042 arm_data
= get_arm_elf_section_data (sec
);
10043 if (arm_data
== NULL
)
10046 mapcount
= arm_data
->mapcount
;
10047 map
= arm_data
->map
;
10048 errcount
= arm_data
->erratumcount
;
10052 unsigned int endianflip
= bfd_big_endian (output_bfd
) ? 3 : 0;
10054 for (errnode
= arm_data
->erratumlist
; errnode
!= 0;
10055 errnode
= errnode
->next
)
10057 bfd_vma index
= errnode
->vma
- offset
;
10059 switch (errnode
->type
)
10061 case VFP11_ERRATUM_BRANCH_TO_ARM_VENEER
:
10063 bfd_vma branch_to_veneer
;
10064 /* Original condition code of instruction, plus bit mask for
10065 ARM B instruction. */
10066 unsigned int insn
= (errnode
->u
.b
.vfp_insn
& 0xf0000000)
10069 /* The instruction is before the label. */
10072 /* Above offset included in -4 below. */
10073 branch_to_veneer
= errnode
->u
.b
.veneer
->vma
10074 - errnode
->vma
- 4;
10076 if ((signed) branch_to_veneer
< -(1 << 25)
10077 || (signed) branch_to_veneer
>= (1 << 25))
10078 (*_bfd_error_handler
) (_("%B: error: VFP11 veneer out of "
10079 "range"), output_bfd
);
10081 insn
|= (branch_to_veneer
>> 2) & 0xffffff;
10082 contents
[endianflip
^ index
] = insn
& 0xff;
10083 contents
[endianflip
^ (index
+ 1)] = (insn
>> 8) & 0xff;
10084 contents
[endianflip
^ (index
+ 2)] = (insn
>> 16) & 0xff;
10085 contents
[endianflip
^ (index
+ 3)] = (insn
>> 24) & 0xff;
10089 case VFP11_ERRATUM_ARM_VENEER
:
10091 bfd_vma branch_from_veneer
;
10094 /* Take size of veneer into account. */
10095 branch_from_veneer
= errnode
->u
.v
.branch
->vma
10096 - errnode
->vma
- 12;
10098 if ((signed) branch_from_veneer
< -(1 << 25)
10099 || (signed) branch_from_veneer
>= (1 << 25))
10100 (*_bfd_error_handler
) (_("%B: error: VFP11 veneer out of "
10101 "range"), output_bfd
);
10103 /* Original instruction. */
10104 insn
= errnode
->u
.v
.branch
->u
.b
.vfp_insn
;
10105 contents
[endianflip
^ index
] = insn
& 0xff;
10106 contents
[endianflip
^ (index
+ 1)] = (insn
>> 8) & 0xff;
10107 contents
[endianflip
^ (index
+ 2)] = (insn
>> 16) & 0xff;
10108 contents
[endianflip
^ (index
+ 3)] = (insn
>> 24) & 0xff;
10110 /* Branch back to insn after original insn. */
10111 insn
= 0xea000000 | ((branch_from_veneer
>> 2) & 0xffffff);
10112 contents
[endianflip
^ (index
+ 4)] = insn
& 0xff;
10113 contents
[endianflip
^ (index
+ 5)] = (insn
>> 8) & 0xff;
10114 contents
[endianflip
^ (index
+ 6)] = (insn
>> 16) & 0xff;
10115 contents
[endianflip
^ (index
+ 7)] = (insn
>> 24) & 0xff;
10128 if (globals
->byteswap_code
)
10130 qsort (map
, mapcount
, sizeof (* map
), elf32_arm_compare_mapping
);
10133 for (i
= 0; i
< mapcount
; i
++)
10135 if (i
== mapcount
- 1)
10138 end
= map
[i
+ 1].vma
;
10140 switch (map
[i
].type
)
10143 /* Byte swap code words. */
10144 while (ptr
+ 3 < end
)
10146 tmp
= contents
[ptr
];
10147 contents
[ptr
] = contents
[ptr
+ 3];
10148 contents
[ptr
+ 3] = tmp
;
10149 tmp
= contents
[ptr
+ 1];
10150 contents
[ptr
+ 1] = contents
[ptr
+ 2];
10151 contents
[ptr
+ 2] = tmp
;
10157 /* Byte swap code halfwords. */
10158 while (ptr
+ 1 < end
)
10160 tmp
= contents
[ptr
];
10161 contents
[ptr
] = contents
[ptr
+ 1];
10162 contents
[ptr
+ 1] = tmp
;
10168 /* Leave data alone. */
10176 arm_data
->mapcount
= 0;
10177 arm_data
->mapsize
= 0;
10178 arm_data
->map
= NULL
;
10179 unrecord_section_with_arm_elf_section_data (sec
);
10185 unrecord_section_via_map_over_sections (bfd
* abfd ATTRIBUTE_UNUSED
,
10187 void * ignore ATTRIBUTE_UNUSED
)
10189 unrecord_section_with_arm_elf_section_data (sec
);
10193 elf32_arm_close_and_cleanup (bfd
* abfd
)
10195 if (abfd
->sections
)
10196 bfd_map_over_sections (abfd
,
10197 unrecord_section_via_map_over_sections
,
10200 return _bfd_elf_close_and_cleanup (abfd
);
10204 elf32_arm_bfd_free_cached_info (bfd
* abfd
)
10206 if (abfd
->sections
)
10207 bfd_map_over_sections (abfd
,
10208 unrecord_section_via_map_over_sections
,
10211 return _bfd_free_cached_info (abfd
);
10214 /* Display STT_ARM_TFUNC symbols as functions. */
10217 elf32_arm_symbol_processing (bfd
*abfd ATTRIBUTE_UNUSED
,
10220 elf_symbol_type
*elfsym
= (elf_symbol_type
*) asym
;
10222 if (ELF_ST_TYPE (elfsym
->internal_elf_sym
.st_info
) == STT_ARM_TFUNC
)
10223 elfsym
->symbol
.flags
|= BSF_FUNCTION
;
10227 /* Mangle thumb function symbols as we read them in. */
10230 elf32_arm_swap_symbol_in (bfd
* abfd
,
10233 Elf_Internal_Sym
*dst
)
10235 if (!bfd_elf32_swap_symbol_in (abfd
, psrc
, pshn
, dst
))
10238 /* New EABI objects mark thumb function symbols by setting the low bit of
10239 the address. Turn these into STT_ARM_TFUNC. */
10240 if (ELF_ST_TYPE (dst
->st_info
) == STT_FUNC
10241 && (dst
->st_value
& 1))
10243 dst
->st_info
= ELF_ST_INFO (ELF_ST_BIND (dst
->st_info
), STT_ARM_TFUNC
);
10244 dst
->st_value
&= ~(bfd_vma
) 1;
10250 /* Mangle thumb function symbols as we write them out. */
10253 elf32_arm_swap_symbol_out (bfd
*abfd
,
10254 const Elf_Internal_Sym
*src
,
10258 Elf_Internal_Sym newsym
;
10260 /* We convert STT_ARM_TFUNC symbols into STT_FUNC with the low bit
10261 of the address set, as per the new EABI. We do this unconditionally
10262 because objcopy does not set the elf header flags until after
10263 it writes out the symbol table. */
10264 if (ELF_ST_TYPE (src
->st_info
) == STT_ARM_TFUNC
)
10267 newsym
.st_info
= ELF_ST_INFO (ELF_ST_BIND (src
->st_info
), STT_FUNC
);
10268 if (newsym
.st_shndx
!= SHN_UNDEF
)
10270 /* Do this only for defined symbols. At link type, the static
10271 linker will simulate the work of dynamic linker of resolving
10272 symbols and will carry over the thumbness of found symbols to
10273 the output symbol table. It's not clear how it happens, but
10274 the thumbness of undefined symbols can well be different at
10275 runtime, and writing '1' for them will be confusing for users
10276 and possibly for dynamic linker itself.
10278 newsym
.st_value
|= 1;
10283 bfd_elf32_swap_symbol_out (abfd
, src
, cdst
, shndx
);
10286 /* Add the PT_ARM_EXIDX program header. */
10289 elf32_arm_modify_segment_map (bfd
*abfd
,
10290 struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
10292 struct elf_segment_map
*m
;
10295 sec
= bfd_get_section_by_name (abfd
, ".ARM.exidx");
10296 if (sec
!= NULL
&& (sec
->flags
& SEC_LOAD
) != 0)
10298 /* If there is already a PT_ARM_EXIDX header, then we do not
10299 want to add another one. This situation arises when running
10300 "strip"; the input binary already has the header. */
10301 m
= elf_tdata (abfd
)->segment_map
;
10302 while (m
&& m
->p_type
!= PT_ARM_EXIDX
)
10306 m
= bfd_zalloc (abfd
, sizeof (struct elf_segment_map
));
10309 m
->p_type
= PT_ARM_EXIDX
;
10311 m
->sections
[0] = sec
;
10313 m
->next
= elf_tdata (abfd
)->segment_map
;
10314 elf_tdata (abfd
)->segment_map
= m
;
10321 /* We may add a PT_ARM_EXIDX program header. */
10324 elf32_arm_additional_program_headers (bfd
*abfd
,
10325 struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
10329 sec
= bfd_get_section_by_name (abfd
, ".ARM.exidx");
10330 if (sec
!= NULL
&& (sec
->flags
& SEC_LOAD
) != 0)
10336 /* We have two function types: STT_FUNC and STT_ARM_TFUNC. */
10338 elf32_arm_is_function_type (unsigned int type
)
10340 return (type
== STT_FUNC
) || (type
== STT_ARM_TFUNC
);
10343 /* We use this to override swap_symbol_in and swap_symbol_out. */
10344 const struct elf_size_info elf32_arm_size_info
= {
10345 sizeof (Elf32_External_Ehdr
),
10346 sizeof (Elf32_External_Phdr
),
10347 sizeof (Elf32_External_Shdr
),
10348 sizeof (Elf32_External_Rel
),
10349 sizeof (Elf32_External_Rela
),
10350 sizeof (Elf32_External_Sym
),
10351 sizeof (Elf32_External_Dyn
),
10352 sizeof (Elf_External_Note
),
10356 ELFCLASS32
, EV_CURRENT
,
10357 bfd_elf32_write_out_phdrs
,
10358 bfd_elf32_write_shdrs_and_ehdr
,
10359 bfd_elf32_checksum_contents
,
10360 bfd_elf32_write_relocs
,
10361 elf32_arm_swap_symbol_in
,
10362 elf32_arm_swap_symbol_out
,
10363 bfd_elf32_slurp_reloc_table
,
10364 bfd_elf32_slurp_symbol_table
,
10365 bfd_elf32_swap_dyn_in
,
10366 bfd_elf32_swap_dyn_out
,
10367 bfd_elf32_swap_reloc_in
,
10368 bfd_elf32_swap_reloc_out
,
10369 bfd_elf32_swap_reloca_in
,
10370 bfd_elf32_swap_reloca_out
10373 #define ELF_ARCH bfd_arch_arm
10374 #define ELF_MACHINE_CODE EM_ARM
10375 #ifdef __QNXTARGET__
10376 #define ELF_MAXPAGESIZE 0x1000
10378 #define ELF_MAXPAGESIZE 0x8000
10380 #define ELF_MINPAGESIZE 0x1000
10381 #define ELF_COMMONPAGESIZE 0x1000
10383 #define bfd_elf32_mkobject elf32_arm_mkobject
10385 #define bfd_elf32_bfd_copy_private_bfd_data elf32_arm_copy_private_bfd_data
10386 #define bfd_elf32_bfd_merge_private_bfd_data elf32_arm_merge_private_bfd_data
10387 #define bfd_elf32_bfd_set_private_flags elf32_arm_set_private_flags
10388 #define bfd_elf32_bfd_print_private_bfd_data elf32_arm_print_private_bfd_data
10389 #define bfd_elf32_bfd_link_hash_table_create elf32_arm_link_hash_table_create
10390 #define bfd_elf32_bfd_reloc_type_lookup elf32_arm_reloc_type_lookup
10391 #define bfd_elf32_bfd_reloc_name_lookup elf32_arm_reloc_name_lookup
10392 #define bfd_elf32_find_nearest_line elf32_arm_find_nearest_line
10393 #define bfd_elf32_find_inliner_info elf32_arm_find_inliner_info
10394 #define bfd_elf32_new_section_hook elf32_arm_new_section_hook
10395 #define bfd_elf32_bfd_is_target_special_symbol elf32_arm_is_target_special_symbol
10396 #define bfd_elf32_close_and_cleanup elf32_arm_close_and_cleanup
10397 #define bfd_elf32_bfd_free_cached_info elf32_arm_bfd_free_cached_info
10399 #define elf_backend_get_symbol_type elf32_arm_get_symbol_type
10400 #define elf_backend_gc_mark_hook elf32_arm_gc_mark_hook
10401 #define elf_backend_gc_mark_extra_sections elf32_arm_gc_mark_extra_sections
10402 #define elf_backend_gc_sweep_hook elf32_arm_gc_sweep_hook
10403 #define elf_backend_check_relocs elf32_arm_check_relocs
10404 #define elf_backend_relocate_section elf32_arm_relocate_section
10405 #define elf_backend_write_section elf32_arm_write_section
10406 #define elf_backend_adjust_dynamic_symbol elf32_arm_adjust_dynamic_symbol
10407 #define elf_backend_create_dynamic_sections elf32_arm_create_dynamic_sections
10408 #define elf_backend_finish_dynamic_symbol elf32_arm_finish_dynamic_symbol
10409 #define elf_backend_finish_dynamic_sections elf32_arm_finish_dynamic_sections
10410 #define elf_backend_size_dynamic_sections elf32_arm_size_dynamic_sections
10411 #define elf_backend_init_index_section _bfd_elf_init_2_index_sections
10412 #define elf_backend_post_process_headers elf32_arm_post_process_headers
10413 #define elf_backend_reloc_type_class elf32_arm_reloc_type_class
10414 #define elf_backend_object_p elf32_arm_object_p
10415 #define elf_backend_section_flags elf32_arm_section_flags
10416 #define elf_backend_fake_sections elf32_arm_fake_sections
10417 #define elf_backend_section_from_shdr elf32_arm_section_from_shdr
10418 #define elf_backend_final_write_processing elf32_arm_final_write_processing
10419 #define elf_backend_copy_indirect_symbol elf32_arm_copy_indirect_symbol
10420 #define elf_backend_symbol_processing elf32_arm_symbol_processing
10421 #define elf_backend_size_info elf32_arm_size_info
10422 #define elf_backend_modify_segment_map elf32_arm_modify_segment_map
10423 #define elf_backend_additional_program_headers \
10424 elf32_arm_additional_program_headers
10425 #define elf_backend_output_arch_local_syms \
10426 elf32_arm_output_arch_local_syms
10427 #define elf_backend_begin_write_processing \
10428 elf32_arm_begin_write_processing
10429 #define elf_backend_is_function_type elf32_arm_is_function_type
10431 #define elf_backend_can_refcount 1
10432 #define elf_backend_can_gc_sections 1
10433 #define elf_backend_plt_readonly 1
10434 #define elf_backend_want_got_plt 1
10435 #define elf_backend_want_plt_sym 0
10436 #define elf_backend_may_use_rel_p 1
10437 #define elf_backend_may_use_rela_p 0
10438 #define elf_backend_default_use_rela_p 0
10440 #define elf_backend_got_header_size 12
10442 #undef elf_backend_obj_attrs_vendor
10443 #define elf_backend_obj_attrs_vendor "aeabi"
10444 #undef elf_backend_obj_attrs_section
10445 #define elf_backend_obj_attrs_section ".ARM.attributes"
10446 #undef elf_backend_obj_attrs_arg_type
10447 #define elf_backend_obj_attrs_arg_type elf32_arm_obj_attrs_arg_type
10448 #undef elf_backend_obj_attrs_section_type
10449 #define elf_backend_obj_attrs_section_type SHT_ARM_ATTRIBUTES
10451 #include "elf32-target.h"
10453 /* VxWorks Targets */
10455 #undef TARGET_LITTLE_SYM
10456 #define TARGET_LITTLE_SYM bfd_elf32_littlearm_vxworks_vec
10457 #undef TARGET_LITTLE_NAME
10458 #define TARGET_LITTLE_NAME "elf32-littlearm-vxworks"
10459 #undef TARGET_BIG_SYM
10460 #define TARGET_BIG_SYM bfd_elf32_bigarm_vxworks_vec
10461 #undef TARGET_BIG_NAME
10462 #define TARGET_BIG_NAME "elf32-bigarm-vxworks"
10464 /* Like elf32_arm_link_hash_table_create -- but overrides
10465 appropriately for VxWorks. */
10466 static struct bfd_link_hash_table
*
10467 elf32_arm_vxworks_link_hash_table_create (bfd
*abfd
)
10469 struct bfd_link_hash_table
*ret
;
10471 ret
= elf32_arm_link_hash_table_create (abfd
);
10474 struct elf32_arm_link_hash_table
*htab
10475 = (struct elf32_arm_link_hash_table
*) ret
;
10477 htab
->vxworks_p
= 1;
10483 elf32_arm_vxworks_final_write_processing (bfd
*abfd
, bfd_boolean linker
)
10485 elf32_arm_final_write_processing (abfd
, linker
);
10486 elf_vxworks_final_write_processing (abfd
, linker
);
10490 #define elf32_bed elf32_arm_vxworks_bed
10492 #undef bfd_elf32_bfd_link_hash_table_create
10493 #define bfd_elf32_bfd_link_hash_table_create \
10494 elf32_arm_vxworks_link_hash_table_create
10495 #undef elf_backend_add_symbol_hook
10496 #define elf_backend_add_symbol_hook \
10497 elf_vxworks_add_symbol_hook
10498 #undef elf_backend_final_write_processing
10499 #define elf_backend_final_write_processing \
10500 elf32_arm_vxworks_final_write_processing
10501 #undef elf_backend_emit_relocs
10502 #define elf_backend_emit_relocs \
10503 elf_vxworks_emit_relocs
10505 #undef elf_backend_may_use_rel_p
10506 #define elf_backend_may_use_rel_p 0
10507 #undef elf_backend_may_use_rela_p
10508 #define elf_backend_may_use_rela_p 1
10509 #undef elf_backend_default_use_rela_p
10510 #define elf_backend_default_use_rela_p 1
10511 #undef elf_backend_want_plt_sym
10512 #define elf_backend_want_plt_sym 1
10513 #undef ELF_MAXPAGESIZE
10514 #define ELF_MAXPAGESIZE 0x1000
10516 #include "elf32-target.h"
10519 /* Symbian OS Targets */
10521 #undef TARGET_LITTLE_SYM
10522 #define TARGET_LITTLE_SYM bfd_elf32_littlearm_symbian_vec
10523 #undef TARGET_LITTLE_NAME
10524 #define TARGET_LITTLE_NAME "elf32-littlearm-symbian"
10525 #undef TARGET_BIG_SYM
10526 #define TARGET_BIG_SYM bfd_elf32_bigarm_symbian_vec
10527 #undef TARGET_BIG_NAME
10528 #define TARGET_BIG_NAME "elf32-bigarm-symbian"
10530 /* Like elf32_arm_link_hash_table_create -- but overrides
10531 appropriately for Symbian OS. */
10532 static struct bfd_link_hash_table
*
10533 elf32_arm_symbian_link_hash_table_create (bfd
*abfd
)
10535 struct bfd_link_hash_table
*ret
;
10537 ret
= elf32_arm_link_hash_table_create (abfd
);
10540 struct elf32_arm_link_hash_table
*htab
10541 = (struct elf32_arm_link_hash_table
*)ret
;
10542 /* There is no PLT header for Symbian OS. */
10543 htab
->plt_header_size
= 0;
10544 /* The PLT entries are each three instructions. */
10545 htab
->plt_entry_size
= 4 * NUM_ELEM (elf32_arm_symbian_plt_entry
);
10546 htab
->symbian_p
= 1;
10547 /* Symbian uses armv5t or above, so use_blx is always true. */
10549 htab
->root
.is_relocatable_executable
= 1;
10554 static const struct bfd_elf_special_section
10555 elf32_arm_symbian_special_sections
[] =
10557 /* In a BPABI executable, the dynamic linking sections do not go in
10558 the loadable read-only segment. The post-linker may wish to
10559 refer to these sections, but they are not part of the final
10561 { STRING_COMMA_LEN (".dynamic"), 0, SHT_DYNAMIC
, 0 },
10562 { STRING_COMMA_LEN (".dynstr"), 0, SHT_STRTAB
, 0 },
10563 { STRING_COMMA_LEN (".dynsym"), 0, SHT_DYNSYM
, 0 },
10564 { STRING_COMMA_LEN (".got"), 0, SHT_PROGBITS
, 0 },
10565 { STRING_COMMA_LEN (".hash"), 0, SHT_HASH
, 0 },
10566 /* These sections do not need to be writable as the SymbianOS
10567 postlinker will arrange things so that no dynamic relocation is
10569 { STRING_COMMA_LEN (".init_array"), 0, SHT_INIT_ARRAY
, SHF_ALLOC
},
10570 { STRING_COMMA_LEN (".fini_array"), 0, SHT_FINI_ARRAY
, SHF_ALLOC
},
10571 { STRING_COMMA_LEN (".preinit_array"), 0, SHT_PREINIT_ARRAY
, SHF_ALLOC
},
10572 { NULL
, 0, 0, 0, 0 }
10576 elf32_arm_symbian_begin_write_processing (bfd
*abfd
,
10577 struct bfd_link_info
*link_info
)
10579 /* BPABI objects are never loaded directly by an OS kernel; they are
10580 processed by a postlinker first, into an OS-specific format. If
10581 the D_PAGED bit is set on the file, BFD will align segments on
10582 page boundaries, so that an OS can directly map the file. With
10583 BPABI objects, that just results in wasted space. In addition,
10584 because we clear the D_PAGED bit, map_sections_to_segments will
10585 recognize that the program headers should not be mapped into any
10586 loadable segment. */
10587 abfd
->flags
&= ~D_PAGED
;
10588 elf32_arm_begin_write_processing(abfd
, link_info
);
10592 elf32_arm_symbian_modify_segment_map (bfd
*abfd
,
10593 struct bfd_link_info
*info
)
10595 struct elf_segment_map
*m
;
10598 /* BPABI shared libraries and executables should have a PT_DYNAMIC
10599 segment. However, because the .dynamic section is not marked
10600 with SEC_LOAD, the generic ELF code will not create such a
10602 dynsec
= bfd_get_section_by_name (abfd
, ".dynamic");
10605 for (m
= elf_tdata (abfd
)->segment_map
; m
!= NULL
; m
= m
->next
)
10606 if (m
->p_type
== PT_DYNAMIC
)
10611 m
= _bfd_elf_make_dynamic_segment (abfd
, dynsec
);
10612 m
->next
= elf_tdata (abfd
)->segment_map
;
10613 elf_tdata (abfd
)->segment_map
= m
;
10617 /* Also call the generic arm routine. */
10618 return elf32_arm_modify_segment_map (abfd
, info
);
10622 #define elf32_bed elf32_arm_symbian_bed
10624 /* The dynamic sections are not allocated on SymbianOS; the postlinker
10625 will process them and then discard them. */
10626 #undef ELF_DYNAMIC_SEC_FLAGS
10627 #define ELF_DYNAMIC_SEC_FLAGS \
10628 (SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED)
10630 #undef bfd_elf32_bfd_link_hash_table_create
10631 #define bfd_elf32_bfd_link_hash_table_create \
10632 elf32_arm_symbian_link_hash_table_create
10633 #undef elf_backend_add_symbol_hook
10635 #undef elf_backend_special_sections
10636 #define elf_backend_special_sections elf32_arm_symbian_special_sections
10638 #undef elf_backend_begin_write_processing
10639 #define elf_backend_begin_write_processing \
10640 elf32_arm_symbian_begin_write_processing
10641 #undef elf_backend_final_write_processing
10642 #define elf_backend_final_write_processing \
10643 elf32_arm_final_write_processing
10644 #undef elf_backend_emit_relocs
10646 #undef elf_backend_modify_segment_map
10647 #define elf_backend_modify_segment_map elf32_arm_symbian_modify_segment_map
10649 /* There is no .got section for BPABI objects, and hence no header. */
10650 #undef elf_backend_got_header_size
10651 #define elf_backend_got_header_size 0
10653 /* Similarly, there is no .got.plt section. */
10654 #undef elf_backend_want_got_plt
10655 #define elf_backend_want_got_plt 0
10657 #undef elf_backend_may_use_rel_p
10658 #define elf_backend_may_use_rel_p 1
10659 #undef elf_backend_may_use_rela_p
10660 #define elf_backend_may_use_rela_p 0
10661 #undef elf_backend_default_use_rela_p
10662 #define elf_backend_default_use_rela_p 0
10663 #undef elf_backend_want_plt_sym
10664 #define elf_backend_want_plt_sym 0
10665 #undef ELF_MAXPAGESIZE
10666 #define ELF_MAXPAGESIZE 0x8000
10668 #include "elf32-target.h"