1 /* 32-bit ELF support for ARM
2 Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
3 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 2 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, MA 02110-1301, USA. */
23 #include "libiberty.h"
26 #include "elf-vxworks.h"
30 #define NUM_ELEM(a) (sizeof (a) / (sizeof (a)[0]))
33 /* Return the relocation section associated with NAME. HTAB is the
34 bfd's elf32_arm_link_hash_entry. */
35 #define RELOC_SECTION(HTAB, NAME) \
36 ((HTAB)->use_rel ? ".rel" NAME : ".rela" NAME)
38 /* Return size of a relocation entry. HTAB is the bfd's
39 elf32_arm_link_hash_entry. */
40 #define RELOC_SIZE(HTAB) \
42 ? sizeof (Elf32_External_Rel) \
43 : sizeof (Elf32_External_Rela))
45 /* Return function to swap relocations in. HTAB is the bfd's
46 elf32_arm_link_hash_entry. */
47 #define SWAP_RELOC_IN(HTAB) \
49 ? bfd_elf32_swap_reloc_in \
50 : bfd_elf32_swap_reloca_in)
52 /* Return function to swap relocations out. HTAB is the bfd's
53 elf32_arm_link_hash_entry. */
54 #define SWAP_RELOC_OUT(HTAB) \
56 ? bfd_elf32_swap_reloc_out \
57 : bfd_elf32_swap_reloca_out)
59 #define elf_info_to_howto 0
60 #define elf_info_to_howto_rel elf32_arm_info_to_howto
62 #define ARM_ELF_ABI_VERSION 0
63 #define ARM_ELF_OS_ABI_VERSION ELFOSABI_ARM
65 static struct elf_backend_data elf32_arm_vxworks_bed
;
67 /* Note: code such as elf32_arm_reloc_type_lookup expect to use e.g.
68 R_ARM_PC24 as an index into this, and find the R_ARM_PC24 HOWTO
71 static reloc_howto_type elf32_arm_howto_table_1
[] =
74 HOWTO (R_ARM_NONE
, /* type */
76 0, /* size (0 = byte, 1 = short, 2 = long) */
78 FALSE
, /* pc_relative */
80 complain_overflow_dont
,/* complain_on_overflow */
81 bfd_elf_generic_reloc
, /* special_function */
82 "R_ARM_NONE", /* name */
83 FALSE
, /* partial_inplace */
86 FALSE
), /* pcrel_offset */
88 HOWTO (R_ARM_PC24
, /* type */
90 2, /* size (0 = byte, 1 = short, 2 = long) */
92 TRUE
, /* pc_relative */
94 complain_overflow_signed
,/* complain_on_overflow */
95 bfd_elf_generic_reloc
, /* special_function */
96 "R_ARM_PC24", /* name */
97 FALSE
, /* partial_inplace */
98 0x00ffffff, /* src_mask */
99 0x00ffffff, /* dst_mask */
100 TRUE
), /* pcrel_offset */
102 /* 32 bit absolute */
103 HOWTO (R_ARM_ABS32
, /* type */
105 2, /* size (0 = byte, 1 = short, 2 = long) */
107 FALSE
, /* pc_relative */
109 complain_overflow_bitfield
,/* complain_on_overflow */
110 bfd_elf_generic_reloc
, /* special_function */
111 "R_ARM_ABS32", /* name */
112 FALSE
, /* partial_inplace */
113 0xffffffff, /* src_mask */
114 0xffffffff, /* dst_mask */
115 FALSE
), /* pcrel_offset */
117 /* standard 32bit pc-relative reloc */
118 HOWTO (R_ARM_REL32
, /* type */
120 2, /* size (0 = byte, 1 = short, 2 = long) */
122 TRUE
, /* pc_relative */
124 complain_overflow_bitfield
,/* complain_on_overflow */
125 bfd_elf_generic_reloc
, /* special_function */
126 "R_ARM_REL32", /* name */
127 FALSE
, /* partial_inplace */
128 0xffffffff, /* src_mask */
129 0xffffffff, /* dst_mask */
130 TRUE
), /* pcrel_offset */
132 /* 8 bit absolute - R_ARM_LDR_PC_G0 in AAELF */
133 HOWTO (R_ARM_LDR_PC_G0
, /* type */
135 0, /* size (0 = byte, 1 = short, 2 = long) */
137 TRUE
, /* pc_relative */
139 complain_overflow_dont
,/* complain_on_overflow */
140 bfd_elf_generic_reloc
, /* special_function */
141 "R_ARM_LDR_PC_G0", /* name */
142 FALSE
, /* partial_inplace */
143 0xffffffff, /* src_mask */
144 0xffffffff, /* dst_mask */
145 TRUE
), /* pcrel_offset */
147 /* 16 bit absolute */
148 HOWTO (R_ARM_ABS16
, /* type */
150 1, /* size (0 = byte, 1 = short, 2 = long) */
152 FALSE
, /* pc_relative */
154 complain_overflow_bitfield
,/* complain_on_overflow */
155 bfd_elf_generic_reloc
, /* special_function */
156 "R_ARM_ABS16", /* name */
157 FALSE
, /* partial_inplace */
158 0x0000ffff, /* src_mask */
159 0x0000ffff, /* dst_mask */
160 FALSE
), /* pcrel_offset */
162 /* 12 bit absolute */
163 HOWTO (R_ARM_ABS12
, /* type */
165 2, /* size (0 = byte, 1 = short, 2 = long) */
167 FALSE
, /* pc_relative */
169 complain_overflow_bitfield
,/* complain_on_overflow */
170 bfd_elf_generic_reloc
, /* special_function */
171 "R_ARM_ABS12", /* name */
172 FALSE
, /* partial_inplace */
173 0x00000fff, /* src_mask */
174 0x00000fff, /* dst_mask */
175 FALSE
), /* pcrel_offset */
177 HOWTO (R_ARM_THM_ABS5
, /* type */
179 1, /* size (0 = byte, 1 = short, 2 = long) */
181 FALSE
, /* pc_relative */
183 complain_overflow_bitfield
,/* complain_on_overflow */
184 bfd_elf_generic_reloc
, /* special_function */
185 "R_ARM_THM_ABS5", /* name */
186 FALSE
, /* partial_inplace */
187 0x000007e0, /* src_mask */
188 0x000007e0, /* dst_mask */
189 FALSE
), /* pcrel_offset */
192 HOWTO (R_ARM_ABS8
, /* type */
194 0, /* size (0 = byte, 1 = short, 2 = long) */
196 FALSE
, /* pc_relative */
198 complain_overflow_bitfield
,/* complain_on_overflow */
199 bfd_elf_generic_reloc
, /* special_function */
200 "R_ARM_ABS8", /* name */
201 FALSE
, /* partial_inplace */
202 0x000000ff, /* src_mask */
203 0x000000ff, /* dst_mask */
204 FALSE
), /* pcrel_offset */
206 HOWTO (R_ARM_SBREL32
, /* type */
208 2, /* size (0 = byte, 1 = short, 2 = long) */
210 FALSE
, /* pc_relative */
212 complain_overflow_dont
,/* complain_on_overflow */
213 bfd_elf_generic_reloc
, /* special_function */
214 "R_ARM_SBREL32", /* name */
215 FALSE
, /* partial_inplace */
216 0xffffffff, /* src_mask */
217 0xffffffff, /* dst_mask */
218 FALSE
), /* pcrel_offset */
220 HOWTO (R_ARM_THM_CALL
, /* type */
222 2, /* size (0 = byte, 1 = short, 2 = long) */
224 TRUE
, /* pc_relative */
226 complain_overflow_signed
,/* complain_on_overflow */
227 bfd_elf_generic_reloc
, /* special_function */
228 "R_ARM_THM_CALL", /* name */
229 FALSE
, /* partial_inplace */
230 0x07ff07ff, /* src_mask */
231 0x07ff07ff, /* dst_mask */
232 TRUE
), /* pcrel_offset */
234 HOWTO (R_ARM_THM_PC8
, /* type */
236 1, /* size (0 = byte, 1 = short, 2 = long) */
238 TRUE
, /* pc_relative */
240 complain_overflow_signed
,/* complain_on_overflow */
241 bfd_elf_generic_reloc
, /* special_function */
242 "R_ARM_THM_PC8", /* name */
243 FALSE
, /* partial_inplace */
244 0x000000ff, /* src_mask */
245 0x000000ff, /* dst_mask */
246 TRUE
), /* pcrel_offset */
248 HOWTO (R_ARM_BREL_ADJ
, /* type */
250 1, /* size (0 = byte, 1 = short, 2 = long) */
252 FALSE
, /* pc_relative */
254 complain_overflow_signed
,/* complain_on_overflow */
255 bfd_elf_generic_reloc
, /* special_function */
256 "R_ARM_BREL_ADJ", /* name */
257 FALSE
, /* partial_inplace */
258 0xffffffff, /* src_mask */
259 0xffffffff, /* dst_mask */
260 FALSE
), /* pcrel_offset */
262 HOWTO (R_ARM_SWI24
, /* type */
264 0, /* size (0 = byte, 1 = short, 2 = long) */
266 FALSE
, /* pc_relative */
268 complain_overflow_signed
,/* complain_on_overflow */
269 bfd_elf_generic_reloc
, /* special_function */
270 "R_ARM_SWI24", /* name */
271 FALSE
, /* partial_inplace */
272 0x00000000, /* src_mask */
273 0x00000000, /* dst_mask */
274 FALSE
), /* pcrel_offset */
276 HOWTO (R_ARM_THM_SWI8
, /* type */
278 0, /* size (0 = byte, 1 = short, 2 = long) */
280 FALSE
, /* pc_relative */
282 complain_overflow_signed
,/* complain_on_overflow */
283 bfd_elf_generic_reloc
, /* special_function */
284 "R_ARM_SWI8", /* name */
285 FALSE
, /* partial_inplace */
286 0x00000000, /* src_mask */
287 0x00000000, /* dst_mask */
288 FALSE
), /* pcrel_offset */
290 /* BLX instruction for the ARM. */
291 HOWTO (R_ARM_XPC25
, /* type */
293 2, /* size (0 = byte, 1 = short, 2 = long) */
295 TRUE
, /* pc_relative */
297 complain_overflow_signed
,/* complain_on_overflow */
298 bfd_elf_generic_reloc
, /* special_function */
299 "R_ARM_XPC25", /* name */
300 FALSE
, /* partial_inplace */
301 0x00ffffff, /* src_mask */
302 0x00ffffff, /* dst_mask */
303 TRUE
), /* pcrel_offset */
305 /* BLX instruction for the Thumb. */
306 HOWTO (R_ARM_THM_XPC22
, /* type */
308 2, /* size (0 = byte, 1 = short, 2 = long) */
310 TRUE
, /* pc_relative */
312 complain_overflow_signed
,/* complain_on_overflow */
313 bfd_elf_generic_reloc
, /* special_function */
314 "R_ARM_THM_XPC22", /* name */
315 FALSE
, /* partial_inplace */
316 0x07ff07ff, /* src_mask */
317 0x07ff07ff, /* dst_mask */
318 TRUE
), /* pcrel_offset */
320 /* Dynamic TLS relocations. */
322 HOWTO (R_ARM_TLS_DTPMOD32
, /* type */
324 2, /* size (0 = byte, 1 = short, 2 = long) */
326 FALSE
, /* pc_relative */
328 complain_overflow_bitfield
,/* complain_on_overflow */
329 bfd_elf_generic_reloc
, /* special_function */
330 "R_ARM_TLS_DTPMOD32", /* name */
331 TRUE
, /* partial_inplace */
332 0xffffffff, /* src_mask */
333 0xffffffff, /* dst_mask */
334 FALSE
), /* pcrel_offset */
336 HOWTO (R_ARM_TLS_DTPOFF32
, /* type */
338 2, /* size (0 = byte, 1 = short, 2 = long) */
340 FALSE
, /* pc_relative */
342 complain_overflow_bitfield
,/* complain_on_overflow */
343 bfd_elf_generic_reloc
, /* special_function */
344 "R_ARM_TLS_DTPOFF32", /* name */
345 TRUE
, /* partial_inplace */
346 0xffffffff, /* src_mask */
347 0xffffffff, /* dst_mask */
348 FALSE
), /* pcrel_offset */
350 HOWTO (R_ARM_TLS_TPOFF32
, /* type */
352 2, /* size (0 = byte, 1 = short, 2 = long) */
354 FALSE
, /* pc_relative */
356 complain_overflow_bitfield
,/* complain_on_overflow */
357 bfd_elf_generic_reloc
, /* special_function */
358 "R_ARM_TLS_TPOFF32", /* name */
359 TRUE
, /* partial_inplace */
360 0xffffffff, /* src_mask */
361 0xffffffff, /* dst_mask */
362 FALSE
), /* pcrel_offset */
364 /* Relocs used in ARM Linux */
366 HOWTO (R_ARM_COPY
, /* type */
368 2, /* size (0 = byte, 1 = short, 2 = long) */
370 FALSE
, /* pc_relative */
372 complain_overflow_bitfield
,/* complain_on_overflow */
373 bfd_elf_generic_reloc
, /* special_function */
374 "R_ARM_COPY", /* name */
375 TRUE
, /* partial_inplace */
376 0xffffffff, /* src_mask */
377 0xffffffff, /* dst_mask */
378 FALSE
), /* pcrel_offset */
380 HOWTO (R_ARM_GLOB_DAT
, /* type */
382 2, /* size (0 = byte, 1 = short, 2 = long) */
384 FALSE
, /* pc_relative */
386 complain_overflow_bitfield
,/* complain_on_overflow */
387 bfd_elf_generic_reloc
, /* special_function */
388 "R_ARM_GLOB_DAT", /* name */
389 TRUE
, /* partial_inplace */
390 0xffffffff, /* src_mask */
391 0xffffffff, /* dst_mask */
392 FALSE
), /* pcrel_offset */
394 HOWTO (R_ARM_JUMP_SLOT
, /* type */
396 2, /* size (0 = byte, 1 = short, 2 = long) */
398 FALSE
, /* pc_relative */
400 complain_overflow_bitfield
,/* complain_on_overflow */
401 bfd_elf_generic_reloc
, /* special_function */
402 "R_ARM_JUMP_SLOT", /* name */
403 TRUE
, /* partial_inplace */
404 0xffffffff, /* src_mask */
405 0xffffffff, /* dst_mask */
406 FALSE
), /* pcrel_offset */
408 HOWTO (R_ARM_RELATIVE
, /* type */
410 2, /* size (0 = byte, 1 = short, 2 = long) */
412 FALSE
, /* pc_relative */
414 complain_overflow_bitfield
,/* complain_on_overflow */
415 bfd_elf_generic_reloc
, /* special_function */
416 "R_ARM_RELATIVE", /* name */
417 TRUE
, /* partial_inplace */
418 0xffffffff, /* src_mask */
419 0xffffffff, /* dst_mask */
420 FALSE
), /* pcrel_offset */
422 HOWTO (R_ARM_GOTOFF32
, /* type */
424 2, /* size (0 = byte, 1 = short, 2 = long) */
426 FALSE
, /* pc_relative */
428 complain_overflow_bitfield
,/* complain_on_overflow */
429 bfd_elf_generic_reloc
, /* special_function */
430 "R_ARM_GOTOFF32", /* name */
431 TRUE
, /* partial_inplace */
432 0xffffffff, /* src_mask */
433 0xffffffff, /* dst_mask */
434 FALSE
), /* pcrel_offset */
436 HOWTO (R_ARM_GOTPC
, /* type */
438 2, /* size (0 = byte, 1 = short, 2 = long) */
440 TRUE
, /* pc_relative */
442 complain_overflow_bitfield
,/* complain_on_overflow */
443 bfd_elf_generic_reloc
, /* special_function */
444 "R_ARM_GOTPC", /* name */
445 TRUE
, /* partial_inplace */
446 0xffffffff, /* src_mask */
447 0xffffffff, /* dst_mask */
448 TRUE
), /* pcrel_offset */
450 HOWTO (R_ARM_GOT32
, /* type */
452 2, /* size (0 = byte, 1 = short, 2 = long) */
454 FALSE
, /* pc_relative */
456 complain_overflow_bitfield
,/* complain_on_overflow */
457 bfd_elf_generic_reloc
, /* special_function */
458 "R_ARM_GOT32", /* name */
459 TRUE
, /* partial_inplace */
460 0xffffffff, /* src_mask */
461 0xffffffff, /* dst_mask */
462 FALSE
), /* pcrel_offset */
464 HOWTO (R_ARM_PLT32
, /* type */
466 2, /* size (0 = byte, 1 = short, 2 = long) */
468 TRUE
, /* pc_relative */
470 complain_overflow_bitfield
,/* complain_on_overflow */
471 bfd_elf_generic_reloc
, /* special_function */
472 "R_ARM_PLT32", /* name */
473 FALSE
, /* partial_inplace */
474 0x00ffffff, /* src_mask */
475 0x00ffffff, /* dst_mask */
476 TRUE
), /* pcrel_offset */
478 HOWTO (R_ARM_CALL
, /* type */
480 2, /* size (0 = byte, 1 = short, 2 = long) */
482 TRUE
, /* pc_relative */
484 complain_overflow_signed
,/* complain_on_overflow */
485 bfd_elf_generic_reloc
, /* special_function */
486 "R_ARM_CALL", /* name */
487 FALSE
, /* partial_inplace */
488 0x00ffffff, /* src_mask */
489 0x00ffffff, /* dst_mask */
490 TRUE
), /* pcrel_offset */
492 HOWTO (R_ARM_JUMP24
, /* type */
494 2, /* size (0 = byte, 1 = short, 2 = long) */
496 TRUE
, /* pc_relative */
498 complain_overflow_signed
,/* complain_on_overflow */
499 bfd_elf_generic_reloc
, /* special_function */
500 "R_ARM_JUMP24", /* name */
501 FALSE
, /* partial_inplace */
502 0x00ffffff, /* src_mask */
503 0x00ffffff, /* dst_mask */
504 TRUE
), /* pcrel_offset */
506 HOWTO (R_ARM_THM_JUMP24
, /* type */
508 2, /* size (0 = byte, 1 = short, 2 = long) */
510 TRUE
, /* pc_relative */
512 complain_overflow_signed
,/* complain_on_overflow */
513 bfd_elf_generic_reloc
, /* special_function */
514 "R_ARM_THM_JUMP24", /* name */
515 FALSE
, /* partial_inplace */
516 0x07ff2fff, /* src_mask */
517 0x07ff2fff, /* dst_mask */
518 TRUE
), /* pcrel_offset */
520 HOWTO (R_ARM_BASE_ABS
, /* type */
522 2, /* size (0 = byte, 1 = short, 2 = long) */
524 FALSE
, /* pc_relative */
526 complain_overflow_dont
,/* complain_on_overflow */
527 bfd_elf_generic_reloc
, /* special_function */
528 "R_ARM_BASE_ABS", /* name */
529 FALSE
, /* partial_inplace */
530 0xffffffff, /* src_mask */
531 0xffffffff, /* dst_mask */
532 FALSE
), /* pcrel_offset */
534 HOWTO (R_ARM_ALU_PCREL7_0
, /* type */
536 2, /* size (0 = byte, 1 = short, 2 = long) */
538 TRUE
, /* pc_relative */
540 complain_overflow_dont
,/* complain_on_overflow */
541 bfd_elf_generic_reloc
, /* special_function */
542 "R_ARM_ALU_PCREL_7_0", /* name */
543 FALSE
, /* partial_inplace */
544 0x00000fff, /* src_mask */
545 0x00000fff, /* dst_mask */
546 TRUE
), /* pcrel_offset */
548 HOWTO (R_ARM_ALU_PCREL15_8
, /* type */
550 2, /* size (0 = byte, 1 = short, 2 = long) */
552 TRUE
, /* pc_relative */
554 complain_overflow_dont
,/* complain_on_overflow */
555 bfd_elf_generic_reloc
, /* special_function */
556 "R_ARM_ALU_PCREL_15_8",/* name */
557 FALSE
, /* partial_inplace */
558 0x00000fff, /* src_mask */
559 0x00000fff, /* dst_mask */
560 TRUE
), /* pcrel_offset */
562 HOWTO (R_ARM_ALU_PCREL23_15
, /* type */
564 2, /* size (0 = byte, 1 = short, 2 = long) */
566 TRUE
, /* pc_relative */
568 complain_overflow_dont
,/* complain_on_overflow */
569 bfd_elf_generic_reloc
, /* special_function */
570 "R_ARM_ALU_PCREL_23_15",/* name */
571 FALSE
, /* partial_inplace */
572 0x00000fff, /* src_mask */
573 0x00000fff, /* dst_mask */
574 TRUE
), /* pcrel_offset */
576 HOWTO (R_ARM_LDR_SBREL_11_0
, /* type */
578 2, /* size (0 = byte, 1 = short, 2 = long) */
580 FALSE
, /* pc_relative */
582 complain_overflow_dont
,/* complain_on_overflow */
583 bfd_elf_generic_reloc
, /* special_function */
584 "R_ARM_LDR_SBREL_11_0",/* name */
585 FALSE
, /* partial_inplace */
586 0x00000fff, /* src_mask */
587 0x00000fff, /* dst_mask */
588 FALSE
), /* pcrel_offset */
590 HOWTO (R_ARM_ALU_SBREL_19_12
, /* type */
592 2, /* size (0 = byte, 1 = short, 2 = long) */
594 FALSE
, /* pc_relative */
596 complain_overflow_dont
,/* complain_on_overflow */
597 bfd_elf_generic_reloc
, /* special_function */
598 "R_ARM_ALU_SBREL_19_12",/* name */
599 FALSE
, /* partial_inplace */
600 0x000ff000, /* src_mask */
601 0x000ff000, /* dst_mask */
602 FALSE
), /* pcrel_offset */
604 HOWTO (R_ARM_ALU_SBREL_27_20
, /* type */
606 2, /* size (0 = byte, 1 = short, 2 = long) */
608 FALSE
, /* pc_relative */
610 complain_overflow_dont
,/* complain_on_overflow */
611 bfd_elf_generic_reloc
, /* special_function */
612 "R_ARM_ALU_SBREL_27_20",/* name */
613 FALSE
, /* partial_inplace */
614 0x0ff00000, /* src_mask */
615 0x0ff00000, /* dst_mask */
616 FALSE
), /* pcrel_offset */
618 HOWTO (R_ARM_TARGET1
, /* type */
620 2, /* size (0 = byte, 1 = short, 2 = long) */
622 FALSE
, /* pc_relative */
624 complain_overflow_dont
,/* complain_on_overflow */
625 bfd_elf_generic_reloc
, /* special_function */
626 "R_ARM_TARGET1", /* name */
627 FALSE
, /* partial_inplace */
628 0xffffffff, /* src_mask */
629 0xffffffff, /* dst_mask */
630 FALSE
), /* pcrel_offset */
632 HOWTO (R_ARM_ROSEGREL32
, /* type */
634 2, /* size (0 = byte, 1 = short, 2 = long) */
636 FALSE
, /* pc_relative */
638 complain_overflow_dont
,/* complain_on_overflow */
639 bfd_elf_generic_reloc
, /* special_function */
640 "R_ARM_ROSEGREL32", /* name */
641 FALSE
, /* partial_inplace */
642 0xffffffff, /* src_mask */
643 0xffffffff, /* dst_mask */
644 FALSE
), /* pcrel_offset */
646 HOWTO (R_ARM_V4BX
, /* type */
648 2, /* size (0 = byte, 1 = short, 2 = long) */
650 FALSE
, /* pc_relative */
652 complain_overflow_dont
,/* complain_on_overflow */
653 bfd_elf_generic_reloc
, /* special_function */
654 "R_ARM_V4BX", /* name */
655 FALSE
, /* partial_inplace */
656 0xffffffff, /* src_mask */
657 0xffffffff, /* dst_mask */
658 FALSE
), /* pcrel_offset */
660 HOWTO (R_ARM_TARGET2
, /* type */
662 2, /* size (0 = byte, 1 = short, 2 = long) */
664 FALSE
, /* pc_relative */
666 complain_overflow_signed
,/* complain_on_overflow */
667 bfd_elf_generic_reloc
, /* special_function */
668 "R_ARM_TARGET2", /* name */
669 FALSE
, /* partial_inplace */
670 0xffffffff, /* src_mask */
671 0xffffffff, /* dst_mask */
672 TRUE
), /* pcrel_offset */
674 HOWTO (R_ARM_PREL31
, /* type */
676 2, /* size (0 = byte, 1 = short, 2 = long) */
678 TRUE
, /* pc_relative */
680 complain_overflow_signed
,/* complain_on_overflow */
681 bfd_elf_generic_reloc
, /* special_function */
682 "R_ARM_PREL31", /* name */
683 FALSE
, /* partial_inplace */
684 0x7fffffff, /* src_mask */
685 0x7fffffff, /* dst_mask */
686 TRUE
), /* pcrel_offset */
688 HOWTO (R_ARM_MOVW_ABS_NC
, /* type */
690 2, /* size (0 = byte, 1 = short, 2 = long) */
692 FALSE
, /* pc_relative */
694 complain_overflow_dont
,/* complain_on_overflow */
695 bfd_elf_generic_reloc
, /* special_function */
696 "R_ARM_MOVW_ABS_NC", /* name */
697 FALSE
, /* partial_inplace */
698 0x0000ffff, /* src_mask */
699 0x0000ffff, /* dst_mask */
700 FALSE
), /* pcrel_offset */
702 HOWTO (R_ARM_MOVT_ABS
, /* type */
704 2, /* size (0 = byte, 1 = short, 2 = long) */
706 FALSE
, /* pc_relative */
708 complain_overflow_bitfield
,/* complain_on_overflow */
709 bfd_elf_generic_reloc
, /* special_function */
710 "R_ARM_MOVT_ABS", /* name */
711 FALSE
, /* partial_inplace */
712 0x0000ffff, /* src_mask */
713 0x0000ffff, /* dst_mask */
714 FALSE
), /* pcrel_offset */
716 HOWTO (R_ARM_MOVW_PREL_NC
, /* type */
718 2, /* size (0 = byte, 1 = short, 2 = long) */
720 TRUE
, /* pc_relative */
722 complain_overflow_dont
,/* complain_on_overflow */
723 bfd_elf_generic_reloc
, /* special_function */
724 "R_ARM_MOVW_PREL_NC", /* name */
725 FALSE
, /* partial_inplace */
726 0x0000ffff, /* src_mask */
727 0x0000ffff, /* dst_mask */
728 TRUE
), /* pcrel_offset */
730 HOWTO (R_ARM_MOVT_PREL
, /* type */
732 2, /* size (0 = byte, 1 = short, 2 = long) */
734 TRUE
, /* pc_relative */
736 complain_overflow_bitfield
,/* complain_on_overflow */
737 bfd_elf_generic_reloc
, /* special_function */
738 "R_ARM_MOVT_PREL", /* name */
739 FALSE
, /* partial_inplace */
740 0x0000ffff, /* src_mask */
741 0x0000ffff, /* dst_mask */
742 TRUE
), /* pcrel_offset */
744 HOWTO (R_ARM_THM_MOVW_ABS_NC
, /* type */
746 2, /* size (0 = byte, 1 = short, 2 = long) */
748 FALSE
, /* pc_relative */
750 complain_overflow_dont
,/* complain_on_overflow */
751 bfd_elf_generic_reloc
, /* special_function */
752 "R_ARM_THM_MOVW_ABS_NC",/* name */
753 FALSE
, /* partial_inplace */
754 0x040f70ff, /* src_mask */
755 0x040f70ff, /* dst_mask */
756 FALSE
), /* pcrel_offset */
758 HOWTO (R_ARM_THM_MOVT_ABS
, /* type */
760 2, /* size (0 = byte, 1 = short, 2 = long) */
762 FALSE
, /* pc_relative */
764 complain_overflow_bitfield
,/* complain_on_overflow */
765 bfd_elf_generic_reloc
, /* special_function */
766 "R_ARM_THM_MOVT_ABS", /* name */
767 FALSE
, /* partial_inplace */
768 0x040f70ff, /* src_mask */
769 0x040f70ff, /* dst_mask */
770 FALSE
), /* pcrel_offset */
772 HOWTO (R_ARM_THM_MOVW_PREL_NC
,/* type */
774 2, /* size (0 = byte, 1 = short, 2 = long) */
776 TRUE
, /* pc_relative */
778 complain_overflow_dont
,/* complain_on_overflow */
779 bfd_elf_generic_reloc
, /* special_function */
780 "R_ARM_THM_MOVW_PREL_NC",/* name */
781 FALSE
, /* partial_inplace */
782 0x040f70ff, /* src_mask */
783 0x040f70ff, /* dst_mask */
784 TRUE
), /* pcrel_offset */
786 HOWTO (R_ARM_THM_MOVT_PREL
, /* type */
788 2, /* size (0 = byte, 1 = short, 2 = long) */
790 TRUE
, /* pc_relative */
792 complain_overflow_bitfield
,/* complain_on_overflow */
793 bfd_elf_generic_reloc
, /* special_function */
794 "R_ARM_THM_MOVT_PREL", /* name */
795 FALSE
, /* partial_inplace */
796 0x040f70ff, /* src_mask */
797 0x040f70ff, /* dst_mask */
798 TRUE
), /* pcrel_offset */
800 HOWTO (R_ARM_THM_JUMP19
, /* type */
802 2, /* size (0 = byte, 1 = short, 2 = long) */
804 TRUE
, /* pc_relative */
806 complain_overflow_signed
,/* complain_on_overflow */
807 bfd_elf_generic_reloc
, /* special_function */
808 "R_ARM_THM_JUMP19", /* name */
809 FALSE
, /* partial_inplace */
810 0x043f2fff, /* src_mask */
811 0x043f2fff, /* dst_mask */
812 TRUE
), /* pcrel_offset */
814 HOWTO (R_ARM_THM_JUMP6
, /* type */
816 1, /* size (0 = byte, 1 = short, 2 = long) */
818 TRUE
, /* pc_relative */
820 complain_overflow_unsigned
,/* complain_on_overflow */
821 bfd_elf_generic_reloc
, /* special_function */
822 "R_ARM_THM_JUMP6", /* name */
823 FALSE
, /* partial_inplace */
824 0x02f8, /* src_mask */
825 0x02f8, /* dst_mask */
826 TRUE
), /* pcrel_offset */
828 /* These are declared as 13-bit signed relocations because we can
829 address -4095 .. 4095(base) by altering ADDW to SUBW or vice
831 HOWTO (R_ARM_THM_ALU_PREL_11_0
,/* type */
833 2, /* size (0 = byte, 1 = short, 2 = long) */
835 TRUE
, /* pc_relative */
837 complain_overflow_dont
,/* complain_on_overflow */
838 bfd_elf_generic_reloc
, /* special_function */
839 "R_ARM_THM_ALU_PREL_11_0",/* name */
840 FALSE
, /* partial_inplace */
841 0xffffffff, /* src_mask */
842 0xffffffff, /* dst_mask */
843 TRUE
), /* pcrel_offset */
845 HOWTO (R_ARM_THM_PC12
, /* type */
847 2, /* size (0 = byte, 1 = short, 2 = long) */
849 TRUE
, /* pc_relative */
851 complain_overflow_dont
,/* complain_on_overflow */
852 bfd_elf_generic_reloc
, /* special_function */
853 "R_ARM_THM_PC12", /* name */
854 FALSE
, /* partial_inplace */
855 0xffffffff, /* src_mask */
856 0xffffffff, /* dst_mask */
857 TRUE
), /* pcrel_offset */
859 HOWTO (R_ARM_ABS32_NOI
, /* type */
861 2, /* size (0 = byte, 1 = short, 2 = long) */
863 FALSE
, /* pc_relative */
865 complain_overflow_dont
,/* complain_on_overflow */
866 bfd_elf_generic_reloc
, /* special_function */
867 "R_ARM_ABS32_NOI", /* name */
868 FALSE
, /* partial_inplace */
869 0xffffffff, /* src_mask */
870 0xffffffff, /* dst_mask */
871 FALSE
), /* pcrel_offset */
873 HOWTO (R_ARM_REL32_NOI
, /* type */
875 2, /* size (0 = byte, 1 = short, 2 = long) */
877 TRUE
, /* pc_relative */
879 complain_overflow_dont
,/* complain_on_overflow */
880 bfd_elf_generic_reloc
, /* special_function */
881 "R_ARM_REL32_NOI", /* name */
882 FALSE
, /* partial_inplace */
883 0xffffffff, /* src_mask */
884 0xffffffff, /* dst_mask */
885 FALSE
), /* pcrel_offset */
887 /* Group relocations. */
889 HOWTO (R_ARM_ALU_PC_G0_NC
, /* type */
891 2, /* size (0 = byte, 1 = short, 2 = long) */
893 TRUE
, /* pc_relative */
895 complain_overflow_dont
,/* complain_on_overflow */
896 bfd_elf_generic_reloc
, /* special_function */
897 "R_ARM_ALU_PC_G0_NC", /* name */
898 FALSE
, /* partial_inplace */
899 0xffffffff, /* src_mask */
900 0xffffffff, /* dst_mask */
901 TRUE
), /* pcrel_offset */
903 HOWTO (R_ARM_ALU_PC_G0
, /* type */
905 2, /* size (0 = byte, 1 = short, 2 = long) */
907 TRUE
, /* pc_relative */
909 complain_overflow_dont
,/* complain_on_overflow */
910 bfd_elf_generic_reloc
, /* special_function */
911 "R_ARM_ALU_PC_G0", /* name */
912 FALSE
, /* partial_inplace */
913 0xffffffff, /* src_mask */
914 0xffffffff, /* dst_mask */
915 TRUE
), /* pcrel_offset */
917 HOWTO (R_ARM_ALU_PC_G1_NC
, /* type */
919 2, /* size (0 = byte, 1 = short, 2 = long) */
921 TRUE
, /* pc_relative */
923 complain_overflow_dont
,/* complain_on_overflow */
924 bfd_elf_generic_reloc
, /* special_function */
925 "R_ARM_ALU_PC_G1_NC", /* name */
926 FALSE
, /* partial_inplace */
927 0xffffffff, /* src_mask */
928 0xffffffff, /* dst_mask */
929 TRUE
), /* pcrel_offset */
931 HOWTO (R_ARM_ALU_PC_G1
, /* type */
933 2, /* size (0 = byte, 1 = short, 2 = long) */
935 TRUE
, /* pc_relative */
937 complain_overflow_dont
,/* complain_on_overflow */
938 bfd_elf_generic_reloc
, /* special_function */
939 "R_ARM_ALU_PC_G1", /* name */
940 FALSE
, /* partial_inplace */
941 0xffffffff, /* src_mask */
942 0xffffffff, /* dst_mask */
943 TRUE
), /* pcrel_offset */
945 HOWTO (R_ARM_ALU_PC_G2
, /* type */
947 2, /* size (0 = byte, 1 = short, 2 = long) */
949 TRUE
, /* pc_relative */
951 complain_overflow_dont
,/* complain_on_overflow */
952 bfd_elf_generic_reloc
, /* special_function */
953 "R_ARM_ALU_PC_G2", /* name */
954 FALSE
, /* partial_inplace */
955 0xffffffff, /* src_mask */
956 0xffffffff, /* dst_mask */
957 TRUE
), /* pcrel_offset */
959 HOWTO (R_ARM_LDR_PC_G1
, /* type */
961 2, /* size (0 = byte, 1 = short, 2 = long) */
963 TRUE
, /* pc_relative */
965 complain_overflow_dont
,/* complain_on_overflow */
966 bfd_elf_generic_reloc
, /* special_function */
967 "R_ARM_LDR_PC_G1", /* name */
968 FALSE
, /* partial_inplace */
969 0xffffffff, /* src_mask */
970 0xffffffff, /* dst_mask */
971 TRUE
), /* pcrel_offset */
973 HOWTO (R_ARM_LDR_PC_G2
, /* type */
975 2, /* size (0 = byte, 1 = short, 2 = long) */
977 TRUE
, /* pc_relative */
979 complain_overflow_dont
,/* complain_on_overflow */
980 bfd_elf_generic_reloc
, /* special_function */
981 "R_ARM_LDR_PC_G2", /* name */
982 FALSE
, /* partial_inplace */
983 0xffffffff, /* src_mask */
984 0xffffffff, /* dst_mask */
985 TRUE
), /* pcrel_offset */
987 HOWTO (R_ARM_LDRS_PC_G0
, /* type */
989 2, /* size (0 = byte, 1 = short, 2 = long) */
991 TRUE
, /* pc_relative */
993 complain_overflow_dont
,/* complain_on_overflow */
994 bfd_elf_generic_reloc
, /* special_function */
995 "R_ARM_LDRS_PC_G0", /* name */
996 FALSE
, /* partial_inplace */
997 0xffffffff, /* src_mask */
998 0xffffffff, /* dst_mask */
999 TRUE
), /* pcrel_offset */
1001 HOWTO (R_ARM_LDRS_PC_G1
, /* type */
1003 2, /* size (0 = byte, 1 = short, 2 = long) */
1005 TRUE
, /* pc_relative */
1007 complain_overflow_dont
,/* complain_on_overflow */
1008 bfd_elf_generic_reloc
, /* special_function */
1009 "R_ARM_LDRS_PC_G1", /* name */
1010 FALSE
, /* partial_inplace */
1011 0xffffffff, /* src_mask */
1012 0xffffffff, /* dst_mask */
1013 TRUE
), /* pcrel_offset */
1015 HOWTO (R_ARM_LDRS_PC_G2
, /* type */
1017 2, /* size (0 = byte, 1 = short, 2 = long) */
1019 TRUE
, /* pc_relative */
1021 complain_overflow_dont
,/* complain_on_overflow */
1022 bfd_elf_generic_reloc
, /* special_function */
1023 "R_ARM_LDRS_PC_G2", /* name */
1024 FALSE
, /* partial_inplace */
1025 0xffffffff, /* src_mask */
1026 0xffffffff, /* dst_mask */
1027 TRUE
), /* pcrel_offset */
1029 HOWTO (R_ARM_LDC_PC_G0
, /* type */
1031 2, /* size (0 = byte, 1 = short, 2 = long) */
1033 TRUE
, /* pc_relative */
1035 complain_overflow_dont
,/* complain_on_overflow */
1036 bfd_elf_generic_reloc
, /* special_function */
1037 "R_ARM_LDC_PC_G0", /* name */
1038 FALSE
, /* partial_inplace */
1039 0xffffffff, /* src_mask */
1040 0xffffffff, /* dst_mask */
1041 TRUE
), /* pcrel_offset */
1043 HOWTO (R_ARM_LDC_PC_G1
, /* type */
1045 2, /* size (0 = byte, 1 = short, 2 = long) */
1047 TRUE
, /* pc_relative */
1049 complain_overflow_dont
,/* complain_on_overflow */
1050 bfd_elf_generic_reloc
, /* special_function */
1051 "R_ARM_LDC_PC_G1", /* name */
1052 FALSE
, /* partial_inplace */
1053 0xffffffff, /* src_mask */
1054 0xffffffff, /* dst_mask */
1055 TRUE
), /* pcrel_offset */
1057 HOWTO (R_ARM_LDC_PC_G2
, /* type */
1059 2, /* size (0 = byte, 1 = short, 2 = long) */
1061 TRUE
, /* pc_relative */
1063 complain_overflow_dont
,/* complain_on_overflow */
1064 bfd_elf_generic_reloc
, /* special_function */
1065 "R_ARM_LDC_PC_G2", /* name */
1066 FALSE
, /* partial_inplace */
1067 0xffffffff, /* src_mask */
1068 0xffffffff, /* dst_mask */
1069 TRUE
), /* pcrel_offset */
1071 HOWTO (R_ARM_ALU_SB_G0_NC
, /* type */
1073 2, /* size (0 = byte, 1 = short, 2 = long) */
1075 TRUE
, /* pc_relative */
1077 complain_overflow_dont
,/* complain_on_overflow */
1078 bfd_elf_generic_reloc
, /* special_function */
1079 "R_ARM_ALU_SB_G0_NC", /* name */
1080 FALSE
, /* partial_inplace */
1081 0xffffffff, /* src_mask */
1082 0xffffffff, /* dst_mask */
1083 TRUE
), /* pcrel_offset */
1085 HOWTO (R_ARM_ALU_SB_G0
, /* type */
1087 2, /* size (0 = byte, 1 = short, 2 = long) */
1089 TRUE
, /* pc_relative */
1091 complain_overflow_dont
,/* complain_on_overflow */
1092 bfd_elf_generic_reloc
, /* special_function */
1093 "R_ARM_ALU_SB_G0", /* name */
1094 FALSE
, /* partial_inplace */
1095 0xffffffff, /* src_mask */
1096 0xffffffff, /* dst_mask */
1097 TRUE
), /* pcrel_offset */
1099 HOWTO (R_ARM_ALU_SB_G1_NC
, /* type */
1101 2, /* size (0 = byte, 1 = short, 2 = long) */
1103 TRUE
, /* pc_relative */
1105 complain_overflow_dont
,/* complain_on_overflow */
1106 bfd_elf_generic_reloc
, /* special_function */
1107 "R_ARM_ALU_SB_G1_NC", /* name */
1108 FALSE
, /* partial_inplace */
1109 0xffffffff, /* src_mask */
1110 0xffffffff, /* dst_mask */
1111 TRUE
), /* pcrel_offset */
1113 HOWTO (R_ARM_ALU_SB_G1
, /* type */
1115 2, /* size (0 = byte, 1 = short, 2 = long) */
1117 TRUE
, /* pc_relative */
1119 complain_overflow_dont
,/* complain_on_overflow */
1120 bfd_elf_generic_reloc
, /* special_function */
1121 "R_ARM_ALU_SB_G1", /* name */
1122 FALSE
, /* partial_inplace */
1123 0xffffffff, /* src_mask */
1124 0xffffffff, /* dst_mask */
1125 TRUE
), /* pcrel_offset */
1127 HOWTO (R_ARM_ALU_SB_G2
, /* type */
1129 2, /* size (0 = byte, 1 = short, 2 = long) */
1131 TRUE
, /* pc_relative */
1133 complain_overflow_dont
,/* complain_on_overflow */
1134 bfd_elf_generic_reloc
, /* special_function */
1135 "R_ARM_ALU_SB_G2", /* name */
1136 FALSE
, /* partial_inplace */
1137 0xffffffff, /* src_mask */
1138 0xffffffff, /* dst_mask */
1139 TRUE
), /* pcrel_offset */
1141 HOWTO (R_ARM_LDR_SB_G0
, /* type */
1143 2, /* size (0 = byte, 1 = short, 2 = long) */
1145 TRUE
, /* pc_relative */
1147 complain_overflow_dont
,/* complain_on_overflow */
1148 bfd_elf_generic_reloc
, /* special_function */
1149 "R_ARM_LDR_SB_G0", /* name */
1150 FALSE
, /* partial_inplace */
1151 0xffffffff, /* src_mask */
1152 0xffffffff, /* dst_mask */
1153 TRUE
), /* pcrel_offset */
1155 HOWTO (R_ARM_LDR_SB_G1
, /* type */
1157 2, /* size (0 = byte, 1 = short, 2 = long) */
1159 TRUE
, /* pc_relative */
1161 complain_overflow_dont
,/* complain_on_overflow */
1162 bfd_elf_generic_reloc
, /* special_function */
1163 "R_ARM_LDR_SB_G1", /* name */
1164 FALSE
, /* partial_inplace */
1165 0xffffffff, /* src_mask */
1166 0xffffffff, /* dst_mask */
1167 TRUE
), /* pcrel_offset */
1169 HOWTO (R_ARM_LDR_SB_G2
, /* type */
1171 2, /* size (0 = byte, 1 = short, 2 = long) */
1173 TRUE
, /* pc_relative */
1175 complain_overflow_dont
,/* complain_on_overflow */
1176 bfd_elf_generic_reloc
, /* special_function */
1177 "R_ARM_LDR_SB_G2", /* name */
1178 FALSE
, /* partial_inplace */
1179 0xffffffff, /* src_mask */
1180 0xffffffff, /* dst_mask */
1181 TRUE
), /* pcrel_offset */
1183 HOWTO (R_ARM_LDRS_SB_G0
, /* type */
1185 2, /* size (0 = byte, 1 = short, 2 = long) */
1187 TRUE
, /* pc_relative */
1189 complain_overflow_dont
,/* complain_on_overflow */
1190 bfd_elf_generic_reloc
, /* special_function */
1191 "R_ARM_LDRS_SB_G0", /* name */
1192 FALSE
, /* partial_inplace */
1193 0xffffffff, /* src_mask */
1194 0xffffffff, /* dst_mask */
1195 TRUE
), /* pcrel_offset */
1197 HOWTO (R_ARM_LDRS_SB_G1
, /* type */
1199 2, /* size (0 = byte, 1 = short, 2 = long) */
1201 TRUE
, /* pc_relative */
1203 complain_overflow_dont
,/* complain_on_overflow */
1204 bfd_elf_generic_reloc
, /* special_function */
1205 "R_ARM_LDRS_SB_G1", /* name */
1206 FALSE
, /* partial_inplace */
1207 0xffffffff, /* src_mask */
1208 0xffffffff, /* dst_mask */
1209 TRUE
), /* pcrel_offset */
1211 HOWTO (R_ARM_LDRS_SB_G2
, /* type */
1213 2, /* size (0 = byte, 1 = short, 2 = long) */
1215 TRUE
, /* pc_relative */
1217 complain_overflow_dont
,/* complain_on_overflow */
1218 bfd_elf_generic_reloc
, /* special_function */
1219 "R_ARM_LDRS_SB_G2", /* name */
1220 FALSE
, /* partial_inplace */
1221 0xffffffff, /* src_mask */
1222 0xffffffff, /* dst_mask */
1223 TRUE
), /* pcrel_offset */
1225 HOWTO (R_ARM_LDC_SB_G0
, /* type */
1227 2, /* size (0 = byte, 1 = short, 2 = long) */
1229 TRUE
, /* pc_relative */
1231 complain_overflow_dont
,/* complain_on_overflow */
1232 bfd_elf_generic_reloc
, /* special_function */
1233 "R_ARM_LDC_SB_G0", /* name */
1234 FALSE
, /* partial_inplace */
1235 0xffffffff, /* src_mask */
1236 0xffffffff, /* dst_mask */
1237 TRUE
), /* pcrel_offset */
1239 HOWTO (R_ARM_LDC_SB_G1
, /* type */
1241 2, /* size (0 = byte, 1 = short, 2 = long) */
1243 TRUE
, /* pc_relative */
1245 complain_overflow_dont
,/* complain_on_overflow */
1246 bfd_elf_generic_reloc
, /* special_function */
1247 "R_ARM_LDC_SB_G1", /* name */
1248 FALSE
, /* partial_inplace */
1249 0xffffffff, /* src_mask */
1250 0xffffffff, /* dst_mask */
1251 TRUE
), /* pcrel_offset */
1253 HOWTO (R_ARM_LDC_SB_G2
, /* type */
1255 2, /* size (0 = byte, 1 = short, 2 = long) */
1257 TRUE
, /* pc_relative */
1259 complain_overflow_dont
,/* complain_on_overflow */
1260 bfd_elf_generic_reloc
, /* special_function */
1261 "R_ARM_LDC_SB_G2", /* name */
1262 FALSE
, /* partial_inplace */
1263 0xffffffff, /* src_mask */
1264 0xffffffff, /* dst_mask */
1265 TRUE
), /* pcrel_offset */
1267 /* End of group relocations. */
1269 HOWTO (R_ARM_MOVW_BREL_NC
, /* type */
1271 2, /* size (0 = byte, 1 = short, 2 = long) */
1273 FALSE
, /* pc_relative */
1275 complain_overflow_dont
,/* complain_on_overflow */
1276 bfd_elf_generic_reloc
, /* special_function */
1277 "R_ARM_MOVW_BREL_NC", /* name */
1278 FALSE
, /* partial_inplace */
1279 0x0000ffff, /* src_mask */
1280 0x0000ffff, /* dst_mask */
1281 FALSE
), /* pcrel_offset */
1283 HOWTO (R_ARM_MOVT_BREL
, /* type */
1285 2, /* size (0 = byte, 1 = short, 2 = long) */
1287 FALSE
, /* pc_relative */
1289 complain_overflow_bitfield
,/* complain_on_overflow */
1290 bfd_elf_generic_reloc
, /* special_function */
1291 "R_ARM_MOVT_BREL", /* name */
1292 FALSE
, /* partial_inplace */
1293 0x0000ffff, /* src_mask */
1294 0x0000ffff, /* dst_mask */
1295 FALSE
), /* pcrel_offset */
1297 HOWTO (R_ARM_MOVW_BREL
, /* type */
1299 2, /* size (0 = byte, 1 = short, 2 = long) */
1301 FALSE
, /* pc_relative */
1303 complain_overflow_dont
,/* complain_on_overflow */
1304 bfd_elf_generic_reloc
, /* special_function */
1305 "R_ARM_MOVW_BREL", /* name */
1306 FALSE
, /* partial_inplace */
1307 0x0000ffff, /* src_mask */
1308 0x0000ffff, /* dst_mask */
1309 FALSE
), /* pcrel_offset */
1311 HOWTO (R_ARM_THM_MOVW_BREL_NC
,/* type */
1313 2, /* size (0 = byte, 1 = short, 2 = long) */
1315 FALSE
, /* pc_relative */
1317 complain_overflow_dont
,/* complain_on_overflow */
1318 bfd_elf_generic_reloc
, /* special_function */
1319 "R_ARM_THM_MOVW_BREL_NC",/* name */
1320 FALSE
, /* partial_inplace */
1321 0x040f70ff, /* src_mask */
1322 0x040f70ff, /* dst_mask */
1323 FALSE
), /* pcrel_offset */
1325 HOWTO (R_ARM_THM_MOVT_BREL
, /* type */
1327 2, /* size (0 = byte, 1 = short, 2 = long) */
1329 FALSE
, /* pc_relative */
1331 complain_overflow_bitfield
,/* complain_on_overflow */
1332 bfd_elf_generic_reloc
, /* special_function */
1333 "R_ARM_THM_MOVT_BREL", /* name */
1334 FALSE
, /* partial_inplace */
1335 0x040f70ff, /* src_mask */
1336 0x040f70ff, /* dst_mask */
1337 FALSE
), /* pcrel_offset */
1339 HOWTO (R_ARM_THM_MOVW_BREL
, /* type */
1341 2, /* size (0 = byte, 1 = short, 2 = long) */
1343 FALSE
, /* pc_relative */
1345 complain_overflow_dont
,/* complain_on_overflow */
1346 bfd_elf_generic_reloc
, /* special_function */
1347 "R_ARM_THM_MOVW_BREL", /* name */
1348 FALSE
, /* partial_inplace */
1349 0x040f70ff, /* src_mask */
1350 0x040f70ff, /* dst_mask */
1351 FALSE
), /* pcrel_offset */
1353 EMPTY_HOWTO (90), /* unallocated */
1358 HOWTO (R_ARM_PLT32_ABS
, /* type */
1360 2, /* size (0 = byte, 1 = short, 2 = long) */
1362 FALSE
, /* pc_relative */
1364 complain_overflow_dont
,/* complain_on_overflow */
1365 bfd_elf_generic_reloc
, /* special_function */
1366 "R_ARM_PLT32_ABS", /* name */
1367 FALSE
, /* partial_inplace */
1368 0xffffffff, /* src_mask */
1369 0xffffffff, /* dst_mask */
1370 FALSE
), /* pcrel_offset */
1372 HOWTO (R_ARM_GOT_ABS
, /* type */
1374 2, /* size (0 = byte, 1 = short, 2 = long) */
1376 FALSE
, /* pc_relative */
1378 complain_overflow_dont
,/* complain_on_overflow */
1379 bfd_elf_generic_reloc
, /* special_function */
1380 "R_ARM_GOT_ABS", /* name */
1381 FALSE
, /* partial_inplace */
1382 0xffffffff, /* src_mask */
1383 0xffffffff, /* dst_mask */
1384 FALSE
), /* pcrel_offset */
1386 HOWTO (R_ARM_GOT_PREL
, /* type */
1388 2, /* size (0 = byte, 1 = short, 2 = long) */
1390 TRUE
, /* pc_relative */
1392 complain_overflow_dont
, /* complain_on_overflow */
1393 bfd_elf_generic_reloc
, /* special_function */
1394 "R_ARM_GOT_PREL", /* name */
1395 FALSE
, /* partial_inplace */
1396 0xffffffff, /* src_mask */
1397 0xffffffff, /* dst_mask */
1398 TRUE
), /* pcrel_offset */
1400 HOWTO (R_ARM_GOT_BREL12
, /* type */
1402 2, /* size (0 = byte, 1 = short, 2 = long) */
1404 FALSE
, /* pc_relative */
1406 complain_overflow_bitfield
,/* complain_on_overflow */
1407 bfd_elf_generic_reloc
, /* special_function */
1408 "R_ARM_GOT_BREL12", /* name */
1409 FALSE
, /* partial_inplace */
1410 0x00000fff, /* src_mask */
1411 0x00000fff, /* dst_mask */
1412 FALSE
), /* pcrel_offset */
1414 HOWTO (R_ARM_GOTOFF12
, /* type */
1416 2, /* size (0 = byte, 1 = short, 2 = long) */
1418 FALSE
, /* pc_relative */
1420 complain_overflow_bitfield
,/* complain_on_overflow */
1421 bfd_elf_generic_reloc
, /* special_function */
1422 "R_ARM_GOTOFF12", /* name */
1423 FALSE
, /* partial_inplace */
1424 0x00000fff, /* src_mask */
1425 0x00000fff, /* dst_mask */
1426 FALSE
), /* pcrel_offset */
1428 EMPTY_HOWTO (R_ARM_GOTRELAX
), /* reserved for future GOT-load optimizations */
1430 /* GNU extension to record C++ vtable member usage */
1431 HOWTO (R_ARM_GNU_VTENTRY
, /* type */
1433 2, /* size (0 = byte, 1 = short, 2 = long) */
1435 FALSE
, /* pc_relative */
1437 complain_overflow_dont
, /* complain_on_overflow */
1438 _bfd_elf_rel_vtable_reloc_fn
, /* special_function */
1439 "R_ARM_GNU_VTENTRY", /* name */
1440 FALSE
, /* partial_inplace */
1443 FALSE
), /* pcrel_offset */
1445 /* GNU extension to record C++ vtable hierarchy */
1446 HOWTO (R_ARM_GNU_VTINHERIT
, /* type */
1448 2, /* size (0 = byte, 1 = short, 2 = long) */
1450 FALSE
, /* pc_relative */
1452 complain_overflow_dont
, /* complain_on_overflow */
1453 NULL
, /* special_function */
1454 "R_ARM_GNU_VTINHERIT", /* name */
1455 FALSE
, /* partial_inplace */
1458 FALSE
), /* pcrel_offset */
1460 HOWTO (R_ARM_THM_JUMP11
, /* type */
1462 1, /* size (0 = byte, 1 = short, 2 = long) */
1464 TRUE
, /* pc_relative */
1466 complain_overflow_signed
, /* complain_on_overflow */
1467 bfd_elf_generic_reloc
, /* special_function */
1468 "R_ARM_THM_JUMP11", /* name */
1469 FALSE
, /* partial_inplace */
1470 0x000007ff, /* src_mask */
1471 0x000007ff, /* dst_mask */
1472 TRUE
), /* pcrel_offset */
1474 HOWTO (R_ARM_THM_JUMP8
, /* type */
1476 1, /* size (0 = byte, 1 = short, 2 = long) */
1478 TRUE
, /* pc_relative */
1480 complain_overflow_signed
, /* complain_on_overflow */
1481 bfd_elf_generic_reloc
, /* special_function */
1482 "R_ARM_THM_JUMP8", /* name */
1483 FALSE
, /* partial_inplace */
1484 0x000000ff, /* src_mask */
1485 0x000000ff, /* dst_mask */
1486 TRUE
), /* pcrel_offset */
1488 /* TLS relocations */
1489 HOWTO (R_ARM_TLS_GD32
, /* type */
1491 2, /* size (0 = byte, 1 = short, 2 = long) */
1493 FALSE
, /* pc_relative */
1495 complain_overflow_bitfield
,/* complain_on_overflow */
1496 NULL
, /* special_function */
1497 "R_ARM_TLS_GD32", /* name */
1498 TRUE
, /* partial_inplace */
1499 0xffffffff, /* src_mask */
1500 0xffffffff, /* dst_mask */
1501 FALSE
), /* pcrel_offset */
1503 HOWTO (R_ARM_TLS_LDM32
, /* type */
1505 2, /* size (0 = byte, 1 = short, 2 = long) */
1507 FALSE
, /* pc_relative */
1509 complain_overflow_bitfield
,/* complain_on_overflow */
1510 bfd_elf_generic_reloc
, /* special_function */
1511 "R_ARM_TLS_LDM32", /* name */
1512 TRUE
, /* partial_inplace */
1513 0xffffffff, /* src_mask */
1514 0xffffffff, /* dst_mask */
1515 FALSE
), /* pcrel_offset */
1517 HOWTO (R_ARM_TLS_LDO32
, /* type */
1519 2, /* size (0 = byte, 1 = short, 2 = long) */
1521 FALSE
, /* pc_relative */
1523 complain_overflow_bitfield
,/* complain_on_overflow */
1524 bfd_elf_generic_reloc
, /* special_function */
1525 "R_ARM_TLS_LDO32", /* name */
1526 TRUE
, /* partial_inplace */
1527 0xffffffff, /* src_mask */
1528 0xffffffff, /* dst_mask */
1529 FALSE
), /* pcrel_offset */
1531 HOWTO (R_ARM_TLS_IE32
, /* type */
1533 2, /* size (0 = byte, 1 = short, 2 = long) */
1535 FALSE
, /* pc_relative */
1537 complain_overflow_bitfield
,/* complain_on_overflow */
1538 NULL
, /* special_function */
1539 "R_ARM_TLS_IE32", /* name */
1540 TRUE
, /* partial_inplace */
1541 0xffffffff, /* src_mask */
1542 0xffffffff, /* dst_mask */
1543 FALSE
), /* pcrel_offset */
1545 HOWTO (R_ARM_TLS_LE32
, /* type */
1547 2, /* size (0 = byte, 1 = short, 2 = long) */
1549 FALSE
, /* pc_relative */
1551 complain_overflow_bitfield
,/* complain_on_overflow */
1552 bfd_elf_generic_reloc
, /* special_function */
1553 "R_ARM_TLS_LE32", /* name */
1554 TRUE
, /* partial_inplace */
1555 0xffffffff, /* src_mask */
1556 0xffffffff, /* dst_mask */
1557 FALSE
), /* pcrel_offset */
1559 HOWTO (R_ARM_TLS_LDO12
, /* type */
1561 2, /* size (0 = byte, 1 = short, 2 = long) */
1563 FALSE
, /* pc_relative */
1565 complain_overflow_bitfield
,/* complain_on_overflow */
1566 bfd_elf_generic_reloc
, /* special_function */
1567 "R_ARM_TLS_LDO12", /* name */
1568 FALSE
, /* partial_inplace */
1569 0x00000fff, /* src_mask */
1570 0x00000fff, /* dst_mask */
1571 FALSE
), /* pcrel_offset */
1573 HOWTO (R_ARM_TLS_LE12
, /* type */
1575 2, /* size (0 = byte, 1 = short, 2 = long) */
1577 FALSE
, /* pc_relative */
1579 complain_overflow_bitfield
,/* complain_on_overflow */
1580 bfd_elf_generic_reloc
, /* special_function */
1581 "R_ARM_TLS_LE12", /* name */
1582 FALSE
, /* partial_inplace */
1583 0x00000fff, /* src_mask */
1584 0x00000fff, /* dst_mask */
1585 FALSE
), /* pcrel_offset */
1587 HOWTO (R_ARM_TLS_IE12GP
, /* type */
1589 2, /* size (0 = byte, 1 = short, 2 = long) */
1591 FALSE
, /* pc_relative */
1593 complain_overflow_bitfield
,/* complain_on_overflow */
1594 bfd_elf_generic_reloc
, /* special_function */
1595 "R_ARM_TLS_IE12GP", /* name */
1596 FALSE
, /* partial_inplace */
1597 0x00000fff, /* src_mask */
1598 0x00000fff, /* dst_mask */
1599 FALSE
), /* pcrel_offset */
1602 /* 112-127 private relocations
1603 128 R_ARM_ME_TOO, obsolete
1604 129-255 unallocated in AAELF.
1606 249-255 extended, currently unused, relocations: */
1608 static reloc_howto_type elf32_arm_howto_table_2
[4] =
1610 HOWTO (R_ARM_RREL32
, /* type */
1612 0, /* size (0 = byte, 1 = short, 2 = long) */
1614 FALSE
, /* pc_relative */
1616 complain_overflow_dont
,/* complain_on_overflow */
1617 bfd_elf_generic_reloc
, /* special_function */
1618 "R_ARM_RREL32", /* name */
1619 FALSE
, /* partial_inplace */
1622 FALSE
), /* pcrel_offset */
1624 HOWTO (R_ARM_RABS32
, /* type */
1626 0, /* size (0 = byte, 1 = short, 2 = long) */
1628 FALSE
, /* pc_relative */
1630 complain_overflow_dont
,/* complain_on_overflow */
1631 bfd_elf_generic_reloc
, /* special_function */
1632 "R_ARM_RABS32", /* name */
1633 FALSE
, /* partial_inplace */
1636 FALSE
), /* pcrel_offset */
1638 HOWTO (R_ARM_RPC24
, /* type */
1640 0, /* size (0 = byte, 1 = short, 2 = long) */
1642 FALSE
, /* pc_relative */
1644 complain_overflow_dont
,/* complain_on_overflow */
1645 bfd_elf_generic_reloc
, /* special_function */
1646 "R_ARM_RPC24", /* name */
1647 FALSE
, /* partial_inplace */
1650 FALSE
), /* pcrel_offset */
1652 HOWTO (R_ARM_RBASE
, /* type */
1654 0, /* size (0 = byte, 1 = short, 2 = long) */
1656 FALSE
, /* pc_relative */
1658 complain_overflow_dont
,/* complain_on_overflow */
1659 bfd_elf_generic_reloc
, /* special_function */
1660 "R_ARM_RBASE", /* name */
1661 FALSE
, /* partial_inplace */
1664 FALSE
) /* pcrel_offset */
1667 static reloc_howto_type
*
1668 elf32_arm_howto_from_type (unsigned int r_type
)
1670 if (r_type
< NUM_ELEM (elf32_arm_howto_table_1
))
1671 return &elf32_arm_howto_table_1
[r_type
];
1673 if (r_type
>= R_ARM_RREL32
1674 && r_type
< R_ARM_RREL32
+ NUM_ELEM (elf32_arm_howto_table_2
))
1675 return &elf32_arm_howto_table_2
[r_type
- R_ARM_RREL32
];
1681 elf32_arm_info_to_howto (bfd
* abfd ATTRIBUTE_UNUSED
, arelent
* bfd_reloc
,
1682 Elf_Internal_Rela
* elf_reloc
)
1684 unsigned int r_type
;
1686 r_type
= ELF32_R_TYPE (elf_reloc
->r_info
);
1687 bfd_reloc
->howto
= elf32_arm_howto_from_type (r_type
);
1690 struct elf32_arm_reloc_map
1692 bfd_reloc_code_real_type bfd_reloc_val
;
1693 unsigned char elf_reloc_val
;
1696 /* All entries in this list must also be present in elf32_arm_howto_table. */
1697 static const struct elf32_arm_reloc_map elf32_arm_reloc_map
[] =
1699 {BFD_RELOC_NONE
, R_ARM_NONE
},
1700 {BFD_RELOC_ARM_PCREL_BRANCH
, R_ARM_PC24
},
1701 {BFD_RELOC_ARM_PCREL_CALL
, R_ARM_CALL
},
1702 {BFD_RELOC_ARM_PCREL_JUMP
, R_ARM_JUMP24
},
1703 {BFD_RELOC_ARM_PCREL_BLX
, R_ARM_XPC25
},
1704 {BFD_RELOC_THUMB_PCREL_BLX
, R_ARM_THM_XPC22
},
1705 {BFD_RELOC_32
, R_ARM_ABS32
},
1706 {BFD_RELOC_32_PCREL
, R_ARM_REL32
},
1707 {BFD_RELOC_8
, R_ARM_ABS8
},
1708 {BFD_RELOC_16
, R_ARM_ABS16
},
1709 {BFD_RELOC_ARM_OFFSET_IMM
, R_ARM_ABS12
},
1710 {BFD_RELOC_ARM_THUMB_OFFSET
, R_ARM_THM_ABS5
},
1711 {BFD_RELOC_THUMB_PCREL_BRANCH25
, R_ARM_THM_JUMP24
},
1712 {BFD_RELOC_THUMB_PCREL_BRANCH23
, R_ARM_THM_CALL
},
1713 {BFD_RELOC_THUMB_PCREL_BRANCH12
, R_ARM_THM_JUMP11
},
1714 {BFD_RELOC_THUMB_PCREL_BRANCH20
, R_ARM_THM_JUMP19
},
1715 {BFD_RELOC_THUMB_PCREL_BRANCH9
, R_ARM_THM_JUMP8
},
1716 {BFD_RELOC_THUMB_PCREL_BRANCH7
, R_ARM_THM_JUMP6
},
1717 {BFD_RELOC_ARM_GLOB_DAT
, R_ARM_GLOB_DAT
},
1718 {BFD_RELOC_ARM_JUMP_SLOT
, R_ARM_JUMP_SLOT
},
1719 {BFD_RELOC_ARM_RELATIVE
, R_ARM_RELATIVE
},
1720 {BFD_RELOC_ARM_GOTOFF
, R_ARM_GOTOFF32
},
1721 {BFD_RELOC_ARM_GOTPC
, R_ARM_GOTPC
},
1722 {BFD_RELOC_ARM_GOT32
, R_ARM_GOT32
},
1723 {BFD_RELOC_ARM_PLT32
, R_ARM_PLT32
},
1724 {BFD_RELOC_ARM_TARGET1
, R_ARM_TARGET1
},
1725 {BFD_RELOC_ARM_ROSEGREL32
, R_ARM_ROSEGREL32
},
1726 {BFD_RELOC_ARM_SBREL32
, R_ARM_SBREL32
},
1727 {BFD_RELOC_ARM_PREL31
, R_ARM_PREL31
},
1728 {BFD_RELOC_ARM_TARGET2
, R_ARM_TARGET2
},
1729 {BFD_RELOC_ARM_PLT32
, R_ARM_PLT32
},
1730 {BFD_RELOC_ARM_TLS_GD32
, R_ARM_TLS_GD32
},
1731 {BFD_RELOC_ARM_TLS_LDO32
, R_ARM_TLS_LDO32
},
1732 {BFD_RELOC_ARM_TLS_LDM32
, R_ARM_TLS_LDM32
},
1733 {BFD_RELOC_ARM_TLS_DTPMOD32
, R_ARM_TLS_DTPMOD32
},
1734 {BFD_RELOC_ARM_TLS_DTPOFF32
, R_ARM_TLS_DTPOFF32
},
1735 {BFD_RELOC_ARM_TLS_TPOFF32
, R_ARM_TLS_TPOFF32
},
1736 {BFD_RELOC_ARM_TLS_IE32
, R_ARM_TLS_IE32
},
1737 {BFD_RELOC_ARM_TLS_LE32
, R_ARM_TLS_LE32
},
1738 {BFD_RELOC_VTABLE_INHERIT
, R_ARM_GNU_VTINHERIT
},
1739 {BFD_RELOC_VTABLE_ENTRY
, R_ARM_GNU_VTENTRY
},
1740 {BFD_RELOC_ARM_MOVW
, R_ARM_MOVW_ABS_NC
},
1741 {BFD_RELOC_ARM_MOVT
, R_ARM_MOVT_ABS
},
1742 {BFD_RELOC_ARM_MOVW_PCREL
, R_ARM_MOVW_PREL_NC
},
1743 {BFD_RELOC_ARM_MOVT_PCREL
, R_ARM_MOVT_PREL
},
1744 {BFD_RELOC_ARM_THUMB_MOVW
, R_ARM_THM_MOVW_ABS_NC
},
1745 {BFD_RELOC_ARM_THUMB_MOVT
, R_ARM_THM_MOVT_ABS
},
1746 {BFD_RELOC_ARM_THUMB_MOVW_PCREL
, R_ARM_THM_MOVW_PREL_NC
},
1747 {BFD_RELOC_ARM_THUMB_MOVT_PCREL
, R_ARM_THM_MOVT_PREL
},
1748 {BFD_RELOC_ARM_ALU_PC_G0_NC
, R_ARM_ALU_PC_G0_NC
},
1749 {BFD_RELOC_ARM_ALU_PC_G0
, R_ARM_ALU_PC_G0
},
1750 {BFD_RELOC_ARM_ALU_PC_G1_NC
, R_ARM_ALU_PC_G1_NC
},
1751 {BFD_RELOC_ARM_ALU_PC_G1
, R_ARM_ALU_PC_G1
},
1752 {BFD_RELOC_ARM_ALU_PC_G2
, R_ARM_ALU_PC_G2
},
1753 {BFD_RELOC_ARM_LDR_PC_G0
, R_ARM_LDR_PC_G0
},
1754 {BFD_RELOC_ARM_LDR_PC_G1
, R_ARM_LDR_PC_G1
},
1755 {BFD_RELOC_ARM_LDR_PC_G2
, R_ARM_LDR_PC_G2
},
1756 {BFD_RELOC_ARM_LDRS_PC_G0
, R_ARM_LDRS_PC_G0
},
1757 {BFD_RELOC_ARM_LDRS_PC_G1
, R_ARM_LDRS_PC_G1
},
1758 {BFD_RELOC_ARM_LDRS_PC_G2
, R_ARM_LDRS_PC_G2
},
1759 {BFD_RELOC_ARM_LDC_PC_G0
, R_ARM_LDC_PC_G0
},
1760 {BFD_RELOC_ARM_LDC_PC_G1
, R_ARM_LDC_PC_G1
},
1761 {BFD_RELOC_ARM_LDC_PC_G2
, R_ARM_LDC_PC_G2
},
1762 {BFD_RELOC_ARM_ALU_SB_G0_NC
, R_ARM_ALU_SB_G0_NC
},
1763 {BFD_RELOC_ARM_ALU_SB_G0
, R_ARM_ALU_SB_G0
},
1764 {BFD_RELOC_ARM_ALU_SB_G1_NC
, R_ARM_ALU_SB_G1_NC
},
1765 {BFD_RELOC_ARM_ALU_SB_G1
, R_ARM_ALU_SB_G1
},
1766 {BFD_RELOC_ARM_ALU_SB_G2
, R_ARM_ALU_SB_G2
},
1767 {BFD_RELOC_ARM_LDR_SB_G0
, R_ARM_LDR_SB_G0
},
1768 {BFD_RELOC_ARM_LDR_SB_G1
, R_ARM_LDR_SB_G1
},
1769 {BFD_RELOC_ARM_LDR_SB_G2
, R_ARM_LDR_SB_G2
},
1770 {BFD_RELOC_ARM_LDRS_SB_G0
, R_ARM_LDRS_SB_G0
},
1771 {BFD_RELOC_ARM_LDRS_SB_G1
, R_ARM_LDRS_SB_G1
},
1772 {BFD_RELOC_ARM_LDRS_SB_G2
, R_ARM_LDRS_SB_G2
},
1773 {BFD_RELOC_ARM_LDC_SB_G0
, R_ARM_LDC_SB_G0
},
1774 {BFD_RELOC_ARM_LDC_SB_G1
, R_ARM_LDC_SB_G1
},
1775 {BFD_RELOC_ARM_LDC_SB_G2
, R_ARM_LDC_SB_G2
}
1778 static reloc_howto_type
*
1779 elf32_arm_reloc_type_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
1780 bfd_reloc_code_real_type code
)
1783 for (i
= 0; i
< NUM_ELEM (elf32_arm_reloc_map
); i
++)
1784 if (elf32_arm_reloc_map
[i
].bfd_reloc_val
== code
)
1785 return elf32_arm_howto_from_type (elf32_arm_reloc_map
[i
].elf_reloc_val
);
1790 /* Support for core dump NOTE sections */
1792 elf32_arm_nabi_grok_prstatus (bfd
*abfd
, Elf_Internal_Note
*note
)
1797 switch (note
->descsz
)
1802 case 148: /* Linux/ARM 32-bit*/
1804 elf_tdata (abfd
)->core_signal
= bfd_get_16 (abfd
, note
->descdata
+ 12);
1807 elf_tdata (abfd
)->core_pid
= bfd_get_32 (abfd
, note
->descdata
+ 24);
1816 /* Make a ".reg/999" section. */
1817 return _bfd_elfcore_make_pseudosection (abfd
, ".reg",
1818 size
, note
->descpos
+ offset
);
1822 elf32_arm_nabi_grok_psinfo (bfd
*abfd
, Elf_Internal_Note
*note
)
1824 switch (note
->descsz
)
1829 case 124: /* Linux/ARM elf_prpsinfo */
1830 elf_tdata (abfd
)->core_program
1831 = _bfd_elfcore_strndup (abfd
, note
->descdata
+ 28, 16);
1832 elf_tdata (abfd
)->core_command
1833 = _bfd_elfcore_strndup (abfd
, note
->descdata
+ 44, 80);
1836 /* Note that for some reason, a spurious space is tacked
1837 onto the end of the args in some (at least one anyway)
1838 implementations, so strip it off if it exists. */
1841 char *command
= elf_tdata (abfd
)->core_command
;
1842 int n
= strlen (command
);
1844 if (0 < n
&& command
[n
- 1] == ' ')
1845 command
[n
- 1] = '\0';
1851 #define TARGET_LITTLE_SYM bfd_elf32_littlearm_vec
1852 #define TARGET_LITTLE_NAME "elf32-littlearm"
1853 #define TARGET_BIG_SYM bfd_elf32_bigarm_vec
1854 #define TARGET_BIG_NAME "elf32-bigarm"
1856 #define elf_backend_grok_prstatus elf32_arm_nabi_grok_prstatus
1857 #define elf_backend_grok_psinfo elf32_arm_nabi_grok_psinfo
1859 typedef unsigned long int insn32
;
1860 typedef unsigned short int insn16
;
1862 /* In lieu of proper flags, assume all EABIv4 or later objects are
1864 #define INTERWORK_FLAG(abfd) \
1865 (EF_ARM_EABI_VERSION (elf_elfheader (abfd)->e_flags) >= EF_ARM_EABI_VER4 \
1866 || (elf_elfheader (abfd)->e_flags & EF_ARM_INTERWORK))
1868 /* The linker script knows the section names for placement.
1869 The entry_names are used to do simple name mangling on the stubs.
1870 Given a function name, and its type, the stub can be found. The
1871 name can be changed. The only requirement is the %s be present. */
1872 #define THUMB2ARM_GLUE_SECTION_NAME ".glue_7t"
1873 #define THUMB2ARM_GLUE_ENTRY_NAME "__%s_from_thumb"
1875 #define ARM2THUMB_GLUE_SECTION_NAME ".glue_7"
1876 #define ARM2THUMB_GLUE_ENTRY_NAME "__%s_from_arm"
1878 #define VFP11_ERRATUM_VENEER_SECTION_NAME ".vfp11_veneer"
1879 #define VFP11_ERRATUM_VENEER_ENTRY_NAME "__vfp11_veneer_%x"
1881 /* The name of the dynamic interpreter. This is put in the .interp
1883 #define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1"
1885 #ifdef FOUR_WORD_PLT
1887 /* The first entry in a procedure linkage table looks like
1888 this. It is set up so that any shared library function that is
1889 called before the relocation has been set up calls the dynamic
1891 static const bfd_vma elf32_arm_plt0_entry
[] =
1893 0xe52de004, /* str lr, [sp, #-4]! */
1894 0xe59fe010, /* ldr lr, [pc, #16] */
1895 0xe08fe00e, /* add lr, pc, lr */
1896 0xe5bef008, /* ldr pc, [lr, #8]! */
1899 /* Subsequent entries in a procedure linkage table look like
1901 static const bfd_vma elf32_arm_plt_entry
[] =
1903 0xe28fc600, /* add ip, pc, #NN */
1904 0xe28cca00, /* add ip, ip, #NN */
1905 0xe5bcf000, /* ldr pc, [ip, #NN]! */
1906 0x00000000, /* unused */
1911 /* The first entry in a procedure linkage table looks like
1912 this. It is set up so that any shared library function that is
1913 called before the relocation has been set up calls the dynamic
1915 static const bfd_vma elf32_arm_plt0_entry
[] =
1917 0xe52de004, /* str lr, [sp, #-4]! */
1918 0xe59fe004, /* ldr lr, [pc, #4] */
1919 0xe08fe00e, /* add lr, pc, lr */
1920 0xe5bef008, /* ldr pc, [lr, #8]! */
1921 0x00000000, /* &GOT[0] - . */
1924 /* Subsequent entries in a procedure linkage table look like
1926 static const bfd_vma elf32_arm_plt_entry
[] =
1928 0xe28fc600, /* add ip, pc, #0xNN00000 */
1929 0xe28cca00, /* add ip, ip, #0xNN000 */
1930 0xe5bcf000, /* ldr pc, [ip, #0xNNN]! */
1935 /* The format of the first entry in the procedure linkage table
1936 for a VxWorks executable. */
1937 static const bfd_vma elf32_arm_vxworks_exec_plt0_entry
[] =
1939 0xe52dc008, /* str ip,[sp,#-8]! */
1940 0xe59fc000, /* ldr ip,[pc] */
1941 0xe59cf008, /* ldr pc,[ip,#8] */
1942 0x00000000, /* .long _GLOBAL_OFFSET_TABLE_ */
1945 /* The format of subsequent entries in a VxWorks executable. */
1946 static const bfd_vma elf32_arm_vxworks_exec_plt_entry
[] =
1948 0xe59fc000, /* ldr ip,[pc] */
1949 0xe59cf000, /* ldr pc,[ip] */
1950 0x00000000, /* .long @got */
1951 0xe59fc000, /* ldr ip,[pc] */
1952 0xea000000, /* b _PLT */
1953 0x00000000, /* .long @pltindex*sizeof(Elf32_Rela) */
1956 /* The format of entries in a VxWorks shared library. */
1957 static const bfd_vma elf32_arm_vxworks_shared_plt_entry
[] =
1959 0xe59fc000, /* ldr ip,[pc] */
1960 0xe79cf009, /* ldr pc,[ip,r9] */
1961 0x00000000, /* .long @got */
1962 0xe59fc000, /* ldr ip,[pc] */
1963 0xe599f008, /* ldr pc,[r9,#8] */
1964 0x00000000, /* .long @pltindex*sizeof(Elf32_Rela) */
1967 /* An initial stub used if the PLT entry is referenced from Thumb code. */
1968 #define PLT_THUMB_STUB_SIZE 4
1969 static const bfd_vma elf32_arm_plt_thumb_stub
[] =
1975 /* The entries in a PLT when using a DLL-based target with multiple
1977 static const bfd_vma elf32_arm_symbian_plt_entry
[] =
1979 0xe51ff004, /* ldr pc, [pc, #-4] */
1980 0x00000000, /* dcd R_ARM_GLOB_DAT(X) */
1983 /* Used to build a map of a section. This is required for mixed-endian
1986 typedef struct elf32_elf_section_map
1991 elf32_arm_section_map
;
1993 /* Information about a VFP11 erratum veneer, or a branch to such a veneer. */
1997 VFP11_ERRATUM_BRANCH_TO_ARM_VENEER
,
1998 VFP11_ERRATUM_BRANCH_TO_THUMB_VENEER
,
1999 VFP11_ERRATUM_ARM_VENEER
,
2000 VFP11_ERRATUM_THUMB_VENEER
2002 elf32_vfp11_erratum_type
;
2004 typedef struct elf32_vfp11_erratum_list
2006 struct elf32_vfp11_erratum_list
*next
;
2012 struct elf32_vfp11_erratum_list
*veneer
;
2013 unsigned int vfp_insn
;
2017 struct elf32_vfp11_erratum_list
*branch
;
2021 elf32_vfp11_erratum_type type
;
2023 elf32_vfp11_erratum_list
;
2025 typedef struct _arm_elf_section_data
2027 struct bfd_elf_section_data elf
;
2028 unsigned int mapcount
;
2029 unsigned int mapsize
;
2030 elf32_arm_section_map
*map
;
2031 unsigned int erratumcount
;
2032 elf32_vfp11_erratum_list
*erratumlist
;
2034 _arm_elf_section_data
;
2036 #define elf32_arm_section_data(sec) \
2037 ((_arm_elf_section_data *) elf_section_data (sec))
2039 /* The size of the thread control block. */
2042 #define NUM_KNOWN_ATTRIBUTES 32
2044 typedef struct aeabi_attribute
2051 typedef struct aeabi_attribute_list
2053 struct aeabi_attribute_list
*next
;
2055 aeabi_attribute attr
;
2056 } aeabi_attribute_list
;
2058 struct elf32_arm_obj_tdata
2060 struct elf_obj_tdata root
;
2062 /* tls_type for each local got entry. */
2063 char *local_got_tls_type
;
2065 aeabi_attribute known_eabi_attributes
[NUM_KNOWN_ATTRIBUTES
];
2066 aeabi_attribute_list
*other_eabi_attributes
;
2069 #define elf32_arm_tdata(abfd) \
2070 ((struct elf32_arm_obj_tdata *) (abfd)->tdata.any)
2072 #define elf32_arm_local_got_tls_type(abfd) \
2073 (elf32_arm_tdata (abfd)->local_got_tls_type)
2076 elf32_arm_mkobject (bfd
*abfd
)
2078 if (abfd
->tdata
.any
== NULL
)
2080 bfd_size_type amt
= sizeof (struct elf32_arm_obj_tdata
);
2081 abfd
->tdata
.any
= bfd_zalloc (abfd
, amt
);
2082 if (abfd
->tdata
.any
== NULL
)
2085 return bfd_elf_mkobject (abfd
);
2088 /* The ARM linker needs to keep track of the number of relocs that it
2089 decides to copy in check_relocs for each symbol. This is so that
2090 it can discard PC relative relocs if it doesn't need them when
2091 linking with -Bsymbolic. We store the information in a field
2092 extending the regular ELF linker hash table. */
2094 /* This structure keeps track of the number of relocs we have copied
2095 for a given symbol. */
2096 struct elf32_arm_relocs_copied
2099 struct elf32_arm_relocs_copied
* next
;
2100 /* A section in dynobj. */
2102 /* Number of relocs copied in this section. */
2103 bfd_size_type count
;
2104 /* Number of PC-relative relocs copied in this section. */
2105 bfd_size_type pc_count
;
2108 #define elf32_arm_hash_entry(ent) ((struct elf32_arm_link_hash_entry *)(ent))
2110 /* Arm ELF linker hash entry. */
2111 struct elf32_arm_link_hash_entry
2113 struct elf_link_hash_entry root
;
2115 /* Number of PC relative relocs copied for this symbol. */
2116 struct elf32_arm_relocs_copied
* relocs_copied
;
2118 /* We reference count Thumb references to a PLT entry separately,
2119 so that we can emit the Thumb trampoline only if needed. */
2120 bfd_signed_vma plt_thumb_refcount
;
2122 /* Since PLT entries have variable size if the Thumb prologue is
2123 used, we need to record the index into .got.plt instead of
2124 recomputing it from the PLT offset. */
2125 bfd_signed_vma plt_got_offset
;
2127 #define GOT_UNKNOWN 0
2128 #define GOT_NORMAL 1
2129 #define GOT_TLS_GD 2
2130 #define GOT_TLS_IE 4
2131 unsigned char tls_type
;
2133 /* The symbol marking the real symbol location for exported thumb
2134 symbols with Arm stubs. */
2135 struct elf_link_hash_entry
*export_glue
;
2138 /* Traverse an arm ELF linker hash table. */
2139 #define elf32_arm_link_hash_traverse(table, func, info) \
2140 (elf_link_hash_traverse \
2142 (bfd_boolean (*) (struct elf_link_hash_entry *, void *)) (func), \
2145 /* Get the ARM elf linker hash table from a link_info structure. */
2146 #define elf32_arm_hash_table(info) \
2147 ((struct elf32_arm_link_hash_table *) ((info)->hash))
2149 /* ARM ELF linker hash table. */
2150 struct elf32_arm_link_hash_table
2152 /* The main hash table. */
2153 struct elf_link_hash_table root
;
2155 /* The size in bytes of the section containing the Thumb-to-ARM glue. */
2156 bfd_size_type thumb_glue_size
;
2158 /* The size in bytes of the section containing the ARM-to-Thumb glue. */
2159 bfd_size_type arm_glue_size
;
2161 /* The size in bytes of the section containing glue for VFP11 erratum
2163 bfd_size_type vfp11_erratum_glue_size
;
2165 /* An arbitrary input BFD chosen to hold the glue sections. */
2166 bfd
* bfd_of_glue_owner
;
2168 /* Nonzero to output a BE8 image. */
2171 /* Zero if R_ARM_TARGET1 means R_ARM_ABS32.
2172 Nonzero if R_ARM_TARGET1 means R_ARM_REL32. */
2175 /* The relocation to use for R_ARM_TARGET2 relocations. */
2178 /* Nonzero to fix BX instructions for ARMv4 targets. */
2181 /* Nonzero if the ARM/Thumb BLX instructions are available for use. */
2184 /* What sort of code sequences we should look for which may trigger the
2185 VFP11 denorm erratum. */
2186 bfd_arm_vfp11_fix vfp11_fix
;
2188 /* Global counter for the number of fixes we have emitted. */
2189 int num_vfp11_fixes
;
2191 /* The number of bytes in the initial entry in the PLT. */
2192 bfd_size_type plt_header_size
;
2194 /* The number of bytes in the subsequent PLT etries. */
2195 bfd_size_type plt_entry_size
;
2197 /* True if the target system is VxWorks. */
2200 /* True if the target system is Symbian OS. */
2203 /* True if the target uses REL relocations. */
2206 /* Short-cuts to get to dynamic linker sections. */
2215 /* The (unloaded but important) VxWorks .rela.plt.unloaded section. */
2218 /* Data for R_ARM_TLS_LDM32 relocations. */
2220 bfd_signed_vma refcount
;
2224 /* Small local sym to section mapping cache. */
2225 struct sym_sec_cache sym_sec
;
2227 /* For convenience in allocate_dynrelocs. */
2231 /* Create an entry in an ARM ELF linker hash table. */
2233 static struct bfd_hash_entry
*
2234 elf32_arm_link_hash_newfunc (struct bfd_hash_entry
* entry
,
2235 struct bfd_hash_table
* table
,
2236 const char * string
)
2238 struct elf32_arm_link_hash_entry
* ret
=
2239 (struct elf32_arm_link_hash_entry
*) entry
;
2241 /* Allocate the structure if it has not already been allocated by a
2243 if (ret
== (struct elf32_arm_link_hash_entry
*) NULL
)
2244 ret
= bfd_hash_allocate (table
, sizeof (struct elf32_arm_link_hash_entry
));
2246 return (struct bfd_hash_entry
*) ret
;
2248 /* Call the allocation method of the superclass. */
2249 ret
= ((struct elf32_arm_link_hash_entry
*)
2250 _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry
*) ret
,
2254 ret
->relocs_copied
= NULL
;
2255 ret
->tls_type
= GOT_UNKNOWN
;
2256 ret
->plt_thumb_refcount
= 0;
2257 ret
->plt_got_offset
= -1;
2258 ret
->export_glue
= NULL
;
2261 return (struct bfd_hash_entry
*) ret
;
2264 /* Return true if NAME is the name of the relocation section associated
2268 reloc_section_p (struct elf32_arm_link_hash_table
*htab
,
2269 const char *name
, asection
*s
)
2272 return CONST_STRNEQ (name
, ".rel") && strcmp (s
->name
, name
+ 4) == 0;
2274 return CONST_STRNEQ (name
, ".rela") && strcmp (s
->name
, name
+ 5) == 0;
2277 /* Create .got, .gotplt, and .rel(a).got sections in DYNOBJ, and set up
2278 shortcuts to them in our hash table. */
2281 create_got_section (bfd
*dynobj
, struct bfd_link_info
*info
)
2283 struct elf32_arm_link_hash_table
*htab
;
2285 htab
= elf32_arm_hash_table (info
);
2286 /* BPABI objects never have a GOT, or associated sections. */
2287 if (htab
->symbian_p
)
2290 if (! _bfd_elf_create_got_section (dynobj
, info
))
2293 htab
->sgot
= bfd_get_section_by_name (dynobj
, ".got");
2294 htab
->sgotplt
= bfd_get_section_by_name (dynobj
, ".got.plt");
2295 if (!htab
->sgot
|| !htab
->sgotplt
)
2298 htab
->srelgot
= bfd_make_section_with_flags (dynobj
,
2299 RELOC_SECTION (htab
, ".got"),
2300 (SEC_ALLOC
| SEC_LOAD
2303 | SEC_LINKER_CREATED
2305 if (htab
->srelgot
== NULL
2306 || ! bfd_set_section_alignment (dynobj
, htab
->srelgot
, 2))
2311 /* Create .plt, .rel(a).plt, .got, .got.plt, .rel(a).got, .dynbss, and
2312 .rel(a).bss sections in DYNOBJ, and set up shortcuts to them in our
2316 elf32_arm_create_dynamic_sections (bfd
*dynobj
, struct bfd_link_info
*info
)
2318 struct elf32_arm_link_hash_table
*htab
;
2320 htab
= elf32_arm_hash_table (info
);
2321 if (!htab
->sgot
&& !create_got_section (dynobj
, info
))
2324 if (!_bfd_elf_create_dynamic_sections (dynobj
, info
))
2327 htab
->splt
= bfd_get_section_by_name (dynobj
, ".plt");
2328 htab
->srelplt
= bfd_get_section_by_name (dynobj
,
2329 RELOC_SECTION (htab
, ".plt"));
2330 htab
->sdynbss
= bfd_get_section_by_name (dynobj
, ".dynbss");
2332 htab
->srelbss
= bfd_get_section_by_name (dynobj
,
2333 RELOC_SECTION (htab
, ".bss"));
2335 if (htab
->vxworks_p
)
2337 if (!elf_vxworks_create_dynamic_sections (dynobj
, info
, &htab
->srelplt2
))
2342 htab
->plt_header_size
= 0;
2343 htab
->plt_entry_size
2344 = 4 * ARRAY_SIZE (elf32_arm_vxworks_shared_plt_entry
);
2348 htab
->plt_header_size
2349 = 4 * ARRAY_SIZE (elf32_arm_vxworks_exec_plt0_entry
);
2350 htab
->plt_entry_size
2351 = 4 * ARRAY_SIZE (elf32_arm_vxworks_exec_plt_entry
);
2358 || (!info
->shared
&& !htab
->srelbss
))
2364 /* Copy the extra info we tack onto an elf_link_hash_entry. */
2367 elf32_arm_copy_indirect_symbol (struct bfd_link_info
*info
,
2368 struct elf_link_hash_entry
*dir
,
2369 struct elf_link_hash_entry
*ind
)
2371 struct elf32_arm_link_hash_entry
*edir
, *eind
;
2373 edir
= (struct elf32_arm_link_hash_entry
*) dir
;
2374 eind
= (struct elf32_arm_link_hash_entry
*) ind
;
2376 if (eind
->relocs_copied
!= NULL
)
2378 if (edir
->relocs_copied
!= NULL
)
2380 struct elf32_arm_relocs_copied
**pp
;
2381 struct elf32_arm_relocs_copied
*p
;
2383 /* Add reloc counts against the indirect sym to the direct sym
2384 list. Merge any entries against the same section. */
2385 for (pp
= &eind
->relocs_copied
; (p
= *pp
) != NULL
; )
2387 struct elf32_arm_relocs_copied
*q
;
2389 for (q
= edir
->relocs_copied
; q
!= NULL
; q
= q
->next
)
2390 if (q
->section
== p
->section
)
2392 q
->pc_count
+= p
->pc_count
;
2393 q
->count
+= p
->count
;
2400 *pp
= edir
->relocs_copied
;
2403 edir
->relocs_copied
= eind
->relocs_copied
;
2404 eind
->relocs_copied
= NULL
;
2407 if (ind
->root
.type
== bfd_link_hash_indirect
)
2409 /* Copy over PLT info. */
2410 edir
->plt_thumb_refcount
+= eind
->plt_thumb_refcount
;
2411 eind
->plt_thumb_refcount
= 0;
2413 if (dir
->got
.refcount
<= 0)
2415 edir
->tls_type
= eind
->tls_type
;
2416 eind
->tls_type
= GOT_UNKNOWN
;
2420 _bfd_elf_link_hash_copy_indirect (info
, dir
, ind
);
2423 /* Create an ARM elf linker hash table. */
2425 static struct bfd_link_hash_table
*
2426 elf32_arm_link_hash_table_create (bfd
*abfd
)
2428 struct elf32_arm_link_hash_table
*ret
;
2429 bfd_size_type amt
= sizeof (struct elf32_arm_link_hash_table
);
2431 ret
= bfd_malloc (amt
);
2435 if (!_bfd_elf_link_hash_table_init (& ret
->root
, abfd
,
2436 elf32_arm_link_hash_newfunc
,
2437 sizeof (struct elf32_arm_link_hash_entry
)))
2444 ret
->sgotplt
= NULL
;
2445 ret
->srelgot
= NULL
;
2447 ret
->srelplt
= NULL
;
2448 ret
->sdynbss
= NULL
;
2449 ret
->srelbss
= NULL
;
2450 ret
->srelplt2
= NULL
;
2451 ret
->thumb_glue_size
= 0;
2452 ret
->arm_glue_size
= 0;
2453 ret
->vfp11_fix
= BFD_ARM_VFP11_FIX_NONE
;
2454 ret
->vfp11_erratum_glue_size
= 0;
2455 ret
->num_vfp11_fixes
= 0;
2456 ret
->bfd_of_glue_owner
= NULL
;
2457 ret
->byteswap_code
= 0;
2458 ret
->target1_is_rel
= 0;
2459 ret
->target2_reloc
= R_ARM_NONE
;
2460 #ifdef FOUR_WORD_PLT
2461 ret
->plt_header_size
= 16;
2462 ret
->plt_entry_size
= 16;
2464 ret
->plt_header_size
= 20;
2465 ret
->plt_entry_size
= 12;
2472 ret
->sym_sec
.abfd
= NULL
;
2474 ret
->tls_ldm_got
.refcount
= 0;
2476 return &ret
->root
.root
;
2479 /* Locate the Thumb encoded calling stub for NAME. */
2481 static struct elf_link_hash_entry
*
2482 find_thumb_glue (struct bfd_link_info
*link_info
,
2484 char **error_message
)
2487 struct elf_link_hash_entry
*hash
;
2488 struct elf32_arm_link_hash_table
*hash_table
;
2490 /* We need a pointer to the armelf specific hash table. */
2491 hash_table
= elf32_arm_hash_table (link_info
);
2493 tmp_name
= bfd_malloc ((bfd_size_type
) strlen (name
)
2494 + strlen (THUMB2ARM_GLUE_ENTRY_NAME
) + 1);
2496 BFD_ASSERT (tmp_name
);
2498 sprintf (tmp_name
, THUMB2ARM_GLUE_ENTRY_NAME
, name
);
2500 hash
= elf_link_hash_lookup
2501 (&(hash_table
)->root
, tmp_name
, FALSE
, FALSE
, TRUE
);
2504 asprintf (error_message
, _("unable to find THUMB glue '%s' for '%s'"),
2512 /* Locate the ARM encoded calling stub for NAME. */
2514 static struct elf_link_hash_entry
*
2515 find_arm_glue (struct bfd_link_info
*link_info
,
2517 char **error_message
)
2520 struct elf_link_hash_entry
*myh
;
2521 struct elf32_arm_link_hash_table
*hash_table
;
2523 /* We need a pointer to the elfarm specific hash table. */
2524 hash_table
= elf32_arm_hash_table (link_info
);
2526 tmp_name
= bfd_malloc ((bfd_size_type
) strlen (name
)
2527 + strlen (ARM2THUMB_GLUE_ENTRY_NAME
) + 1);
2529 BFD_ASSERT (tmp_name
);
2531 sprintf (tmp_name
, ARM2THUMB_GLUE_ENTRY_NAME
, name
);
2533 myh
= elf_link_hash_lookup
2534 (&(hash_table
)->root
, tmp_name
, FALSE
, FALSE
, TRUE
);
2537 asprintf (error_message
, _("unable to find ARM glue '%s' for '%s'"),
2545 /* ARM->Thumb glue (static images):
2549 ldr r12, __func_addr
2552 .word func @ behave as if you saw a ARM_32 reloc.
2554 (relocatable images)
2557 ldr r12, __func_offset
2564 #define ARM2THUMB_STATIC_GLUE_SIZE 12
2565 static const insn32 a2t1_ldr_insn
= 0xe59fc000;
2566 static const insn32 a2t2_bx_r12_insn
= 0xe12fff1c;
2567 static const insn32 a2t3_func_addr_insn
= 0x00000001;
2569 #define ARM2THUMB_PIC_GLUE_SIZE 16
2570 static const insn32 a2t1p_ldr_insn
= 0xe59fc004;
2571 static const insn32 a2t2p_add_pc_insn
= 0xe08cc00f;
2572 static const insn32 a2t3p_bx_r12_insn
= 0xe12fff1c;
2574 /* Thumb->ARM: Thumb->(non-interworking aware) ARM
2578 __func_from_thumb: __func_from_thumb:
2580 nop ldr r6, __func_addr
2582 __func_change_to_arm: bx r6
2584 __func_back_to_thumb:
2590 #define THUMB2ARM_GLUE_SIZE 8
2591 static const insn16 t2a1_bx_pc_insn
= 0x4778;
2592 static const insn16 t2a2_noop_insn
= 0x46c0;
2593 static const insn32 t2a3_b_insn
= 0xea000000;
2595 #define VFP11_ERRATUM_VENEER_SIZE 8
2597 #ifndef ELFARM_NABI_C_INCLUDED
2599 bfd_elf32_arm_allocate_interworking_sections (struct bfd_link_info
* info
)
2603 struct elf32_arm_link_hash_table
* globals
;
2605 globals
= elf32_arm_hash_table (info
);
2607 BFD_ASSERT (globals
!= NULL
);
2609 if (globals
->arm_glue_size
!= 0)
2611 BFD_ASSERT (globals
->bfd_of_glue_owner
!= NULL
);
2613 s
= bfd_get_section_by_name (globals
->bfd_of_glue_owner
,
2614 ARM2THUMB_GLUE_SECTION_NAME
);
2616 BFD_ASSERT (s
!= NULL
);
2618 foo
= bfd_alloc (globals
->bfd_of_glue_owner
, globals
->arm_glue_size
);
2620 BFD_ASSERT (s
->size
== globals
->arm_glue_size
);
2624 if (globals
->thumb_glue_size
!= 0)
2626 BFD_ASSERT (globals
->bfd_of_glue_owner
!= NULL
);
2628 s
= bfd_get_section_by_name
2629 (globals
->bfd_of_glue_owner
, THUMB2ARM_GLUE_SECTION_NAME
);
2631 BFD_ASSERT (s
!= NULL
);
2633 foo
= bfd_alloc (globals
->bfd_of_glue_owner
, globals
->thumb_glue_size
);
2635 BFD_ASSERT (s
->size
== globals
->thumb_glue_size
);
2639 if (globals
->vfp11_erratum_glue_size
!= 0)
2641 BFD_ASSERT (globals
->bfd_of_glue_owner
!= NULL
);
2643 s
= bfd_get_section_by_name
2644 (globals
->bfd_of_glue_owner
, VFP11_ERRATUM_VENEER_SECTION_NAME
);
2646 BFD_ASSERT (s
!= NULL
);
2648 foo
= bfd_alloc (globals
->bfd_of_glue_owner
,
2649 globals
->vfp11_erratum_glue_size
);
2651 BFD_ASSERT (s
->size
== globals
->vfp11_erratum_glue_size
);
2658 /* Allocate space and symbols for calling a Thumb function from Arm mode.
2659 returns the symbol identifying teh stub. */
2660 static struct elf_link_hash_entry
*
2661 record_arm_to_thumb_glue (struct bfd_link_info
* link_info
,
2662 struct elf_link_hash_entry
* h
)
2664 const char * name
= h
->root
.root
.string
;
2667 struct elf_link_hash_entry
* myh
;
2668 struct bfd_link_hash_entry
* bh
;
2669 struct elf32_arm_link_hash_table
* globals
;
2673 globals
= elf32_arm_hash_table (link_info
);
2675 BFD_ASSERT (globals
!= NULL
);
2676 BFD_ASSERT (globals
->bfd_of_glue_owner
!= NULL
);
2678 s
= bfd_get_section_by_name
2679 (globals
->bfd_of_glue_owner
, ARM2THUMB_GLUE_SECTION_NAME
);
2681 BFD_ASSERT (s
!= NULL
);
2683 tmp_name
= bfd_malloc ((bfd_size_type
) strlen (name
) + strlen (ARM2THUMB_GLUE_ENTRY_NAME
) + 1);
2685 BFD_ASSERT (tmp_name
);
2687 sprintf (tmp_name
, ARM2THUMB_GLUE_ENTRY_NAME
, name
);
2689 myh
= elf_link_hash_lookup
2690 (&(globals
)->root
, tmp_name
, FALSE
, FALSE
, TRUE
);
2694 /* We've already seen this guy. */
2699 /* The only trick here is using hash_table->arm_glue_size as the value.
2700 Even though the section isn't allocated yet, this is where we will be
2703 val
= globals
->arm_glue_size
+ 1;
2704 _bfd_generic_link_add_one_symbol (link_info
, globals
->bfd_of_glue_owner
,
2705 tmp_name
, BSF_GLOBAL
, s
, val
,
2706 NULL
, TRUE
, FALSE
, &bh
);
2708 myh
= (struct elf_link_hash_entry
*) bh
;
2709 myh
->type
= ELF_ST_INFO (STB_LOCAL
, STT_FUNC
);
2710 myh
->forced_local
= 1;
2714 if ((link_info
->shared
|| globals
->root
.is_relocatable_executable
))
2715 size
= ARM2THUMB_PIC_GLUE_SIZE
;
2717 size
= ARM2THUMB_STATIC_GLUE_SIZE
;
2720 globals
->arm_glue_size
+= size
;
2726 record_thumb_to_arm_glue (struct bfd_link_info
*link_info
,
2727 struct elf_link_hash_entry
*h
)
2729 const char *name
= h
->root
.root
.string
;
2732 struct elf_link_hash_entry
*myh
;
2733 struct bfd_link_hash_entry
*bh
;
2734 struct elf32_arm_link_hash_table
*hash_table
;
2737 hash_table
= elf32_arm_hash_table (link_info
);
2739 BFD_ASSERT (hash_table
!= NULL
);
2740 BFD_ASSERT (hash_table
->bfd_of_glue_owner
!= NULL
);
2742 s
= bfd_get_section_by_name
2743 (hash_table
->bfd_of_glue_owner
, THUMB2ARM_GLUE_SECTION_NAME
);
2745 BFD_ASSERT (s
!= NULL
);
2747 tmp_name
= bfd_malloc ((bfd_size_type
) strlen (name
)
2748 + strlen (THUMB2ARM_GLUE_ENTRY_NAME
) + 1);
2750 BFD_ASSERT (tmp_name
);
2752 sprintf (tmp_name
, THUMB2ARM_GLUE_ENTRY_NAME
, name
);
2754 myh
= elf_link_hash_lookup
2755 (&(hash_table
)->root
, tmp_name
, FALSE
, FALSE
, TRUE
);
2759 /* We've already seen this guy. */
2765 val
= hash_table
->thumb_glue_size
+ 1;
2766 _bfd_generic_link_add_one_symbol (link_info
, hash_table
->bfd_of_glue_owner
,
2767 tmp_name
, BSF_GLOBAL
, s
, val
,
2768 NULL
, TRUE
, FALSE
, &bh
);
2770 /* If we mark it 'Thumb', the disassembler will do a better job. */
2771 myh
= (struct elf_link_hash_entry
*) bh
;
2772 myh
->type
= ELF_ST_INFO (STB_LOCAL
, STT_ARM_TFUNC
);
2773 myh
->forced_local
= 1;
2777 #define CHANGE_TO_ARM "__%s_change_to_arm"
2778 #define BACK_FROM_ARM "__%s_back_from_arm"
2780 /* Allocate another symbol to mark where we switch to Arm mode. */
2781 tmp_name
= bfd_malloc ((bfd_size_type
) strlen (name
)
2782 + strlen (CHANGE_TO_ARM
) + 1);
2784 BFD_ASSERT (tmp_name
);
2786 sprintf (tmp_name
, CHANGE_TO_ARM
, name
);
2789 val
= hash_table
->thumb_glue_size
+ 4,
2790 _bfd_generic_link_add_one_symbol (link_info
, hash_table
->bfd_of_glue_owner
,
2791 tmp_name
, BSF_LOCAL
, s
, val
,
2792 NULL
, TRUE
, FALSE
, &bh
);
2796 s
->size
+= THUMB2ARM_GLUE_SIZE
;
2797 hash_table
->thumb_glue_size
+= THUMB2ARM_GLUE_SIZE
;
2803 /* Add an entry to the code/data map for section SEC. */
2806 elf32_arm_section_map_add (asection
*sec
, char type
, bfd_vma vma
)
2808 struct _arm_elf_section_data
*sec_data
= elf32_arm_section_data (sec
);
2809 unsigned int newidx
;
2811 if (sec_data
->map
== NULL
)
2813 sec_data
->map
= bfd_malloc (sizeof (elf32_arm_section_map
));
2814 sec_data
->mapcount
= 0;
2815 sec_data
->mapsize
= 1;
2818 newidx
= sec_data
->mapcount
++;
2820 if (sec_data
->mapcount
> sec_data
->mapsize
)
2822 sec_data
->mapsize
*= 2;
2823 sec_data
->map
= bfd_realloc (sec_data
->map
, sec_data
->mapsize
2824 * sizeof (elf32_arm_section_map
));
2827 sec_data
->map
[newidx
].vma
= vma
;
2828 sec_data
->map
[newidx
].type
= type
;
2832 /* Record information about a VFP11 denorm-erratum veneer. Only ARM-mode
2833 veneers are handled for now. */
2836 record_vfp11_erratum_veneer (struct bfd_link_info
*link_info
,
2837 elf32_vfp11_erratum_list
*branch
,
2839 asection
*branch_sec
,
2840 unsigned int offset
)
2843 struct elf32_arm_link_hash_table
*hash_table
;
2845 struct elf_link_hash_entry
*myh
;
2846 struct bfd_link_hash_entry
*bh
;
2848 struct _arm_elf_section_data
*sec_data
;
2850 elf32_vfp11_erratum_list
*newerr
;
2852 hash_table
= elf32_arm_hash_table (link_info
);
2854 BFD_ASSERT (hash_table
!= NULL
);
2855 BFD_ASSERT (hash_table
->bfd_of_glue_owner
!= NULL
);
2857 s
= bfd_get_section_by_name
2858 (hash_table
->bfd_of_glue_owner
, VFP11_ERRATUM_VENEER_SECTION_NAME
);
2860 sec_data
= elf32_arm_section_data (s
);
2862 BFD_ASSERT (s
!= NULL
);
2864 tmp_name
= bfd_malloc ((bfd_size_type
) strlen
2865 (VFP11_ERRATUM_VENEER_ENTRY_NAME
) + 10);
2867 BFD_ASSERT (tmp_name
);
2869 sprintf (tmp_name
, VFP11_ERRATUM_VENEER_ENTRY_NAME
,
2870 hash_table
->num_vfp11_fixes
);
2872 myh
= elf_link_hash_lookup
2873 (&(hash_table
)->root
, tmp_name
, FALSE
, FALSE
, FALSE
);
2875 BFD_ASSERT (myh
== NULL
);
2878 val
= hash_table
->vfp11_erratum_glue_size
;
2879 _bfd_generic_link_add_one_symbol (link_info
, hash_table
->bfd_of_glue_owner
,
2880 tmp_name
, BSF_FUNCTION
| BSF_LOCAL
, s
, val
,
2881 NULL
, TRUE
, FALSE
, &bh
);
2883 myh
= (struct elf_link_hash_entry
*) bh
;
2884 myh
->type
= ELF_ST_INFO (STB_LOCAL
, STT_FUNC
);
2885 myh
->forced_local
= 1;
2887 /* Link veneer back to calling location. */
2888 errcount
= ++(sec_data
->erratumcount
);
2889 newerr
= bfd_zmalloc (sizeof (elf32_vfp11_erratum_list
));
2891 newerr
->type
= VFP11_ERRATUM_ARM_VENEER
;
2893 newerr
->u
.v
.branch
= branch
;
2894 newerr
->u
.v
.id
= hash_table
->num_vfp11_fixes
;
2895 branch
->u
.b
.veneer
= newerr
;
2897 newerr
->next
= sec_data
->erratumlist
;
2898 sec_data
->erratumlist
= newerr
;
2900 /* A symbol for the return from the veneer. */
2901 sprintf (tmp_name
, VFP11_ERRATUM_VENEER_ENTRY_NAME
"_r",
2902 hash_table
->num_vfp11_fixes
);
2904 myh
= elf_link_hash_lookup
2905 (&(hash_table
)->root
, tmp_name
, FALSE
, FALSE
, FALSE
);
2912 _bfd_generic_link_add_one_symbol (link_info
, branch_bfd
, tmp_name
, BSF_LOCAL
,
2913 branch_sec
, val
, NULL
, TRUE
, FALSE
, &bh
);
2915 myh
= (struct elf_link_hash_entry
*) bh
;
2916 myh
->type
= ELF_ST_INFO (STB_LOCAL
, STT_FUNC
);
2917 myh
->forced_local
= 1;
2921 /* Generate a mapping symbol for the veneer section, and explicitly add an
2922 entry for that symbol to the code/data map for the section. */
2923 if (hash_table
->vfp11_erratum_glue_size
== 0)
2926 /* FIXME: Creates an ARM symbol. Thumb mode will need attention if it
2927 ever requires this erratum fix. */
2928 _bfd_generic_link_add_one_symbol (link_info
,
2929 hash_table
->bfd_of_glue_owner
, "$a",
2930 BSF_LOCAL
, s
, 0, NULL
,
2933 myh
= (struct elf_link_hash_entry
*) bh
;
2934 myh
->type
= ELF_ST_INFO (STB_LOCAL
, STT_NOTYPE
);
2935 myh
->forced_local
= 1;
2937 /* The elf32_arm_init_maps function only cares about symbols from input
2938 BFDs. We must make a note of this generated mapping symbol
2939 ourselves so that code byteswapping works properly in
2940 elf32_arm_write_section. */
2941 elf32_arm_section_map_add (s
, 'a', 0);
2944 s
->size
+= VFP11_ERRATUM_VENEER_SIZE
;
2945 hash_table
->vfp11_erratum_glue_size
+= VFP11_ERRATUM_VENEER_SIZE
;
2946 hash_table
->num_vfp11_fixes
++;
2948 /* The offset of the veneer. */
2952 /* Add the glue sections to ABFD. This function is called from the
2953 linker scripts in ld/emultempl/{armelf}.em. */
2956 bfd_elf32_arm_add_glue_sections_to_bfd (bfd
*abfd
,
2957 struct bfd_link_info
*info
)
2962 /* If we are only performing a partial
2963 link do not bother adding the glue. */
2964 if (info
->relocatable
)
2967 sec
= bfd_get_section_by_name (abfd
, ARM2THUMB_GLUE_SECTION_NAME
);
2971 /* Note: we do not include the flag SEC_LINKER_CREATED, as this
2972 will prevent elf_link_input_bfd() from processing the contents
2974 flags
= (SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_IN_MEMORY
2975 | SEC_CODE
| SEC_READONLY
);
2977 sec
= bfd_make_section_with_flags (abfd
,
2978 ARM2THUMB_GLUE_SECTION_NAME
,
2982 || !bfd_set_section_alignment (abfd
, sec
, 2))
2985 /* Set the gc mark to prevent the section from being removed by garbage
2986 collection, despite the fact that no relocs refer to this section. */
2990 sec
= bfd_get_section_by_name (abfd
, THUMB2ARM_GLUE_SECTION_NAME
);
2994 flags
= (SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_IN_MEMORY
2995 | SEC_CODE
| SEC_READONLY
);
2997 sec
= bfd_make_section_with_flags (abfd
,
2998 THUMB2ARM_GLUE_SECTION_NAME
,
3002 || !bfd_set_section_alignment (abfd
, sec
, 2))
3008 sec
= bfd_get_section_by_name (abfd
, VFP11_ERRATUM_VENEER_SECTION_NAME
);
3012 flags
= (SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_IN_MEMORY
3013 | SEC_CODE
| SEC_READONLY
);
3015 sec
= bfd_make_section_with_flags (abfd
,
3016 VFP11_ERRATUM_VENEER_SECTION_NAME
,
3020 || !bfd_set_section_alignment (abfd
, sec
, 2))
3029 /* Select a BFD to be used to hold the sections used by the glue code.
3030 This function is called from the linker scripts in ld/emultempl/
3034 bfd_elf32_arm_get_bfd_for_interworking (bfd
*abfd
, struct bfd_link_info
*info
)
3036 struct elf32_arm_link_hash_table
*globals
;
3038 /* If we are only performing a partial link
3039 do not bother getting a bfd to hold the glue. */
3040 if (info
->relocatable
)
3043 /* Make sure we don't attach the glue sections to a dynamic object. */
3044 BFD_ASSERT (!(abfd
->flags
& DYNAMIC
));
3046 globals
= elf32_arm_hash_table (info
);
3048 BFD_ASSERT (globals
!= NULL
);
3050 if (globals
->bfd_of_glue_owner
!= NULL
)
3053 /* Save the bfd for later use. */
3054 globals
->bfd_of_glue_owner
= abfd
;
3059 static void check_use_blx(struct elf32_arm_link_hash_table
*globals
)
3061 if (elf32_arm_get_eabi_attr_int (globals
->obfd
, Tag_CPU_arch
) > 2)
3062 globals
->use_blx
= 1;
3066 bfd_elf32_arm_process_before_allocation (bfd
*abfd
,
3067 struct bfd_link_info
*link_info
)
3069 Elf_Internal_Shdr
*symtab_hdr
;
3070 Elf_Internal_Rela
*internal_relocs
= NULL
;
3071 Elf_Internal_Rela
*irel
, *irelend
;
3072 bfd_byte
*contents
= NULL
;
3075 struct elf32_arm_link_hash_table
*globals
;
3077 /* If we are only performing a partial link do not bother
3078 to construct any glue. */
3079 if (link_info
->relocatable
)
3082 /* Here we have a bfd that is to be included on the link. We have a hook
3083 to do reloc rummaging, before section sizes are nailed down. */
3084 globals
= elf32_arm_hash_table (link_info
);
3085 check_use_blx (globals
);
3087 BFD_ASSERT (globals
!= NULL
);
3088 BFD_ASSERT (globals
->bfd_of_glue_owner
!= NULL
);
3090 if (globals
->byteswap_code
&& !bfd_big_endian (abfd
))
3092 _bfd_error_handler (_("%B: BE8 images only valid in big-endian mode."),
3097 /* Rummage around all the relocs and map the glue vectors. */
3098 sec
= abfd
->sections
;
3103 for (; sec
!= NULL
; sec
= sec
->next
)
3105 if (sec
->reloc_count
== 0)
3108 if ((sec
->flags
& SEC_EXCLUDE
) != 0)
3111 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
3113 /* Load the relocs. */
3115 = _bfd_elf_link_read_relocs (abfd
, sec
, (void *) NULL
,
3116 (Elf_Internal_Rela
*) NULL
, FALSE
);
3118 if (internal_relocs
== NULL
)
3121 irelend
= internal_relocs
+ sec
->reloc_count
;
3122 for (irel
= internal_relocs
; irel
< irelend
; irel
++)
3125 unsigned long r_index
;
3127 struct elf_link_hash_entry
*h
;
3129 r_type
= ELF32_R_TYPE (irel
->r_info
);
3130 r_index
= ELF32_R_SYM (irel
->r_info
);
3132 /* These are the only relocation types we care about. */
3133 if ( r_type
!= R_ARM_PC24
3134 && r_type
!= R_ARM_PLT32
3135 && r_type
!= R_ARM_CALL
3136 && r_type
!= R_ARM_JUMP24
3137 && r_type
!= R_ARM_THM_CALL
)
3140 /* Get the section contents if we haven't done so already. */
3141 if (contents
== NULL
)
3143 /* Get cached copy if it exists. */
3144 if (elf_section_data (sec
)->this_hdr
.contents
!= NULL
)
3145 contents
= elf_section_data (sec
)->this_hdr
.contents
;
3148 /* Go get them off disk. */
3149 if (! bfd_malloc_and_get_section (abfd
, sec
, &contents
))
3154 /* If the relocation is not against a symbol it cannot concern us. */
3157 /* We don't care about local symbols. */
3158 if (r_index
< symtab_hdr
->sh_info
)
3161 /* This is an external symbol. */
3162 r_index
-= symtab_hdr
->sh_info
;
3163 h
= (struct elf_link_hash_entry
*)
3164 elf_sym_hashes (abfd
)[r_index
];
3166 /* If the relocation is against a static symbol it must be within
3167 the current section and so cannot be a cross ARM/Thumb relocation. */
3171 /* If the call will go through a PLT entry then we do not need
3173 if (globals
->splt
!= NULL
&& h
->plt
.offset
!= (bfd_vma
) -1)
3182 /* This one is a call from arm code. We need to look up
3183 the target of the call. If it is a thumb target, we
3185 if (ELF_ST_TYPE(h
->type
) == STT_ARM_TFUNC
3186 && !(r_type
== R_ARM_CALL
&& globals
->use_blx
))
3187 record_arm_to_thumb_glue (link_info
, h
);
3190 case R_ARM_THM_CALL
:
3191 /* This one is a call from thumb code. We look
3192 up the target of the call. If it is not a thumb
3193 target, we insert glue. */
3194 if (ELF_ST_TYPE (h
->type
) != STT_ARM_TFUNC
&& !globals
->use_blx
)
3195 record_thumb_to_arm_glue (link_info
, h
);
3203 if (contents
!= NULL
3204 && elf_section_data (sec
)->this_hdr
.contents
!= contents
)
3208 if (internal_relocs
!= NULL
3209 && elf_section_data (sec
)->relocs
!= internal_relocs
)
3210 free (internal_relocs
);
3211 internal_relocs
= NULL
;
3217 if (contents
!= NULL
3218 && elf_section_data (sec
)->this_hdr
.contents
!= contents
)
3220 if (internal_relocs
!= NULL
3221 && elf_section_data (sec
)->relocs
!= internal_relocs
)
3222 free (internal_relocs
);
3229 /* Initialise maps of ARM/Thumb/data for input BFDs. */
3232 bfd_elf32_arm_init_maps (bfd
*abfd
)
3234 Elf_Internal_Sym
*isymbuf
;
3235 Elf_Internal_Shdr
*hdr
;
3236 unsigned int i
, localsyms
;
3238 if ((abfd
->flags
& DYNAMIC
) != 0)
3241 hdr
= &elf_tdata (abfd
)->symtab_hdr
;
3242 localsyms
= hdr
->sh_info
;
3244 /* Obtain a buffer full of symbols for this BFD. The hdr->sh_info field
3245 should contain the number of local symbols, which should come before any
3246 global symbols. Mapping symbols are always local. */
3247 isymbuf
= bfd_elf_get_elf_syms (abfd
, hdr
, localsyms
, 0, NULL
, NULL
,
3250 /* No internal symbols read? Skip this BFD. */
3251 if (isymbuf
== NULL
)
3254 for (i
= 0; i
< localsyms
; i
++)
3256 Elf_Internal_Sym
*isym
= &isymbuf
[i
];
3257 asection
*sec
= bfd_section_from_elf_index (abfd
, isym
->st_shndx
);
3261 && ELF_ST_BIND (isym
->st_info
) == STB_LOCAL
)
3263 name
= bfd_elf_string_from_elf_section (abfd
,
3264 hdr
->sh_link
, isym
->st_name
);
3266 if (bfd_is_arm_special_symbol_name (name
,
3267 BFD_ARM_SPECIAL_SYM_TYPE_MAP
))
3268 elf32_arm_section_map_add (sec
, name
[1], isym
->st_value
);
3275 bfd_elf32_arm_set_vfp11_fix (bfd
*obfd
, struct bfd_link_info
*link_info
)
3277 struct elf32_arm_link_hash_table
*globals
= elf32_arm_hash_table (link_info
);
3278 aeabi_attribute
*out_attr
= elf32_arm_tdata (obfd
)->known_eabi_attributes
;
3280 /* We assume that ARMv7+ does not need the VFP11 denorm erratum fix. */
3281 if (out_attr
[Tag_CPU_arch
].i
>= TAG_CPU_ARCH_V7
)
3283 switch (globals
->vfp11_fix
)
3285 case BFD_ARM_VFP11_FIX_DEFAULT
:
3286 case BFD_ARM_VFP11_FIX_NONE
:
3287 globals
->vfp11_fix
= BFD_ARM_VFP11_FIX_NONE
;
3291 /* Give a warning, but do as the user requests anyway. */
3292 (*_bfd_error_handler
) (_("%B: warning: selected VFP11 erratum "
3293 "workaround is not necessary for target architecture"), obfd
);
3296 else if (globals
->vfp11_fix
== BFD_ARM_VFP11_FIX_DEFAULT
)
3297 /* For earlier architectures, we might need the workaround, but do not
3298 enable it by default. If users is running with broken hardware, they
3299 must enable the erratum fix explicitly. */
3300 globals
->vfp11_fix
= BFD_ARM_VFP11_FIX_NONE
;
3304 enum bfd_arm_vfp11_pipe
{
3311 /* Return a VFP register number. This is encoded as RX:X for single-precision
3312 registers, or X:RX for double-precision registers, where RX is the group of
3313 four bits in the instruction encoding and X is the single extension bit.
3314 RX and X fields are specified using their lowest (starting) bit. The return
3317 0...31: single-precision registers s0...s31
3318 32...63: double-precision registers d0...d31.
3320 Although X should be zero for VFP11 (encoding d0...d15 only), we might
3321 encounter VFP3 instructions, so we allow the full range for DP registers. */
3324 bfd_arm_vfp11_regno (unsigned int insn
, bfd_boolean is_double
, unsigned int rx
,
3328 return (((insn
>> rx
) & 0xf) | (((insn
>> x
) & 1) << 4)) + 32;
3330 return (((insn
>> rx
) & 0xf) << 1) | ((insn
>> x
) & 1);
3333 /* Set bits in *WMASK according to a register number REG as encoded by
3334 bfd_arm_vfp11_regno(). Ignore d16-d31. */
3337 bfd_arm_vfp11_write_mask (unsigned int *wmask
, unsigned int reg
)
3342 *wmask
|= 3 << ((reg
- 32) * 2);
3345 /* Return TRUE if WMASK overwrites anything in REGS. */
3348 bfd_arm_vfp11_antidependency (unsigned int wmask
, int *regs
, int numregs
)
3352 for (i
= 0; i
< numregs
; i
++)
3354 unsigned int reg
= regs
[i
];
3356 if (reg
< 32 && (wmask
& (1 << reg
)) != 0)
3364 if ((wmask
& (3 << (reg
* 2))) != 0)
3371 /* In this function, we're interested in two things: finding input registers
3372 for VFP data-processing instructions, and finding the set of registers which
3373 arbitrary VFP instructions may write to. We use a 32-bit unsigned int to
3374 hold the written set, so FLDM etc. are easy to deal with (we're only
3375 interested in 32 SP registers or 16 dp registers, due to the VFP version
3376 implemented by the chip in question). DP registers are marked by setting
3377 both SP registers in the write mask). */
3379 static enum bfd_arm_vfp11_pipe
3380 bfd_arm_vfp11_insn_decode (unsigned int insn
, unsigned int *destmask
, int *regs
,
3383 enum bfd_arm_vfp11_pipe pipe
= VFP11_BAD
;
3384 bfd_boolean is_double
= ((insn
& 0xf00) == 0xb00) ? 1 : 0;
3386 if ((insn
& 0x0f000e10) == 0x0e000a00) /* A data-processing insn. */
3389 unsigned int fd
= bfd_arm_vfp11_regno (insn
, is_double
, 12, 22);
3390 unsigned int fm
= bfd_arm_vfp11_regno (insn
, is_double
, 0, 5);
3392 pqrs
= ((insn
& 0x00800000) >> 20)
3393 | ((insn
& 0x00300000) >> 19)
3394 | ((insn
& 0x00000040) >> 6);
3398 case 0: /* fmac[sd]. */
3399 case 1: /* fnmac[sd]. */
3400 case 2: /* fmsc[sd]. */
3401 case 3: /* fnmsc[sd]. */
3403 bfd_arm_vfp11_write_mask (destmask
, fd
);
3405 regs
[1] = bfd_arm_vfp11_regno (insn
, is_double
, 16, 7); /* Fn. */
3410 case 4: /* fmul[sd]. */
3411 case 5: /* fnmul[sd]. */
3412 case 6: /* fadd[sd]. */
3413 case 7: /* fsub[sd]. */
3417 case 8: /* fdiv[sd]. */
3420 bfd_arm_vfp11_write_mask (destmask
, fd
);
3421 regs
[0] = bfd_arm_vfp11_regno (insn
, is_double
, 16, 7); /* Fn. */
3426 case 15: /* extended opcode. */
3428 unsigned int extn
= ((insn
>> 15) & 0x1e)
3429 | ((insn
>> 7) & 1);
3433 case 0: /* fcpy[sd]. */
3434 case 1: /* fabs[sd]. */
3435 case 2: /* fneg[sd]. */
3436 case 8: /* fcmp[sd]. */
3437 case 9: /* fcmpe[sd]. */
3438 case 10: /* fcmpz[sd]. */
3439 case 11: /* fcmpez[sd]. */
3440 case 16: /* fuito[sd]. */
3441 case 17: /* fsito[sd]. */
3442 case 24: /* ftoui[sd]. */
3443 case 25: /* ftouiz[sd]. */
3444 case 26: /* ftosi[sd]. */
3445 case 27: /* ftosiz[sd]. */
3446 /* These instructions will not bounce due to underflow. */
3451 case 3: /* fsqrt[sd]. */
3452 /* fsqrt cannot underflow, but it can (perhaps) overwrite
3453 registers to cause the erratum in previous instructions. */
3454 bfd_arm_vfp11_write_mask (destmask
, fd
);
3458 case 15: /* fcvt{ds,sd}. */
3462 bfd_arm_vfp11_write_mask (destmask
, fd
);
3464 /* Only FCVTSD can underflow. */
3465 if ((insn
& 0x100) != 0)
3484 /* Two-register transfer. */
3485 else if ((insn
& 0x0fe00ed0) == 0x0c400a10)
3487 unsigned int fm
= bfd_arm_vfp11_regno (insn
, is_double
, 0, 5);
3489 if ((insn
& 0x100000) == 0)
3492 bfd_arm_vfp11_write_mask (destmask
, fm
);
3495 bfd_arm_vfp11_write_mask (destmask
, fm
);
3496 bfd_arm_vfp11_write_mask (destmask
, fm
+ 1);
3502 else if ((insn
& 0x0e100e00) == 0x0c100a00) /* A load insn. */
3504 int fd
= bfd_arm_vfp11_regno (insn
, is_double
, 12, 22);
3505 unsigned int puw
= ((insn
>> 21) & 0x1) | (((insn
>> 23) & 3) << 1);
3509 case 0: /* Two-reg transfer. We should catch these above. */
3512 case 2: /* fldm[sdx]. */
3516 unsigned int i
, offset
= insn
& 0xff;
3521 for (i
= fd
; i
< fd
+ offset
; i
++)
3522 bfd_arm_vfp11_write_mask (destmask
, i
);
3526 case 4: /* fld[sd]. */
3528 bfd_arm_vfp11_write_mask (destmask
, fd
);
3537 /* Single-register transfer. Note L==0. */
3538 else if ((insn
& 0x0f100e10) == 0x0e000a10)
3540 unsigned int opcode
= (insn
>> 21) & 7;
3541 unsigned int fn
= bfd_arm_vfp11_regno (insn
, is_double
, 16, 7);
3545 case 0: /* fmsr/fmdlr. */
3546 case 1: /* fmdhr. */
3547 /* Mark fmdhr and fmdlr as writing to the whole of the DP
3548 destination register. I don't know if this is exactly right,
3549 but it is the conservative choice. */
3550 bfd_arm_vfp11_write_mask (destmask
, fn
);
3564 static int elf32_arm_compare_mapping (const void * a
, const void * b
);
3567 /* Look for potentially-troublesome code sequences which might trigger the
3568 VFP11 denormal/antidependency erratum. See, e.g., the ARM1136 errata sheet
3569 (available from ARM) for details of the erratum. A short version is
3570 described in ld.texinfo. */
3573 bfd_elf32_arm_vfp11_erratum_scan (bfd
*abfd
, struct bfd_link_info
*link_info
)
3576 bfd_byte
*contents
= NULL
;
3578 int regs
[3], numregs
= 0;
3579 struct elf32_arm_link_hash_table
*globals
= elf32_arm_hash_table (link_info
);
3580 int use_vector
= (globals
->vfp11_fix
== BFD_ARM_VFP11_FIX_VECTOR
);
3582 /* We use a simple FSM to match troublesome VFP11 instruction sequences.
3583 The states transition as follows:
3585 0 -> 1 (vector) or 0 -> 2 (scalar)
3586 A VFP FMAC-pipeline instruction has been seen. Fill
3587 regs[0]..regs[numregs-1] with its input operands. Remember this
3588 instruction in 'first_fmac'.
3591 Any instruction, except for a VFP instruction which overwrites
3596 A VFP instruction has been seen which overwrites any of regs[*].
3597 We must make a veneer! Reset state to 0 before examining next
3601 If we fail to match anything in state 2, reset to state 0 and reset
3602 the instruction pointer to the instruction after 'first_fmac'.
3604 If the VFP11 vector mode is in use, there must be at least two unrelated
3605 instructions between anti-dependent VFP11 instructions to properly avoid
3606 triggering the erratum, hence the use of the extra state 1.
3609 /* If we are only performing a partial link do not bother
3610 to construct any glue. */
3611 if (link_info
->relocatable
)
3614 /* We should have chosen a fix type by the time we get here. */
3615 BFD_ASSERT (globals
->vfp11_fix
!= BFD_ARM_VFP11_FIX_DEFAULT
);
3617 if (globals
->vfp11_fix
== BFD_ARM_VFP11_FIX_NONE
)
3620 for (sec
= abfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
3622 unsigned int i
, span
, first_fmac
= 0, veneer_of_insn
= 0;
3623 struct _arm_elf_section_data
*sec_data
;
3625 /* If we don't have executable progbits, we're not interested in this
3626 section. Also skip if section is to be excluded. */
3627 if (elf_section_type (sec
) != SHT_PROGBITS
3628 || (elf_section_flags (sec
) & SHF_EXECINSTR
) == 0
3629 || (sec
->flags
& SEC_EXCLUDE
) != 0
3630 || strcmp (sec
->name
, VFP11_ERRATUM_VENEER_SECTION_NAME
) == 0)
3633 sec_data
= elf32_arm_section_data (sec
);
3635 if (sec_data
->mapcount
== 0)
3638 if (elf_section_data (sec
)->this_hdr
.contents
!= NULL
)
3639 contents
= elf_section_data (sec
)->this_hdr
.contents
;
3640 else if (! bfd_malloc_and_get_section (abfd
, sec
, &contents
))
3643 qsort (sec_data
->map
, sec_data
->mapcount
, sizeof (elf32_arm_section_map
),
3644 elf32_arm_compare_mapping
);
3646 for (span
= 0; span
< sec_data
->mapcount
; span
++)
3648 unsigned int span_start
= sec_data
->map
[span
].vma
;
3649 unsigned int span_end
= (span
== sec_data
->mapcount
- 1)
3650 ? sec
->size
: sec_data
->map
[span
+ 1].vma
;
3651 char span_type
= sec_data
->map
[span
].type
;
3653 /* FIXME: Only ARM mode is supported at present. We may need to
3654 support Thumb-2 mode also at some point. */
3655 if (span_type
!= 'a')
3658 for (i
= span_start
; i
< span_end
;)
3660 unsigned int next_i
= i
+ 4;
3661 unsigned int insn
= bfd_big_endian (abfd
)
3662 ? (contents
[i
] << 24)
3663 | (contents
[i
+ 1] << 16)
3664 | (contents
[i
+ 2] << 8)
3666 : (contents
[i
+ 3] << 24)
3667 | (contents
[i
+ 2] << 16)
3668 | (contents
[i
+ 1] << 8)
3670 unsigned int writemask
= 0;
3671 enum bfd_arm_vfp11_pipe pipe
;
3676 pipe
= bfd_arm_vfp11_insn_decode (insn
, &writemask
, regs
,
3678 /* I'm assuming the VFP11 erratum can trigger with denorm
3679 operands on either the FMAC or the DS pipeline. This might
3680 lead to slightly overenthusiastic veneer insertion. */
3681 if (pipe
== VFP11_FMAC
|| pipe
== VFP11_DS
)
3683 state
= use_vector
? 1 : 2;
3685 veneer_of_insn
= insn
;
3691 int other_regs
[3], other_numregs
;
3692 pipe
= bfd_arm_vfp11_insn_decode (insn
, &writemask
,
3695 if (pipe
!= VFP11_BAD
3696 && bfd_arm_vfp11_antidependency (writemask
, regs
,
3706 int other_regs
[3], other_numregs
;
3707 pipe
= bfd_arm_vfp11_insn_decode (insn
, &writemask
,
3710 if (pipe
!= VFP11_BAD
3711 && bfd_arm_vfp11_antidependency (writemask
, regs
,
3717 next_i
= first_fmac
+ 4;
3723 abort (); /* Should be unreachable. */
3728 elf32_vfp11_erratum_list
*newerr
3729 = bfd_zmalloc (sizeof (elf32_vfp11_erratum_list
));
3732 errcount
= ++(elf32_arm_section_data (sec
)->erratumcount
);
3734 newerr
->u
.b
.vfp_insn
= veneer_of_insn
;
3739 newerr
->type
= VFP11_ERRATUM_BRANCH_TO_ARM_VENEER
;
3746 record_vfp11_erratum_veneer (link_info
, newerr
, abfd
, sec
,
3751 newerr
->next
= sec_data
->erratumlist
;
3752 sec_data
->erratumlist
= newerr
;
3761 if (contents
!= NULL
3762 && elf_section_data (sec
)->this_hdr
.contents
!= contents
)
3770 if (contents
!= NULL
3771 && elf_section_data (sec
)->this_hdr
.contents
!= contents
)
3777 /* Find virtual-memory addresses for VFP11 erratum veneers and return locations
3778 after sections have been laid out, using specially-named symbols. */
3781 bfd_elf32_arm_vfp11_fix_veneer_locations (bfd
*abfd
,
3782 struct bfd_link_info
*link_info
)
3785 struct elf32_arm_link_hash_table
*globals
;
3788 if (link_info
->relocatable
)
3791 globals
= elf32_arm_hash_table (link_info
);
3793 tmp_name
= bfd_malloc ((bfd_size_type
) strlen
3794 (VFP11_ERRATUM_VENEER_ENTRY_NAME
) + 10);
3796 for (sec
= abfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
3798 struct _arm_elf_section_data
*sec_data
= elf32_arm_section_data (sec
);
3799 elf32_vfp11_erratum_list
*errnode
= sec_data
->erratumlist
;
3801 for (; errnode
!= NULL
; errnode
= errnode
->next
)
3803 struct elf_link_hash_entry
*myh
;
3806 switch (errnode
->type
)
3808 case VFP11_ERRATUM_BRANCH_TO_ARM_VENEER
:
3809 case VFP11_ERRATUM_BRANCH_TO_THUMB_VENEER
:
3810 /* Find veneer symbol. */
3811 sprintf (tmp_name
, VFP11_ERRATUM_VENEER_ENTRY_NAME
,
3812 errnode
->u
.b
.veneer
->u
.v
.id
);
3814 myh
= elf_link_hash_lookup
3815 (&(globals
)->root
, tmp_name
, FALSE
, FALSE
, TRUE
);
3818 (*_bfd_error_handler
) (_("%B: unable to find VFP11 veneer "
3819 "`%s'"), abfd
, tmp_name
);
3821 vma
= myh
->root
.u
.def
.section
->output_section
->vma
3822 + myh
->root
.u
.def
.section
->output_offset
3823 + myh
->root
.u
.def
.value
;
3825 errnode
->u
.b
.veneer
->vma
= vma
;
3828 case VFP11_ERRATUM_ARM_VENEER
:
3829 case VFP11_ERRATUM_THUMB_VENEER
:
3830 /* Find return location. */
3831 sprintf (tmp_name
, VFP11_ERRATUM_VENEER_ENTRY_NAME
"_r",
3834 myh
= elf_link_hash_lookup
3835 (&(globals
)->root
, tmp_name
, FALSE
, FALSE
, TRUE
);
3838 (*_bfd_error_handler
) (_("%B: unable to find VFP11 veneer "
3839 "`%s'"), abfd
, tmp_name
);
3841 vma
= myh
->root
.u
.def
.section
->output_section
->vma
3842 + myh
->root
.u
.def
.section
->output_offset
3843 + myh
->root
.u
.def
.value
;
3845 errnode
->u
.v
.branch
->vma
= vma
;
3858 /* Set target relocation values needed during linking. */
3861 bfd_elf32_arm_set_target_relocs (struct bfd_link_info
*link_info
,
3863 char * target2_type
,
3866 bfd_arm_vfp11_fix vfp11_fix
)
3868 struct elf32_arm_link_hash_table
*globals
;
3870 globals
= elf32_arm_hash_table (link_info
);
3872 globals
->target1_is_rel
= target1_is_rel
;
3873 if (strcmp (target2_type
, "rel") == 0)
3874 globals
->target2_reloc
= R_ARM_REL32
;
3875 else if (strcmp (target2_type
, "abs") == 0)
3876 globals
->target2_reloc
= R_ARM_ABS32
;
3877 else if (strcmp (target2_type
, "got-rel") == 0)
3878 globals
->target2_reloc
= R_ARM_GOT_PREL
;
3881 _bfd_error_handler (_("Invalid TARGET2 relocation type '%s'."),
3884 globals
->fix_v4bx
= fix_v4bx
;
3885 globals
->use_blx
|= use_blx
;
3886 globals
->vfp11_fix
= vfp11_fix
;
3889 /* The thumb form of a long branch is a bit finicky, because the offset
3890 encoding is split over two fields, each in it's own instruction. They
3891 can occur in any order. So given a thumb form of long branch, and an
3892 offset, insert the offset into the thumb branch and return finished
3895 It takes two thumb instructions to encode the target address. Each has
3896 11 bits to invest. The upper 11 bits are stored in one (identified by
3897 H-0.. see below), the lower 11 bits are stored in the other (identified
3900 Combine together and shifted left by 1 (it's a half word address) and
3904 H-0, upper address-0 = 000
3906 H-1, lower address-0 = 800
3908 They can be ordered either way, but the arm tools I've seen always put
3909 the lower one first. It probably doesn't matter. krk@cygnus.com
3911 XXX: Actually the order does matter. The second instruction (H-1)
3912 moves the computed address into the PC, so it must be the second one
3913 in the sequence. The problem, however is that whilst little endian code
3914 stores the instructions in HI then LOW order, big endian code does the
3915 reverse. nickc@cygnus.com. */
3917 #define LOW_HI_ORDER 0xF800F000
3918 #define HI_LOW_ORDER 0xF000F800
3921 insert_thumb_branch (insn32 br_insn
, int rel_off
)
3923 unsigned int low_bits
;
3924 unsigned int high_bits
;
3926 BFD_ASSERT ((rel_off
& 1) != 1);
3928 rel_off
>>= 1; /* Half word aligned address. */
3929 low_bits
= rel_off
& 0x000007FF; /* The bottom 11 bits. */
3930 high_bits
= (rel_off
>> 11) & 0x000007FF; /* The top 11 bits. */
3932 if ((br_insn
& LOW_HI_ORDER
) == LOW_HI_ORDER
)
3933 br_insn
= LOW_HI_ORDER
| (low_bits
<< 16) | high_bits
;
3934 else if ((br_insn
& HI_LOW_ORDER
) == HI_LOW_ORDER
)
3935 br_insn
= HI_LOW_ORDER
| (high_bits
<< 16) | low_bits
;
3937 /* FIXME: abort is probably not the right call. krk@cygnus.com */
3938 abort (); /* Error - not a valid branch instruction form. */
3944 /* Store an Arm insn into an output section not processed by
3945 elf32_arm_write_section. */
3948 put_arm_insn (struct elf32_arm_link_hash_table
*htab
,
3949 bfd
* output_bfd
, bfd_vma val
, void * ptr
)
3951 if (htab
->byteswap_code
!= bfd_little_endian (output_bfd
))
3952 bfd_putl32 (val
, ptr
);
3954 bfd_putb32 (val
, ptr
);
3958 /* Store a 16-bit Thumb insn into an output section not processed by
3959 elf32_arm_write_section. */
3962 put_thumb_insn (struct elf32_arm_link_hash_table
*htab
,
3963 bfd
* output_bfd
, bfd_vma val
, void * ptr
)
3965 if (htab
->byteswap_code
!= bfd_little_endian (output_bfd
))
3966 bfd_putl16 (val
, ptr
);
3968 bfd_putb16 (val
, ptr
);
3972 /* Thumb code calling an ARM function. */
3975 elf32_thumb_to_arm_stub (struct bfd_link_info
* info
,
3979 asection
* input_section
,
3980 bfd_byte
* hit_data
,
3983 bfd_signed_vma addend
,
3985 char **error_message
)
3989 unsigned long int tmp
;
3990 long int ret_offset
;
3991 struct elf_link_hash_entry
* myh
;
3992 struct elf32_arm_link_hash_table
* globals
;
3994 myh
= find_thumb_glue (info
, name
, error_message
);
3998 globals
= elf32_arm_hash_table (info
);
4000 BFD_ASSERT (globals
!= NULL
);
4001 BFD_ASSERT (globals
->bfd_of_glue_owner
!= NULL
);
4003 my_offset
= myh
->root
.u
.def
.value
;
4005 s
= bfd_get_section_by_name (globals
->bfd_of_glue_owner
,
4006 THUMB2ARM_GLUE_SECTION_NAME
);
4008 BFD_ASSERT (s
!= NULL
);
4009 BFD_ASSERT (s
->contents
!= NULL
);
4010 BFD_ASSERT (s
->output_section
!= NULL
);
4012 if ((my_offset
& 0x01) == 0x01)
4015 && sym_sec
->owner
!= NULL
4016 && !INTERWORK_FLAG (sym_sec
->owner
))
4018 (*_bfd_error_handler
)
4019 (_("%B(%s): warning: interworking not enabled.\n"
4020 " first occurrence: %B: thumb call to arm"),
4021 sym_sec
->owner
, input_bfd
, name
);
4027 myh
->root
.u
.def
.value
= my_offset
;
4029 put_thumb_insn (globals
, output_bfd
, (bfd_vma
) t2a1_bx_pc_insn
,
4030 s
->contents
+ my_offset
);
4032 put_thumb_insn (globals
, output_bfd
, (bfd_vma
) t2a2_noop_insn
,
4033 s
->contents
+ my_offset
+ 2);
4036 /* Address of destination of the stub. */
4037 ((bfd_signed_vma
) val
)
4039 /* Offset from the start of the current section
4040 to the start of the stubs. */
4042 /* Offset of the start of this stub from the start of the stubs. */
4044 /* Address of the start of the current section. */
4045 + s
->output_section
->vma
)
4046 /* The branch instruction is 4 bytes into the stub. */
4048 /* ARM branches work from the pc of the instruction + 8. */
4051 put_arm_insn (globals
, output_bfd
,
4052 (bfd_vma
) t2a3_b_insn
| ((ret_offset
>> 2) & 0x00FFFFFF),
4053 s
->contents
+ my_offset
+ 4);
4056 BFD_ASSERT (my_offset
<= globals
->thumb_glue_size
);
4058 /* Now go back and fix up the original BL insn to point to here. */
4060 /* Address of where the stub is located. */
4061 (s
->output_section
->vma
+ s
->output_offset
+ my_offset
)
4062 /* Address of where the BL is located. */
4063 - (input_section
->output_section
->vma
+ input_section
->output_offset
4065 /* Addend in the relocation. */
4067 /* Biassing for PC-relative addressing. */
4070 tmp
= bfd_get_32 (input_bfd
, hit_data
4071 - input_section
->vma
);
4073 bfd_put_32 (output_bfd
,
4074 (bfd_vma
) insert_thumb_branch (tmp
, ret_offset
),
4075 hit_data
- input_section
->vma
);
4080 /* Populate an Arm to Thumb stub. Returns the stub symbol. */
4082 static struct elf_link_hash_entry
*
4083 elf32_arm_create_thumb_stub (struct bfd_link_info
* info
,
4090 char **error_message
)
4093 long int ret_offset
;
4094 struct elf_link_hash_entry
* myh
;
4095 struct elf32_arm_link_hash_table
* globals
;
4097 myh
= find_arm_glue (info
, name
, error_message
);
4101 globals
= elf32_arm_hash_table (info
);
4103 BFD_ASSERT (globals
!= NULL
);
4104 BFD_ASSERT (globals
->bfd_of_glue_owner
!= NULL
);
4106 my_offset
= myh
->root
.u
.def
.value
;
4108 if ((my_offset
& 0x01) == 0x01)
4111 && sym_sec
->owner
!= NULL
4112 && !INTERWORK_FLAG (sym_sec
->owner
))
4114 (*_bfd_error_handler
)
4115 (_("%B(%s): warning: interworking not enabled.\n"
4116 " first occurrence: %B: arm call to thumb"),
4117 sym_sec
->owner
, input_bfd
, name
);
4121 myh
->root
.u
.def
.value
= my_offset
;
4123 if ((info
->shared
|| globals
->root
.is_relocatable_executable
))
4125 /* For relocatable objects we can't use absolute addresses,
4126 so construct the address from a relative offset. */
4127 /* TODO: If the offset is small it's probably worth
4128 constructing the address with adds. */
4129 put_arm_insn (globals
, output_bfd
, (bfd_vma
) a2t1p_ldr_insn
,
4130 s
->contents
+ my_offset
);
4131 put_arm_insn (globals
, output_bfd
, (bfd_vma
) a2t2p_add_pc_insn
,
4132 s
->contents
+ my_offset
+ 4);
4133 put_arm_insn (globals
, output_bfd
, (bfd_vma
) a2t3p_bx_r12_insn
,
4134 s
->contents
+ my_offset
+ 8);
4135 /* Adjust the offset by 4 for the position of the add,
4136 and 8 for the pipeline offset. */
4137 ret_offset
= (val
- (s
->output_offset
4138 + s
->output_section
->vma
4141 bfd_put_32 (output_bfd
, ret_offset
,
4142 s
->contents
+ my_offset
+ 12);
4146 put_arm_insn (globals
, output_bfd
, (bfd_vma
) a2t1_ldr_insn
,
4147 s
->contents
+ my_offset
);
4149 put_arm_insn (globals
, output_bfd
, (bfd_vma
) a2t2_bx_r12_insn
,
4150 s
->contents
+ my_offset
+ 4);
4152 /* It's a thumb address. Add the low order bit. */
4153 bfd_put_32 (output_bfd
, val
| a2t3_func_addr_insn
,
4154 s
->contents
+ my_offset
+ 8);
4158 BFD_ASSERT (my_offset
<= globals
->arm_glue_size
);
4163 /* Arm code calling a Thumb function. */
4166 elf32_arm_to_thumb_stub (struct bfd_link_info
* info
,
4170 asection
* input_section
,
4171 bfd_byte
* hit_data
,
4174 bfd_signed_vma addend
,
4176 char **error_message
)
4178 unsigned long int tmp
;
4181 long int ret_offset
;
4182 struct elf_link_hash_entry
* myh
;
4183 struct elf32_arm_link_hash_table
* globals
;
4185 globals
= elf32_arm_hash_table (info
);
4187 BFD_ASSERT (globals
!= NULL
);
4188 BFD_ASSERT (globals
->bfd_of_glue_owner
!= NULL
);
4190 s
= bfd_get_section_by_name (globals
->bfd_of_glue_owner
,
4191 ARM2THUMB_GLUE_SECTION_NAME
);
4192 BFD_ASSERT (s
!= NULL
);
4193 BFD_ASSERT (s
->contents
!= NULL
);
4194 BFD_ASSERT (s
->output_section
!= NULL
);
4196 myh
= elf32_arm_create_thumb_stub (info
, name
, input_bfd
, output_bfd
,
4197 sym_sec
, val
, s
, error_message
);
4201 my_offset
= myh
->root
.u
.def
.value
;
4202 tmp
= bfd_get_32 (input_bfd
, hit_data
);
4203 tmp
= tmp
& 0xFF000000;
4205 /* Somehow these are both 4 too far, so subtract 8. */
4206 ret_offset
= (s
->output_offset
4208 + s
->output_section
->vma
4209 - (input_section
->output_offset
4210 + input_section
->output_section
->vma
4214 tmp
= tmp
| ((ret_offset
>> 2) & 0x00FFFFFF);
4216 bfd_put_32 (output_bfd
, (bfd_vma
) tmp
, hit_data
- input_section
->vma
);
4221 /* Populate Arm stub for an exported Thumb function. */
4224 elf32_arm_to_thumb_export_stub (struct elf_link_hash_entry
*h
, void * inf
)
4226 struct bfd_link_info
* info
= (struct bfd_link_info
*) inf
;
4228 struct elf_link_hash_entry
* myh
;
4229 struct elf32_arm_link_hash_entry
*eh
;
4230 struct elf32_arm_link_hash_table
* globals
;
4233 char *error_message
;
4235 eh
= elf32_arm_hash_entry(h
);
4236 /* Allocate stubs for exported Thumb functions on v4t. */
4237 if (eh
->export_glue
== NULL
)
4240 globals
= elf32_arm_hash_table (info
);
4242 BFD_ASSERT (globals
!= NULL
);
4243 BFD_ASSERT (globals
->bfd_of_glue_owner
!= NULL
);
4245 s
= bfd_get_section_by_name (globals
->bfd_of_glue_owner
,
4246 ARM2THUMB_GLUE_SECTION_NAME
);
4247 BFD_ASSERT (s
!= NULL
);
4248 BFD_ASSERT (s
->contents
!= NULL
);
4249 BFD_ASSERT (s
->output_section
!= NULL
);
4251 sec
= eh
->export_glue
->root
.u
.def
.section
;
4253 BFD_ASSERT (sec
->output_section
!= NULL
);
4255 val
= eh
->export_glue
->root
.u
.def
.value
+ sec
->output_offset
4256 + sec
->output_section
->vma
;
4257 myh
= elf32_arm_create_thumb_stub (info
, h
->root
.root
.string
,
4258 h
->root
.u
.def
.section
->owner
,
4259 globals
->obfd
, sec
, val
, s
,
4265 /* Generate Arm stubs for exported Thumb symbols. */
4267 elf32_arm_begin_write_processing (bfd
*abfd ATTRIBUTE_UNUSED
,
4268 struct bfd_link_info
*link_info
)
4270 struct elf32_arm_link_hash_table
* globals
;
4275 globals
= elf32_arm_hash_table (link_info
);
4276 /* If blx is available then exported Thumb symbols are OK and there is
4278 if (globals
->use_blx
)
4281 elf_link_hash_traverse (&globals
->root
, elf32_arm_to_thumb_export_stub
,
4285 /* Some relocations map to different relocations depending on the
4286 target. Return the real relocation. */
4288 arm_real_reloc_type (struct elf32_arm_link_hash_table
* globals
,
4294 if (globals
->target1_is_rel
)
4300 return globals
->target2_reloc
;
4307 /* Return the base VMA address which should be subtracted from real addresses
4308 when resolving @dtpoff relocation.
4309 This is PT_TLS segment p_vaddr. */
4312 dtpoff_base (struct bfd_link_info
*info
)
4314 /* If tls_sec is NULL, we should have signalled an error already. */
4315 if (elf_hash_table (info
)->tls_sec
== NULL
)
4317 return elf_hash_table (info
)->tls_sec
->vma
;
4320 /* Return the relocation value for @tpoff relocation
4321 if STT_TLS virtual address is ADDRESS. */
4324 tpoff (struct bfd_link_info
*info
, bfd_vma address
)
4326 struct elf_link_hash_table
*htab
= elf_hash_table (info
);
4329 /* If tls_sec is NULL, we should have signalled an error already. */
4330 if (htab
->tls_sec
== NULL
)
4332 base
= align_power ((bfd_vma
) TCB_SIZE
, htab
->tls_sec
->alignment_power
);
4333 return address
- htab
->tls_sec
->vma
+ base
;
4336 /* Perform an R_ARM_ABS12 relocation on the field pointed to by DATA.
4337 VALUE is the relocation value. */
4339 static bfd_reloc_status_type
4340 elf32_arm_abs12_reloc (bfd
*abfd
, void *data
, bfd_vma value
)
4343 return bfd_reloc_overflow
;
4345 value
|= bfd_get_32 (abfd
, data
) & 0xfffff000;
4346 bfd_put_32 (abfd
, value
, data
);
4347 return bfd_reloc_ok
;
4350 /* For a given value of n, calculate the value of G_n as required to
4351 deal with group relocations. We return it in the form of an
4352 encoded constant-and-rotation, together with the final residual. If n is
4353 specified as less than zero, then final_residual is filled with the
4354 input value and no further action is performed. */
4357 calculate_group_reloc_mask (bfd_vma value
, int n
, bfd_vma
*final_residual
)
4361 bfd_vma encoded_g_n
= 0;
4362 bfd_vma residual
= value
; /* Also known as Y_n. */
4364 for (current_n
= 0; current_n
<= n
; current_n
++)
4368 /* Calculate which part of the value to mask. */
4375 /* Determine the most significant bit in the residual and
4376 align the resulting value to a 2-bit boundary. */
4377 for (msb
= 30; msb
>= 0; msb
-= 2)
4378 if (residual
& (3 << msb
))
4381 /* The desired shift is now (msb - 6), or zero, whichever
4388 /* Calculate g_n in 32-bit as well as encoded constant+rotation form. */
4389 g_n
= residual
& (0xff << shift
);
4390 encoded_g_n
= (g_n
>> shift
)
4391 | ((g_n
<= 0xff ? 0 : (32 - shift
) / 2) << 8);
4393 /* Calculate the residual for the next time around. */
4397 *final_residual
= residual
;
4402 /* Given an ARM instruction, determine whether it is an ADD or a SUB.
4403 Returns 1 if it is an ADD, -1 if it is a SUB, and 0 otherwise. */
4405 identify_add_or_sub(bfd_vma insn
)
4407 int opcode
= insn
& 0x1e00000;
4409 if (opcode
== 1 << 23) /* ADD */
4412 if (opcode
== 1 << 22) /* SUB */
4418 /* Determine if we're dealing with a Thumb-2 object. */
4420 static int using_thumb2 (struct elf32_arm_link_hash_table
*globals
)
4422 int arch
= elf32_arm_get_eabi_attr_int (globals
->obfd
, Tag_CPU_arch
);
4423 return arch
== TAG_CPU_ARCH_V6T2
|| arch
>= TAG_CPU_ARCH_V7
;
4426 /* Perform a relocation as part of a final link. */
4428 static bfd_reloc_status_type
4429 elf32_arm_final_link_relocate (reloc_howto_type
* howto
,
4432 asection
* input_section
,
4433 bfd_byte
* contents
,
4434 Elf_Internal_Rela
* rel
,
4436 struct bfd_link_info
* info
,
4438 const char * sym_name
,
4440 struct elf_link_hash_entry
* h
,
4441 bfd_boolean
* unresolved_reloc_p
,
4442 char **error_message
)
4444 unsigned long r_type
= howto
->type
;
4445 unsigned long r_symndx
;
4446 bfd_byte
* hit_data
= contents
+ rel
->r_offset
;
4447 bfd
* dynobj
= NULL
;
4448 Elf_Internal_Shdr
* symtab_hdr
;
4449 struct elf_link_hash_entry
** sym_hashes
;
4450 bfd_vma
* local_got_offsets
;
4451 asection
* sgot
= NULL
;
4452 asection
* splt
= NULL
;
4453 asection
* sreloc
= NULL
;
4455 bfd_signed_vma signed_addend
;
4456 struct elf32_arm_link_hash_table
* globals
;
4458 globals
= elf32_arm_hash_table (info
);
4460 /* Some relocation type map to different relocations depending on the
4461 target. We pick the right one here. */
4462 r_type
= arm_real_reloc_type (globals
, r_type
);
4463 if (r_type
!= howto
->type
)
4464 howto
= elf32_arm_howto_from_type (r_type
);
4466 /* If the start address has been set, then set the EF_ARM_HASENTRY
4467 flag. Setting this more than once is redundant, but the cost is
4468 not too high, and it keeps the code simple.
4470 The test is done here, rather than somewhere else, because the
4471 start address is only set just before the final link commences.
4473 Note - if the user deliberately sets a start address of 0, the
4474 flag will not be set. */
4475 if (bfd_get_start_address (output_bfd
) != 0)
4476 elf_elfheader (output_bfd
)->e_flags
|= EF_ARM_HASENTRY
;
4478 dynobj
= elf_hash_table (info
)->dynobj
;
4481 sgot
= bfd_get_section_by_name (dynobj
, ".got");
4482 splt
= bfd_get_section_by_name (dynobj
, ".plt");
4484 symtab_hdr
= & elf_tdata (input_bfd
)->symtab_hdr
;
4485 sym_hashes
= elf_sym_hashes (input_bfd
);
4486 local_got_offsets
= elf_local_got_offsets (input_bfd
);
4487 r_symndx
= ELF32_R_SYM (rel
->r_info
);
4489 if (globals
->use_rel
)
4491 addend
= bfd_get_32 (input_bfd
, hit_data
) & howto
->src_mask
;
4493 if (addend
& ((howto
->src_mask
+ 1) >> 1))
4496 signed_addend
&= ~ howto
->src_mask
;
4497 signed_addend
|= addend
;
4500 signed_addend
= addend
;
4503 addend
= signed_addend
= rel
->r_addend
;
4508 /* We don't need to find a value for this symbol. It's just a
4510 *unresolved_reloc_p
= FALSE
;
4511 return bfd_reloc_ok
;
4514 if (!globals
->vxworks_p
)
4515 return elf32_arm_abs12_reloc (input_bfd
, hit_data
, value
+ addend
);
4519 case R_ARM_ABS32_NOI
:
4521 case R_ARM_REL32_NOI
:
4527 /* r_symndx will be zero only for relocs against symbols
4528 from removed linkonce sections, or sections discarded by
4532 _bfd_clear_contents (howto
, input_bfd
, contents
+ rel
->r_offset
);
4533 return bfd_reloc_ok
;
4536 /* Handle relocations which should use the PLT entry. ABS32/REL32
4537 will use the symbol's value, which may point to a PLT entry, but we
4538 don't need to handle that here. If we created a PLT entry, all
4539 branches in this object should go to it. */
4540 if ((r_type
!= R_ARM_ABS32
&& r_type
!= R_ARM_REL32
4541 && r_type
!= R_ARM_ABS32_NOI
&& r_type
!= R_ARM_REL32_NOI
)
4544 && h
->plt
.offset
!= (bfd_vma
) -1)
4546 /* If we've created a .plt section, and assigned a PLT entry to
4547 this function, it should not be known to bind locally. If
4548 it were, we would have cleared the PLT entry. */
4549 BFD_ASSERT (!SYMBOL_CALLS_LOCAL (info
, h
));
4551 value
= (splt
->output_section
->vma
4552 + splt
->output_offset
4554 *unresolved_reloc_p
= FALSE
;
4555 return _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
4556 contents
, rel
->r_offset
, value
,
4560 /* When generating a shared object or relocatable executable, these
4561 relocations are copied into the output file to be resolved at
4563 if ((info
->shared
|| globals
->root
.is_relocatable_executable
)
4564 && (input_section
->flags
& SEC_ALLOC
)
4565 && ((r_type
!= R_ARM_REL32
&& r_type
!= R_ARM_REL32_NOI
)
4566 || !SYMBOL_CALLS_LOCAL (info
, h
))
4568 || ELF_ST_VISIBILITY (h
->other
) == STV_DEFAULT
4569 || h
->root
.type
!= bfd_link_hash_undefweak
)
4570 && r_type
!= R_ARM_PC24
4571 && r_type
!= R_ARM_CALL
4572 && r_type
!= R_ARM_JUMP24
4573 && r_type
!= R_ARM_PREL31
4574 && r_type
!= R_ARM_PLT32
)
4576 Elf_Internal_Rela outrel
;
4578 bfd_boolean skip
, relocate
;
4580 *unresolved_reloc_p
= FALSE
;
4586 name
= (bfd_elf_string_from_elf_section
4588 elf_elfheader (input_bfd
)->e_shstrndx
,
4589 elf_section_data (input_section
)->rel_hdr
.sh_name
));
4591 return bfd_reloc_notsupported
;
4593 BFD_ASSERT (reloc_section_p (globals
, name
, input_section
));
4595 sreloc
= bfd_get_section_by_name (dynobj
, name
);
4596 BFD_ASSERT (sreloc
!= NULL
);
4602 outrel
.r_addend
= addend
;
4604 _bfd_elf_section_offset (output_bfd
, info
, input_section
,
4606 if (outrel
.r_offset
== (bfd_vma
) -1)
4608 else if (outrel
.r_offset
== (bfd_vma
) -2)
4609 skip
= TRUE
, relocate
= TRUE
;
4610 outrel
.r_offset
+= (input_section
->output_section
->vma
4611 + input_section
->output_offset
);
4614 memset (&outrel
, 0, sizeof outrel
);
4619 || !h
->def_regular
))
4620 outrel
.r_info
= ELF32_R_INFO (h
->dynindx
, r_type
);
4625 /* This symbol is local, or marked to become local. */
4626 if (sym_flags
== STT_ARM_TFUNC
)
4628 if (globals
->symbian_p
)
4632 /* On Symbian OS, the data segment and text segement
4633 can be relocated independently. Therefore, we
4634 must indicate the segment to which this
4635 relocation is relative. The BPABI allows us to
4636 use any symbol in the right segment; we just use
4637 the section symbol as it is convenient. (We
4638 cannot use the symbol given by "h" directly as it
4639 will not appear in the dynamic symbol table.)
4641 Note that the dynamic linker ignores the section
4642 symbol value, so we don't subtract osec->vma
4643 from the emitted reloc addend. */
4645 osec
= sym_sec
->output_section
;
4647 osec
= input_section
->output_section
;
4648 symbol
= elf_section_data (osec
)->dynindx
;
4651 struct elf_link_hash_table
*htab
= elf_hash_table (info
);
4653 if ((osec
->flags
& SEC_READONLY
) == 0
4654 && htab
->data_index_section
!= NULL
)
4655 osec
= htab
->data_index_section
;
4657 osec
= htab
->text_index_section
;
4658 symbol
= elf_section_data (osec
)->dynindx
;
4660 BFD_ASSERT (symbol
!= 0);
4663 /* On SVR4-ish systems, the dynamic loader cannot
4664 relocate the text and data segments independently,
4665 so the symbol does not matter. */
4667 outrel
.r_info
= ELF32_R_INFO (symbol
, R_ARM_RELATIVE
);
4668 if (globals
->use_rel
)
4671 outrel
.r_addend
+= value
;
4674 loc
= sreloc
->contents
;
4675 loc
+= sreloc
->reloc_count
++ * RELOC_SIZE (globals
);
4676 SWAP_RELOC_OUT (globals
) (output_bfd
, &outrel
, loc
);
4678 /* If this reloc is against an external symbol, we do not want to
4679 fiddle with the addend. Otherwise, we need to include the symbol
4680 value so that it becomes an addend for the dynamic reloc. */
4682 return bfd_reloc_ok
;
4684 return _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
4685 contents
, rel
->r_offset
, value
,
4688 else switch (r_type
)
4691 return elf32_arm_abs12_reloc (input_bfd
, hit_data
, value
+ addend
);
4693 case R_ARM_XPC25
: /* Arm BLX instruction. */
4696 case R_ARM_PC24
: /* Arm B/BL instruction */
4698 if (r_type
== R_ARM_XPC25
)
4700 /* Check for Arm calling Arm function. */
4701 /* FIXME: Should we translate the instruction into a BL
4702 instruction instead ? */
4703 if (sym_flags
!= STT_ARM_TFUNC
)
4704 (*_bfd_error_handler
)
4705 (_("\%B: Warning: Arm BLX instruction targets Arm function '%s'."),
4707 h
? h
->root
.root
.string
: "(local)");
4709 else if (r_type
!= R_ARM_CALL
|| !globals
->use_blx
)
4711 /* Check for Arm calling Thumb function. */
4712 if (sym_flags
== STT_ARM_TFUNC
)
4714 if (elf32_arm_to_thumb_stub (info
, sym_name
, input_bfd
,
4715 output_bfd
, input_section
,
4716 hit_data
, sym_sec
, rel
->r_offset
,
4717 signed_addend
, value
,
4719 return bfd_reloc_ok
;
4721 return bfd_reloc_dangerous
;
4725 /* The ARM ELF ABI says that this reloc is computed as: S - P + A
4727 S is the address of the symbol in the relocation.
4728 P is address of the instruction being relocated.
4729 A is the addend (extracted from the instruction) in bytes.
4731 S is held in 'value'.
4732 P is the base address of the section containing the
4733 instruction plus the offset of the reloc into that
4735 (input_section->output_section->vma +
4736 input_section->output_offset +
4738 A is the addend, converted into bytes, ie:
4741 Note: None of these operations have knowledge of the pipeline
4742 size of the processor, thus it is up to the assembler to
4743 encode this information into the addend. */
4744 value
-= (input_section
->output_section
->vma
4745 + input_section
->output_offset
);
4746 value
-= rel
->r_offset
;
4747 if (globals
->use_rel
)
4748 value
+= (signed_addend
<< howto
->size
);
4750 /* RELA addends do not have to be adjusted by howto->size. */
4751 value
+= signed_addend
;
4753 signed_addend
= value
;
4754 signed_addend
>>= howto
->rightshift
;
4756 /* It is not an error for an undefined weak reference to be
4757 out of range. Any program that branches to such a symbol
4758 is going to crash anyway, so there is no point worrying
4759 about getting the destination exactly right. */
4760 if (! h
|| h
->root
.type
!= bfd_link_hash_undefweak
)
4762 /* Perform a signed range check. */
4763 if ( signed_addend
> ((bfd_signed_vma
) (howto
->dst_mask
>> 1))
4764 || signed_addend
< - ((bfd_signed_vma
) ((howto
->dst_mask
+ 1) >> 1)))
4765 return bfd_reloc_overflow
;
4768 addend
= (value
& 2);
4770 value
= (signed_addend
& howto
->dst_mask
)
4771 | (bfd_get_32 (input_bfd
, hit_data
) & (~ howto
->dst_mask
));
4773 /* Set the H bit in the BLX instruction. */
4774 if (sym_flags
== STT_ARM_TFUNC
)
4779 value
&= ~(bfd_vma
)(1 << 24);
4781 if (r_type
== R_ARM_CALL
)
4783 /* Select the correct instruction (BL or BLX). */
4784 if (sym_flags
== STT_ARM_TFUNC
)
4788 value
&= ~(bfd_vma
)(1 << 28);
4796 if (sym_flags
== STT_ARM_TFUNC
)
4800 case R_ARM_ABS32_NOI
:
4806 if (sym_flags
== STT_ARM_TFUNC
)
4808 value
-= (input_section
->output_section
->vma
4809 + input_section
->output_offset
+ rel
->r_offset
);
4812 case R_ARM_REL32_NOI
:
4814 value
-= (input_section
->output_section
->vma
4815 + input_section
->output_offset
+ rel
->r_offset
);
4819 value
-= (input_section
->output_section
->vma
4820 + input_section
->output_offset
+ rel
->r_offset
);
4821 value
+= signed_addend
;
4822 if (! h
|| h
->root
.type
!= bfd_link_hash_undefweak
)
4824 /* Check for overflow */
4825 if ((value
^ (value
>> 1)) & (1 << 30))
4826 return bfd_reloc_overflow
;
4828 value
&= 0x7fffffff;
4829 value
|= (bfd_get_32 (input_bfd
, hit_data
) & 0x80000000);
4830 if (sym_flags
== STT_ARM_TFUNC
)
4835 bfd_put_32 (input_bfd
, value
, hit_data
);
4836 return bfd_reloc_ok
;
4840 if ((long) value
> 0x7f || (long) value
< -0x80)
4841 return bfd_reloc_overflow
;
4843 bfd_put_8 (input_bfd
, value
, hit_data
);
4844 return bfd_reloc_ok
;
4849 if ((long) value
> 0x7fff || (long) value
< -0x8000)
4850 return bfd_reloc_overflow
;
4852 bfd_put_16 (input_bfd
, value
, hit_data
);
4853 return bfd_reloc_ok
;
4855 case R_ARM_THM_ABS5
:
4856 /* Support ldr and str instructions for the thumb. */
4857 if (globals
->use_rel
)
4859 /* Need to refetch addend. */
4860 addend
= bfd_get_16 (input_bfd
, hit_data
) & howto
->src_mask
;
4861 /* ??? Need to determine shift amount from operand size. */
4862 addend
>>= howto
->rightshift
;
4866 /* ??? Isn't value unsigned? */
4867 if ((long) value
> 0x1f || (long) value
< -0x10)
4868 return bfd_reloc_overflow
;
4870 /* ??? Value needs to be properly shifted into place first. */
4871 value
|= bfd_get_16 (input_bfd
, hit_data
) & 0xf83f;
4872 bfd_put_16 (input_bfd
, value
, hit_data
);
4873 return bfd_reloc_ok
;
4875 case R_ARM_THM_ALU_PREL_11_0
:
4876 /* Corresponds to: addw.w reg, pc, #offset (and similarly for subw). */
4879 bfd_signed_vma relocation
;
4881 insn
= (bfd_get_16 (input_bfd
, hit_data
) << 16)
4882 | bfd_get_16 (input_bfd
, hit_data
+ 2);
4884 if (globals
->use_rel
)
4886 signed_addend
= (insn
& 0xff) | ((insn
& 0x7000) >> 4)
4887 | ((insn
& (1 << 26)) >> 15);
4888 if (insn
& 0xf00000)
4889 signed_addend
= -signed_addend
;
4892 relocation
= value
+ signed_addend
;
4893 relocation
-= (input_section
->output_section
->vma
4894 + input_section
->output_offset
4897 value
= abs (relocation
);
4899 if (value
>= 0x1000)
4900 return bfd_reloc_overflow
;
4902 insn
= (insn
& 0xfb0f8f00) | (value
& 0xff)
4903 | ((value
& 0x700) << 4)
4904 | ((value
& 0x800) << 15);
4908 bfd_put_16 (input_bfd
, insn
>> 16, hit_data
);
4909 bfd_put_16 (input_bfd
, insn
& 0xffff, hit_data
+ 2);
4911 return bfd_reloc_ok
;
4914 case R_ARM_THM_PC12
:
4915 /* Corresponds to: ldr.w reg, [pc, #offset]. */
4918 bfd_signed_vma relocation
;
4920 insn
= (bfd_get_16 (input_bfd
, hit_data
) << 16)
4921 | bfd_get_16 (input_bfd
, hit_data
+ 2);
4923 if (globals
->use_rel
)
4925 signed_addend
= insn
& 0xfff;
4926 if (!(insn
& (1 << 23)))
4927 signed_addend
= -signed_addend
;
4930 relocation
= value
+ signed_addend
;
4931 relocation
-= (input_section
->output_section
->vma
4932 + input_section
->output_offset
4935 value
= abs (relocation
);
4937 if (value
>= 0x1000)
4938 return bfd_reloc_overflow
;
4940 insn
= (insn
& 0xff7ff000) | value
;
4941 if (relocation
>= 0)
4944 bfd_put_16 (input_bfd
, insn
>> 16, hit_data
);
4945 bfd_put_16 (input_bfd
, insn
& 0xffff, hit_data
+ 2);
4947 return bfd_reloc_ok
;
4950 case R_ARM_THM_XPC22
:
4951 case R_ARM_THM_CALL
:
4952 /* Thumb BL (branch long instruction). */
4956 bfd_boolean overflow
= FALSE
;
4957 bfd_vma upper_insn
= bfd_get_16 (input_bfd
, hit_data
);
4958 bfd_vma lower_insn
= bfd_get_16 (input_bfd
, hit_data
+ 2);
4959 bfd_signed_vma reloc_signed_max
;
4960 bfd_signed_vma reloc_signed_min
;
4962 bfd_signed_vma signed_check
;
4964 int thumb2
= using_thumb2 (globals
);
4966 /* Fetch the addend. We use the Thumb-2 encoding (backwards compatible
4967 with Thumb-1) involving the J1 and J2 bits. */
4968 if (globals
->use_rel
)
4970 bfd_vma s
= (upper_insn
& (1 << 10)) >> 10;
4971 bfd_vma upper
= upper_insn
& 0x3ff;
4972 bfd_vma lower
= lower_insn
& 0x7ff;
4973 bfd_vma j1
= (lower_insn
& (1 << 13)) >> 13;
4974 bfd_vma j2
= (lower_insn
& (1 << 11)) >> 11;
4975 bfd_vma i1
= j1
^ s
? 0 : 1;
4976 bfd_vma i2
= j2
^ s
? 0 : 1;
4978 addend
= (i1
<< 23) | (i2
<< 22) | (upper
<< 12) | (lower
<< 1);
4980 addend
= (addend
| ((s
? 0 : 1) << 24)) - (1 << 24);
4982 signed_addend
= addend
;
4985 if (r_type
== R_ARM_THM_XPC22
)
4987 /* Check for Thumb to Thumb call. */
4988 /* FIXME: Should we translate the instruction into a BL
4989 instruction instead ? */
4990 if (sym_flags
== STT_ARM_TFUNC
)
4991 (*_bfd_error_handler
)
4992 (_("%B: Warning: Thumb BLX instruction targets thumb function '%s'."),
4994 h
? h
->root
.root
.string
: "(local)");
4998 /* If it is not a call to Thumb, assume call to Arm.
4999 If it is a call relative to a section name, then it is not a
5000 function call at all, but rather a long jump. Calls through
5001 the PLT do not require stubs. */
5002 if (sym_flags
!= STT_ARM_TFUNC
&& sym_flags
!= STT_SECTION
5003 && (h
== NULL
|| splt
== NULL
5004 || h
->plt
.offset
== (bfd_vma
) -1))
5006 if (globals
->use_blx
)
5008 /* Convert BL to BLX. */
5009 lower_insn
= (lower_insn
& ~0x1000) | 0x0800;
5011 else if (elf32_thumb_to_arm_stub
5012 (info
, sym_name
, input_bfd
, output_bfd
, input_section
,
5013 hit_data
, sym_sec
, rel
->r_offset
, signed_addend
, value
,
5015 return bfd_reloc_ok
;
5017 return bfd_reloc_dangerous
;
5019 else if (sym_flags
== STT_ARM_TFUNC
&& globals
->use_blx
)
5021 /* Make sure this is a BL. */
5022 lower_insn
|= 0x1800;
5026 /* Handle calls via the PLT. */
5027 if (h
!= NULL
&& splt
!= NULL
&& h
->plt
.offset
!= (bfd_vma
) -1)
5029 value
= (splt
->output_section
->vma
5030 + splt
->output_offset
5032 if (globals
->use_blx
)
5034 /* If the Thumb BLX instruction is available, convert the
5035 BL to a BLX instruction to call the ARM-mode PLT entry. */
5036 lower_insn
= (lower_insn
& ~0x1000) | 0x0800;
5039 /* Target the Thumb stub before the ARM PLT entry. */
5040 value
-= PLT_THUMB_STUB_SIZE
;
5041 *unresolved_reloc_p
= FALSE
;
5044 relocation
= value
+ signed_addend
;
5046 relocation
-= (input_section
->output_section
->vma
5047 + input_section
->output_offset
5050 check
= relocation
>> howto
->rightshift
;
5052 /* If this is a signed value, the rightshift just dropped
5053 leading 1 bits (assuming twos complement). */
5054 if ((bfd_signed_vma
) relocation
>= 0)
5055 signed_check
= check
;
5057 signed_check
= check
| ~((bfd_vma
) -1 >> howto
->rightshift
);
5059 /* Calculate the permissable maximum and minimum values for
5060 this relocation according to whether we're relocating for
5062 bitsize
= howto
->bitsize
;
5065 reloc_signed_max
= ((1 << (bitsize
- 1)) - 1) >> howto
->rightshift
;
5066 reloc_signed_min
= ~reloc_signed_max
;
5068 /* Assumes two's complement. */
5069 if (signed_check
> reloc_signed_max
|| signed_check
< reloc_signed_min
)
5072 if ((lower_insn
& 0x1800) == 0x0800)
5073 /* For a BLX instruction, make sure that the relocation is rounded up
5074 to a word boundary. This follows the semantics of the instruction
5075 which specifies that bit 1 of the target address will come from bit
5076 1 of the base address. */
5077 relocation
= (relocation
+ 2) & ~ 3;
5079 /* Put RELOCATION back into the insn. Assumes two's complement.
5080 We use the Thumb-2 encoding, which is safe even if dealing with
5081 a Thumb-1 instruction by virtue of our overflow check above. */
5082 reloc_sign
= (signed_check
< 0) ? 1 : 0;
5083 upper_insn
= (upper_insn
& ~(bfd_vma
) 0x7ff)
5084 | ((relocation
>> 12) & 0x3ff)
5085 | (reloc_sign
<< 10);
5086 lower_insn
= (lower_insn
& ~(bfd_vma
) 0x2fff)
5087 | (((!((relocation
>> 23) & 1)) ^ reloc_sign
) << 13)
5088 | (((!((relocation
>> 22) & 1)) ^ reloc_sign
) << 11)
5089 | ((relocation
>> 1) & 0x7ff);
5091 /* Put the relocated value back in the object file: */
5092 bfd_put_16 (input_bfd
, upper_insn
, hit_data
);
5093 bfd_put_16 (input_bfd
, lower_insn
, hit_data
+ 2);
5095 return (overflow
? bfd_reloc_overflow
: bfd_reloc_ok
);
5099 case R_ARM_THM_JUMP24
:
5100 /* Thumb32 unconditional branch instruction. */
5103 bfd_boolean overflow
= FALSE
;
5104 bfd_vma upper_insn
= bfd_get_16 (input_bfd
, hit_data
);
5105 bfd_vma lower_insn
= bfd_get_16 (input_bfd
, hit_data
+ 2);
5106 bfd_signed_vma reloc_signed_max
= ((1 << (howto
->bitsize
- 1)) - 1) >> howto
->rightshift
;
5107 bfd_signed_vma reloc_signed_min
= ~ reloc_signed_max
;
5109 bfd_signed_vma signed_check
;
5111 /* Need to refetch the addend, reconstruct the top three bits, and glue the
5112 two pieces together. */
5113 if (globals
->use_rel
)
5115 bfd_vma S
= (upper_insn
& 0x0400) >> 10;
5116 bfd_vma hi
= (upper_insn
& 0x03ff);
5117 bfd_vma I1
= (lower_insn
& 0x2000) >> 13;
5118 bfd_vma I2
= (lower_insn
& 0x0800) >> 11;
5119 bfd_vma lo
= (lower_insn
& 0x07ff);
5125 signed_addend
= (S
<< 24) | (I1
<< 23) | (I2
<< 22) | (hi
<< 12) | (lo
<< 1);
5126 signed_addend
-= (1 << 24); /* Sign extend. */
5129 /* ??? Should handle interworking? GCC might someday try to
5130 use this for tail calls. */
5132 relocation
= value
+ signed_addend
;
5133 relocation
-= (input_section
->output_section
->vma
5134 + input_section
->output_offset
5137 check
= relocation
>> howto
->rightshift
;
5139 /* If this is a signed value, the rightshift just dropped
5140 leading 1 bits (assuming twos complement). */
5141 if ((bfd_signed_vma
) relocation
>= 0)
5142 signed_check
= check
;
5144 signed_check
= check
| ~((bfd_vma
) -1 >> howto
->rightshift
);
5146 /* Assumes two's complement. */
5147 if (signed_check
> reloc_signed_max
|| signed_check
< reloc_signed_min
)
5150 /* Put RELOCATION back into the insn. */
5152 bfd_vma S
= (relocation
& 0x01000000) >> 24;
5153 bfd_vma I1
= (relocation
& 0x00800000) >> 23;
5154 bfd_vma I2
= (relocation
& 0x00400000) >> 22;
5155 bfd_vma hi
= (relocation
& 0x003ff000) >> 12;
5156 bfd_vma lo
= (relocation
& 0x00000ffe) >> 1;
5161 upper_insn
= (upper_insn
& (bfd_vma
) 0xf800) | (S
<< 10) | hi
;
5162 lower_insn
= (lower_insn
& (bfd_vma
) 0xd000) | (I1
<< 13) | (I2
<< 11) | lo
;
5165 /* Put the relocated value back in the object file: */
5166 bfd_put_16 (input_bfd
, upper_insn
, hit_data
);
5167 bfd_put_16 (input_bfd
, lower_insn
, hit_data
+ 2);
5169 return (overflow
? bfd_reloc_overflow
: bfd_reloc_ok
);
5172 case R_ARM_THM_JUMP19
:
5173 /* Thumb32 conditional branch instruction. */
5176 bfd_boolean overflow
= FALSE
;
5177 bfd_vma upper_insn
= bfd_get_16 (input_bfd
, hit_data
);
5178 bfd_vma lower_insn
= bfd_get_16 (input_bfd
, hit_data
+ 2);
5179 bfd_signed_vma reloc_signed_max
= ((1 << (howto
->bitsize
- 1)) - 1) >> howto
->rightshift
;
5180 bfd_signed_vma reloc_signed_min
= ~ reloc_signed_max
;
5182 bfd_signed_vma signed_check
;
5184 /* Need to refetch the addend, reconstruct the top three bits,
5185 and squish the two 11 bit pieces together. */
5186 if (globals
->use_rel
)
5188 bfd_vma S
= (upper_insn
& 0x0400) >> 10;
5189 bfd_vma upper
= (upper_insn
& 0x001f);
5190 bfd_vma J1
= (lower_insn
& 0x2000) >> 13;
5191 bfd_vma J2
= (lower_insn
& 0x0800) >> 11;
5192 bfd_vma lower
= (lower_insn
& 0x07ff);
5197 upper
-= 0x0100; /* Sign extend. */
5199 addend
= (upper
<< 12) | (lower
<< 1);
5200 signed_addend
= addend
;
5203 /* ??? Should handle interworking? GCC might someday try to
5204 use this for tail calls. */
5206 relocation
= value
+ signed_addend
;
5207 relocation
-= (input_section
->output_section
->vma
5208 + input_section
->output_offset
5211 check
= relocation
>> howto
->rightshift
;
5213 /* If this is a signed value, the rightshift just dropped
5214 leading 1 bits (assuming twos complement). */
5215 if ((bfd_signed_vma
) relocation
>= 0)
5216 signed_check
= check
;
5218 signed_check
= check
| ~((bfd_vma
) -1 >> howto
->rightshift
);
5220 /* Assumes two's complement. */
5221 if (signed_check
> reloc_signed_max
|| signed_check
< reloc_signed_min
)
5224 /* Put RELOCATION back into the insn. */
5226 bfd_vma S
= (relocation
& 0x00100000) >> 20;
5227 bfd_vma J2
= (relocation
& 0x00080000) >> 19;
5228 bfd_vma J1
= (relocation
& 0x00040000) >> 18;
5229 bfd_vma hi
= (relocation
& 0x0003f000) >> 12;
5230 bfd_vma lo
= (relocation
& 0x00000ffe) >> 1;
5232 upper_insn
= (upper_insn
& 0xfb30) | (S
<< 10) | hi
;
5233 lower_insn
= (lower_insn
& 0xd000) | (J1
<< 13) | (J2
<< 11) | lo
;
5236 /* Put the relocated value back in the object file: */
5237 bfd_put_16 (input_bfd
, upper_insn
, hit_data
);
5238 bfd_put_16 (input_bfd
, lower_insn
, hit_data
+ 2);
5240 return (overflow
? bfd_reloc_overflow
: bfd_reloc_ok
);
5243 case R_ARM_THM_JUMP11
:
5244 case R_ARM_THM_JUMP8
:
5245 case R_ARM_THM_JUMP6
:
5246 /* Thumb B (branch) instruction). */
5248 bfd_signed_vma relocation
;
5249 bfd_signed_vma reloc_signed_max
= (1 << (howto
->bitsize
- 1)) - 1;
5250 bfd_signed_vma reloc_signed_min
= ~ reloc_signed_max
;
5251 bfd_signed_vma signed_check
;
5253 /* CZB cannot jump backward. */
5254 if (r_type
== R_ARM_THM_JUMP6
)
5255 reloc_signed_min
= 0;
5257 if (globals
->use_rel
)
5259 /* Need to refetch addend. */
5260 addend
= bfd_get_16 (input_bfd
, hit_data
) & howto
->src_mask
;
5261 if (addend
& ((howto
->src_mask
+ 1) >> 1))
5264 signed_addend
&= ~ howto
->src_mask
;
5265 signed_addend
|= addend
;
5268 signed_addend
= addend
;
5269 /* The value in the insn has been right shifted. We need to
5270 undo this, so that we can perform the address calculation
5271 in terms of bytes. */
5272 signed_addend
<<= howto
->rightshift
;
5274 relocation
= value
+ signed_addend
;
5276 relocation
-= (input_section
->output_section
->vma
5277 + input_section
->output_offset
5280 relocation
>>= howto
->rightshift
;
5281 signed_check
= relocation
;
5283 if (r_type
== R_ARM_THM_JUMP6
)
5284 relocation
= ((relocation
& 0x0020) << 4) | ((relocation
& 0x001f) << 3);
5286 relocation
&= howto
->dst_mask
;
5287 relocation
|= (bfd_get_16 (input_bfd
, hit_data
) & (~ howto
->dst_mask
));
5289 bfd_put_16 (input_bfd
, relocation
, hit_data
);
5291 /* Assumes two's complement. */
5292 if (signed_check
> reloc_signed_max
|| signed_check
< reloc_signed_min
)
5293 return bfd_reloc_overflow
;
5295 return bfd_reloc_ok
;
5298 case R_ARM_ALU_PCREL7_0
:
5299 case R_ARM_ALU_PCREL15_8
:
5300 case R_ARM_ALU_PCREL23_15
:
5305 insn
= bfd_get_32 (input_bfd
, hit_data
);
5306 if (globals
->use_rel
)
5308 /* Extract the addend. */
5309 addend
= (insn
& 0xff) << ((insn
& 0xf00) >> 7);
5310 signed_addend
= addend
;
5312 relocation
= value
+ signed_addend
;
5314 relocation
-= (input_section
->output_section
->vma
5315 + input_section
->output_offset
5317 insn
= (insn
& ~0xfff)
5318 | ((howto
->bitpos
<< 7) & 0xf00)
5319 | ((relocation
>> howto
->bitpos
) & 0xff);
5320 bfd_put_32 (input_bfd
, value
, hit_data
);
5322 return bfd_reloc_ok
;
5324 case R_ARM_GNU_VTINHERIT
:
5325 case R_ARM_GNU_VTENTRY
:
5326 return bfd_reloc_ok
;
5328 case R_ARM_GOTOFF32
:
5329 /* Relocation is relative to the start of the
5330 global offset table. */
5332 BFD_ASSERT (sgot
!= NULL
);
5334 return bfd_reloc_notsupported
;
5336 /* If we are addressing a Thumb function, we need to adjust the
5337 address by one, so that attempts to call the function pointer will
5338 correctly interpret it as Thumb code. */
5339 if (sym_flags
== STT_ARM_TFUNC
)
5342 /* Note that sgot->output_offset is not involved in this
5343 calculation. We always want the start of .got. If we
5344 define _GLOBAL_OFFSET_TABLE in a different way, as is
5345 permitted by the ABI, we might have to change this
5347 value
-= sgot
->output_section
->vma
;
5348 return _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
5349 contents
, rel
->r_offset
, value
,
5353 /* Use global offset table as symbol value. */
5354 BFD_ASSERT (sgot
!= NULL
);
5357 return bfd_reloc_notsupported
;
5359 *unresolved_reloc_p
= FALSE
;
5360 value
= sgot
->output_section
->vma
;
5361 return _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
5362 contents
, rel
->r_offset
, value
,
5366 case R_ARM_GOT_PREL
:
5367 /* Relocation is to the entry for this symbol in the
5368 global offset table. */
5370 return bfd_reloc_notsupported
;
5377 off
= h
->got
.offset
;
5378 BFD_ASSERT (off
!= (bfd_vma
) -1);
5379 dyn
= globals
->root
.dynamic_sections_created
;
5381 if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn
, info
->shared
, h
)
5383 && SYMBOL_REFERENCES_LOCAL (info
, h
))
5384 || (ELF_ST_VISIBILITY (h
->other
)
5385 && h
->root
.type
== bfd_link_hash_undefweak
))
5387 /* This is actually a static link, or it is a -Bsymbolic link
5388 and the symbol is defined locally. We must initialize this
5389 entry in the global offset table. Since the offset must
5390 always be a multiple of 4, we use the least significant bit
5391 to record whether we have initialized it already.
5393 When doing a dynamic link, we create a .rel(a).got relocation
5394 entry to initialize the value. This is done in the
5395 finish_dynamic_symbol routine. */
5400 /* If we are addressing a Thumb function, we need to
5401 adjust the address by one, so that attempts to
5402 call the function pointer will correctly
5403 interpret it as Thumb code. */
5404 if (sym_flags
== STT_ARM_TFUNC
)
5407 bfd_put_32 (output_bfd
, value
, sgot
->contents
+ off
);
5412 *unresolved_reloc_p
= FALSE
;
5414 value
= sgot
->output_offset
+ off
;
5420 BFD_ASSERT (local_got_offsets
!= NULL
&&
5421 local_got_offsets
[r_symndx
] != (bfd_vma
) -1);
5423 off
= local_got_offsets
[r_symndx
];
5425 /* The offset must always be a multiple of 4. We use the
5426 least significant bit to record whether we have already
5427 generated the necessary reloc. */
5432 /* If we are addressing a Thumb function, we need to
5433 adjust the address by one, so that attempts to
5434 call the function pointer will correctly
5435 interpret it as Thumb code. */
5436 if (sym_flags
== STT_ARM_TFUNC
)
5439 if (globals
->use_rel
)
5440 bfd_put_32 (output_bfd
, value
, sgot
->contents
+ off
);
5445 Elf_Internal_Rela outrel
;
5448 srelgot
= (bfd_get_section_by_name
5449 (dynobj
, RELOC_SECTION (globals
, ".got")));
5450 BFD_ASSERT (srelgot
!= NULL
);
5452 outrel
.r_addend
= addend
+ value
;
5453 outrel
.r_offset
= (sgot
->output_section
->vma
5454 + sgot
->output_offset
5456 outrel
.r_info
= ELF32_R_INFO (0, R_ARM_RELATIVE
);
5457 loc
= srelgot
->contents
;
5458 loc
+= srelgot
->reloc_count
++ * RELOC_SIZE (globals
);
5459 SWAP_RELOC_OUT (globals
) (output_bfd
, &outrel
, loc
);
5462 local_got_offsets
[r_symndx
] |= 1;
5465 value
= sgot
->output_offset
+ off
;
5467 if (r_type
!= R_ARM_GOT32
)
5468 value
+= sgot
->output_section
->vma
;
5470 return _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
5471 contents
, rel
->r_offset
, value
,
5474 case R_ARM_TLS_LDO32
:
5475 value
= value
- dtpoff_base (info
);
5477 return _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
5478 contents
, rel
->r_offset
, value
,
5481 case R_ARM_TLS_LDM32
:
5485 if (globals
->sgot
== NULL
)
5488 off
= globals
->tls_ldm_got
.offset
;
5494 /* If we don't know the module number, create a relocation
5498 Elf_Internal_Rela outrel
;
5501 if (globals
->srelgot
== NULL
)
5504 outrel
.r_addend
= 0;
5505 outrel
.r_offset
= (globals
->sgot
->output_section
->vma
5506 + globals
->sgot
->output_offset
+ off
);
5507 outrel
.r_info
= ELF32_R_INFO (0, R_ARM_TLS_DTPMOD32
);
5509 if (globals
->use_rel
)
5510 bfd_put_32 (output_bfd
, outrel
.r_addend
,
5511 globals
->sgot
->contents
+ off
);
5513 loc
= globals
->srelgot
->contents
;
5514 loc
+= globals
->srelgot
->reloc_count
++ * RELOC_SIZE (globals
);
5515 SWAP_RELOC_OUT (globals
) (output_bfd
, &outrel
, loc
);
5518 bfd_put_32 (output_bfd
, 1, globals
->sgot
->contents
+ off
);
5520 globals
->tls_ldm_got
.offset
|= 1;
5523 value
= globals
->sgot
->output_section
->vma
+ globals
->sgot
->output_offset
+ off
5524 - (input_section
->output_section
->vma
+ input_section
->output_offset
+ rel
->r_offset
);
5526 return _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
5527 contents
, rel
->r_offset
, value
,
5531 case R_ARM_TLS_GD32
:
5532 case R_ARM_TLS_IE32
:
5538 if (globals
->sgot
== NULL
)
5545 dyn
= globals
->root
.dynamic_sections_created
;
5546 if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn
, info
->shared
, h
)
5548 || !SYMBOL_REFERENCES_LOCAL (info
, h
)))
5550 *unresolved_reloc_p
= FALSE
;
5553 off
= h
->got
.offset
;
5554 tls_type
= ((struct elf32_arm_link_hash_entry
*) h
)->tls_type
;
5558 if (local_got_offsets
== NULL
)
5560 off
= local_got_offsets
[r_symndx
];
5561 tls_type
= elf32_arm_local_got_tls_type (input_bfd
)[r_symndx
];
5564 if (tls_type
== GOT_UNKNOWN
)
5571 bfd_boolean need_relocs
= FALSE
;
5572 Elf_Internal_Rela outrel
;
5573 bfd_byte
*loc
= NULL
;
5576 /* The GOT entries have not been initialized yet. Do it
5577 now, and emit any relocations. If both an IE GOT and a
5578 GD GOT are necessary, we emit the GD first. */
5580 if ((info
->shared
|| indx
!= 0)
5582 || ELF_ST_VISIBILITY (h
->other
) == STV_DEFAULT
5583 || h
->root
.type
!= bfd_link_hash_undefweak
))
5586 if (globals
->srelgot
== NULL
)
5588 loc
= globals
->srelgot
->contents
;
5589 loc
+= globals
->srelgot
->reloc_count
* RELOC_SIZE (globals
);
5592 if (tls_type
& GOT_TLS_GD
)
5596 outrel
.r_addend
= 0;
5597 outrel
.r_offset
= (globals
->sgot
->output_section
->vma
5598 + globals
->sgot
->output_offset
5600 outrel
.r_info
= ELF32_R_INFO (indx
, R_ARM_TLS_DTPMOD32
);
5602 if (globals
->use_rel
)
5603 bfd_put_32 (output_bfd
, outrel
.r_addend
,
5604 globals
->sgot
->contents
+ cur_off
);
5606 SWAP_RELOC_OUT (globals
) (output_bfd
, &outrel
, loc
);
5607 globals
->srelgot
->reloc_count
++;
5608 loc
+= RELOC_SIZE (globals
);
5611 bfd_put_32 (output_bfd
, value
- dtpoff_base (info
),
5612 globals
->sgot
->contents
+ cur_off
+ 4);
5615 outrel
.r_addend
= 0;
5616 outrel
.r_info
= ELF32_R_INFO (indx
,
5617 R_ARM_TLS_DTPOFF32
);
5618 outrel
.r_offset
+= 4;
5620 if (globals
->use_rel
)
5621 bfd_put_32 (output_bfd
, outrel
.r_addend
,
5622 globals
->sgot
->contents
+ cur_off
+ 4);
5625 SWAP_RELOC_OUT (globals
) (output_bfd
, &outrel
, loc
);
5626 globals
->srelgot
->reloc_count
++;
5627 loc
+= RELOC_SIZE (globals
);
5632 /* If we are not emitting relocations for a
5633 general dynamic reference, then we must be in a
5634 static link or an executable link with the
5635 symbol binding locally. Mark it as belonging
5636 to module 1, the executable. */
5637 bfd_put_32 (output_bfd
, 1,
5638 globals
->sgot
->contents
+ cur_off
);
5639 bfd_put_32 (output_bfd
, value
- dtpoff_base (info
),
5640 globals
->sgot
->contents
+ cur_off
+ 4);
5646 if (tls_type
& GOT_TLS_IE
)
5651 outrel
.r_addend
= value
- dtpoff_base (info
);
5653 outrel
.r_addend
= 0;
5654 outrel
.r_offset
= (globals
->sgot
->output_section
->vma
5655 + globals
->sgot
->output_offset
5657 outrel
.r_info
= ELF32_R_INFO (indx
, R_ARM_TLS_TPOFF32
);
5659 if (globals
->use_rel
)
5660 bfd_put_32 (output_bfd
, outrel
.r_addend
,
5661 globals
->sgot
->contents
+ cur_off
);
5663 SWAP_RELOC_OUT (globals
) (output_bfd
, &outrel
, loc
);
5664 globals
->srelgot
->reloc_count
++;
5665 loc
+= RELOC_SIZE (globals
);
5668 bfd_put_32 (output_bfd
, tpoff (info
, value
),
5669 globals
->sgot
->contents
+ cur_off
);
5676 local_got_offsets
[r_symndx
] |= 1;
5679 if ((tls_type
& GOT_TLS_GD
) && r_type
!= R_ARM_TLS_GD32
)
5681 value
= globals
->sgot
->output_section
->vma
+ globals
->sgot
->output_offset
+ off
5682 - (input_section
->output_section
->vma
+ input_section
->output_offset
+ rel
->r_offset
);
5684 return _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
5685 contents
, rel
->r_offset
, value
,
5689 case R_ARM_TLS_LE32
:
5692 (*_bfd_error_handler
)
5693 (_("%B(%A+0x%lx): R_ARM_TLS_LE32 relocation not permitted in shared object"),
5694 input_bfd
, input_section
,
5695 (long) rel
->r_offset
, howto
->name
);
5699 value
= tpoff (info
, value
);
5701 return _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
5702 contents
, rel
->r_offset
, value
,
5706 if (globals
->fix_v4bx
)
5708 bfd_vma insn
= bfd_get_32 (input_bfd
, hit_data
);
5710 /* Ensure that we have a BX instruction. */
5711 BFD_ASSERT ((insn
& 0x0ffffff0) == 0x012fff10);
5713 /* Preserve Rm (lowest four bits) and the condition code
5714 (highest four bits). Other bits encode MOV PC,Rm. */
5715 insn
= (insn
& 0xf000000f) | 0x01a0f000;
5717 bfd_put_32 (input_bfd
, insn
, hit_data
);
5719 return bfd_reloc_ok
;
5721 case R_ARM_MOVW_ABS_NC
:
5722 case R_ARM_MOVT_ABS
:
5723 case R_ARM_MOVW_PREL_NC
:
5724 case R_ARM_MOVT_PREL
:
5725 /* Until we properly support segment-base-relative addressing then
5726 we assume the segment base to be zero, as for the group relocations.
5727 Thus R_ARM_MOVW_BREL_NC has the same semantics as R_ARM_MOVW_ABS_NC
5728 and R_ARM_MOVT_BREL has the same semantics as R_ARM_MOVT_ABS. */
5729 case R_ARM_MOVW_BREL_NC
:
5730 case R_ARM_MOVW_BREL
:
5731 case R_ARM_MOVT_BREL
:
5733 bfd_vma insn
= bfd_get_32 (input_bfd
, hit_data
);
5735 if (globals
->use_rel
)
5737 addend
= ((insn
>> 4) & 0xf000) | (insn
& 0xfff);
5738 signed_addend
= (addend
^ 0x10000) - 0x10000;
5741 value
+= signed_addend
;
5743 if (r_type
== R_ARM_MOVW_PREL_NC
|| r_type
== R_ARM_MOVT_PREL
)
5744 value
-= (input_section
->output_section
->vma
5745 + input_section
->output_offset
+ rel
->r_offset
);
5747 if (r_type
== R_ARM_MOVW_BREL
&& value
>= 0x10000)
5748 return bfd_reloc_overflow
;
5750 if (sym_flags
== STT_ARM_TFUNC
)
5753 if (r_type
== R_ARM_MOVT_ABS
|| r_type
== R_ARM_MOVT_PREL
5754 || r_type
== R_ARM_MOVT_BREL
)
5758 insn
|= value
& 0xfff;
5759 insn
|= (value
& 0xf000) << 4;
5760 bfd_put_32 (input_bfd
, insn
, hit_data
);
5762 return bfd_reloc_ok
;
5764 case R_ARM_THM_MOVW_ABS_NC
:
5765 case R_ARM_THM_MOVT_ABS
:
5766 case R_ARM_THM_MOVW_PREL_NC
:
5767 case R_ARM_THM_MOVT_PREL
:
5768 /* Until we properly support segment-base-relative addressing then
5769 we assume the segment base to be zero, as for the above relocations.
5770 Thus R_ARM_THM_MOVW_BREL_NC has the same semantics as
5771 R_ARM_THM_MOVW_ABS_NC and R_ARM_THM_MOVT_BREL has the same semantics
5772 as R_ARM_THM_MOVT_ABS. */
5773 case R_ARM_THM_MOVW_BREL_NC
:
5774 case R_ARM_THM_MOVW_BREL
:
5775 case R_ARM_THM_MOVT_BREL
:
5779 insn
= bfd_get_16 (input_bfd
, hit_data
) << 16;
5780 insn
|= bfd_get_16 (input_bfd
, hit_data
+ 2);
5782 if (globals
->use_rel
)
5784 addend
= ((insn
>> 4) & 0xf000)
5785 | ((insn
>> 15) & 0x0800)
5786 | ((insn
>> 4) & 0x0700)
5788 signed_addend
= (addend
^ 0x10000) - 0x10000;
5791 value
+= signed_addend
;
5793 if (r_type
== R_ARM_THM_MOVW_PREL_NC
|| r_type
== R_ARM_THM_MOVT_PREL
)
5794 value
-= (input_section
->output_section
->vma
5795 + input_section
->output_offset
+ rel
->r_offset
);
5797 if (r_type
== R_ARM_THM_MOVW_BREL
&& value
>= 0x10000)
5798 return bfd_reloc_overflow
;
5800 if (sym_flags
== STT_ARM_TFUNC
)
5803 if (r_type
== R_ARM_THM_MOVT_ABS
|| r_type
== R_ARM_THM_MOVT_PREL
5804 || r_type
== R_ARM_THM_MOVT_BREL
)
5808 insn
|= (value
& 0xf000) << 4;
5809 insn
|= (value
& 0x0800) << 15;
5810 insn
|= (value
& 0x0700) << 4;
5811 insn
|= (value
& 0x00ff);
5813 bfd_put_16 (input_bfd
, insn
>> 16, hit_data
);
5814 bfd_put_16 (input_bfd
, insn
& 0xffff, hit_data
+ 2);
5816 return bfd_reloc_ok
;
5818 case R_ARM_ALU_PC_G0_NC
:
5819 case R_ARM_ALU_PC_G1_NC
:
5820 case R_ARM_ALU_PC_G0
:
5821 case R_ARM_ALU_PC_G1
:
5822 case R_ARM_ALU_PC_G2
:
5823 case R_ARM_ALU_SB_G0_NC
:
5824 case R_ARM_ALU_SB_G1_NC
:
5825 case R_ARM_ALU_SB_G0
:
5826 case R_ARM_ALU_SB_G1
:
5827 case R_ARM_ALU_SB_G2
:
5829 bfd_vma insn
= bfd_get_32 (input_bfd
, hit_data
);
5830 bfd_vma pc
= input_section
->output_section
->vma
5831 + input_section
->output_offset
+ rel
->r_offset
;
5832 /* sb should be the origin of the *segment* containing the symbol.
5833 It is not clear how to obtain this OS-dependent value, so we
5834 make an arbitrary choice of zero. */
5838 bfd_signed_vma signed_value
;
5841 /* Determine which group of bits to select. */
5844 case R_ARM_ALU_PC_G0_NC
:
5845 case R_ARM_ALU_PC_G0
:
5846 case R_ARM_ALU_SB_G0_NC
:
5847 case R_ARM_ALU_SB_G0
:
5851 case R_ARM_ALU_PC_G1_NC
:
5852 case R_ARM_ALU_PC_G1
:
5853 case R_ARM_ALU_SB_G1_NC
:
5854 case R_ARM_ALU_SB_G1
:
5858 case R_ARM_ALU_PC_G2
:
5859 case R_ARM_ALU_SB_G2
:
5867 /* If REL, extract the addend from the insn. If RELA, it will
5868 have already been fetched for us. */
5869 if (globals
->use_rel
)
5872 bfd_vma constant
= insn
& 0xff;
5873 bfd_vma rotation
= (insn
& 0xf00) >> 8;
5876 signed_addend
= constant
;
5879 /* Compensate for the fact that in the instruction, the
5880 rotation is stored in multiples of 2 bits. */
5883 /* Rotate "constant" right by "rotation" bits. */
5884 signed_addend
= (constant
>> rotation
) |
5885 (constant
<< (8 * sizeof (bfd_vma
) - rotation
));
5888 /* Determine if the instruction is an ADD or a SUB.
5889 (For REL, this determines the sign of the addend.) */
5890 negative
= identify_add_or_sub (insn
);
5893 (*_bfd_error_handler
)
5894 (_("%B(%A+0x%lx): Only ADD or SUB instructions are allowed for ALU group relocations"),
5895 input_bfd
, input_section
,
5896 (long) rel
->r_offset
, howto
->name
);
5897 return bfd_reloc_overflow
;
5900 signed_addend
*= negative
;
5903 /* Compute the value (X) to go in the place. */
5904 if (r_type
== R_ARM_ALU_PC_G0_NC
5905 || r_type
== R_ARM_ALU_PC_G1_NC
5906 || r_type
== R_ARM_ALU_PC_G0
5907 || r_type
== R_ARM_ALU_PC_G1
5908 || r_type
== R_ARM_ALU_PC_G2
)
5910 signed_value
= value
- pc
+ signed_addend
;
5912 /* Section base relative. */
5913 signed_value
= value
- sb
+ signed_addend
;
5915 /* If the target symbol is a Thumb function, then set the
5916 Thumb bit in the address. */
5917 if (sym_flags
== STT_ARM_TFUNC
)
5920 /* Calculate the value of the relevant G_n, in encoded
5921 constant-with-rotation format. */
5922 g_n
= calculate_group_reloc_mask (abs (signed_value
), group
,
5925 /* Check for overflow if required. */
5926 if ((r_type
== R_ARM_ALU_PC_G0
5927 || r_type
== R_ARM_ALU_PC_G1
5928 || r_type
== R_ARM_ALU_PC_G2
5929 || r_type
== R_ARM_ALU_SB_G0
5930 || r_type
== R_ARM_ALU_SB_G1
5931 || r_type
== R_ARM_ALU_SB_G2
) && residual
!= 0)
5933 (*_bfd_error_handler
)
5934 (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"),
5935 input_bfd
, input_section
,
5936 (long) rel
->r_offset
, abs (signed_value
), howto
->name
);
5937 return bfd_reloc_overflow
;
5940 /* Mask out the value and the ADD/SUB part of the opcode; take care
5941 not to destroy the S bit. */
5944 /* Set the opcode according to whether the value to go in the
5945 place is negative. */
5946 if (signed_value
< 0)
5951 /* Encode the offset. */
5954 bfd_put_32 (input_bfd
, insn
, hit_data
);
5956 return bfd_reloc_ok
;
5958 case R_ARM_LDR_PC_G0
:
5959 case R_ARM_LDR_PC_G1
:
5960 case R_ARM_LDR_PC_G2
:
5961 case R_ARM_LDR_SB_G0
:
5962 case R_ARM_LDR_SB_G1
:
5963 case R_ARM_LDR_SB_G2
:
5965 bfd_vma insn
= bfd_get_32 (input_bfd
, hit_data
);
5966 bfd_vma pc
= input_section
->output_section
->vma
5967 + input_section
->output_offset
+ rel
->r_offset
;
5968 bfd_vma sb
= 0; /* See note above. */
5970 bfd_signed_vma signed_value
;
5973 /* Determine which groups of bits to calculate. */
5976 case R_ARM_LDR_PC_G0
:
5977 case R_ARM_LDR_SB_G0
:
5981 case R_ARM_LDR_PC_G1
:
5982 case R_ARM_LDR_SB_G1
:
5986 case R_ARM_LDR_PC_G2
:
5987 case R_ARM_LDR_SB_G2
:
5995 /* If REL, extract the addend from the insn. If RELA, it will
5996 have already been fetched for us. */
5997 if (globals
->use_rel
)
5999 int negative
= (insn
& (1 << 23)) ? 1 : -1;
6000 signed_addend
= negative
* (insn
& 0xfff);
6003 /* Compute the value (X) to go in the place. */
6004 if (r_type
== R_ARM_LDR_PC_G0
6005 || r_type
== R_ARM_LDR_PC_G1
6006 || r_type
== R_ARM_LDR_PC_G2
)
6008 signed_value
= value
- pc
+ signed_addend
;
6010 /* Section base relative. */
6011 signed_value
= value
- sb
+ signed_addend
;
6013 /* Calculate the value of the relevant G_{n-1} to obtain
6014 the residual at that stage. */
6015 calculate_group_reloc_mask (abs (signed_value
), group
- 1, &residual
);
6017 /* Check for overflow. */
6018 if (residual
>= 0x1000)
6020 (*_bfd_error_handler
)
6021 (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"),
6022 input_bfd
, input_section
,
6023 (long) rel
->r_offset
, abs (signed_value
), howto
->name
);
6024 return bfd_reloc_overflow
;
6027 /* Mask out the value and U bit. */
6030 /* Set the U bit if the value to go in the place is non-negative. */
6031 if (signed_value
>= 0)
6034 /* Encode the offset. */
6037 bfd_put_32 (input_bfd
, insn
, hit_data
);
6039 return bfd_reloc_ok
;
6041 case R_ARM_LDRS_PC_G0
:
6042 case R_ARM_LDRS_PC_G1
:
6043 case R_ARM_LDRS_PC_G2
:
6044 case R_ARM_LDRS_SB_G0
:
6045 case R_ARM_LDRS_SB_G1
:
6046 case R_ARM_LDRS_SB_G2
:
6048 bfd_vma insn
= bfd_get_32 (input_bfd
, hit_data
);
6049 bfd_vma pc
= input_section
->output_section
->vma
6050 + input_section
->output_offset
+ rel
->r_offset
;
6051 bfd_vma sb
= 0; /* See note above. */
6053 bfd_signed_vma signed_value
;
6056 /* Determine which groups of bits to calculate. */
6059 case R_ARM_LDRS_PC_G0
:
6060 case R_ARM_LDRS_SB_G0
:
6064 case R_ARM_LDRS_PC_G1
:
6065 case R_ARM_LDRS_SB_G1
:
6069 case R_ARM_LDRS_PC_G2
:
6070 case R_ARM_LDRS_SB_G2
:
6078 /* If REL, extract the addend from the insn. If RELA, it will
6079 have already been fetched for us. */
6080 if (globals
->use_rel
)
6082 int negative
= (insn
& (1 << 23)) ? 1 : -1;
6083 signed_addend
= negative
* (((insn
& 0xf00) >> 4) + (insn
& 0xf));
6086 /* Compute the value (X) to go in the place. */
6087 if (r_type
== R_ARM_LDRS_PC_G0
6088 || r_type
== R_ARM_LDRS_PC_G1
6089 || r_type
== R_ARM_LDRS_PC_G2
)
6091 signed_value
= value
- pc
+ signed_addend
;
6093 /* Section base relative. */
6094 signed_value
= value
- sb
+ signed_addend
;
6096 /* Calculate the value of the relevant G_{n-1} to obtain
6097 the residual at that stage. */
6098 calculate_group_reloc_mask (abs (signed_value
), group
- 1, &residual
);
6100 /* Check for overflow. */
6101 if (residual
>= 0x100)
6103 (*_bfd_error_handler
)
6104 (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"),
6105 input_bfd
, input_section
,
6106 (long) rel
->r_offset
, abs (signed_value
), howto
->name
);
6107 return bfd_reloc_overflow
;
6110 /* Mask out the value and U bit. */
6113 /* Set the U bit if the value to go in the place is non-negative. */
6114 if (signed_value
>= 0)
6117 /* Encode the offset. */
6118 insn
|= ((residual
& 0xf0) << 4) | (residual
& 0xf);
6120 bfd_put_32 (input_bfd
, insn
, hit_data
);
6122 return bfd_reloc_ok
;
6124 case R_ARM_LDC_PC_G0
:
6125 case R_ARM_LDC_PC_G1
:
6126 case R_ARM_LDC_PC_G2
:
6127 case R_ARM_LDC_SB_G0
:
6128 case R_ARM_LDC_SB_G1
:
6129 case R_ARM_LDC_SB_G2
:
6131 bfd_vma insn
= bfd_get_32 (input_bfd
, hit_data
);
6132 bfd_vma pc
= input_section
->output_section
->vma
6133 + input_section
->output_offset
+ rel
->r_offset
;
6134 bfd_vma sb
= 0; /* See note above. */
6136 bfd_signed_vma signed_value
;
6139 /* Determine which groups of bits to calculate. */
6142 case R_ARM_LDC_PC_G0
:
6143 case R_ARM_LDC_SB_G0
:
6147 case R_ARM_LDC_PC_G1
:
6148 case R_ARM_LDC_SB_G1
:
6152 case R_ARM_LDC_PC_G2
:
6153 case R_ARM_LDC_SB_G2
:
6161 /* If REL, extract the addend from the insn. If RELA, it will
6162 have already been fetched for us. */
6163 if (globals
->use_rel
)
6165 int negative
= (insn
& (1 << 23)) ? 1 : -1;
6166 signed_addend
= negative
* ((insn
& 0xff) << 2);
6169 /* Compute the value (X) to go in the place. */
6170 if (r_type
== R_ARM_LDC_PC_G0
6171 || r_type
== R_ARM_LDC_PC_G1
6172 || r_type
== R_ARM_LDC_PC_G2
)
6174 signed_value
= value
- pc
+ signed_addend
;
6176 /* Section base relative. */
6177 signed_value
= value
- sb
+ signed_addend
;
6179 /* Calculate the value of the relevant G_{n-1} to obtain
6180 the residual at that stage. */
6181 calculate_group_reloc_mask (abs (signed_value
), group
- 1, &residual
);
6183 /* Check for overflow. (The absolute value to go in the place must be
6184 divisible by four and, after having been divided by four, must
6185 fit in eight bits.) */
6186 if ((residual
& 0x3) != 0 || residual
>= 0x400)
6188 (*_bfd_error_handler
)
6189 (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"),
6190 input_bfd
, input_section
,
6191 (long) rel
->r_offset
, abs (signed_value
), howto
->name
);
6192 return bfd_reloc_overflow
;
6195 /* Mask out the value and U bit. */
6198 /* Set the U bit if the value to go in the place is non-negative. */
6199 if (signed_value
>= 0)
6202 /* Encode the offset. */
6203 insn
|= residual
>> 2;
6205 bfd_put_32 (input_bfd
, insn
, hit_data
);
6207 return bfd_reloc_ok
;
6210 return bfd_reloc_notsupported
;
6216 uleb128_size (unsigned int i
)
6228 /* Return TRUE if the attribute has the default value (0/""). */
6230 is_default_attr (aeabi_attribute
*attr
)
6232 if ((attr
->type
& 1) && attr
->i
!= 0)
6234 if ((attr
->type
& 2) && attr
->s
&& *attr
->s
)
6240 /* Return the size of a single attribute. */
6242 eabi_attr_size(int tag
, aeabi_attribute
*attr
)
6246 if (is_default_attr (attr
))
6249 size
= uleb128_size (tag
);
6251 size
+= uleb128_size (attr
->i
);
6253 size
+= strlen ((char *)attr
->s
) + 1;
6257 /* Returns the size of the eabi object attributess section. */
6259 elf32_arm_eabi_attr_size (bfd
*abfd
)
6262 aeabi_attribute
*attr
;
6263 aeabi_attribute_list
*list
;
6266 attr
= elf32_arm_tdata (abfd
)->known_eabi_attributes
;
6267 size
= 16; /* 'A' <size> "aeabi" 0x1 <size>. */
6268 for (i
= 4; i
< NUM_KNOWN_ATTRIBUTES
; i
++)
6269 size
+= eabi_attr_size (i
, &attr
[i
]);
6271 for (list
= elf32_arm_tdata (abfd
)->other_eabi_attributes
;
6274 size
+= eabi_attr_size (list
->tag
, &list
->attr
);
6280 write_uleb128 (bfd_byte
*p
, unsigned int val
)
6295 /* Write attribute ATTR to butter P, and return a pointer to the following
6298 write_eabi_attribute (bfd_byte
*p
, int tag
, aeabi_attribute
*attr
)
6300 /* Suppress default entries. */
6301 if (is_default_attr(attr
))
6304 p
= write_uleb128 (p
, tag
);
6306 p
= write_uleb128 (p
, attr
->i
);
6311 len
= strlen (attr
->s
) + 1;
6312 memcpy (p
, attr
->s
, len
);
6319 /* Write the contents of the eabi attributes section to p. */
6321 elf32_arm_set_eabi_attr_contents (bfd
*abfd
, bfd_byte
*contents
, bfd_vma size
)
6324 aeabi_attribute
*attr
;
6325 aeabi_attribute_list
*list
;
6330 bfd_put_32 (abfd
, size
- 1, p
);
6332 memcpy (p
, "aeabi", 6);
6335 bfd_put_32 (abfd
, size
- 11, p
);
6338 attr
= elf32_arm_tdata (abfd
)->known_eabi_attributes
;
6339 for (i
= 4; i
< NUM_KNOWN_ATTRIBUTES
; i
++)
6340 p
= write_eabi_attribute (p
, i
, &attr
[i
]);
6342 for (list
= elf32_arm_tdata (abfd
)->other_eabi_attributes
;
6345 p
= write_eabi_attribute (p
, list
->tag
, &list
->attr
);
6348 /* Override final_link to handle EABI object attribute sections. */
6351 elf32_arm_bfd_final_link (bfd
*abfd
, struct bfd_link_info
*info
)
6354 struct bfd_link_order
*p
;
6355 asection
*attr_section
= NULL
;
6359 /* elf32_arm_merge_private_bfd_data will already have merged the
6360 object attributes. Remove the input sections from the link, and set
6361 the contents of the output secton. */
6362 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
6364 if (strcmp (o
->name
, ".ARM.attributes") == 0)
6366 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
6368 asection
*input_section
;
6370 if (p
->type
!= bfd_indirect_link_order
)
6372 input_section
= p
->u
.indirect
.section
;
6373 /* Hack: reset the SEC_HAS_CONTENTS flag so that
6374 elf_link_input_bfd ignores this section. */
6375 input_section
->flags
&= ~SEC_HAS_CONTENTS
;
6378 size
= elf32_arm_eabi_attr_size (abfd
);
6379 bfd_set_section_size (abfd
, o
, size
);
6381 /* Skip this section later on. */
6382 o
->map_head
.link_order
= NULL
;
6385 /* Invoke the ELF linker to do all the work. */
6386 if (!bfd_elf_final_link (abfd
, info
))
6391 contents
= bfd_malloc(size
);
6392 if (contents
== NULL
)
6394 elf32_arm_set_eabi_attr_contents (abfd
, contents
, size
);
6395 bfd_set_section_contents (abfd
, attr_section
, contents
, 0, size
);
6402 /* Add INCREMENT to the reloc (of type HOWTO) at ADDRESS. */
6404 arm_add_to_rel (bfd
* abfd
,
6406 reloc_howto_type
* howto
,
6407 bfd_signed_vma increment
)
6409 bfd_signed_vma addend
;
6411 if (howto
->type
== R_ARM_THM_CALL
)
6413 int upper_insn
, lower_insn
;
6416 upper_insn
= bfd_get_16 (abfd
, address
);
6417 lower_insn
= bfd_get_16 (abfd
, address
+ 2);
6418 upper
= upper_insn
& 0x7ff;
6419 lower
= lower_insn
& 0x7ff;
6421 addend
= (upper
<< 12) | (lower
<< 1);
6422 addend
+= increment
;
6425 upper_insn
= (upper_insn
& 0xf800) | ((addend
>> 11) & 0x7ff);
6426 lower_insn
= (lower_insn
& 0xf800) | (addend
& 0x7ff);
6428 bfd_put_16 (abfd
, (bfd_vma
) upper_insn
, address
);
6429 bfd_put_16 (abfd
, (bfd_vma
) lower_insn
, address
+ 2);
6435 contents
= bfd_get_32 (abfd
, address
);
6437 /* Get the (signed) value from the instruction. */
6438 addend
= contents
& howto
->src_mask
;
6439 if (addend
& ((howto
->src_mask
+ 1) >> 1))
6441 bfd_signed_vma mask
;
6444 mask
&= ~ howto
->src_mask
;
6448 /* Add in the increment, (which is a byte value). */
6449 switch (howto
->type
)
6452 addend
+= increment
;
6459 addend
<<= howto
->size
;
6460 addend
+= increment
;
6462 /* Should we check for overflow here ? */
6464 /* Drop any undesired bits. */
6465 addend
>>= howto
->rightshift
;
6469 contents
= (contents
& ~ howto
->dst_mask
) | (addend
& howto
->dst_mask
);
6471 bfd_put_32 (abfd
, contents
, address
);
6475 #define IS_ARM_TLS_RELOC(R_TYPE) \
6476 ((R_TYPE) == R_ARM_TLS_GD32 \
6477 || (R_TYPE) == R_ARM_TLS_LDO32 \
6478 || (R_TYPE) == R_ARM_TLS_LDM32 \
6479 || (R_TYPE) == R_ARM_TLS_DTPOFF32 \
6480 || (R_TYPE) == R_ARM_TLS_DTPMOD32 \
6481 || (R_TYPE) == R_ARM_TLS_TPOFF32 \
6482 || (R_TYPE) == R_ARM_TLS_LE32 \
6483 || (R_TYPE) == R_ARM_TLS_IE32)
6485 /* Relocate an ARM ELF section. */
6487 elf32_arm_relocate_section (bfd
* output_bfd
,
6488 struct bfd_link_info
* info
,
6490 asection
* input_section
,
6491 bfd_byte
* contents
,
6492 Elf_Internal_Rela
* relocs
,
6493 Elf_Internal_Sym
* local_syms
,
6494 asection
** local_sections
)
6496 Elf_Internal_Shdr
*symtab_hdr
;
6497 struct elf_link_hash_entry
**sym_hashes
;
6498 Elf_Internal_Rela
*rel
;
6499 Elf_Internal_Rela
*relend
;
6501 struct elf32_arm_link_hash_table
* globals
;
6503 globals
= elf32_arm_hash_table (info
);
6504 if (info
->relocatable
&& !globals
->use_rel
)
6507 symtab_hdr
= & elf_tdata (input_bfd
)->symtab_hdr
;
6508 sym_hashes
= elf_sym_hashes (input_bfd
);
6511 relend
= relocs
+ input_section
->reloc_count
;
6512 for (; rel
< relend
; rel
++)
6515 reloc_howto_type
* howto
;
6516 unsigned long r_symndx
;
6517 Elf_Internal_Sym
* sym
;
6519 struct elf_link_hash_entry
* h
;
6521 bfd_reloc_status_type r
;
6524 bfd_boolean unresolved_reloc
= FALSE
;
6525 char *error_message
= NULL
;
6527 r_symndx
= ELF32_R_SYM (rel
->r_info
);
6528 r_type
= ELF32_R_TYPE (rel
->r_info
);
6529 r_type
= arm_real_reloc_type (globals
, r_type
);
6531 if ( r_type
== R_ARM_GNU_VTENTRY
6532 || r_type
== R_ARM_GNU_VTINHERIT
)
6535 bfd_reloc
.howto
= elf32_arm_howto_from_type (r_type
);
6536 howto
= bfd_reloc
.howto
;
6538 if (info
->relocatable
&& globals
->use_rel
)
6540 /* This is a relocatable link. We don't have to change
6541 anything, unless the reloc is against a section symbol,
6542 in which case we have to adjust according to where the
6543 section symbol winds up in the output section. */
6544 if (r_symndx
< symtab_hdr
->sh_info
)
6546 sym
= local_syms
+ r_symndx
;
6547 if (ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
)
6549 sec
= local_sections
[r_symndx
];
6550 arm_add_to_rel (input_bfd
, contents
+ rel
->r_offset
,
6552 (bfd_signed_vma
) (sec
->output_offset
6560 /* This is a final link. */
6565 if (r_symndx
< symtab_hdr
->sh_info
)
6567 sym
= local_syms
+ r_symndx
;
6568 sym_type
= ELF32_ST_TYPE (sym
->st_info
);
6569 sec
= local_sections
[r_symndx
];
6570 if (globals
->use_rel
)
6572 relocation
= (sec
->output_section
->vma
6573 + sec
->output_offset
6575 if ((sec
->flags
& SEC_MERGE
)
6576 && ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
)
6579 bfd_vma addend
, value
;
6581 if (howto
->rightshift
)
6583 (*_bfd_error_handler
)
6584 (_("%B(%A+0x%lx): %s relocation against SEC_MERGE section"),
6585 input_bfd
, input_section
,
6586 (long) rel
->r_offset
, howto
->name
);
6590 value
= bfd_get_32 (input_bfd
, contents
+ rel
->r_offset
);
6592 /* Get the (signed) value from the instruction. */
6593 addend
= value
& howto
->src_mask
;
6594 if (addend
& ((howto
->src_mask
+ 1) >> 1))
6596 bfd_signed_vma mask
;
6599 mask
&= ~ howto
->src_mask
;
6604 _bfd_elf_rel_local_sym (output_bfd
, sym
, &msec
, addend
)
6606 addend
+= msec
->output_section
->vma
+ msec
->output_offset
;
6607 value
= (value
& ~ howto
->dst_mask
) | (addend
& howto
->dst_mask
);
6608 bfd_put_32 (input_bfd
, value
, contents
+ rel
->r_offset
);
6612 relocation
= _bfd_elf_rela_local_sym (output_bfd
, sym
, &sec
, rel
);
6618 RELOC_FOR_GLOBAL_SYMBOL (info
, input_bfd
, input_section
, rel
,
6619 r_symndx
, symtab_hdr
, sym_hashes
,
6621 unresolved_reloc
, warned
);
6627 name
= h
->root
.root
.string
;
6630 name
= (bfd_elf_string_from_elf_section
6631 (input_bfd
, symtab_hdr
->sh_link
, sym
->st_name
));
6632 if (name
== NULL
|| *name
== '\0')
6633 name
= bfd_section_name (input_bfd
, sec
);
6637 && r_type
!= R_ARM_NONE
6639 || h
->root
.type
== bfd_link_hash_defined
6640 || h
->root
.type
== bfd_link_hash_defweak
)
6641 && IS_ARM_TLS_RELOC (r_type
) != (sym_type
== STT_TLS
))
6643 (*_bfd_error_handler
)
6644 ((sym_type
== STT_TLS
6645 ? _("%B(%A+0x%lx): %s used with TLS symbol %s")
6646 : _("%B(%A+0x%lx): %s used with non-TLS symbol %s")),
6649 (long) rel
->r_offset
,
6654 r
= elf32_arm_final_link_relocate (howto
, input_bfd
, output_bfd
,
6655 input_section
, contents
, rel
,
6656 relocation
, info
, sec
, name
,
6657 (h
? ELF_ST_TYPE (h
->type
) :
6658 ELF_ST_TYPE (sym
->st_info
)), h
,
6659 &unresolved_reloc
, &error_message
);
6661 /* Dynamic relocs are not propagated for SEC_DEBUGGING sections
6662 because such sections are not SEC_ALLOC and thus ld.so will
6663 not process them. */
6664 if (unresolved_reloc
6665 && !((input_section
->flags
& SEC_DEBUGGING
) != 0
6668 (*_bfd_error_handler
)
6669 (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
6672 (long) rel
->r_offset
,
6674 h
->root
.root
.string
);
6678 if (r
!= bfd_reloc_ok
)
6682 case bfd_reloc_overflow
:
6683 /* If the overflowing reloc was to an undefined symbol,
6684 we have already printed one error message and there
6685 is no point complaining again. */
6687 h
->root
.type
!= bfd_link_hash_undefined
)
6688 && (!((*info
->callbacks
->reloc_overflow
)
6689 (info
, (h
? &h
->root
: NULL
), name
, howto
->name
,
6690 (bfd_vma
) 0, input_bfd
, input_section
,
6695 case bfd_reloc_undefined
:
6696 if (!((*info
->callbacks
->undefined_symbol
)
6697 (info
, name
, input_bfd
, input_section
,
6698 rel
->r_offset
, TRUE
)))
6702 case bfd_reloc_outofrange
:
6703 error_message
= _("out of range");
6706 case bfd_reloc_notsupported
:
6707 error_message
= _("unsupported relocation");
6710 case bfd_reloc_dangerous
:
6711 /* error_message should already be set. */
6715 error_message
= _("unknown error");
6719 BFD_ASSERT (error_message
!= NULL
);
6720 if (!((*info
->callbacks
->reloc_dangerous
)
6721 (info
, error_message
, input_bfd
, input_section
,
6732 /* Allocate/find an object attribute. */
6733 static aeabi_attribute
*
6734 elf32_arm_new_eabi_attr (bfd
*abfd
, int tag
)
6736 aeabi_attribute
*attr
;
6737 aeabi_attribute_list
*list
;
6738 aeabi_attribute_list
*p
;
6739 aeabi_attribute_list
**lastp
;
6742 if (tag
< NUM_KNOWN_ATTRIBUTES
)
6744 /* Knwon tags are preallocated. */
6745 attr
= &elf32_arm_tdata (abfd
)->known_eabi_attributes
[tag
];
6749 /* Create a new tag. */
6750 list
= (aeabi_attribute_list
*)
6751 bfd_alloc (abfd
, sizeof (aeabi_attribute_list
));
6752 memset (list
, 0, sizeof (aeabi_attribute_list
));
6754 /* Keep the tag list in order. */
6755 lastp
= &elf32_arm_tdata (abfd
)->other_eabi_attributes
;
6756 for (p
= *lastp
; p
; p
= p
->next
)
6762 list
->next
= *lastp
;
6771 elf32_arm_get_eabi_attr_int (bfd
*abfd
, int tag
)
6773 aeabi_attribute_list
*p
;
6775 if (tag
< NUM_KNOWN_ATTRIBUTES
)
6777 /* Knwon tags are preallocated. */
6778 return elf32_arm_tdata (abfd
)->known_eabi_attributes
[tag
].i
;
6782 for (p
= elf32_arm_tdata (abfd
)->other_eabi_attributes
;
6796 elf32_arm_add_eabi_attr_int (bfd
*abfd
, int tag
, unsigned int i
)
6798 aeabi_attribute
*attr
;
6800 attr
= elf32_arm_new_eabi_attr (abfd
, tag
);
6806 attr_strdup (bfd
*abfd
, const char * s
)
6811 len
= strlen (s
) + 1;
6812 p
= (char *)bfd_alloc(abfd
, len
);
6813 return memcpy (p
, s
, len
);
6817 elf32_arm_add_eabi_attr_string (bfd
*abfd
, int tag
, const char *s
)
6819 aeabi_attribute
*attr
;
6821 attr
= elf32_arm_new_eabi_attr (abfd
, tag
);
6823 attr
->s
= attr_strdup (abfd
, s
);
6827 elf32_arm_add_eabi_attr_compat (bfd
*abfd
, unsigned int i
, const char *s
)
6829 aeabi_attribute_list
*list
;
6830 aeabi_attribute_list
*p
;
6831 aeabi_attribute_list
**lastp
;
6833 list
= (aeabi_attribute_list
*)
6834 bfd_alloc (abfd
, sizeof (aeabi_attribute_list
));
6835 memset (list
, 0, sizeof (aeabi_attribute_list
));
6836 list
->tag
= Tag_compatibility
;
6837 list
->attr
.type
= 3;
6839 list
->attr
.s
= attr_strdup (abfd
, s
);
6841 lastp
= &elf32_arm_tdata (abfd
)->other_eabi_attributes
;
6842 for (p
= *lastp
; p
; p
= p
->next
)
6845 if (p
->tag
!= Tag_compatibility
)
6847 cmp
= strcmp(s
, p
->attr
.s
);
6848 if (cmp
< 0 || (cmp
== 0 && i
< p
->attr
.i
))
6852 list
->next
= *lastp
;
6856 /* Set the right machine number. */
6859 elf32_arm_object_p (bfd
*abfd
)
6863 mach
= bfd_arm_get_mach_from_notes (abfd
, ARM_NOTE_SECTION
);
6865 if (mach
!= bfd_mach_arm_unknown
)
6866 bfd_default_set_arch_mach (abfd
, bfd_arch_arm
, mach
);
6868 else if (elf_elfheader (abfd
)->e_flags
& EF_ARM_MAVERICK_FLOAT
)
6869 bfd_default_set_arch_mach (abfd
, bfd_arch_arm
, bfd_mach_arm_ep9312
);
6872 bfd_default_set_arch_mach (abfd
, bfd_arch_arm
, mach
);
6877 /* Function to keep ARM specific flags in the ELF header. */
6880 elf32_arm_set_private_flags (bfd
*abfd
, flagword flags
)
6882 if (elf_flags_init (abfd
)
6883 && elf_elfheader (abfd
)->e_flags
!= flags
)
6885 if (EF_ARM_EABI_VERSION (flags
) == EF_ARM_EABI_UNKNOWN
)
6887 if (flags
& EF_ARM_INTERWORK
)
6888 (*_bfd_error_handler
)
6889 (_("Warning: Not setting interworking flag of %B since it has already been specified as non-interworking"),
6893 (_("Warning: Clearing the interworking flag of %B due to outside request"),
6899 elf_elfheader (abfd
)->e_flags
= flags
;
6900 elf_flags_init (abfd
) = TRUE
;
6906 /* Copy the eabi object attribute from IBFD to OBFD. */
6908 copy_eabi_attributes (bfd
*ibfd
, bfd
*obfd
)
6910 aeabi_attribute
*in_attr
;
6911 aeabi_attribute
*out_attr
;
6912 aeabi_attribute_list
*list
;
6915 in_attr
= &elf32_arm_tdata (ibfd
)->known_eabi_attributes
[4];
6916 out_attr
= &elf32_arm_tdata (obfd
)->known_eabi_attributes
[4];
6917 for (i
= 4; i
< NUM_KNOWN_ATTRIBUTES
; i
++)
6919 out_attr
->i
= in_attr
->i
;
6920 if (in_attr
->s
&& *in_attr
->s
)
6921 out_attr
->s
= attr_strdup (obfd
, in_attr
->s
);
6926 for (list
= elf32_arm_tdata (ibfd
)->other_eabi_attributes
;
6930 in_attr
= &list
->attr
;
6931 switch (in_attr
->type
)
6934 elf32_arm_add_eabi_attr_int (obfd
, list
->tag
, in_attr
->i
);
6937 elf32_arm_add_eabi_attr_string (obfd
, list
->tag
, in_attr
->s
);
6940 elf32_arm_add_eabi_attr_compat (obfd
, in_attr
->i
, in_attr
->s
);
6949 /* Copy backend specific data from one object module to another. */
6952 elf32_arm_copy_private_bfd_data (bfd
*ibfd
, bfd
*obfd
)
6957 if ( bfd_get_flavour (ibfd
) != bfd_target_elf_flavour
6958 || bfd_get_flavour (obfd
) != bfd_target_elf_flavour
)
6961 in_flags
= elf_elfheader (ibfd
)->e_flags
;
6962 out_flags
= elf_elfheader (obfd
)->e_flags
;
6964 if (elf_flags_init (obfd
)
6965 && EF_ARM_EABI_VERSION (out_flags
) == EF_ARM_EABI_UNKNOWN
6966 && in_flags
!= out_flags
)
6968 /* Cannot mix APCS26 and APCS32 code. */
6969 if ((in_flags
& EF_ARM_APCS_26
) != (out_flags
& EF_ARM_APCS_26
))
6972 /* Cannot mix float APCS and non-float APCS code. */
6973 if ((in_flags
& EF_ARM_APCS_FLOAT
) != (out_flags
& EF_ARM_APCS_FLOAT
))
6976 /* If the src and dest have different interworking flags
6977 then turn off the interworking bit. */
6978 if ((in_flags
& EF_ARM_INTERWORK
) != (out_flags
& EF_ARM_INTERWORK
))
6980 if (out_flags
& EF_ARM_INTERWORK
)
6982 (_("Warning: Clearing the interworking flag of %B because non-interworking code in %B has been linked with it"),
6985 in_flags
&= ~EF_ARM_INTERWORK
;
6988 /* Likewise for PIC, though don't warn for this case. */
6989 if ((in_flags
& EF_ARM_PIC
) != (out_flags
& EF_ARM_PIC
))
6990 in_flags
&= ~EF_ARM_PIC
;
6993 elf_elfheader (obfd
)->e_flags
= in_flags
;
6994 elf_flags_init (obfd
) = TRUE
;
6996 /* Also copy the EI_OSABI field. */
6997 elf_elfheader (obfd
)->e_ident
[EI_OSABI
] =
6998 elf_elfheader (ibfd
)->e_ident
[EI_OSABI
];
7000 /* Copy EABI object attributes. */
7001 copy_eabi_attributes (ibfd
, obfd
);
7006 /* Values for Tag_ABI_PCS_R9_use. */
7015 /* Values for Tag_ABI_PCS_RW_data. */
7018 AEABI_PCS_RW_data_absolute
,
7019 AEABI_PCS_RW_data_PCrel
,
7020 AEABI_PCS_RW_data_SBrel
,
7021 AEABI_PCS_RW_data_unused
7024 /* Values for Tag_ABI_enum_size. */
7030 AEABI_enum_forced_wide
7033 /* Merge EABI object attributes from IBFD into OBFD. Raise an error if there
7034 are conflicting attributes. */
7036 elf32_arm_merge_eabi_attributes (bfd
*ibfd
, bfd
*obfd
)
7038 aeabi_attribute
*in_attr
;
7039 aeabi_attribute
*out_attr
;
7040 aeabi_attribute_list
*in_list
;
7041 aeabi_attribute_list
*out_list
;
7042 /* Some tags have 0 = don't care, 1 = strong requirement,
7043 2 = weak requirement. */
7044 static const int order_312
[3] = {3, 1, 2};
7047 if (!elf32_arm_tdata (obfd
)->known_eabi_attributes
[0].i
)
7049 /* This is the first object. Copy the attributes. */
7050 copy_eabi_attributes (ibfd
, obfd
);
7052 /* Use the Tag_null value to indicate the attributes have been
7054 elf32_arm_tdata (obfd
)->known_eabi_attributes
[0].i
= 1;
7059 in_attr
= elf32_arm_tdata (ibfd
)->known_eabi_attributes
;
7060 out_attr
= elf32_arm_tdata (obfd
)->known_eabi_attributes
;
7061 /* This needs to happen before Tag_ABI_FP_number_model is merged. */
7062 if (in_attr
[Tag_ABI_VFP_args
].i
!= out_attr
[Tag_ABI_VFP_args
].i
)
7064 /* Ignore mismatches if teh object doesn't use floating point. */
7065 if (out_attr
[Tag_ABI_FP_number_model
].i
== 0)
7066 out_attr
[Tag_ABI_VFP_args
].i
= in_attr
[Tag_ABI_VFP_args
].i
;
7067 else if (in_attr
[Tag_ABI_FP_number_model
].i
!= 0)
7070 (_("ERROR: %B uses VFP register arguments, %B does not"),
7076 for (i
= 4; i
< NUM_KNOWN_ATTRIBUTES
; i
++)
7078 /* Merge this attribute with existing attributes. */
7081 case Tag_CPU_raw_name
:
7083 /* Use whichever has the greatest architecture requirements. We
7084 won't necessarily have both the above tags, so make sure input
7085 name is non-NULL. */
7086 if (in_attr
[Tag_CPU_arch
].i
> out_attr
[Tag_CPU_arch
].i
7088 out_attr
[i
].s
= attr_strdup(obfd
, in_attr
[i
].s
);
7091 case Tag_ABI_optimization_goals
:
7092 case Tag_ABI_FP_optimization_goals
:
7093 /* Use the first value seen. */
7097 case Tag_ARM_ISA_use
:
7098 case Tag_THUMB_ISA_use
:
7102 /* ??? Do NEON and WMMX conflict? */
7103 case Tag_ABI_FP_rounding
:
7104 case Tag_ABI_FP_denormal
:
7105 case Tag_ABI_FP_exceptions
:
7106 case Tag_ABI_FP_user_exceptions
:
7107 case Tag_ABI_FP_number_model
:
7108 case Tag_ABI_align8_preserved
:
7109 case Tag_ABI_HardFP_use
:
7110 /* Use the largest value specified. */
7111 if (in_attr
[i
].i
> out_attr
[i
].i
)
7112 out_attr
[i
].i
= in_attr
[i
].i
;
7115 case Tag_CPU_arch_profile
:
7116 /* Warn if conflicting architecture profiles used. */
7117 if (out_attr
[i
].i
&& in_attr
[i
].i
&& in_attr
[i
].i
!= out_attr
[i
].i
)
7120 (_("ERROR: %B: Conflicting architecture profiles %c/%c"),
7121 ibfd
, in_attr
[i
].i
, out_attr
[i
].i
);
7125 out_attr
[i
].i
= in_attr
[i
].i
;
7127 case Tag_PCS_config
:
7128 if (out_attr
[i
].i
== 0)
7129 out_attr
[i
].i
= in_attr
[i
].i
;
7130 else if (in_attr
[i
].i
!= 0 && out_attr
[i
].i
!= 0)
7132 /* It's sometimes ok to mix different configs, so this is only
7135 (_("Warning: %B: Conflicting platform configuration"), ibfd
);
7138 case Tag_ABI_PCS_R9_use
:
7139 if (in_attr
[i
].i
!= out_attr
[i
].i
7140 && out_attr
[i
].i
!= AEABI_R9_unused
7141 && in_attr
[i
].i
!= AEABI_R9_unused
)
7144 (_("ERROR: %B: Conflicting use of R9"), ibfd
);
7147 if (out_attr
[i
].i
== AEABI_R9_unused
)
7148 out_attr
[i
].i
= in_attr
[i
].i
;
7150 case Tag_ABI_PCS_RW_data
:
7151 if (in_attr
[i
].i
== AEABI_PCS_RW_data_SBrel
7152 && out_attr
[Tag_ABI_PCS_R9_use
].i
!= AEABI_R9_SB
7153 && out_attr
[Tag_ABI_PCS_R9_use
].i
!= AEABI_R9_unused
)
7156 (_("ERROR: %B: SB relative addressing conflicts with use of R9"),
7160 /* Use the smallest value specified. */
7161 if (in_attr
[i
].i
< out_attr
[i
].i
)
7162 out_attr
[i
].i
= in_attr
[i
].i
;
7164 case Tag_ABI_PCS_RO_data
:
7165 /* Use the smallest value specified. */
7166 if (in_attr
[i
].i
< out_attr
[i
].i
)
7167 out_attr
[i
].i
= in_attr
[i
].i
;
7169 case Tag_ABI_PCS_GOT_use
:
7170 if (in_attr
[i
].i
> 2 || out_attr
[i
].i
> 2
7171 || order_312
[in_attr
[i
].i
] < order_312
[out_attr
[i
].i
])
7172 out_attr
[i
].i
= in_attr
[i
].i
;
7174 case Tag_ABI_PCS_wchar_t
:
7175 if (out_attr
[i
].i
&& in_attr
[i
].i
&& out_attr
[i
].i
!= in_attr
[i
].i
)
7178 (_("ERROR: %B: Conflicting definitions of wchar_t"), ibfd
);
7182 out_attr
[i
].i
= in_attr
[i
].i
;
7184 case Tag_ABI_align8_needed
:
7185 /* ??? Check against Tag_ABI_align8_preserved. */
7186 if (in_attr
[i
].i
> 2 || out_attr
[i
].i
> 2
7187 || order_312
[in_attr
[i
].i
] < order_312
[out_attr
[i
].i
])
7188 out_attr
[i
].i
= in_attr
[i
].i
;
7190 case Tag_ABI_enum_size
:
7191 if (in_attr
[i
].i
!= AEABI_enum_unused
)
7193 if (out_attr
[i
].i
== AEABI_enum_unused
7194 || out_attr
[i
].i
== AEABI_enum_forced_wide
)
7196 /* The existing object is compatible with anything.
7197 Use whatever requirements the new object has. */
7198 out_attr
[i
].i
= in_attr
[i
].i
;
7200 else if (in_attr
[i
].i
!= AEABI_enum_forced_wide
7201 && out_attr
[i
].i
!= in_attr
[i
].i
)
7204 (_("ERROR: %B: Conflicting enum sizes"), ibfd
);
7208 case Tag_ABI_VFP_args
:
7211 case Tag_ABI_WMMX_args
:
7212 if (in_attr
[i
].i
!= out_attr
[i
].i
)
7215 (_("ERROR: %B uses iWMMXt register arguments, %B does not"),
7220 default: /* All known attributes should be explicitly covered. */
7225 in_list
= elf32_arm_tdata (ibfd
)->other_eabi_attributes
;
7226 out_list
= elf32_arm_tdata (ibfd
)->other_eabi_attributes
;
7227 while (in_list
&& in_list
->tag
== Tag_compatibility
)
7229 in_attr
= &in_list
->attr
;
7230 if (in_attr
->i
== 0)
7232 if (in_attr
->i
== 1)
7235 (_("ERROR: %B: Must be processed by '%s' toolchain"),
7239 if (!out_list
|| out_list
->tag
!= Tag_compatibility
7240 || strcmp (in_attr
->s
, out_list
->attr
.s
) != 0)
7242 /* Add this compatibility tag to the output. */
7243 elf32_arm_add_eabi_attr_compat (obfd
, in_attr
->i
, in_attr
->s
);
7246 out_attr
= &out_list
->attr
;
7247 /* Check all the input tags with the same identifier. */
7250 if (out_list
->tag
!= Tag_compatibility
7251 || in_attr
->i
!= out_attr
->i
7252 || strcmp (in_attr
->s
, out_attr
->s
) != 0)
7255 (_("ERROR: %B: Incompatible object tag '%s':%d"),
7256 ibfd
, in_attr
->s
, in_attr
->i
);
7259 in_list
= in_list
->next
;
7260 if (in_list
->tag
!= Tag_compatibility
7261 || strcmp (in_attr
->s
, in_list
->attr
.s
) != 0)
7263 in_attr
= &in_list
->attr
;
7264 out_list
= out_list
->next
;
7266 out_attr
= &out_list
->attr
;
7269 /* Check the output doesn't have extra tags with this identifier. */
7270 if (out_list
&& out_list
->tag
== Tag_compatibility
7271 && strcmp (in_attr
->s
, out_list
->attr
.s
) == 0)
7274 (_("ERROR: %B: Incompatible object tag '%s':%d"),
7275 ibfd
, in_attr
->s
, out_list
->attr
.i
);
7280 for (; in_list
; in_list
= in_list
->next
)
7282 if ((in_list
->tag
& 128) < 64)
7285 (_("Warning: %B: Unknown EABI object attribute %d"),
7286 ibfd
, in_list
->tag
);
7294 /* Return TRUE if the two EABI versions are incompatible. */
7297 elf32_arm_versions_compatible (unsigned iver
, unsigned over
)
7299 /* v4 and v5 are the same spec before and after it was released,
7300 so allow mixing them. */
7301 if ((iver
== EF_ARM_EABI_VER4
&& over
== EF_ARM_EABI_VER5
)
7302 || (iver
== EF_ARM_EABI_VER5
&& over
== EF_ARM_EABI_VER4
))
7305 return (iver
== over
);
7308 /* Merge backend specific data from an object file to the output
7309 object file when linking. */
7312 elf32_arm_merge_private_bfd_data (bfd
* ibfd
, bfd
* obfd
)
7316 bfd_boolean flags_compatible
= TRUE
;
7319 /* Check if we have the same endianess. */
7320 if (! _bfd_generic_verify_endian_match (ibfd
, obfd
))
7323 if ( bfd_get_flavour (ibfd
) != bfd_target_elf_flavour
7324 || bfd_get_flavour (obfd
) != bfd_target_elf_flavour
)
7327 if (!elf32_arm_merge_eabi_attributes (ibfd
, obfd
))
7330 /* The input BFD must have had its flags initialised. */
7331 /* The following seems bogus to me -- The flags are initialized in
7332 the assembler but I don't think an elf_flags_init field is
7333 written into the object. */
7334 /* BFD_ASSERT (elf_flags_init (ibfd)); */
7336 in_flags
= elf_elfheader (ibfd
)->e_flags
;
7337 out_flags
= elf_elfheader (obfd
)->e_flags
;
7339 if (!elf_flags_init (obfd
))
7341 /* If the input is the default architecture and had the default
7342 flags then do not bother setting the flags for the output
7343 architecture, instead allow future merges to do this. If no
7344 future merges ever set these flags then they will retain their
7345 uninitialised values, which surprise surprise, correspond
7346 to the default values. */
7347 if (bfd_get_arch_info (ibfd
)->the_default
7348 && elf_elfheader (ibfd
)->e_flags
== 0)
7351 elf_flags_init (obfd
) = TRUE
;
7352 elf_elfheader (obfd
)->e_flags
= in_flags
;
7354 if (bfd_get_arch (obfd
) == bfd_get_arch (ibfd
)
7355 && bfd_get_arch_info (obfd
)->the_default
)
7356 return bfd_set_arch_mach (obfd
, bfd_get_arch (ibfd
), bfd_get_mach (ibfd
));
7361 /* Determine what should happen if the input ARM architecture
7362 does not match the output ARM architecture. */
7363 if (! bfd_arm_merge_machines (ibfd
, obfd
))
7366 /* Identical flags must be compatible. */
7367 if (in_flags
== out_flags
)
7370 /* Check to see if the input BFD actually contains any sections. If
7371 not, its flags may not have been initialised either, but it
7372 cannot actually cause any incompatiblity. Do not short-circuit
7373 dynamic objects; their section list may be emptied by
7374 elf_link_add_object_symbols.
7376 Also check to see if there are no code sections in the input.
7377 In this case there is no need to check for code specific flags.
7378 XXX - do we need to worry about floating-point format compatability
7379 in data sections ? */
7380 if (!(ibfd
->flags
& DYNAMIC
))
7382 bfd_boolean null_input_bfd
= TRUE
;
7383 bfd_boolean only_data_sections
= TRUE
;
7385 for (sec
= ibfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
7387 /* Ignore synthetic glue sections. */
7388 if (strcmp (sec
->name
, ".glue_7")
7389 && strcmp (sec
->name
, ".glue_7t"))
7391 if ((bfd_get_section_flags (ibfd
, sec
)
7392 & (SEC_LOAD
| SEC_CODE
| SEC_HAS_CONTENTS
))
7393 == (SEC_LOAD
| SEC_CODE
| SEC_HAS_CONTENTS
))
7394 only_data_sections
= FALSE
;
7396 null_input_bfd
= FALSE
;
7401 if (null_input_bfd
|| only_data_sections
)
7405 /* Complain about various flag mismatches. */
7406 if (!elf32_arm_versions_compatible (EF_ARM_EABI_VERSION (in_flags
),
7407 EF_ARM_EABI_VERSION (out_flags
)))
7410 (_("ERROR: Source object %B has EABI version %d, but target %B has EABI version %d"),
7412 (in_flags
& EF_ARM_EABIMASK
) >> 24,
7413 (out_flags
& EF_ARM_EABIMASK
) >> 24);
7417 /* Not sure what needs to be checked for EABI versions >= 1. */
7418 /* VxWorks libraries do not use these flags. */
7419 if (get_elf_backend_data (obfd
) != &elf32_arm_vxworks_bed
7420 && get_elf_backend_data (ibfd
) != &elf32_arm_vxworks_bed
7421 && EF_ARM_EABI_VERSION (in_flags
) == EF_ARM_EABI_UNKNOWN
)
7423 if ((in_flags
& EF_ARM_APCS_26
) != (out_flags
& EF_ARM_APCS_26
))
7426 (_("ERROR: %B is compiled for APCS-%d, whereas target %B uses APCS-%d"),
7428 in_flags
& EF_ARM_APCS_26
? 26 : 32,
7429 out_flags
& EF_ARM_APCS_26
? 26 : 32);
7430 flags_compatible
= FALSE
;
7433 if ((in_flags
& EF_ARM_APCS_FLOAT
) != (out_flags
& EF_ARM_APCS_FLOAT
))
7435 if (in_flags
& EF_ARM_APCS_FLOAT
)
7437 (_("ERROR: %B passes floats in float registers, whereas %B passes them in integer registers"),
7441 (_("ERROR: %B passes floats in integer registers, whereas %B passes them in float registers"),
7444 flags_compatible
= FALSE
;
7447 if ((in_flags
& EF_ARM_VFP_FLOAT
) != (out_flags
& EF_ARM_VFP_FLOAT
))
7449 if (in_flags
& EF_ARM_VFP_FLOAT
)
7451 (_("ERROR: %B uses VFP instructions, whereas %B does not"),
7455 (_("ERROR: %B uses FPA instructions, whereas %B does not"),
7458 flags_compatible
= FALSE
;
7461 if ((in_flags
& EF_ARM_MAVERICK_FLOAT
) != (out_flags
& EF_ARM_MAVERICK_FLOAT
))
7463 if (in_flags
& EF_ARM_MAVERICK_FLOAT
)
7465 (_("ERROR: %B uses Maverick instructions, whereas %B does not"),
7469 (_("ERROR: %B does not use Maverick instructions, whereas %B does"),
7472 flags_compatible
= FALSE
;
7475 #ifdef EF_ARM_SOFT_FLOAT
7476 if ((in_flags
& EF_ARM_SOFT_FLOAT
) != (out_flags
& EF_ARM_SOFT_FLOAT
))
7478 /* We can allow interworking between code that is VFP format
7479 layout, and uses either soft float or integer regs for
7480 passing floating point arguments and results. We already
7481 know that the APCS_FLOAT flags match; similarly for VFP
7483 if ((in_flags
& EF_ARM_APCS_FLOAT
) != 0
7484 || (in_flags
& EF_ARM_VFP_FLOAT
) == 0)
7486 if (in_flags
& EF_ARM_SOFT_FLOAT
)
7488 (_("ERROR: %B uses software FP, whereas %B uses hardware FP"),
7492 (_("ERROR: %B uses hardware FP, whereas %B uses software FP"),
7495 flags_compatible
= FALSE
;
7500 /* Interworking mismatch is only a warning. */
7501 if ((in_flags
& EF_ARM_INTERWORK
) != (out_flags
& EF_ARM_INTERWORK
))
7503 if (in_flags
& EF_ARM_INTERWORK
)
7506 (_("Warning: %B supports interworking, whereas %B does not"),
7512 (_("Warning: %B does not support interworking, whereas %B does"),
7518 return flags_compatible
;
7521 /* Display the flags field. */
7524 elf32_arm_print_private_bfd_data (bfd
*abfd
, void * ptr
)
7526 FILE * file
= (FILE *) ptr
;
7527 unsigned long flags
;
7529 BFD_ASSERT (abfd
!= NULL
&& ptr
!= NULL
);
7531 /* Print normal ELF private data. */
7532 _bfd_elf_print_private_bfd_data (abfd
, ptr
);
7534 flags
= elf_elfheader (abfd
)->e_flags
;
7535 /* Ignore init flag - it may not be set, despite the flags field
7536 containing valid data. */
7538 /* xgettext:c-format */
7539 fprintf (file
, _("private flags = %lx:"), elf_elfheader (abfd
)->e_flags
);
7541 switch (EF_ARM_EABI_VERSION (flags
))
7543 case EF_ARM_EABI_UNKNOWN
:
7544 /* The following flag bits are GNU extensions and not part of the
7545 official ARM ELF extended ABI. Hence they are only decoded if
7546 the EABI version is not set. */
7547 if (flags
& EF_ARM_INTERWORK
)
7548 fprintf (file
, _(" [interworking enabled]"));
7550 if (flags
& EF_ARM_APCS_26
)
7551 fprintf (file
, " [APCS-26]");
7553 fprintf (file
, " [APCS-32]");
7555 if (flags
& EF_ARM_VFP_FLOAT
)
7556 fprintf (file
, _(" [VFP float format]"));
7557 else if (flags
& EF_ARM_MAVERICK_FLOAT
)
7558 fprintf (file
, _(" [Maverick float format]"));
7560 fprintf (file
, _(" [FPA float format]"));
7562 if (flags
& EF_ARM_APCS_FLOAT
)
7563 fprintf (file
, _(" [floats passed in float registers]"));
7565 if (flags
& EF_ARM_PIC
)
7566 fprintf (file
, _(" [position independent]"));
7568 if (flags
& EF_ARM_NEW_ABI
)
7569 fprintf (file
, _(" [new ABI]"));
7571 if (flags
& EF_ARM_OLD_ABI
)
7572 fprintf (file
, _(" [old ABI]"));
7574 if (flags
& EF_ARM_SOFT_FLOAT
)
7575 fprintf (file
, _(" [software FP]"));
7577 flags
&= ~(EF_ARM_INTERWORK
| EF_ARM_APCS_26
| EF_ARM_APCS_FLOAT
7578 | EF_ARM_PIC
| EF_ARM_NEW_ABI
| EF_ARM_OLD_ABI
7579 | EF_ARM_SOFT_FLOAT
| EF_ARM_VFP_FLOAT
7580 | EF_ARM_MAVERICK_FLOAT
);
7583 case EF_ARM_EABI_VER1
:
7584 fprintf (file
, _(" [Version1 EABI]"));
7586 if (flags
& EF_ARM_SYMSARESORTED
)
7587 fprintf (file
, _(" [sorted symbol table]"));
7589 fprintf (file
, _(" [unsorted symbol table]"));
7591 flags
&= ~ EF_ARM_SYMSARESORTED
;
7594 case EF_ARM_EABI_VER2
:
7595 fprintf (file
, _(" [Version2 EABI]"));
7597 if (flags
& EF_ARM_SYMSARESORTED
)
7598 fprintf (file
, _(" [sorted symbol table]"));
7600 fprintf (file
, _(" [unsorted symbol table]"));
7602 if (flags
& EF_ARM_DYNSYMSUSESEGIDX
)
7603 fprintf (file
, _(" [dynamic symbols use segment index]"));
7605 if (flags
& EF_ARM_MAPSYMSFIRST
)
7606 fprintf (file
, _(" [mapping symbols precede others]"));
7608 flags
&= ~(EF_ARM_SYMSARESORTED
| EF_ARM_DYNSYMSUSESEGIDX
7609 | EF_ARM_MAPSYMSFIRST
);
7612 case EF_ARM_EABI_VER3
:
7613 fprintf (file
, _(" [Version3 EABI]"));
7616 case EF_ARM_EABI_VER4
:
7617 fprintf (file
, _(" [Version4 EABI]"));
7620 case EF_ARM_EABI_VER5
:
7621 fprintf (file
, _(" [Version5 EABI]"));
7623 if (flags
& EF_ARM_BE8
)
7624 fprintf (file
, _(" [BE8]"));
7626 if (flags
& EF_ARM_LE8
)
7627 fprintf (file
, _(" [LE8]"));
7629 flags
&= ~(EF_ARM_LE8
| EF_ARM_BE8
);
7633 fprintf (file
, _(" <EABI version unrecognised>"));
7637 flags
&= ~ EF_ARM_EABIMASK
;
7639 if (flags
& EF_ARM_RELEXEC
)
7640 fprintf (file
, _(" [relocatable executable]"));
7642 if (flags
& EF_ARM_HASENTRY
)
7643 fprintf (file
, _(" [has entry point]"));
7645 flags
&= ~ (EF_ARM_RELEXEC
| EF_ARM_HASENTRY
);
7648 fprintf (file
, _("<Unrecognised flag bits set>"));
7656 elf32_arm_get_symbol_type (Elf_Internal_Sym
* elf_sym
, int type
)
7658 switch (ELF_ST_TYPE (elf_sym
->st_info
))
7661 return ELF_ST_TYPE (elf_sym
->st_info
);
7664 /* If the symbol is not an object, return the STT_ARM_16BIT flag.
7665 This allows us to distinguish between data used by Thumb instructions
7666 and non-data (which is probably code) inside Thumb regions of an
7668 if (type
!= STT_OBJECT
&& type
!= STT_TLS
)
7669 return ELF_ST_TYPE (elf_sym
->st_info
);
7680 elf32_arm_gc_mark_hook (asection
*sec
,
7681 struct bfd_link_info
*info
,
7682 Elf_Internal_Rela
*rel
,
7683 struct elf_link_hash_entry
*h
,
7684 Elf_Internal_Sym
*sym
)
7687 switch (ELF32_R_TYPE (rel
->r_info
))
7689 case R_ARM_GNU_VTINHERIT
:
7690 case R_ARM_GNU_VTENTRY
:
7694 return _bfd_elf_gc_mark_hook (sec
, info
, rel
, h
, sym
);
7697 /* Update the got entry reference counts for the section being removed. */
7700 elf32_arm_gc_sweep_hook (bfd
* abfd
,
7701 struct bfd_link_info
* info
,
7703 const Elf_Internal_Rela
* relocs
)
7705 Elf_Internal_Shdr
*symtab_hdr
;
7706 struct elf_link_hash_entry
**sym_hashes
;
7707 bfd_signed_vma
*local_got_refcounts
;
7708 const Elf_Internal_Rela
*rel
, *relend
;
7709 struct elf32_arm_link_hash_table
* globals
;
7711 globals
= elf32_arm_hash_table (info
);
7713 elf_section_data (sec
)->local_dynrel
= NULL
;
7715 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
7716 sym_hashes
= elf_sym_hashes (abfd
);
7717 local_got_refcounts
= elf_local_got_refcounts (abfd
);
7719 relend
= relocs
+ sec
->reloc_count
;
7720 for (rel
= relocs
; rel
< relend
; rel
++)
7722 unsigned long r_symndx
;
7723 struct elf_link_hash_entry
*h
= NULL
;
7726 r_symndx
= ELF32_R_SYM (rel
->r_info
);
7727 if (r_symndx
>= symtab_hdr
->sh_info
)
7729 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
7730 while (h
->root
.type
== bfd_link_hash_indirect
7731 || h
->root
.type
== bfd_link_hash_warning
)
7732 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
7735 r_type
= ELF32_R_TYPE (rel
->r_info
);
7736 r_type
= arm_real_reloc_type (globals
, r_type
);
7740 case R_ARM_GOT_PREL
:
7741 case R_ARM_TLS_GD32
:
7742 case R_ARM_TLS_IE32
:
7745 if (h
->got
.refcount
> 0)
7746 h
->got
.refcount
-= 1;
7748 else if (local_got_refcounts
!= NULL
)
7750 if (local_got_refcounts
[r_symndx
] > 0)
7751 local_got_refcounts
[r_symndx
] -= 1;
7755 case R_ARM_TLS_LDM32
:
7756 elf32_arm_hash_table (info
)->tls_ldm_got
.refcount
-= 1;
7760 case R_ARM_ABS32_NOI
:
7762 case R_ARM_REL32_NOI
:
7768 case R_ARM_THM_CALL
:
7769 case R_ARM_MOVW_ABS_NC
:
7770 case R_ARM_MOVT_ABS
:
7771 case R_ARM_MOVW_PREL_NC
:
7772 case R_ARM_MOVT_PREL
:
7773 case R_ARM_THM_MOVW_ABS_NC
:
7774 case R_ARM_THM_MOVT_ABS
:
7775 case R_ARM_THM_MOVW_PREL_NC
:
7776 case R_ARM_THM_MOVT_PREL
:
7777 /* Should the interworking branches be here also? */
7781 struct elf32_arm_link_hash_entry
*eh
;
7782 struct elf32_arm_relocs_copied
**pp
;
7783 struct elf32_arm_relocs_copied
*p
;
7785 eh
= (struct elf32_arm_link_hash_entry
*) h
;
7787 if (h
->plt
.refcount
> 0)
7789 h
->plt
.refcount
-= 1;
7790 if (ELF32_R_TYPE (rel
->r_info
) == R_ARM_THM_CALL
)
7791 eh
->plt_thumb_refcount
--;
7794 if (r_type
== R_ARM_ABS32
7795 || r_type
== R_ARM_REL32
7796 || r_type
== R_ARM_ABS32_NOI
7797 || r_type
== R_ARM_REL32_NOI
)
7799 for (pp
= &eh
->relocs_copied
; (p
= *pp
) != NULL
;
7801 if (p
->section
== sec
)
7804 if (ELF32_R_TYPE (rel
->r_info
) == R_ARM_REL32
7805 || ELF32_R_TYPE (rel
->r_info
) == R_ARM_REL32_NOI
)
7823 /* Look through the relocs for a section during the first phase. */
7826 elf32_arm_check_relocs (bfd
*abfd
, struct bfd_link_info
*info
,
7827 asection
*sec
, const Elf_Internal_Rela
*relocs
)
7829 Elf_Internal_Shdr
*symtab_hdr
;
7830 struct elf_link_hash_entry
**sym_hashes
;
7831 struct elf_link_hash_entry
**sym_hashes_end
;
7832 const Elf_Internal_Rela
*rel
;
7833 const Elf_Internal_Rela
*rel_end
;
7836 bfd_vma
*local_got_offsets
;
7837 struct elf32_arm_link_hash_table
*htab
;
7839 if (info
->relocatable
)
7842 htab
= elf32_arm_hash_table (info
);
7845 /* Create dynamic sections for relocatable executables so that we can
7846 copy relocations. */
7847 if (htab
->root
.is_relocatable_executable
7848 && ! htab
->root
.dynamic_sections_created
)
7850 if (! _bfd_elf_link_create_dynamic_sections (abfd
, info
))
7854 dynobj
= elf_hash_table (info
)->dynobj
;
7855 local_got_offsets
= elf_local_got_offsets (abfd
);
7857 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
7858 sym_hashes
= elf_sym_hashes (abfd
);
7859 sym_hashes_end
= sym_hashes
7860 + symtab_hdr
->sh_size
/ sizeof (Elf32_External_Sym
);
7862 if (!elf_bad_symtab (abfd
))
7863 sym_hashes_end
-= symtab_hdr
->sh_info
;
7865 rel_end
= relocs
+ sec
->reloc_count
;
7866 for (rel
= relocs
; rel
< rel_end
; rel
++)
7868 struct elf_link_hash_entry
*h
;
7869 struct elf32_arm_link_hash_entry
*eh
;
7870 unsigned long r_symndx
;
7873 r_symndx
= ELF32_R_SYM (rel
->r_info
);
7874 r_type
= ELF32_R_TYPE (rel
->r_info
);
7875 r_type
= arm_real_reloc_type (htab
, r_type
);
7877 if (r_symndx
>= NUM_SHDR_ENTRIES (symtab_hdr
))
7879 (*_bfd_error_handler
) (_("%B: bad symbol index: %d"), abfd
,
7884 if (r_symndx
< symtab_hdr
->sh_info
)
7888 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
7889 while (h
->root
.type
== bfd_link_hash_indirect
7890 || h
->root
.type
== bfd_link_hash_warning
)
7891 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
7894 eh
= (struct elf32_arm_link_hash_entry
*) h
;
7899 case R_ARM_GOT_PREL
:
7900 case R_ARM_TLS_GD32
:
7901 case R_ARM_TLS_IE32
:
7902 /* This symbol requires a global offset table entry. */
7904 int tls_type
, old_tls_type
;
7908 case R_ARM_TLS_GD32
: tls_type
= GOT_TLS_GD
; break;
7909 case R_ARM_TLS_IE32
: tls_type
= GOT_TLS_IE
; break;
7910 default: tls_type
= GOT_NORMAL
; break;
7916 old_tls_type
= elf32_arm_hash_entry (h
)->tls_type
;
7920 bfd_signed_vma
*local_got_refcounts
;
7922 /* This is a global offset table entry for a local symbol. */
7923 local_got_refcounts
= elf_local_got_refcounts (abfd
);
7924 if (local_got_refcounts
== NULL
)
7928 size
= symtab_hdr
->sh_info
;
7929 size
*= (sizeof (bfd_signed_vma
) + sizeof(char));
7930 local_got_refcounts
= bfd_zalloc (abfd
, size
);
7931 if (local_got_refcounts
== NULL
)
7933 elf_local_got_refcounts (abfd
) = local_got_refcounts
;
7934 elf32_arm_local_got_tls_type (abfd
)
7935 = (char *) (local_got_refcounts
+ symtab_hdr
->sh_info
);
7937 local_got_refcounts
[r_symndx
] += 1;
7938 old_tls_type
= elf32_arm_local_got_tls_type (abfd
) [r_symndx
];
7941 /* We will already have issued an error message if there is a
7942 TLS / non-TLS mismatch, based on the symbol type. We don't
7943 support any linker relaxations. So just combine any TLS
7945 if (old_tls_type
!= GOT_UNKNOWN
&& old_tls_type
!= GOT_NORMAL
7946 && tls_type
!= GOT_NORMAL
)
7947 tls_type
|= old_tls_type
;
7949 if (old_tls_type
!= tls_type
)
7952 elf32_arm_hash_entry (h
)->tls_type
= tls_type
;
7954 elf32_arm_local_got_tls_type (abfd
) [r_symndx
] = tls_type
;
7959 case R_ARM_TLS_LDM32
:
7960 if (r_type
== R_ARM_TLS_LDM32
)
7961 htab
->tls_ldm_got
.refcount
++;
7964 case R_ARM_GOTOFF32
:
7966 if (htab
->sgot
== NULL
)
7968 if (htab
->root
.dynobj
== NULL
)
7969 htab
->root
.dynobj
= abfd
;
7970 if (!create_got_section (htab
->root
.dynobj
, info
))
7976 /* VxWorks uses dynamic R_ARM_ABS12 relocations for
7977 ldr __GOTT_INDEX__ offsets. */
7978 if (!htab
->vxworks_p
)
7983 case R_ARM_ABS32_NOI
:
7985 case R_ARM_REL32_NOI
:
7991 case R_ARM_THM_CALL
:
7992 case R_ARM_MOVW_ABS_NC
:
7993 case R_ARM_MOVT_ABS
:
7994 case R_ARM_MOVW_PREL_NC
:
7995 case R_ARM_MOVT_PREL
:
7996 case R_ARM_THM_MOVW_ABS_NC
:
7997 case R_ARM_THM_MOVT_ABS
:
7998 case R_ARM_THM_MOVW_PREL_NC
:
7999 case R_ARM_THM_MOVT_PREL
:
8000 /* Should the interworking branches be listed here? */
8003 /* If this reloc is in a read-only section, we might
8004 need a copy reloc. We can't check reliably at this
8005 stage whether the section is read-only, as input
8006 sections have not yet been mapped to output sections.
8007 Tentatively set the flag for now, and correct in
8008 adjust_dynamic_symbol. */
8012 /* We may need a .plt entry if the function this reloc
8013 refers to is in a different object. We can't tell for
8014 sure yet, because something later might force the
8016 if (r_type
!= R_ARM_ABS32
8017 && r_type
!= R_ARM_REL32
8018 && r_type
!= R_ARM_ABS32_NOI
8019 && r_type
!= R_ARM_REL32_NOI
)
8022 /* If we create a PLT entry, this relocation will reference
8023 it, even if it's an ABS32 relocation. */
8024 h
->plt
.refcount
+= 1;
8026 if (r_type
== R_ARM_THM_CALL
)
8027 eh
->plt_thumb_refcount
+= 1;
8030 /* If we are creating a shared library or relocatable executable,
8031 and this is a reloc against a global symbol, or a non PC
8032 relative reloc against a local symbol, then we need to copy
8033 the reloc into the shared library. However, if we are linking
8034 with -Bsymbolic, we do not need to copy a reloc against a
8035 global symbol which is defined in an object we are
8036 including in the link (i.e., DEF_REGULAR is set). At
8037 this point we have not seen all the input files, so it is
8038 possible that DEF_REGULAR is not set now but will be set
8039 later (it is never cleared). We account for that
8040 possibility below by storing information in the
8041 relocs_copied field of the hash table entry. */
8042 if ((info
->shared
|| htab
->root
.is_relocatable_executable
)
8043 && (sec
->flags
& SEC_ALLOC
) != 0
8044 && ((r_type
== R_ARM_ABS32
|| r_type
== R_ARM_ABS32_NOI
)
8045 || (h
!= NULL
&& ! h
->needs_plt
8046 && (! info
->symbolic
|| ! h
->def_regular
))))
8048 struct elf32_arm_relocs_copied
*p
, **head
;
8050 /* When creating a shared object, we must copy these
8051 reloc types into the output file. We create a reloc
8052 section in dynobj and make room for this reloc. */
8057 name
= (bfd_elf_string_from_elf_section
8059 elf_elfheader (abfd
)->e_shstrndx
,
8060 elf_section_data (sec
)->rel_hdr
.sh_name
));
8064 BFD_ASSERT (reloc_section_p (htab
, name
, sec
));
8066 sreloc
= bfd_get_section_by_name (dynobj
, name
);
8071 flags
= (SEC_HAS_CONTENTS
| SEC_READONLY
8072 | SEC_IN_MEMORY
| SEC_LINKER_CREATED
);
8073 if ((sec
->flags
& SEC_ALLOC
) != 0
8074 /* BPABI objects never have dynamic
8075 relocations mapped. */
8076 && !htab
->symbian_p
)
8077 flags
|= SEC_ALLOC
| SEC_LOAD
;
8078 sreloc
= bfd_make_section_with_flags (dynobj
,
8082 || ! bfd_set_section_alignment (dynobj
, sreloc
, 2))
8086 elf_section_data (sec
)->sreloc
= sreloc
;
8089 /* If this is a global symbol, we count the number of
8090 relocations we need for this symbol. */
8093 head
= &((struct elf32_arm_link_hash_entry
*) h
)->relocs_copied
;
8097 /* Track dynamic relocs needed for local syms too.
8098 We really need local syms available to do this
8104 s
= bfd_section_from_r_symndx (abfd
, &htab
->sym_sec
,
8109 vpp
= &elf_section_data (s
)->local_dynrel
;
8110 head
= (struct elf32_arm_relocs_copied
**) vpp
;
8114 if (p
== NULL
|| p
->section
!= sec
)
8116 bfd_size_type amt
= sizeof *p
;
8118 p
= bfd_alloc (htab
->root
.dynobj
, amt
);
8128 if (r_type
== R_ARM_REL32
|| r_type
== R_ARM_REL32_NOI
)
8134 /* This relocation describes the C++ object vtable hierarchy.
8135 Reconstruct it for later use during GC. */
8136 case R_ARM_GNU_VTINHERIT
:
8137 if (!bfd_elf_gc_record_vtinherit (abfd
, sec
, h
, rel
->r_offset
))
8141 /* This relocation describes which C++ vtable entries are actually
8142 used. Record for later use during GC. */
8143 case R_ARM_GNU_VTENTRY
:
8144 if (!bfd_elf_gc_record_vtentry (abfd
, sec
, h
, rel
->r_offset
))
8153 /* Unwinding tables are not referenced directly. This pass marks them as
8154 required if the corresponding code section is marked. */
8157 elf32_arm_gc_mark_extra_sections(struct bfd_link_info
*info
,
8158 elf_gc_mark_hook_fn gc_mark_hook
)
8161 Elf_Internal_Shdr
**elf_shdrp
;
8164 /* Marking EH data may cause additional code sections to be marked,
8165 requiring multiple passes. */
8170 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link_next
)
8174 if (bfd_get_flavour (sub
) != bfd_target_elf_flavour
)
8177 elf_shdrp
= elf_elfsections (sub
);
8178 for (o
= sub
->sections
; o
!= NULL
; o
= o
->next
)
8180 Elf_Internal_Shdr
*hdr
;
8181 hdr
= &elf_section_data (o
)->this_hdr
;
8182 if (hdr
->sh_type
== SHT_ARM_EXIDX
&& hdr
->sh_link
8184 && elf_shdrp
[hdr
->sh_link
]->bfd_section
->gc_mark
)
8187 if (!_bfd_elf_gc_mark (info
, o
, gc_mark_hook
))
8197 /* Treat mapping symbols as special target symbols. */
8200 elf32_arm_is_target_special_symbol (bfd
* abfd ATTRIBUTE_UNUSED
, asymbol
* sym
)
8202 return bfd_is_arm_special_symbol_name (sym
->name
,
8203 BFD_ARM_SPECIAL_SYM_TYPE_ANY
);
8206 /* This is a copy of elf_find_function() from elf.c except that
8207 ARM mapping symbols are ignored when looking for function names
8208 and STT_ARM_TFUNC is considered to a function type. */
8211 arm_elf_find_function (bfd
* abfd ATTRIBUTE_UNUSED
,
8215 const char ** filename_ptr
,
8216 const char ** functionname_ptr
)
8218 const char * filename
= NULL
;
8219 asymbol
* func
= NULL
;
8220 bfd_vma low_func
= 0;
8223 for (p
= symbols
; *p
!= NULL
; p
++)
8227 q
= (elf_symbol_type
*) *p
;
8229 switch (ELF_ST_TYPE (q
->internal_elf_sym
.st_info
))
8234 filename
= bfd_asymbol_name (&q
->symbol
);
8239 /* Skip mapping symbols. */
8240 if ((q
->symbol
.flags
& BSF_LOCAL
)
8241 && bfd_is_arm_special_symbol_name (q
->symbol
.name
,
8242 BFD_ARM_SPECIAL_SYM_TYPE_ANY
))
8245 if (bfd_get_section (&q
->symbol
) == section
8246 && q
->symbol
.value
>= low_func
8247 && q
->symbol
.value
<= offset
)
8249 func
= (asymbol
*) q
;
8250 low_func
= q
->symbol
.value
;
8260 *filename_ptr
= filename
;
8261 if (functionname_ptr
)
8262 *functionname_ptr
= bfd_asymbol_name (func
);
8268 /* Find the nearest line to a particular section and offset, for error
8269 reporting. This code is a duplicate of the code in elf.c, except
8270 that it uses arm_elf_find_function. */
8273 elf32_arm_find_nearest_line (bfd
* abfd
,
8277 const char ** filename_ptr
,
8278 const char ** functionname_ptr
,
8279 unsigned int * line_ptr
)
8281 bfd_boolean found
= FALSE
;
8283 /* We skip _bfd_dwarf1_find_nearest_line since no known ARM toolchain uses it. */
8285 if (_bfd_dwarf2_find_nearest_line (abfd
, section
, symbols
, offset
,
8286 filename_ptr
, functionname_ptr
,
8288 & elf_tdata (abfd
)->dwarf2_find_line_info
))
8290 if (!*functionname_ptr
)
8291 arm_elf_find_function (abfd
, section
, symbols
, offset
,
8292 *filename_ptr
? NULL
: filename_ptr
,
8298 if (! _bfd_stab_section_find_nearest_line (abfd
, symbols
, section
, offset
,
8299 & found
, filename_ptr
,
8300 functionname_ptr
, line_ptr
,
8301 & elf_tdata (abfd
)->line_info
))
8304 if (found
&& (*functionname_ptr
|| *line_ptr
))
8307 if (symbols
== NULL
)
8310 if (! arm_elf_find_function (abfd
, section
, symbols
, offset
,
8311 filename_ptr
, functionname_ptr
))
8319 elf32_arm_find_inliner_info (bfd
* abfd
,
8320 const char ** filename_ptr
,
8321 const char ** functionname_ptr
,
8322 unsigned int * line_ptr
)
8325 found
= _bfd_dwarf2_find_inliner_info (abfd
, filename_ptr
,
8326 functionname_ptr
, line_ptr
,
8327 & elf_tdata (abfd
)->dwarf2_find_line_info
);
8331 /* Adjust a symbol defined by a dynamic object and referenced by a
8332 regular object. The current definition is in some section of the
8333 dynamic object, but we're not including those sections. We have to
8334 change the definition to something the rest of the link can
8338 elf32_arm_adjust_dynamic_symbol (struct bfd_link_info
* info
,
8339 struct elf_link_hash_entry
* h
)
8343 unsigned int power_of_two
;
8344 struct elf32_arm_link_hash_entry
* eh
;
8345 struct elf32_arm_link_hash_table
*globals
;
8347 globals
= elf32_arm_hash_table (info
);
8348 dynobj
= elf_hash_table (info
)->dynobj
;
8350 /* Make sure we know what is going on here. */
8351 BFD_ASSERT (dynobj
!= NULL
8353 || h
->u
.weakdef
!= NULL
8356 && !h
->def_regular
)));
8358 eh
= (struct elf32_arm_link_hash_entry
*) h
;
8360 /* If this is a function, put it in the procedure linkage table. We
8361 will fill in the contents of the procedure linkage table later,
8362 when we know the address of the .got section. */
8363 if (h
->type
== STT_FUNC
|| h
->type
== STT_ARM_TFUNC
8366 if (h
->plt
.refcount
<= 0
8367 || SYMBOL_CALLS_LOCAL (info
, h
)
8368 || (ELF_ST_VISIBILITY (h
->other
) != STV_DEFAULT
8369 && h
->root
.type
== bfd_link_hash_undefweak
))
8371 /* This case can occur if we saw a PLT32 reloc in an input
8372 file, but the symbol was never referred to by a dynamic
8373 object, or if all references were garbage collected. In
8374 such a case, we don't actually need to build a procedure
8375 linkage table, and we can just do a PC24 reloc instead. */
8376 h
->plt
.offset
= (bfd_vma
) -1;
8377 eh
->plt_thumb_refcount
= 0;
8385 /* It's possible that we incorrectly decided a .plt reloc was
8386 needed for an R_ARM_PC24 or similar reloc to a non-function sym
8387 in check_relocs. We can't decide accurately between function
8388 and non-function syms in check-relocs; Objects loaded later in
8389 the link may change h->type. So fix it now. */
8390 h
->plt
.offset
= (bfd_vma
) -1;
8391 eh
->plt_thumb_refcount
= 0;
8394 /* If this is a weak symbol, and there is a real definition, the
8395 processor independent code will have arranged for us to see the
8396 real definition first, and we can just use the same value. */
8397 if (h
->u
.weakdef
!= NULL
)
8399 BFD_ASSERT (h
->u
.weakdef
->root
.type
== bfd_link_hash_defined
8400 || h
->u
.weakdef
->root
.type
== bfd_link_hash_defweak
);
8401 h
->root
.u
.def
.section
= h
->u
.weakdef
->root
.u
.def
.section
;
8402 h
->root
.u
.def
.value
= h
->u
.weakdef
->root
.u
.def
.value
;
8406 /* If there are no non-GOT references, we do not need a copy
8408 if (!h
->non_got_ref
)
8411 /* This is a reference to a symbol defined by a dynamic object which
8412 is not a function. */
8414 /* If we are creating a shared library, we must presume that the
8415 only references to the symbol are via the global offset table.
8416 For such cases we need not do anything here; the relocations will
8417 be handled correctly by relocate_section. Relocatable executables
8418 can reference data in shared objects directly, so we don't need to
8419 do anything here. */
8420 if (info
->shared
|| globals
->root
.is_relocatable_executable
)
8425 (*_bfd_error_handler
) (_("dynamic variable `%s' is zero size"),
8426 h
->root
.root
.string
);
8430 /* We must allocate the symbol in our .dynbss section, which will
8431 become part of the .bss section of the executable. There will be
8432 an entry for this symbol in the .dynsym section. The dynamic
8433 object will contain position independent code, so all references
8434 from the dynamic object to this symbol will go through the global
8435 offset table. The dynamic linker will use the .dynsym entry to
8436 determine the address it must put in the global offset table, so
8437 both the dynamic object and the regular object will refer to the
8438 same memory location for the variable. */
8439 s
= bfd_get_section_by_name (dynobj
, ".dynbss");
8440 BFD_ASSERT (s
!= NULL
);
8442 /* We must generate a R_ARM_COPY reloc to tell the dynamic linker to
8443 copy the initial value out of the dynamic object and into the
8444 runtime process image. We need to remember the offset into the
8445 .rel(a).bss section we are going to use. */
8446 if ((h
->root
.u
.def
.section
->flags
& SEC_ALLOC
) != 0)
8450 srel
= bfd_get_section_by_name (dynobj
, RELOC_SECTION (globals
, ".bss"));
8451 BFD_ASSERT (srel
!= NULL
);
8452 srel
->size
+= RELOC_SIZE (globals
);
8456 /* We need to figure out the alignment required for this symbol. I
8457 have no idea how ELF linkers handle this. */
8458 power_of_two
= bfd_log2 (h
->size
);
8459 if (power_of_two
> 3)
8462 /* Apply the required alignment. */
8463 s
->size
= BFD_ALIGN (s
->size
, (bfd_size_type
) (1 << power_of_two
));
8464 if (power_of_two
> bfd_get_section_alignment (dynobj
, s
))
8466 if (! bfd_set_section_alignment (dynobj
, s
, power_of_two
))
8470 /* Define the symbol as being at this point in the section. */
8471 h
->root
.u
.def
.section
= s
;
8472 h
->root
.u
.def
.value
= s
->size
;
8474 /* Increment the section size to make room for the symbol. */
8480 /* Allocate space in .plt, .got and associated reloc sections for
8484 allocate_dynrelocs (struct elf_link_hash_entry
*h
, void * inf
)
8486 struct bfd_link_info
*info
;
8487 struct elf32_arm_link_hash_table
*htab
;
8488 struct elf32_arm_link_hash_entry
*eh
;
8489 struct elf32_arm_relocs_copied
*p
;
8491 eh
= (struct elf32_arm_link_hash_entry
*) h
;
8493 if (h
->root
.type
== bfd_link_hash_indirect
)
8496 if (h
->root
.type
== bfd_link_hash_warning
)
8497 /* When warning symbols are created, they **replace** the "real"
8498 entry in the hash table, thus we never get to see the real
8499 symbol in a hash traversal. So look at it now. */
8500 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
8502 info
= (struct bfd_link_info
*) inf
;
8503 htab
= elf32_arm_hash_table (info
);
8505 if (htab
->root
.dynamic_sections_created
8506 && h
->plt
.refcount
> 0)
8508 /* Make sure this symbol is output as a dynamic symbol.
8509 Undefined weak syms won't yet be marked as dynamic. */
8510 if (h
->dynindx
== -1
8511 && !h
->forced_local
)
8513 if (! bfd_elf_link_record_dynamic_symbol (info
, h
))
8518 || WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, 0, h
))
8520 asection
*s
= htab
->splt
;
8522 /* If this is the first .plt entry, make room for the special
8525 s
->size
+= htab
->plt_header_size
;
8527 h
->plt
.offset
= s
->size
;
8529 /* If we will insert a Thumb trampoline before this PLT, leave room
8531 if (!htab
->use_blx
&& eh
->plt_thumb_refcount
> 0)
8533 h
->plt
.offset
+= PLT_THUMB_STUB_SIZE
;
8534 s
->size
+= PLT_THUMB_STUB_SIZE
;
8537 /* If this symbol is not defined in a regular file, and we are
8538 not generating a shared library, then set the symbol to this
8539 location in the .plt. This is required to make function
8540 pointers compare as equal between the normal executable and
8541 the shared library. */
8545 h
->root
.u
.def
.section
= s
;
8546 h
->root
.u
.def
.value
= h
->plt
.offset
;
8548 /* Make sure the function is not marked as Thumb, in case
8549 it is the target of an ABS32 relocation, which will
8550 point to the PLT entry. */
8551 if (ELF_ST_TYPE (h
->type
) == STT_ARM_TFUNC
)
8552 h
->type
= ELF_ST_INFO (ELF_ST_BIND (h
->type
), STT_FUNC
);
8555 /* Make room for this entry. */
8556 s
->size
+= htab
->plt_entry_size
;
8558 if (!htab
->symbian_p
)
8560 /* We also need to make an entry in the .got.plt section, which
8561 will be placed in the .got section by the linker script. */
8562 eh
->plt_got_offset
= htab
->sgotplt
->size
;
8563 htab
->sgotplt
->size
+= 4;
8566 /* We also need to make an entry in the .rel(a).plt section. */
8567 htab
->srelplt
->size
+= RELOC_SIZE (htab
);
8569 /* VxWorks executables have a second set of relocations for
8570 each PLT entry. They go in a separate relocation section,
8571 which is processed by the kernel loader. */
8572 if (htab
->vxworks_p
&& !info
->shared
)
8574 /* There is a relocation for the initial PLT entry:
8575 an R_ARM_32 relocation for _GLOBAL_OFFSET_TABLE_. */
8576 if (h
->plt
.offset
== htab
->plt_header_size
)
8577 htab
->srelplt2
->size
+= RELOC_SIZE (htab
);
8579 /* There are two extra relocations for each subsequent
8580 PLT entry: an R_ARM_32 relocation for the GOT entry,
8581 and an R_ARM_32 relocation for the PLT entry. */
8582 htab
->srelplt2
->size
+= RELOC_SIZE (htab
) * 2;
8587 h
->plt
.offset
= (bfd_vma
) -1;
8593 h
->plt
.offset
= (bfd_vma
) -1;
8597 if (h
->got
.refcount
> 0)
8601 int tls_type
= elf32_arm_hash_entry (h
)->tls_type
;
8604 /* Make sure this symbol is output as a dynamic symbol.
8605 Undefined weak syms won't yet be marked as dynamic. */
8606 if (h
->dynindx
== -1
8607 && !h
->forced_local
)
8609 if (! bfd_elf_link_record_dynamic_symbol (info
, h
))
8613 if (!htab
->symbian_p
)
8616 h
->got
.offset
= s
->size
;
8618 if (tls_type
== GOT_UNKNOWN
)
8621 if (tls_type
== GOT_NORMAL
)
8622 /* Non-TLS symbols need one GOT slot. */
8626 if (tls_type
& GOT_TLS_GD
)
8627 /* R_ARM_TLS_GD32 needs 2 consecutive GOT slots. */
8629 if (tls_type
& GOT_TLS_IE
)
8630 /* R_ARM_TLS_IE32 needs one GOT slot. */
8634 dyn
= htab
->root
.dynamic_sections_created
;
8637 if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn
, info
->shared
, h
)
8639 || !SYMBOL_REFERENCES_LOCAL (info
, h
)))
8642 if (tls_type
!= GOT_NORMAL
8643 && (info
->shared
|| indx
!= 0)
8644 && (ELF_ST_VISIBILITY (h
->other
) == STV_DEFAULT
8645 || h
->root
.type
!= bfd_link_hash_undefweak
))
8647 if (tls_type
& GOT_TLS_IE
)
8648 htab
->srelgot
->size
+= RELOC_SIZE (htab
);
8650 if (tls_type
& GOT_TLS_GD
)
8651 htab
->srelgot
->size
+= RELOC_SIZE (htab
);
8653 if ((tls_type
& GOT_TLS_GD
) && indx
!= 0)
8654 htab
->srelgot
->size
+= RELOC_SIZE (htab
);
8656 else if ((ELF_ST_VISIBILITY (h
->other
) == STV_DEFAULT
8657 || h
->root
.type
!= bfd_link_hash_undefweak
)
8659 || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn
, 0, h
)))
8660 htab
->srelgot
->size
+= RELOC_SIZE (htab
);
8664 h
->got
.offset
= (bfd_vma
) -1;
8666 /* Allocate stubs for exported Thumb functions on v4t. */
8667 if (!htab
->use_blx
&& h
->dynindx
!= -1
8669 && ELF_ST_TYPE (h
->type
) == STT_ARM_TFUNC
8670 && ELF_ST_VISIBILITY (h
->other
) == STV_DEFAULT
)
8672 struct elf_link_hash_entry
* th
;
8673 struct bfd_link_hash_entry
* bh
;
8674 struct elf_link_hash_entry
* myh
;
8678 /* Create a new symbol to regist the real location of the function. */
8679 s
= h
->root
.u
.def
.section
;
8680 sprintf(name
, "__real_%s", h
->root
.root
.string
);
8681 _bfd_generic_link_add_one_symbol (info
, s
->owner
,
8682 name
, BSF_GLOBAL
, s
,
8683 h
->root
.u
.def
.value
,
8684 NULL
, TRUE
, FALSE
, &bh
);
8686 myh
= (struct elf_link_hash_entry
*) bh
;
8687 myh
->type
= ELF_ST_INFO (STB_LOCAL
, STT_ARM_TFUNC
);
8688 myh
->forced_local
= 1;
8689 eh
->export_glue
= myh
;
8690 th
= record_arm_to_thumb_glue (info
, h
);
8691 /* Point the symbol at the stub. */
8692 h
->type
= ELF_ST_INFO (ELF_ST_BIND (h
->type
), STT_FUNC
);
8693 h
->root
.u
.def
.section
= th
->root
.u
.def
.section
;
8694 h
->root
.u
.def
.value
= th
->root
.u
.def
.value
& ~1;
8697 if (eh
->relocs_copied
== NULL
)
8700 /* In the shared -Bsymbolic case, discard space allocated for
8701 dynamic pc-relative relocs against symbols which turn out to be
8702 defined in regular objects. For the normal shared case, discard
8703 space for pc-relative relocs that have become local due to symbol
8704 visibility changes. */
8706 if (info
->shared
|| htab
->root
.is_relocatable_executable
)
8708 /* The only reloc thats uses pc_count are R_ARM_REL32 and
8709 R_ARM_REL32_NOI, which will appear on something like
8710 ".long foo - .". We want calls to protected symbols to resolve
8711 directly to the function rather than going via the plt. If people
8712 want function pointer comparisons to work as expected then they
8713 should avoid writing assembly like ".long foo - .". */
8714 if (SYMBOL_CALLS_LOCAL (info
, h
))
8716 struct elf32_arm_relocs_copied
**pp
;
8718 for (pp
= &eh
->relocs_copied
; (p
= *pp
) != NULL
; )
8720 p
->count
-= p
->pc_count
;
8729 /* Also discard relocs on undefined weak syms with non-default
8731 if (eh
->relocs_copied
!= NULL
8732 && h
->root
.type
== bfd_link_hash_undefweak
)
8734 if (ELF_ST_VISIBILITY (h
->other
) != STV_DEFAULT
)
8735 eh
->relocs_copied
= NULL
;
8737 /* Make sure undefined weak symbols are output as a dynamic
8739 else if (h
->dynindx
== -1
8740 && !h
->forced_local
)
8742 if (! bfd_elf_link_record_dynamic_symbol (info
, h
))
8747 else if (htab
->root
.is_relocatable_executable
&& h
->dynindx
== -1
8748 && h
->root
.type
== bfd_link_hash_new
)
8750 /* Output absolute symbols so that we can create relocations
8751 against them. For normal symbols we output a relocation
8752 against the section that contains them. */
8753 if (! bfd_elf_link_record_dynamic_symbol (info
, h
))
8760 /* For the non-shared case, discard space for relocs against
8761 symbols which turn out to need copy relocs or are not
8767 || (htab
->root
.dynamic_sections_created
8768 && (h
->root
.type
== bfd_link_hash_undefweak
8769 || h
->root
.type
== bfd_link_hash_undefined
))))
8771 /* Make sure this symbol is output as a dynamic symbol.
8772 Undefined weak syms won't yet be marked as dynamic. */
8773 if (h
->dynindx
== -1
8774 && !h
->forced_local
)
8776 if (! bfd_elf_link_record_dynamic_symbol (info
, h
))
8780 /* If that succeeded, we know we'll be keeping all the
8782 if (h
->dynindx
!= -1)
8786 eh
->relocs_copied
= NULL
;
8791 /* Finally, allocate space. */
8792 for (p
= eh
->relocs_copied
; p
!= NULL
; p
= p
->next
)
8794 asection
*sreloc
= elf_section_data (p
->section
)->sreloc
;
8795 sreloc
->size
+= p
->count
* RELOC_SIZE (htab
);
8801 /* Find any dynamic relocs that apply to read-only sections. */
8804 elf32_arm_readonly_dynrelocs (struct elf_link_hash_entry
*h
, PTR inf
)
8806 struct elf32_arm_link_hash_entry
*eh
;
8807 struct elf32_arm_relocs_copied
*p
;
8809 if (h
->root
.type
== bfd_link_hash_warning
)
8810 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
8812 eh
= (struct elf32_arm_link_hash_entry
*) h
;
8813 for (p
= eh
->relocs_copied
; p
!= NULL
; p
= p
->next
)
8815 asection
*s
= p
->section
;
8817 if (s
!= NULL
&& (s
->flags
& SEC_READONLY
) != 0)
8819 struct bfd_link_info
*info
= (struct bfd_link_info
*) inf
;
8821 info
->flags
|= DF_TEXTREL
;
8823 /* Not an error, just cut short the traversal. */
8831 bfd_elf32_arm_set_byteswap_code (struct bfd_link_info
*info
,
8834 struct elf32_arm_link_hash_table
*globals
;
8836 globals
= elf32_arm_hash_table (info
);
8837 globals
->byteswap_code
= byteswap_code
;
8840 /* Set the sizes of the dynamic sections. */
8843 elf32_arm_size_dynamic_sections (bfd
* output_bfd ATTRIBUTE_UNUSED
,
8844 struct bfd_link_info
* info
)
8851 struct elf32_arm_link_hash_table
*htab
;
8853 htab
= elf32_arm_hash_table (info
);
8854 dynobj
= elf_hash_table (info
)->dynobj
;
8855 BFD_ASSERT (dynobj
!= NULL
);
8856 check_use_blx (htab
);
8858 if (elf_hash_table (info
)->dynamic_sections_created
)
8860 /* Set the contents of the .interp section to the interpreter. */
8861 if (info
->executable
)
8863 s
= bfd_get_section_by_name (dynobj
, ".interp");
8864 BFD_ASSERT (s
!= NULL
);
8865 s
->size
= sizeof ELF_DYNAMIC_INTERPRETER
;
8866 s
->contents
= (unsigned char *) ELF_DYNAMIC_INTERPRETER
;
8870 /* Set up .got offsets for local syms, and space for local dynamic
8872 for (ibfd
= info
->input_bfds
; ibfd
!= NULL
; ibfd
= ibfd
->link_next
)
8874 bfd_signed_vma
*local_got
;
8875 bfd_signed_vma
*end_local_got
;
8876 char *local_tls_type
;
8877 bfd_size_type locsymcount
;
8878 Elf_Internal_Shdr
*symtab_hdr
;
8881 if (bfd_get_flavour (ibfd
) != bfd_target_elf_flavour
)
8884 for (s
= ibfd
->sections
; s
!= NULL
; s
= s
->next
)
8886 struct elf32_arm_relocs_copied
*p
;
8888 for (p
= elf_section_data (s
)->local_dynrel
; p
!= NULL
; p
= p
->next
)
8890 if (!bfd_is_abs_section (p
->section
)
8891 && bfd_is_abs_section (p
->section
->output_section
))
8893 /* Input section has been discarded, either because
8894 it is a copy of a linkonce section or due to
8895 linker script /DISCARD/, so we'll be discarding
8898 else if (p
->count
!= 0)
8900 srel
= elf_section_data (p
->section
)->sreloc
;
8901 srel
->size
+= p
->count
* RELOC_SIZE (htab
);
8902 if ((p
->section
->output_section
->flags
& SEC_READONLY
) != 0)
8903 info
->flags
|= DF_TEXTREL
;
8908 local_got
= elf_local_got_refcounts (ibfd
);
8912 symtab_hdr
= &elf_tdata (ibfd
)->symtab_hdr
;
8913 locsymcount
= symtab_hdr
->sh_info
;
8914 end_local_got
= local_got
+ locsymcount
;
8915 local_tls_type
= elf32_arm_local_got_tls_type (ibfd
);
8917 srel
= htab
->srelgot
;
8918 for (; local_got
< end_local_got
; ++local_got
, ++local_tls_type
)
8922 *local_got
= s
->size
;
8923 if (*local_tls_type
& GOT_TLS_GD
)
8924 /* TLS_GD relocs need an 8-byte structure in the GOT. */
8926 if (*local_tls_type
& GOT_TLS_IE
)
8928 if (*local_tls_type
== GOT_NORMAL
)
8931 if (info
->shared
|| *local_tls_type
== GOT_TLS_GD
)
8932 srel
->size
+= RELOC_SIZE (htab
);
8935 *local_got
= (bfd_vma
) -1;
8939 if (htab
->tls_ldm_got
.refcount
> 0)
8941 /* Allocate two GOT entries and one dynamic relocation (if necessary)
8942 for R_ARM_TLS_LDM32 relocations. */
8943 htab
->tls_ldm_got
.offset
= htab
->sgot
->size
;
8944 htab
->sgot
->size
+= 8;
8946 htab
->srelgot
->size
+= RELOC_SIZE (htab
);
8949 htab
->tls_ldm_got
.offset
= -1;
8951 /* Allocate global sym .plt and .got entries, and space for global
8952 sym dynamic relocs. */
8953 elf_link_hash_traverse (& htab
->root
, allocate_dynrelocs
, info
);
8955 /* Here we rummage through the found bfds to collect glue information. */
8956 for (ibfd
= info
->input_bfds
; ibfd
!= NULL
; ibfd
= ibfd
->link_next
)
8958 /* Initialise mapping tables for code/data. */
8959 bfd_elf32_arm_init_maps (ibfd
);
8961 if (!bfd_elf32_arm_process_before_allocation (ibfd
, info
)
8962 || !bfd_elf32_arm_vfp11_erratum_scan (ibfd
, info
))
8963 /* xgettext:c-format */
8964 _bfd_error_handler (_("Errors encountered processing file %s"),
8968 /* The check_relocs and adjust_dynamic_symbol entry points have
8969 determined the sizes of the various dynamic sections. Allocate
8973 for (s
= dynobj
->sections
; s
!= NULL
; s
= s
->next
)
8977 if ((s
->flags
& SEC_LINKER_CREATED
) == 0)
8980 /* It's OK to base decisions on the section name, because none
8981 of the dynobj section names depend upon the input files. */
8982 name
= bfd_get_section_name (dynobj
, s
);
8984 if (strcmp (name
, ".plt") == 0)
8986 /* Remember whether there is a PLT. */
8989 else if (CONST_STRNEQ (name
, ".rel"))
8993 /* Remember whether there are any reloc sections other
8994 than .rel(a).plt and .rela.plt.unloaded. */
8995 if (s
!= htab
->srelplt
&& s
!= htab
->srelplt2
)
8998 /* We use the reloc_count field as a counter if we need
8999 to copy relocs into the output file. */
9003 else if (! CONST_STRNEQ (name
, ".got")
9004 && strcmp (name
, ".dynbss") != 0)
9006 /* It's not one of our sections, so don't allocate space. */
9012 /* If we don't need this section, strip it from the
9013 output file. This is mostly to handle .rel(a).bss and
9014 .rel(a).plt. We must create both sections in
9015 create_dynamic_sections, because they must be created
9016 before the linker maps input sections to output
9017 sections. The linker does that before
9018 adjust_dynamic_symbol is called, and it is that
9019 function which decides whether anything needs to go
9020 into these sections. */
9021 s
->flags
|= SEC_EXCLUDE
;
9025 if ((s
->flags
& SEC_HAS_CONTENTS
) == 0)
9028 /* Allocate memory for the section contents. */
9029 s
->contents
= (bfd_byte
*) bfd_zalloc (dynobj
, s
->size
);
9030 if (s
->contents
== NULL
)
9034 if (elf_hash_table (info
)->dynamic_sections_created
)
9036 /* Add some entries to the .dynamic section. We fill in the
9037 values later, in elf32_arm_finish_dynamic_sections, but we
9038 must add the entries now so that we get the correct size for
9039 the .dynamic section. The DT_DEBUG entry is filled in by the
9040 dynamic linker and used by the debugger. */
9041 #define add_dynamic_entry(TAG, VAL) \
9042 _bfd_elf_add_dynamic_entry (info, TAG, VAL)
9044 if (info
->executable
)
9046 if (!add_dynamic_entry (DT_DEBUG
, 0))
9052 if ( !add_dynamic_entry (DT_PLTGOT
, 0)
9053 || !add_dynamic_entry (DT_PLTRELSZ
, 0)
9054 || !add_dynamic_entry (DT_PLTREL
,
9055 htab
->use_rel
? DT_REL
: DT_RELA
)
9056 || !add_dynamic_entry (DT_JMPREL
, 0))
9064 if (!add_dynamic_entry (DT_REL
, 0)
9065 || !add_dynamic_entry (DT_RELSZ
, 0)
9066 || !add_dynamic_entry (DT_RELENT
, RELOC_SIZE (htab
)))
9071 if (!add_dynamic_entry (DT_RELA
, 0)
9072 || !add_dynamic_entry (DT_RELASZ
, 0)
9073 || !add_dynamic_entry (DT_RELAENT
, RELOC_SIZE (htab
)))
9078 /* If any dynamic relocs apply to a read-only section,
9079 then we need a DT_TEXTREL entry. */
9080 if ((info
->flags
& DF_TEXTREL
) == 0)
9081 elf_link_hash_traverse (&htab
->root
, elf32_arm_readonly_dynrelocs
,
9084 if ((info
->flags
& DF_TEXTREL
) != 0)
9086 if (!add_dynamic_entry (DT_TEXTREL
, 0))
9090 #undef add_dynamic_entry
9095 /* Finish up dynamic symbol handling. We set the contents of various
9096 dynamic sections here. */
9099 elf32_arm_finish_dynamic_symbol (bfd
* output_bfd
, struct bfd_link_info
* info
,
9100 struct elf_link_hash_entry
* h
, Elf_Internal_Sym
* sym
)
9103 struct elf32_arm_link_hash_table
*htab
;
9104 struct elf32_arm_link_hash_entry
*eh
;
9106 dynobj
= elf_hash_table (info
)->dynobj
;
9107 htab
= elf32_arm_hash_table (info
);
9108 eh
= (struct elf32_arm_link_hash_entry
*) h
;
9110 if (h
->plt
.offset
!= (bfd_vma
) -1)
9116 Elf_Internal_Rela rel
;
9118 /* This symbol has an entry in the procedure linkage table. Set
9121 BFD_ASSERT (h
->dynindx
!= -1);
9123 splt
= bfd_get_section_by_name (dynobj
, ".plt");
9124 srel
= bfd_get_section_by_name (dynobj
, RELOC_SECTION (htab
, ".plt"));
9125 BFD_ASSERT (splt
!= NULL
&& srel
!= NULL
);
9127 /* Fill in the entry in the procedure linkage table. */
9128 if (htab
->symbian_p
)
9130 put_arm_insn (htab
, output_bfd
,
9131 elf32_arm_symbian_plt_entry
[0],
9132 splt
->contents
+ h
->plt
.offset
);
9133 bfd_put_32 (output_bfd
,
9134 elf32_arm_symbian_plt_entry
[1],
9135 splt
->contents
+ h
->plt
.offset
+ 4);
9137 /* Fill in the entry in the .rel.plt section. */
9138 rel
.r_offset
= (splt
->output_section
->vma
9139 + splt
->output_offset
9140 + h
->plt
.offset
+ 4);
9141 rel
.r_info
= ELF32_R_INFO (h
->dynindx
, R_ARM_GLOB_DAT
);
9143 /* Get the index in the procedure linkage table which
9144 corresponds to this symbol. This is the index of this symbol
9145 in all the symbols for which we are making plt entries. The
9146 first entry in the procedure linkage table is reserved. */
9147 plt_index
= ((h
->plt
.offset
- htab
->plt_header_size
)
9148 / htab
->plt_entry_size
);
9152 bfd_vma got_offset
, got_address
, plt_address
;
9153 bfd_vma got_displacement
;
9157 sgot
= bfd_get_section_by_name (dynobj
, ".got.plt");
9158 BFD_ASSERT (sgot
!= NULL
);
9160 /* Get the offset into the .got.plt table of the entry that
9161 corresponds to this function. */
9162 got_offset
= eh
->plt_got_offset
;
9164 /* Get the index in the procedure linkage table which
9165 corresponds to this symbol. This is the index of this symbol
9166 in all the symbols for which we are making plt entries. The
9167 first three entries in .got.plt are reserved; after that
9168 symbols appear in the same order as in .plt. */
9169 plt_index
= (got_offset
- 12) / 4;
9171 /* Calculate the address of the GOT entry. */
9172 got_address
= (sgot
->output_section
->vma
9173 + sgot
->output_offset
9176 /* ...and the address of the PLT entry. */
9177 plt_address
= (splt
->output_section
->vma
9178 + splt
->output_offset
9181 ptr
= htab
->splt
->contents
+ h
->plt
.offset
;
9182 if (htab
->vxworks_p
&& info
->shared
)
9187 for (i
= 0; i
!= htab
->plt_entry_size
/ 4; i
++, ptr
+= 4)
9189 val
= elf32_arm_vxworks_shared_plt_entry
[i
];
9191 val
|= got_address
- sgot
->output_section
->vma
;
9193 val
|= plt_index
* RELOC_SIZE (htab
);
9194 if (i
== 2 || i
== 5)
9195 bfd_put_32 (output_bfd
, val
, ptr
);
9197 put_arm_insn (htab
, output_bfd
, val
, ptr
);
9200 else if (htab
->vxworks_p
)
9205 for (i
= 0; i
!= htab
->plt_entry_size
/ 4; i
++)
9207 val
= elf32_arm_vxworks_exec_plt_entry
[i
];
9211 val
|= 0xffffff & -((h
->plt
.offset
+ i
* 4 + 8) >> 2);
9213 val
|= plt_index
* RELOC_SIZE (htab
);
9214 if (i
== 2 || i
== 5)
9215 bfd_put_32 (output_bfd
, val
, ptr
);
9217 put_arm_insn (htab
, output_bfd
, val
, ptr
);
9220 loc
= (htab
->srelplt2
->contents
9221 + (plt_index
* 2 + 1) * RELOC_SIZE (htab
));
9223 /* Create the .rela.plt.unloaded R_ARM_ABS32 relocation
9224 referencing the GOT for this PLT entry. */
9225 rel
.r_offset
= plt_address
+ 8;
9226 rel
.r_info
= ELF32_R_INFO (htab
->root
.hgot
->indx
, R_ARM_ABS32
);
9227 rel
.r_addend
= got_offset
;
9228 SWAP_RELOC_OUT (htab
) (output_bfd
, &rel
, loc
);
9229 loc
+= RELOC_SIZE (htab
);
9231 /* Create the R_ARM_ABS32 relocation referencing the
9232 beginning of the PLT for this GOT entry. */
9233 rel
.r_offset
= got_address
;
9234 rel
.r_info
= ELF32_R_INFO (htab
->root
.hplt
->indx
, R_ARM_ABS32
);
9236 SWAP_RELOC_OUT (htab
) (output_bfd
, &rel
, loc
);
9240 /* Calculate the displacement between the PLT slot and the
9241 entry in the GOT. The eight-byte offset accounts for the
9242 value produced by adding to pc in the first instruction
9244 got_displacement
= got_address
- (plt_address
+ 8);
9246 BFD_ASSERT ((got_displacement
& 0xf0000000) == 0);
9248 if (!htab
->use_blx
&& eh
->plt_thumb_refcount
> 0)
9250 put_thumb_insn (htab
, output_bfd
,
9251 elf32_arm_plt_thumb_stub
[0], ptr
- 4);
9252 put_thumb_insn (htab
, output_bfd
,
9253 elf32_arm_plt_thumb_stub
[1], ptr
- 2);
9256 put_arm_insn (htab
, output_bfd
,
9257 elf32_arm_plt_entry
[0]
9258 | ((got_displacement
& 0x0ff00000) >> 20),
9260 put_arm_insn (htab
, output_bfd
,
9261 elf32_arm_plt_entry
[1]
9262 | ((got_displacement
& 0x000ff000) >> 12),
9264 put_arm_insn (htab
, output_bfd
,
9265 elf32_arm_plt_entry
[2]
9266 | (got_displacement
& 0x00000fff),
9268 #ifdef FOUR_WORD_PLT
9269 bfd_put_32 (output_bfd
, elf32_arm_plt_entry
[3], ptr
+ 12);
9273 /* Fill in the entry in the global offset table. */
9274 bfd_put_32 (output_bfd
,
9275 (splt
->output_section
->vma
9276 + splt
->output_offset
),
9277 sgot
->contents
+ got_offset
);
9279 /* Fill in the entry in the .rel(a).plt section. */
9281 rel
.r_offset
= got_address
;
9282 rel
.r_info
= ELF32_R_INFO (h
->dynindx
, R_ARM_JUMP_SLOT
);
9285 loc
= srel
->contents
+ plt_index
* RELOC_SIZE (htab
);
9286 SWAP_RELOC_OUT (htab
) (output_bfd
, &rel
, loc
);
9288 if (!h
->def_regular
)
9290 /* Mark the symbol as undefined, rather than as defined in
9291 the .plt section. Leave the value alone. */
9292 sym
->st_shndx
= SHN_UNDEF
;
9293 /* If the symbol is weak, we do need to clear the value.
9294 Otherwise, the PLT entry would provide a definition for
9295 the symbol even if the symbol wasn't defined anywhere,
9296 and so the symbol would never be NULL. */
9297 if (!h
->ref_regular_nonweak
)
9302 if (h
->got
.offset
!= (bfd_vma
) -1
9303 && (elf32_arm_hash_entry (h
)->tls_type
& GOT_TLS_GD
) == 0
9304 && (elf32_arm_hash_entry (h
)->tls_type
& GOT_TLS_IE
) == 0)
9308 Elf_Internal_Rela rel
;
9312 /* This symbol has an entry in the global offset table. Set it
9314 sgot
= bfd_get_section_by_name (dynobj
, ".got");
9315 srel
= bfd_get_section_by_name (dynobj
, RELOC_SECTION (htab
, ".got"));
9316 BFD_ASSERT (sgot
!= NULL
&& srel
!= NULL
);
9318 offset
= (h
->got
.offset
& ~(bfd_vma
) 1);
9320 rel
.r_offset
= (sgot
->output_section
->vma
9321 + sgot
->output_offset
9324 /* If this is a static link, or it is a -Bsymbolic link and the
9325 symbol is defined locally or was forced to be local because
9326 of a version file, we just want to emit a RELATIVE reloc.
9327 The entry in the global offset table will already have been
9328 initialized in the relocate_section function. */
9330 && SYMBOL_REFERENCES_LOCAL (info
, h
))
9332 BFD_ASSERT((h
->got
.offset
& 1) != 0);
9333 rel
.r_info
= ELF32_R_INFO (0, R_ARM_RELATIVE
);
9336 rel
.r_addend
= bfd_get_32 (output_bfd
, sgot
->contents
+ offset
);
9337 bfd_put_32 (output_bfd
, (bfd_vma
) 0, sgot
->contents
+ offset
);
9342 BFD_ASSERT((h
->got
.offset
& 1) == 0);
9343 bfd_put_32 (output_bfd
, (bfd_vma
) 0, sgot
->contents
+ offset
);
9344 rel
.r_info
= ELF32_R_INFO (h
->dynindx
, R_ARM_GLOB_DAT
);
9347 loc
= srel
->contents
+ srel
->reloc_count
++ * RELOC_SIZE (htab
);
9348 SWAP_RELOC_OUT (htab
) (output_bfd
, &rel
, loc
);
9354 Elf_Internal_Rela rel
;
9357 /* This symbol needs a copy reloc. Set it up. */
9358 BFD_ASSERT (h
->dynindx
!= -1
9359 && (h
->root
.type
== bfd_link_hash_defined
9360 || h
->root
.type
== bfd_link_hash_defweak
));
9362 s
= bfd_get_section_by_name (h
->root
.u
.def
.section
->owner
,
9363 RELOC_SECTION (htab
, ".bss"));
9364 BFD_ASSERT (s
!= NULL
);
9367 rel
.r_offset
= (h
->root
.u
.def
.value
9368 + h
->root
.u
.def
.section
->output_section
->vma
9369 + h
->root
.u
.def
.section
->output_offset
);
9370 rel
.r_info
= ELF32_R_INFO (h
->dynindx
, R_ARM_COPY
);
9371 loc
= s
->contents
+ s
->reloc_count
++ * RELOC_SIZE (htab
);
9372 SWAP_RELOC_OUT (htab
) (output_bfd
, &rel
, loc
);
9375 /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. On VxWorks,
9376 the _GLOBAL_OFFSET_TABLE_ symbol is not absolute: it is relative
9377 to the ".got" section. */
9378 if (strcmp (h
->root
.root
.string
, "_DYNAMIC") == 0
9379 || (!htab
->vxworks_p
&& h
== htab
->root
.hgot
))
9380 sym
->st_shndx
= SHN_ABS
;
9385 /* Finish up the dynamic sections. */
9388 elf32_arm_finish_dynamic_sections (bfd
* output_bfd
, struct bfd_link_info
* info
)
9394 dynobj
= elf_hash_table (info
)->dynobj
;
9396 sgot
= bfd_get_section_by_name (dynobj
, ".got.plt");
9397 BFD_ASSERT (elf32_arm_hash_table (info
)->symbian_p
|| sgot
!= NULL
);
9398 sdyn
= bfd_get_section_by_name (dynobj
, ".dynamic");
9400 if (elf_hash_table (info
)->dynamic_sections_created
)
9403 Elf32_External_Dyn
*dyncon
, *dynconend
;
9404 struct elf32_arm_link_hash_table
*htab
;
9406 htab
= elf32_arm_hash_table (info
);
9407 splt
= bfd_get_section_by_name (dynobj
, ".plt");
9408 BFD_ASSERT (splt
!= NULL
&& sdyn
!= NULL
);
9410 dyncon
= (Elf32_External_Dyn
*) sdyn
->contents
;
9411 dynconend
= (Elf32_External_Dyn
*) (sdyn
->contents
+ sdyn
->size
);
9413 for (; dyncon
< dynconend
; dyncon
++)
9415 Elf_Internal_Dyn dyn
;
9419 bfd_elf32_swap_dyn_in (dynobj
, dyncon
, &dyn
);
9430 goto get_vma_if_bpabi
;
9433 goto get_vma_if_bpabi
;
9436 goto get_vma_if_bpabi
;
9438 name
= ".gnu.version";
9439 goto get_vma_if_bpabi
;
9441 name
= ".gnu.version_d";
9442 goto get_vma_if_bpabi
;
9444 name
= ".gnu.version_r";
9445 goto get_vma_if_bpabi
;
9451 name
= RELOC_SECTION (htab
, ".plt");
9453 s
= bfd_get_section_by_name (output_bfd
, name
);
9454 BFD_ASSERT (s
!= NULL
);
9455 if (!htab
->symbian_p
)
9456 dyn
.d_un
.d_ptr
= s
->vma
;
9458 /* In the BPABI, tags in the PT_DYNAMIC section point
9459 at the file offset, not the memory address, for the
9460 convenience of the post linker. */
9461 dyn
.d_un
.d_ptr
= s
->filepos
;
9462 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
9466 if (htab
->symbian_p
)
9471 s
= bfd_get_section_by_name (output_bfd
,
9472 RELOC_SECTION (htab
, ".plt"));
9473 BFD_ASSERT (s
!= NULL
);
9474 dyn
.d_un
.d_val
= s
->size
;
9475 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
9480 if (!htab
->symbian_p
)
9482 /* My reading of the SVR4 ABI indicates that the
9483 procedure linkage table relocs (DT_JMPREL) should be
9484 included in the overall relocs (DT_REL). This is
9485 what Solaris does. However, UnixWare can not handle
9486 that case. Therefore, we override the DT_RELSZ entry
9487 here to make it not include the JMPREL relocs. Since
9488 the linker script arranges for .rel(a).plt to follow all
9489 other relocation sections, we don't have to worry
9490 about changing the DT_REL entry. */
9491 s
= bfd_get_section_by_name (output_bfd
,
9492 RELOC_SECTION (htab
, ".plt"));
9494 dyn
.d_un
.d_val
-= s
->size
;
9495 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
9502 /* In the BPABI, the DT_REL tag must point at the file
9503 offset, not the VMA, of the first relocation
9504 section. So, we use code similar to that in
9505 elflink.c, but do not check for SHF_ALLOC on the
9506 relcoation section, since relocations sections are
9507 never allocated under the BPABI. The comments above
9508 about Unixware notwithstanding, we include all of the
9509 relocations here. */
9510 if (htab
->symbian_p
)
9513 type
= ((dyn
.d_tag
== DT_REL
|| dyn
.d_tag
== DT_RELSZ
)
9514 ? SHT_REL
: SHT_RELA
);
9516 for (i
= 1; i
< elf_numsections (output_bfd
); i
++)
9518 Elf_Internal_Shdr
*hdr
9519 = elf_elfsections (output_bfd
)[i
];
9520 if (hdr
->sh_type
== type
)
9522 if (dyn
.d_tag
== DT_RELSZ
9523 || dyn
.d_tag
== DT_RELASZ
)
9524 dyn
.d_un
.d_val
+= hdr
->sh_size
;
9525 else if ((ufile_ptr
) hdr
->sh_offset
9526 <= dyn
.d_un
.d_val
- 1)
9527 dyn
.d_un
.d_val
= hdr
->sh_offset
;
9530 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
9534 /* Set the bottom bit of DT_INIT/FINI if the
9535 corresponding function is Thumb. */
9537 name
= info
->init_function
;
9540 name
= info
->fini_function
;
9542 /* If it wasn't set by elf_bfd_final_link
9543 then there is nothing to adjust. */
9544 if (dyn
.d_un
.d_val
!= 0)
9546 struct elf_link_hash_entry
* eh
;
9548 eh
= elf_link_hash_lookup (elf_hash_table (info
), name
,
9549 FALSE
, FALSE
, TRUE
);
9550 if (eh
!= (struct elf_link_hash_entry
*) NULL
9551 && ELF_ST_TYPE (eh
->type
) == STT_ARM_TFUNC
)
9553 dyn
.d_un
.d_val
|= 1;
9554 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
9561 /* Fill in the first entry in the procedure linkage table. */
9562 if (splt
->size
> 0 && elf32_arm_hash_table (info
)->plt_header_size
)
9564 const bfd_vma
*plt0_entry
;
9565 bfd_vma got_address
, plt_address
, got_displacement
;
9567 /* Calculate the addresses of the GOT and PLT. */
9568 got_address
= sgot
->output_section
->vma
+ sgot
->output_offset
;
9569 plt_address
= splt
->output_section
->vma
+ splt
->output_offset
;
9571 if (htab
->vxworks_p
)
9573 /* The VxWorks GOT is relocated by the dynamic linker.
9574 Therefore, we must emit relocations rather than simply
9575 computing the values now. */
9576 Elf_Internal_Rela rel
;
9578 plt0_entry
= elf32_arm_vxworks_exec_plt0_entry
;
9579 put_arm_insn (htab
, output_bfd
, plt0_entry
[0],
9580 splt
->contents
+ 0);
9581 put_arm_insn (htab
, output_bfd
, plt0_entry
[1],
9582 splt
->contents
+ 4);
9583 put_arm_insn (htab
, output_bfd
, plt0_entry
[2],
9584 splt
->contents
+ 8);
9585 bfd_put_32 (output_bfd
, got_address
, splt
->contents
+ 12);
9587 /* Generate a relocation for _GLOBAL_OFFSET_TABLE_. */
9588 rel
.r_offset
= plt_address
+ 12;
9589 rel
.r_info
= ELF32_R_INFO (htab
->root
.hgot
->indx
, R_ARM_ABS32
);
9591 SWAP_RELOC_OUT (htab
) (output_bfd
, &rel
,
9592 htab
->srelplt2
->contents
);
9596 got_displacement
= got_address
- (plt_address
+ 16);
9598 plt0_entry
= elf32_arm_plt0_entry
;
9599 put_arm_insn (htab
, output_bfd
, plt0_entry
[0],
9600 splt
->contents
+ 0);
9601 put_arm_insn (htab
, output_bfd
, plt0_entry
[1],
9602 splt
->contents
+ 4);
9603 put_arm_insn (htab
, output_bfd
, plt0_entry
[2],
9604 splt
->contents
+ 8);
9605 put_arm_insn (htab
, output_bfd
, plt0_entry
[3],
9606 splt
->contents
+ 12);
9608 #ifdef FOUR_WORD_PLT
9609 /* The displacement value goes in the otherwise-unused
9610 last word of the second entry. */
9611 bfd_put_32 (output_bfd
, got_displacement
, splt
->contents
+ 28);
9613 bfd_put_32 (output_bfd
, got_displacement
, splt
->contents
+ 16);
9618 /* UnixWare sets the entsize of .plt to 4, although that doesn't
9619 really seem like the right value. */
9620 if (splt
->output_section
->owner
== output_bfd
)
9621 elf_section_data (splt
->output_section
)->this_hdr
.sh_entsize
= 4;
9623 if (htab
->vxworks_p
&& !info
->shared
&& htab
->splt
->size
> 0)
9625 /* Correct the .rel(a).plt.unloaded relocations. They will have
9626 incorrect symbol indexes. */
9630 num_plts
= ((htab
->splt
->size
- htab
->plt_header_size
)
9631 / htab
->plt_entry_size
);
9632 p
= htab
->srelplt2
->contents
+ RELOC_SIZE (htab
);
9634 for (; num_plts
; num_plts
--)
9636 Elf_Internal_Rela rel
;
9638 SWAP_RELOC_IN (htab
) (output_bfd
, p
, &rel
);
9639 rel
.r_info
= ELF32_R_INFO (htab
->root
.hgot
->indx
, R_ARM_ABS32
);
9640 SWAP_RELOC_OUT (htab
) (output_bfd
, &rel
, p
);
9641 p
+= RELOC_SIZE (htab
);
9643 SWAP_RELOC_IN (htab
) (output_bfd
, p
, &rel
);
9644 rel
.r_info
= ELF32_R_INFO (htab
->root
.hplt
->indx
, R_ARM_ABS32
);
9645 SWAP_RELOC_OUT (htab
) (output_bfd
, &rel
, p
);
9646 p
+= RELOC_SIZE (htab
);
9651 /* Fill in the first three entries in the global offset table. */
9657 bfd_put_32 (output_bfd
, (bfd_vma
) 0, sgot
->contents
);
9659 bfd_put_32 (output_bfd
,
9660 sdyn
->output_section
->vma
+ sdyn
->output_offset
,
9662 bfd_put_32 (output_bfd
, (bfd_vma
) 0, sgot
->contents
+ 4);
9663 bfd_put_32 (output_bfd
, (bfd_vma
) 0, sgot
->contents
+ 8);
9666 elf_section_data (sgot
->output_section
)->this_hdr
.sh_entsize
= 4;
9673 elf32_arm_post_process_headers (bfd
* abfd
, struct bfd_link_info
* link_info ATTRIBUTE_UNUSED
)
9675 Elf_Internal_Ehdr
* i_ehdrp
; /* ELF file header, internal form. */
9676 struct elf32_arm_link_hash_table
*globals
;
9678 i_ehdrp
= elf_elfheader (abfd
);
9680 if (EF_ARM_EABI_VERSION (i_ehdrp
->e_flags
) == EF_ARM_EABI_UNKNOWN
)
9681 i_ehdrp
->e_ident
[EI_OSABI
] = ELFOSABI_ARM
;
9683 i_ehdrp
->e_ident
[EI_OSABI
] = 0;
9684 i_ehdrp
->e_ident
[EI_ABIVERSION
] = ARM_ELF_ABI_VERSION
;
9688 globals
= elf32_arm_hash_table (link_info
);
9689 if (globals
->byteswap_code
)
9690 i_ehdrp
->e_flags
|= EF_ARM_BE8
;
9694 static enum elf_reloc_type_class
9695 elf32_arm_reloc_type_class (const Elf_Internal_Rela
*rela
)
9697 switch ((int) ELF32_R_TYPE (rela
->r_info
))
9699 case R_ARM_RELATIVE
:
9700 return reloc_class_relative
;
9701 case R_ARM_JUMP_SLOT
:
9702 return reloc_class_plt
;
9704 return reloc_class_copy
;
9706 return reloc_class_normal
;
9710 /* Set the right machine number for an Arm ELF file. */
9713 elf32_arm_section_flags (flagword
*flags
, const Elf_Internal_Shdr
*hdr
)
9715 if (hdr
->sh_type
== SHT_NOTE
)
9716 *flags
|= SEC_LINK_ONCE
| SEC_LINK_DUPLICATES_SAME_CONTENTS
;
9722 elf32_arm_final_write_processing (bfd
*abfd
, bfd_boolean linker ATTRIBUTE_UNUSED
)
9724 bfd_arm_update_notes (abfd
, ARM_NOTE_SECTION
);
9727 /* Return TRUE if this is an unwinding table entry. */
9730 is_arm_elf_unwind_section_name (bfd
* abfd ATTRIBUTE_UNUSED
, const char * name
)
9732 return (CONST_STRNEQ (name
, ELF_STRING_ARM_unwind
)
9733 || CONST_STRNEQ (name
, ELF_STRING_ARM_unwind_once
));
9737 /* Set the type and flags for an ARM section. We do this by
9738 the section name, which is a hack, but ought to work. */
9741 elf32_arm_fake_sections (bfd
* abfd
, Elf_Internal_Shdr
* hdr
, asection
* sec
)
9745 name
= bfd_get_section_name (abfd
, sec
);
9747 if (is_arm_elf_unwind_section_name (abfd
, name
))
9749 hdr
->sh_type
= SHT_ARM_EXIDX
;
9750 hdr
->sh_flags
|= SHF_LINK_ORDER
;
9752 else if (strcmp(name
, ".ARM.attributes") == 0)
9754 hdr
->sh_type
= SHT_ARM_ATTRIBUTES
;
9759 /* Parse an Arm EABI attributes section. */
9761 elf32_arm_parse_attributes (bfd
*abfd
, Elf_Internal_Shdr
* hdr
)
9767 contents
= bfd_malloc (hdr
->sh_size
);
9770 if (!bfd_get_section_contents (abfd
, hdr
->bfd_section
, contents
, 0,
9779 len
= hdr
->sh_size
- 1;
9783 bfd_vma section_len
;
9785 section_len
= bfd_get_32 (abfd
, p
);
9787 if (section_len
> len
)
9790 namelen
= strlen ((char *)p
) + 1;
9791 section_len
-= namelen
+ 4;
9792 if (strcmp((char *)p
, "aeabi") != 0)
9794 /* Vendor section. Ignore it. */
9795 p
+= namelen
+ section_len
;
9800 while (section_len
> 0)
9805 bfd_vma subsection_len
;
9808 tag
= read_unsigned_leb128 (abfd
, p
, &n
);
9810 subsection_len
= bfd_get_32 (abfd
, p
);
9812 if (subsection_len
> section_len
)
9813 subsection_len
= section_len
;
9814 section_len
-= subsection_len
;
9815 subsection_len
-= n
+ 4;
9816 end
= p
+ subsection_len
;
9822 bfd_boolean is_string
;
9824 tag
= read_unsigned_leb128 (abfd
, p
, &n
);
9826 if (tag
== 4 || tag
== 5)
9831 is_string
= (tag
& 1) != 0;
9832 if (tag
== Tag_compatibility
)
9834 val
= read_unsigned_leb128 (abfd
, p
, &n
);
9836 elf32_arm_add_eabi_attr_compat (abfd
, val
,
9838 p
+= strlen ((char *)p
) + 1;
9842 elf32_arm_add_eabi_attr_string (abfd
, tag
,
9844 p
+= strlen ((char *)p
) + 1;
9848 val
= read_unsigned_leb128 (abfd
, p
, &n
);
9850 elf32_arm_add_eabi_attr_int (abfd
, tag
, val
);
9856 /* Don't have anywhere convenient to attach these.
9857 Fall through for now. */
9859 /* Ignore things we don't kow about. */
9860 p
+= subsection_len
;
9871 /* Handle an ARM specific section when reading an object file. This is
9872 called when bfd_section_from_shdr finds a section with an unknown
9876 elf32_arm_section_from_shdr (bfd
*abfd
,
9877 Elf_Internal_Shdr
* hdr
,
9881 /* There ought to be a place to keep ELF backend specific flags, but
9882 at the moment there isn't one. We just keep track of the
9883 sections by their name, instead. Fortunately, the ABI gives
9884 names for all the ARM specific sections, so we will probably get
9886 switch (hdr
->sh_type
)
9889 case SHT_ARM_PREEMPTMAP
:
9890 case SHT_ARM_ATTRIBUTES
:
9897 if (! _bfd_elf_make_section_from_shdr (abfd
, hdr
, name
, shindex
))
9900 if (hdr
->sh_type
== SHT_ARM_ATTRIBUTES
)
9901 elf32_arm_parse_attributes(abfd
, hdr
);
9905 /* A structure used to record a list of sections, independently
9906 of the next and prev fields in the asection structure. */
9907 typedef struct section_list
9910 struct section_list
* next
;
9911 struct section_list
* prev
;
9915 /* Unfortunately we need to keep a list of sections for which
9916 an _arm_elf_section_data structure has been allocated. This
9917 is because it is possible for functions like elf32_arm_write_section
9918 to be called on a section which has had an elf_data_structure
9919 allocated for it (and so the used_by_bfd field is valid) but
9920 for which the ARM extended version of this structure - the
9921 _arm_elf_section_data structure - has not been allocated. */
9922 static section_list
* sections_with_arm_elf_section_data
= NULL
;
9925 record_section_with_arm_elf_section_data (asection
* sec
)
9927 struct section_list
* entry
;
9929 entry
= bfd_malloc (sizeof (* entry
));
9933 entry
->next
= sections_with_arm_elf_section_data
;
9935 if (entry
->next
!= NULL
)
9936 entry
->next
->prev
= entry
;
9937 sections_with_arm_elf_section_data
= entry
;
9940 static struct section_list
*
9941 find_arm_elf_section_entry (asection
* sec
)
9943 struct section_list
* entry
;
9944 static struct section_list
* last_entry
= NULL
;
9946 /* This is a short cut for the typical case where the sections are added
9947 to the sections_with_arm_elf_section_data list in forward order and
9948 then looked up here in backwards order. This makes a real difference
9949 to the ld-srec/sec64k.exp linker test. */
9950 entry
= sections_with_arm_elf_section_data
;
9951 if (last_entry
!= NULL
)
9953 if (last_entry
->sec
== sec
)
9955 else if (last_entry
->next
!= NULL
9956 && last_entry
->next
->sec
== sec
)
9957 entry
= last_entry
->next
;
9960 for (; entry
; entry
= entry
->next
)
9961 if (entry
->sec
== sec
)
9965 /* Record the entry prior to this one - it is the entry we are most
9966 likely to want to locate next time. Also this way if we have been
9967 called from unrecord_section_with_arm_elf_section_data() we will not
9968 be caching a pointer that is about to be freed. */
9969 last_entry
= entry
->prev
;
9974 static _arm_elf_section_data
*
9975 get_arm_elf_section_data (asection
* sec
)
9977 struct section_list
* entry
;
9979 entry
= find_arm_elf_section_entry (sec
);
9982 return elf32_arm_section_data (entry
->sec
);
9988 unrecord_section_with_arm_elf_section_data (asection
* sec
)
9990 struct section_list
* entry
;
9992 entry
= find_arm_elf_section_entry (sec
);
9996 if (entry
->prev
!= NULL
)
9997 entry
->prev
->next
= entry
->next
;
9998 if (entry
->next
!= NULL
)
9999 entry
->next
->prev
= entry
->prev
;
10000 if (entry
== sections_with_arm_elf_section_data
)
10001 sections_with_arm_elf_section_data
= entry
->next
;
10010 struct bfd_link_info
*info
;
10012 bfd_vma plt_offset
;
10013 bfd_boolean (*func
) (void *, const char *, Elf_Internal_Sym
*,
10014 asection
*, struct elf_link_hash_entry
*);
10015 } output_arch_syminfo
;
10017 enum map_symbol_type
10025 /* Output a single PLT mapping symbol. */
10028 elf32_arm_ouput_plt_map_sym (output_arch_syminfo
*osi
,
10029 enum map_symbol_type type
,
10032 static const char *names
[3] = {"$a", "$t", "$d"};
10033 struct elf32_arm_link_hash_table
*htab
;
10034 Elf_Internal_Sym sym
;
10036 htab
= elf32_arm_hash_table (osi
->info
);
10037 sym
.st_value
= osi
->plt_offset
+ offset
;
10040 sym
.st_info
= ELF_ST_INFO (STB_LOCAL
, STT_NOTYPE
);
10041 sym
.st_shndx
= osi
->plt_shndx
;
10042 if (!osi
->func (osi
->finfo
, names
[type
], &sym
, htab
->splt
, NULL
))
10048 /* Output mapping symbols for PLT entries associated with H. */
10051 elf32_arm_output_plt_map (struct elf_link_hash_entry
*h
, void *inf
)
10053 output_arch_syminfo
*osi
= (output_arch_syminfo
*) inf
;
10054 struct elf32_arm_link_hash_table
*htab
;
10055 struct elf32_arm_link_hash_entry
*eh
;
10058 htab
= elf32_arm_hash_table (osi
->info
);
10060 if (h
->root
.type
== bfd_link_hash_indirect
)
10063 if (h
->root
.type
== bfd_link_hash_warning
)
10064 /* When warning symbols are created, they **replace** the "real"
10065 entry in the hash table, thus we never get to see the real
10066 symbol in a hash traversal. So look at it now. */
10067 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
10069 if (h
->plt
.offset
== (bfd_vma
) -1)
10072 eh
= (struct elf32_arm_link_hash_entry
*) h
;
10073 addr
= h
->plt
.offset
;
10074 if (htab
->symbian_p
)
10076 if (!elf32_arm_ouput_plt_map_sym (osi
, ARM_MAP_ARM
, addr
))
10078 if (!elf32_arm_ouput_plt_map_sym (osi
, ARM_MAP_DATA
, addr
+ 4))
10081 else if (htab
->vxworks_p
)
10083 if (!elf32_arm_ouput_plt_map_sym (osi
, ARM_MAP_ARM
, addr
))
10085 if (!elf32_arm_ouput_plt_map_sym (osi
, ARM_MAP_DATA
, addr
+ 8))
10087 if (!elf32_arm_ouput_plt_map_sym (osi
, ARM_MAP_ARM
, addr
+ 12))
10089 if (!elf32_arm_ouput_plt_map_sym (osi
, ARM_MAP_DATA
, addr
+ 20))
10094 bfd_boolean thumb_stub
;
10096 thumb_stub
= eh
->plt_thumb_refcount
> 0 && !htab
->use_blx
;
10099 if (!elf32_arm_ouput_plt_map_sym (osi
, ARM_MAP_THUMB
, addr
- 4))
10102 #ifdef FOUR_WORD_PLT
10103 if (!elf32_arm_ouput_plt_map_sym (osi
, ARM_MAP_ARM
, addr
))
10105 if (!elf32_arm_ouput_plt_map_sym (osi
, ARM_MAP_DATA
, addr
+ 12))
10108 /* A three-word PLT with no Thumb thunk contains only Arm code,
10109 so only need to output a mapping symbol for the first PLT entry and
10110 entries with thumb thunks. */
10111 if (thumb_stub
|| addr
== 20)
10113 if (!elf32_arm_ouput_plt_map_sym (osi
, ARM_MAP_ARM
, addr
))
10123 /* Output mapping symbols for the PLT. */
10126 elf32_arm_output_arch_local_syms (bfd
*output_bfd
,
10127 struct bfd_link_info
*info
,
10128 void *finfo
, bfd_boolean (*func
) (void *, const char *,
10129 Elf_Internal_Sym
*,
10131 struct elf_link_hash_entry
*))
10133 output_arch_syminfo osi
;
10134 struct elf32_arm_link_hash_table
*htab
;
10136 htab
= elf32_arm_hash_table (info
);
10137 if (!htab
->splt
|| htab
->splt
->size
== 0)
10140 check_use_blx(htab
);
10144 osi
.plt_shndx
= _bfd_elf_section_from_bfd_section (output_bfd
,
10145 htab
->splt
->output_section
);
10146 osi
.plt_offset
= htab
->splt
->output_section
->vma
;
10148 /* Output mapping symbols for the plt header. SymbianOS does not have a
10150 if (htab
->vxworks_p
)
10152 /* VxWorks shared libraries have no PLT header. */
10155 if (!elf32_arm_ouput_plt_map_sym (&osi
, ARM_MAP_ARM
, 0))
10157 if (!elf32_arm_ouput_plt_map_sym (&osi
, ARM_MAP_DATA
, 12))
10161 else if (!htab
->symbian_p
)
10163 if (!elf32_arm_ouput_plt_map_sym (&osi
, ARM_MAP_ARM
, 0))
10165 #ifndef FOUR_WORD_PLT
10166 if (!elf32_arm_ouput_plt_map_sym (&osi
, ARM_MAP_DATA
, 16))
10171 elf_link_hash_traverse (&htab
->root
, elf32_arm_output_plt_map
, (void *) &osi
);
10175 /* Allocate target specific section data. */
10178 elf32_arm_new_section_hook (bfd
*abfd
, asection
*sec
)
10180 if (!sec
->used_by_bfd
)
10182 _arm_elf_section_data
*sdata
;
10183 bfd_size_type amt
= sizeof (*sdata
);
10185 sdata
= bfd_zalloc (abfd
, amt
);
10188 sec
->used_by_bfd
= sdata
;
10191 record_section_with_arm_elf_section_data (sec
);
10193 return _bfd_elf_new_section_hook (abfd
, sec
);
10197 /* Used to order a list of mapping symbols by address. */
10200 elf32_arm_compare_mapping (const void * a
, const void * b
)
10202 return ((const elf32_arm_section_map
*) a
)->vma
10203 > ((const elf32_arm_section_map
*) b
)->vma
;
10207 /* Do code byteswapping. Return FALSE afterwards so that the section is
10208 written out as normal. */
10211 elf32_arm_write_section (bfd
*output_bfd
,
10212 struct bfd_link_info
*link_info
, asection
*sec
,
10213 bfd_byte
*contents
)
10215 int mapcount
, errcount
;
10216 _arm_elf_section_data
*arm_data
;
10217 struct elf32_arm_link_hash_table
*globals
= elf32_arm_hash_table (link_info
);
10218 elf32_arm_section_map
*map
;
10219 elf32_vfp11_erratum_list
*errnode
;
10222 bfd_vma offset
= sec
->output_section
->vma
+ sec
->output_offset
;
10226 /* If this section has not been allocated an _arm_elf_section_data
10227 structure then we cannot record anything. */
10228 arm_data
= get_arm_elf_section_data (sec
);
10229 if (arm_data
== NULL
)
10232 mapcount
= arm_data
->mapcount
;
10233 map
= arm_data
->map
;
10234 errcount
= arm_data
->erratumcount
;
10238 unsigned int endianflip
= bfd_big_endian (output_bfd
) ? 3 : 0;
10240 for (errnode
= arm_data
->erratumlist
; errnode
!= 0;
10241 errnode
= errnode
->next
)
10243 bfd_vma index
= errnode
->vma
- offset
;
10245 switch (errnode
->type
)
10247 case VFP11_ERRATUM_BRANCH_TO_ARM_VENEER
:
10249 bfd_vma branch_to_veneer
;
10250 /* Original condition code of instruction, plus bit mask for
10251 ARM B instruction. */
10252 unsigned int insn
= (errnode
->u
.b
.vfp_insn
& 0xf0000000)
10255 /* The instruction is before the label. */
10258 /* Above offset included in -4 below. */
10259 branch_to_veneer
= errnode
->u
.b
.veneer
->vma
10260 - errnode
->vma
- 4;
10262 if ((signed) branch_to_veneer
< -(1 << 25)
10263 || (signed) branch_to_veneer
>= (1 << 25))
10264 (*_bfd_error_handler
) (_("%B: error: VFP11 veneer out of "
10265 "range"), output_bfd
);
10267 insn
|= (branch_to_veneer
>> 2) & 0xffffff;
10268 contents
[endianflip
^ index
] = insn
& 0xff;
10269 contents
[endianflip
^ (index
+ 1)] = (insn
>> 8) & 0xff;
10270 contents
[endianflip
^ (index
+ 2)] = (insn
>> 16) & 0xff;
10271 contents
[endianflip
^ (index
+ 3)] = (insn
>> 24) & 0xff;
10275 case VFP11_ERRATUM_ARM_VENEER
:
10277 bfd_vma branch_from_veneer
;
10280 /* Take size of veneer into account. */
10281 branch_from_veneer
= errnode
->u
.v
.branch
->vma
10282 - errnode
->vma
- 12;
10284 if ((signed) branch_from_veneer
< -(1 << 25)
10285 || (signed) branch_from_veneer
>= (1 << 25))
10286 (*_bfd_error_handler
) (_("%B: error: VFP11 veneer out of "
10287 "range"), output_bfd
);
10289 /* Original instruction. */
10290 insn
= errnode
->u
.v
.branch
->u
.b
.vfp_insn
;
10291 contents
[endianflip
^ index
] = insn
& 0xff;
10292 contents
[endianflip
^ (index
+ 1)] = (insn
>> 8) & 0xff;
10293 contents
[endianflip
^ (index
+ 2)] = (insn
>> 16) & 0xff;
10294 contents
[endianflip
^ (index
+ 3)] = (insn
>> 24) & 0xff;
10296 /* Branch back to insn after original insn. */
10297 insn
= 0xea000000 | ((branch_from_veneer
>> 2) & 0xffffff);
10298 contents
[endianflip
^ (index
+ 4)] = insn
& 0xff;
10299 contents
[endianflip
^ (index
+ 5)] = (insn
>> 8) & 0xff;
10300 contents
[endianflip
^ (index
+ 6)] = (insn
>> 16) & 0xff;
10301 contents
[endianflip
^ (index
+ 7)] = (insn
>> 24) & 0xff;
10314 if (globals
->byteswap_code
)
10316 qsort (map
, mapcount
, sizeof (* map
), elf32_arm_compare_mapping
);
10319 for (i
= 0; i
< mapcount
; i
++)
10321 if (i
== mapcount
- 1)
10324 end
= map
[i
+ 1].vma
;
10326 switch (map
[i
].type
)
10329 /* Byte swap code words. */
10330 while (ptr
+ 3 < end
)
10332 tmp
= contents
[ptr
];
10333 contents
[ptr
] = contents
[ptr
+ 3];
10334 contents
[ptr
+ 3] = tmp
;
10335 tmp
= contents
[ptr
+ 1];
10336 contents
[ptr
+ 1] = contents
[ptr
+ 2];
10337 contents
[ptr
+ 2] = tmp
;
10343 /* Byte swap code halfwords. */
10344 while (ptr
+ 1 < end
)
10346 tmp
= contents
[ptr
];
10347 contents
[ptr
] = contents
[ptr
+ 1];
10348 contents
[ptr
+ 1] = tmp
;
10354 /* Leave data alone. */
10362 arm_data
->mapcount
= 0;
10363 arm_data
->mapsize
= 0;
10364 arm_data
->map
= NULL
;
10365 unrecord_section_with_arm_elf_section_data (sec
);
10371 unrecord_section_via_map_over_sections (bfd
* abfd ATTRIBUTE_UNUSED
,
10373 void * ignore ATTRIBUTE_UNUSED
)
10375 unrecord_section_with_arm_elf_section_data (sec
);
10379 elf32_arm_close_and_cleanup (bfd
* abfd
)
10381 if (abfd
->sections
)
10382 bfd_map_over_sections (abfd
,
10383 unrecord_section_via_map_over_sections
,
10386 return _bfd_elf_close_and_cleanup (abfd
);
10390 elf32_arm_bfd_free_cached_info (bfd
* abfd
)
10392 if (abfd
->sections
)
10393 bfd_map_over_sections (abfd
,
10394 unrecord_section_via_map_over_sections
,
10397 return _bfd_free_cached_info (abfd
);
10400 /* Display STT_ARM_TFUNC symbols as functions. */
10403 elf32_arm_symbol_processing (bfd
*abfd ATTRIBUTE_UNUSED
,
10406 elf_symbol_type
*elfsym
= (elf_symbol_type
*) asym
;
10408 if (ELF_ST_TYPE (elfsym
->internal_elf_sym
.st_info
) == STT_ARM_TFUNC
)
10409 elfsym
->symbol
.flags
|= BSF_FUNCTION
;
10413 /* Mangle thumb function symbols as we read them in. */
10416 elf32_arm_swap_symbol_in (bfd
* abfd
,
10419 Elf_Internal_Sym
*dst
)
10421 if (!bfd_elf32_swap_symbol_in (abfd
, psrc
, pshn
, dst
))
10424 /* New EABI objects mark thumb function symbols by setting the low bit of
10425 the address. Turn these into STT_ARM_TFUNC. */
10426 if (ELF_ST_TYPE (dst
->st_info
) == STT_FUNC
10427 && (dst
->st_value
& 1))
10429 dst
->st_info
= ELF_ST_INFO (ELF_ST_BIND (dst
->st_info
), STT_ARM_TFUNC
);
10430 dst
->st_value
&= ~(bfd_vma
) 1;
10436 /* Mangle thumb function symbols as we write them out. */
10439 elf32_arm_swap_symbol_out (bfd
*abfd
,
10440 const Elf_Internal_Sym
*src
,
10444 Elf_Internal_Sym newsym
;
10446 /* We convert STT_ARM_TFUNC symbols into STT_FUNC with the low bit
10447 of the address set, as per the new EABI. We do this unconditionally
10448 because objcopy does not set the elf header flags until after
10449 it writes out the symbol table. */
10450 if (ELF_ST_TYPE (src
->st_info
) == STT_ARM_TFUNC
)
10453 newsym
.st_info
= ELF_ST_INFO (ELF_ST_BIND (src
->st_info
), STT_FUNC
);
10454 if (newsym
.st_shndx
!= SHN_UNDEF
)
10456 /* Do this only for defined symbols. At link type, the static
10457 linker will simulate the work of dynamic linker of resolving
10458 symbols and will carry over the thumbness of found symbols to
10459 the output symbol table. It's not clear how it happens, but
10460 the thumbness of undefined symbols can well be different at
10461 runtime, and writing '1' for them will be confusing for users
10462 and possibly for dynamic linker itself.
10464 newsym
.st_value
|= 1;
10469 bfd_elf32_swap_symbol_out (abfd
, src
, cdst
, shndx
);
10472 /* Add the PT_ARM_EXIDX program header. */
10475 elf32_arm_modify_segment_map (bfd
*abfd
,
10476 struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
10478 struct elf_segment_map
*m
;
10481 sec
= bfd_get_section_by_name (abfd
, ".ARM.exidx");
10482 if (sec
!= NULL
&& (sec
->flags
& SEC_LOAD
) != 0)
10484 /* If there is already a PT_ARM_EXIDX header, then we do not
10485 want to add another one. This situation arises when running
10486 "strip"; the input binary already has the header. */
10487 m
= elf_tdata (abfd
)->segment_map
;
10488 while (m
&& m
->p_type
!= PT_ARM_EXIDX
)
10492 m
= bfd_zalloc (abfd
, sizeof (struct elf_segment_map
));
10495 m
->p_type
= PT_ARM_EXIDX
;
10497 m
->sections
[0] = sec
;
10499 m
->next
= elf_tdata (abfd
)->segment_map
;
10500 elf_tdata (abfd
)->segment_map
= m
;
10507 /* We may add a PT_ARM_EXIDX program header. */
10510 elf32_arm_additional_program_headers (bfd
*abfd
,
10511 struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
10515 sec
= bfd_get_section_by_name (abfd
, ".ARM.exidx");
10516 if (sec
!= NULL
&& (sec
->flags
& SEC_LOAD
) != 0)
10522 /* We use this to override swap_symbol_in and swap_symbol_out. */
10523 const struct elf_size_info elf32_arm_size_info
= {
10524 sizeof (Elf32_External_Ehdr
),
10525 sizeof (Elf32_External_Phdr
),
10526 sizeof (Elf32_External_Shdr
),
10527 sizeof (Elf32_External_Rel
),
10528 sizeof (Elf32_External_Rela
),
10529 sizeof (Elf32_External_Sym
),
10530 sizeof (Elf32_External_Dyn
),
10531 sizeof (Elf_External_Note
),
10535 ELFCLASS32
, EV_CURRENT
,
10536 bfd_elf32_write_out_phdrs
,
10537 bfd_elf32_write_shdrs_and_ehdr
,
10538 bfd_elf32_write_relocs
,
10539 elf32_arm_swap_symbol_in
,
10540 elf32_arm_swap_symbol_out
,
10541 bfd_elf32_slurp_reloc_table
,
10542 bfd_elf32_slurp_symbol_table
,
10543 bfd_elf32_swap_dyn_in
,
10544 bfd_elf32_swap_dyn_out
,
10545 bfd_elf32_swap_reloc_in
,
10546 bfd_elf32_swap_reloc_out
,
10547 bfd_elf32_swap_reloca_in
,
10548 bfd_elf32_swap_reloca_out
10551 #define ELF_ARCH bfd_arch_arm
10552 #define ELF_MACHINE_CODE EM_ARM
10553 #ifdef __QNXTARGET__
10554 #define ELF_MAXPAGESIZE 0x1000
10556 #define ELF_MAXPAGESIZE 0x8000
10558 #define ELF_MINPAGESIZE 0x1000
10559 #define ELF_COMMONPAGESIZE 0x1000
10561 #define bfd_elf32_mkobject elf32_arm_mkobject
10563 #define bfd_elf32_bfd_copy_private_bfd_data elf32_arm_copy_private_bfd_data
10564 #define bfd_elf32_bfd_merge_private_bfd_data elf32_arm_merge_private_bfd_data
10565 #define bfd_elf32_bfd_set_private_flags elf32_arm_set_private_flags
10566 #define bfd_elf32_bfd_print_private_bfd_data elf32_arm_print_private_bfd_data
10567 #define bfd_elf32_bfd_link_hash_table_create elf32_arm_link_hash_table_create
10568 #define bfd_elf32_bfd_reloc_type_lookup elf32_arm_reloc_type_lookup
10569 #define bfd_elf32_find_nearest_line elf32_arm_find_nearest_line
10570 #define bfd_elf32_find_inliner_info elf32_arm_find_inliner_info
10571 #define bfd_elf32_new_section_hook elf32_arm_new_section_hook
10572 #define bfd_elf32_bfd_is_target_special_symbol elf32_arm_is_target_special_symbol
10573 #define bfd_elf32_close_and_cleanup elf32_arm_close_and_cleanup
10574 #define bfd_elf32_bfd_free_cached_info elf32_arm_bfd_free_cached_info
10575 #define bfd_elf32_bfd_final_link elf32_arm_bfd_final_link
10577 #define elf_backend_get_symbol_type elf32_arm_get_symbol_type
10578 #define elf_backend_gc_mark_hook elf32_arm_gc_mark_hook
10579 #define elf_backend_gc_mark_extra_sections elf32_arm_gc_mark_extra_sections
10580 #define elf_backend_gc_sweep_hook elf32_arm_gc_sweep_hook
10581 #define elf_backend_check_relocs elf32_arm_check_relocs
10582 #define elf_backend_relocate_section elf32_arm_relocate_section
10583 #define elf_backend_write_section elf32_arm_write_section
10584 #define elf_backend_adjust_dynamic_symbol elf32_arm_adjust_dynamic_symbol
10585 #define elf_backend_create_dynamic_sections elf32_arm_create_dynamic_sections
10586 #define elf_backend_finish_dynamic_symbol elf32_arm_finish_dynamic_symbol
10587 #define elf_backend_finish_dynamic_sections elf32_arm_finish_dynamic_sections
10588 #define elf_backend_size_dynamic_sections elf32_arm_size_dynamic_sections
10589 #define elf_backend_init_index_section _bfd_elf_init_2_index_sections
10590 #define elf_backend_post_process_headers elf32_arm_post_process_headers
10591 #define elf_backend_reloc_type_class elf32_arm_reloc_type_class
10592 #define elf_backend_object_p elf32_arm_object_p
10593 #define elf_backend_section_flags elf32_arm_section_flags
10594 #define elf_backend_fake_sections elf32_arm_fake_sections
10595 #define elf_backend_section_from_shdr elf32_arm_section_from_shdr
10596 #define elf_backend_final_write_processing elf32_arm_final_write_processing
10597 #define elf_backend_copy_indirect_symbol elf32_arm_copy_indirect_symbol
10598 #define elf_backend_symbol_processing elf32_arm_symbol_processing
10599 #define elf_backend_size_info elf32_arm_size_info
10600 #define elf_backend_modify_segment_map elf32_arm_modify_segment_map
10601 #define elf_backend_additional_program_headers \
10602 elf32_arm_additional_program_headers
10603 #define elf_backend_output_arch_local_syms \
10604 elf32_arm_output_arch_local_syms
10605 #define elf_backend_begin_write_processing \
10606 elf32_arm_begin_write_processing
10608 #define elf_backend_can_refcount 1
10609 #define elf_backend_can_gc_sections 1
10610 #define elf_backend_plt_readonly 1
10611 #define elf_backend_want_got_plt 1
10612 #define elf_backend_want_plt_sym 0
10613 #define elf_backend_may_use_rel_p 1
10614 #define elf_backend_may_use_rela_p 0
10615 #define elf_backend_default_use_rela_p 0
10616 #define elf_backend_rela_normal 0
10618 #define elf_backend_got_header_size 12
10620 #include "elf32-target.h"
10622 /* VxWorks Targets */
10624 #undef TARGET_LITTLE_SYM
10625 #define TARGET_LITTLE_SYM bfd_elf32_littlearm_vxworks_vec
10626 #undef TARGET_LITTLE_NAME
10627 #define TARGET_LITTLE_NAME "elf32-littlearm-vxworks"
10628 #undef TARGET_BIG_SYM
10629 #define TARGET_BIG_SYM bfd_elf32_bigarm_vxworks_vec
10630 #undef TARGET_BIG_NAME
10631 #define TARGET_BIG_NAME "elf32-bigarm-vxworks"
10633 /* Like elf32_arm_link_hash_table_create -- but overrides
10634 appropriately for VxWorks. */
10635 static struct bfd_link_hash_table
*
10636 elf32_arm_vxworks_link_hash_table_create (bfd
*abfd
)
10638 struct bfd_link_hash_table
*ret
;
10640 ret
= elf32_arm_link_hash_table_create (abfd
);
10643 struct elf32_arm_link_hash_table
*htab
10644 = (struct elf32_arm_link_hash_table
*) ret
;
10646 htab
->vxworks_p
= 1;
10652 elf32_arm_vxworks_final_write_processing (bfd
*abfd
, bfd_boolean linker
)
10654 elf32_arm_final_write_processing (abfd
, linker
);
10655 elf_vxworks_final_write_processing (abfd
, linker
);
10659 #define elf32_bed elf32_arm_vxworks_bed
10661 #undef bfd_elf32_bfd_link_hash_table_create
10662 #define bfd_elf32_bfd_link_hash_table_create \
10663 elf32_arm_vxworks_link_hash_table_create
10664 #undef elf_backend_add_symbol_hook
10665 #define elf_backend_add_symbol_hook \
10666 elf_vxworks_add_symbol_hook
10667 #undef elf_backend_final_write_processing
10668 #define elf_backend_final_write_processing \
10669 elf32_arm_vxworks_final_write_processing
10670 #undef elf_backend_emit_relocs
10671 #define elf_backend_emit_relocs \
10672 elf_vxworks_emit_relocs
10674 #undef elf_backend_may_use_rel_p
10675 #define elf_backend_may_use_rel_p 0
10676 #undef elf_backend_may_use_rela_p
10677 #define elf_backend_may_use_rela_p 1
10678 #undef elf_backend_default_use_rela_p
10679 #define elf_backend_default_use_rela_p 1
10680 #undef elf_backend_rela_normal
10681 #define elf_backend_rela_normal 1
10682 #undef elf_backend_want_plt_sym
10683 #define elf_backend_want_plt_sym 1
10684 #undef ELF_MAXPAGESIZE
10685 #define ELF_MAXPAGESIZE 0x1000
10687 #include "elf32-target.h"
10690 /* Symbian OS Targets */
10692 #undef TARGET_LITTLE_SYM
10693 #define TARGET_LITTLE_SYM bfd_elf32_littlearm_symbian_vec
10694 #undef TARGET_LITTLE_NAME
10695 #define TARGET_LITTLE_NAME "elf32-littlearm-symbian"
10696 #undef TARGET_BIG_SYM
10697 #define TARGET_BIG_SYM bfd_elf32_bigarm_symbian_vec
10698 #undef TARGET_BIG_NAME
10699 #define TARGET_BIG_NAME "elf32-bigarm-symbian"
10701 /* Like elf32_arm_link_hash_table_create -- but overrides
10702 appropriately for Symbian OS. */
10703 static struct bfd_link_hash_table
*
10704 elf32_arm_symbian_link_hash_table_create (bfd
*abfd
)
10706 struct bfd_link_hash_table
*ret
;
10708 ret
= elf32_arm_link_hash_table_create (abfd
);
10711 struct elf32_arm_link_hash_table
*htab
10712 = (struct elf32_arm_link_hash_table
*)ret
;
10713 /* There is no PLT header for Symbian OS. */
10714 htab
->plt_header_size
= 0;
10715 /* The PLT entries are each three instructions. */
10716 htab
->plt_entry_size
= 4 * NUM_ELEM (elf32_arm_symbian_plt_entry
);
10717 htab
->symbian_p
= 1;
10718 /* Symbian uses armv5t or above, so use_blx is always true. */
10720 htab
->root
.is_relocatable_executable
= 1;
10725 static const struct bfd_elf_special_section
10726 elf32_arm_symbian_special_sections
[] =
10728 /* In a BPABI executable, the dynamic linking sections do not go in
10729 the loadable read-only segment. The post-linker may wish to
10730 refer to these sections, but they are not part of the final
10732 { STRING_COMMA_LEN (".dynamic"), 0, SHT_DYNAMIC
, 0 },
10733 { STRING_COMMA_LEN (".dynstr"), 0, SHT_STRTAB
, 0 },
10734 { STRING_COMMA_LEN (".dynsym"), 0, SHT_DYNSYM
, 0 },
10735 { STRING_COMMA_LEN (".got"), 0, SHT_PROGBITS
, 0 },
10736 { STRING_COMMA_LEN (".hash"), 0, SHT_HASH
, 0 },
10737 /* These sections do not need to be writable as the SymbianOS
10738 postlinker will arrange things so that no dynamic relocation is
10740 { STRING_COMMA_LEN (".init_array"), 0, SHT_INIT_ARRAY
, SHF_ALLOC
},
10741 { STRING_COMMA_LEN (".fini_array"), 0, SHT_FINI_ARRAY
, SHF_ALLOC
},
10742 { STRING_COMMA_LEN (".preinit_array"), 0, SHT_PREINIT_ARRAY
, SHF_ALLOC
},
10743 { NULL
, 0, 0, 0, 0 }
10747 elf32_arm_symbian_begin_write_processing (bfd
*abfd
,
10748 struct bfd_link_info
*link_info
)
10750 /* BPABI objects are never loaded directly by an OS kernel; they are
10751 processed by a postlinker first, into an OS-specific format. If
10752 the D_PAGED bit is set on the file, BFD will align segments on
10753 page boundaries, so that an OS can directly map the file. With
10754 BPABI objects, that just results in wasted space. In addition,
10755 because we clear the D_PAGED bit, map_sections_to_segments will
10756 recognize that the program headers should not be mapped into any
10757 loadable segment. */
10758 abfd
->flags
&= ~D_PAGED
;
10759 elf32_arm_begin_write_processing(abfd
, link_info
);
10763 elf32_arm_symbian_modify_segment_map (bfd
*abfd
,
10764 struct bfd_link_info
*info
)
10766 struct elf_segment_map
*m
;
10769 /* BPABI shared libraries and executables should have a PT_DYNAMIC
10770 segment. However, because the .dynamic section is not marked
10771 with SEC_LOAD, the generic ELF code will not create such a
10773 dynsec
= bfd_get_section_by_name (abfd
, ".dynamic");
10776 for (m
= elf_tdata (abfd
)->segment_map
; m
!= NULL
; m
= m
->next
)
10777 if (m
->p_type
== PT_DYNAMIC
)
10782 m
= _bfd_elf_make_dynamic_segment (abfd
, dynsec
);
10783 m
->next
= elf_tdata (abfd
)->segment_map
;
10784 elf_tdata (abfd
)->segment_map
= m
;
10788 /* Also call the generic arm routine. */
10789 return elf32_arm_modify_segment_map (abfd
, info
);
10793 #define elf32_bed elf32_arm_symbian_bed
10795 /* The dynamic sections are not allocated on SymbianOS; the postlinker
10796 will process them and then discard them. */
10797 #undef ELF_DYNAMIC_SEC_FLAGS
10798 #define ELF_DYNAMIC_SEC_FLAGS \
10799 (SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED)
10801 #undef bfd_elf32_bfd_link_hash_table_create
10802 #define bfd_elf32_bfd_link_hash_table_create \
10803 elf32_arm_symbian_link_hash_table_create
10804 #undef elf_backend_add_symbol_hook
10806 #undef elf_backend_special_sections
10807 #define elf_backend_special_sections elf32_arm_symbian_special_sections
10809 #undef elf_backend_begin_write_processing
10810 #define elf_backend_begin_write_processing \
10811 elf32_arm_symbian_begin_write_processing
10812 #undef elf_backend_final_write_processing
10813 #define elf_backend_final_write_processing \
10814 elf32_arm_final_write_processing
10815 #undef elf_backend_emit_relocs
10817 #undef elf_backend_modify_segment_map
10818 #define elf_backend_modify_segment_map elf32_arm_symbian_modify_segment_map
10820 /* There is no .got section for BPABI objects, and hence no header. */
10821 #undef elf_backend_got_header_size
10822 #define elf_backend_got_header_size 0
10824 /* Similarly, there is no .got.plt section. */
10825 #undef elf_backend_want_got_plt
10826 #define elf_backend_want_got_plt 0
10828 #undef elf_backend_may_use_rel_p
10829 #define elf_backend_may_use_rel_p 1
10830 #undef elf_backend_may_use_rela_p
10831 #define elf_backend_may_use_rela_p 0
10832 #undef elf_backend_default_use_rela_p
10833 #define elf_backend_default_use_rela_p 0
10834 #undef elf_backend_rela_normal
10835 #define elf_backend_rela_normal 0
10836 #undef elf_backend_want_plt_sym
10837 #define elf_backend_want_plt_sym 0
10838 #undef ELF_MAXPAGESIZE
10839 #define ELF_MAXPAGESIZE 0x8000
10841 #include "elf32-target.h"