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 const 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_signed
,/* complain_on_overflow */
838 bfd_elf_generic_reloc
, /* special_function */
839 "R_ARM_THM_ALU_PREL_11_0",/* name */
840 FALSE
, /* partial_inplace */
841 0x040070ff, /* src_mask */
842 0x040070ff, /* 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_signed
,/* complain_on_overflow */
852 bfd_elf_generic_reloc
, /* special_function */
853 "R_ARM_THM_PC12", /* name */
854 FALSE
, /* partial_inplace */
855 0x040070ff, /* src_mask */
856 0x040070ff, /* 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 /* The name of the dynamic interpreter. This is put in the .interp
1880 #define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1"
1882 #ifdef FOUR_WORD_PLT
1884 /* The first entry in a procedure linkage table looks like
1885 this. It is set up so that any shared library function that is
1886 called before the relocation has been set up calls the dynamic
1888 static const bfd_vma elf32_arm_plt0_entry
[] =
1890 0xe52de004, /* str lr, [sp, #-4]! */
1891 0xe59fe010, /* ldr lr, [pc, #16] */
1892 0xe08fe00e, /* add lr, pc, lr */
1893 0xe5bef008, /* ldr pc, [lr, #8]! */
1896 /* Subsequent entries in a procedure linkage table look like
1898 static const bfd_vma elf32_arm_plt_entry
[] =
1900 0xe28fc600, /* add ip, pc, #NN */
1901 0xe28cca00, /* add ip, ip, #NN */
1902 0xe5bcf000, /* ldr pc, [ip, #NN]! */
1903 0x00000000, /* unused */
1908 /* The first entry in a procedure linkage table looks like
1909 this. It is set up so that any shared library function that is
1910 called before the relocation has been set up calls the dynamic
1912 static const bfd_vma elf32_arm_plt0_entry
[] =
1914 0xe52de004, /* str lr, [sp, #-4]! */
1915 0xe59fe004, /* ldr lr, [pc, #4] */
1916 0xe08fe00e, /* add lr, pc, lr */
1917 0xe5bef008, /* ldr pc, [lr, #8]! */
1918 0x00000000, /* &GOT[0] - . */
1921 /* Subsequent entries in a procedure linkage table look like
1923 static const bfd_vma elf32_arm_plt_entry
[] =
1925 0xe28fc600, /* add ip, pc, #0xNN00000 */
1926 0xe28cca00, /* add ip, ip, #0xNN000 */
1927 0xe5bcf000, /* ldr pc, [ip, #0xNNN]! */
1932 /* The format of the first entry in the procedure linkage table
1933 for a VxWorks executable. */
1934 static const bfd_vma elf32_arm_vxworks_exec_plt0_entry
[] =
1936 0xe52dc008, /* str ip,[sp,#-8]! */
1937 0xe59fc000, /* ldr ip,[pc] */
1938 0xe59cf008, /* ldr pc,[ip,#8] */
1939 0x00000000, /* .long _GLOBAL_OFFSET_TABLE_ */
1942 /* The format of subsequent entries in a VxWorks executable. */
1943 static const bfd_vma elf32_arm_vxworks_exec_plt_entry
[] =
1945 0xe59fc000, /* ldr ip,[pc] */
1946 0xe59cf000, /* ldr pc,[ip] */
1947 0x00000000, /* .long @got */
1948 0xe59fc000, /* ldr ip,[pc] */
1949 0xea000000, /* b _PLT */
1950 0x00000000, /* .long @pltindex*sizeof(Elf32_Rela) */
1953 /* The format of entries in a VxWorks shared library. */
1954 static const bfd_vma elf32_arm_vxworks_shared_plt_entry
[] =
1956 0xe59fc000, /* ldr ip,[pc] */
1957 0xe79cf009, /* ldr pc,[ip,r9] */
1958 0x00000000, /* .long @got */
1959 0xe59fc000, /* ldr ip,[pc] */
1960 0xe599f008, /* ldr pc,[r9,#8] */
1961 0x00000000, /* .long @pltindex*sizeof(Elf32_Rela) */
1964 /* An initial stub used if the PLT entry is referenced from Thumb code. */
1965 #define PLT_THUMB_STUB_SIZE 4
1966 static const bfd_vma elf32_arm_plt_thumb_stub
[] =
1972 /* The entries in a PLT when using a DLL-based target with multiple
1974 static const bfd_vma elf32_arm_symbian_plt_entry
[] =
1976 0xe51ff004, /* ldr pc, [pc, #-4] */
1977 0x00000000, /* dcd R_ARM_GLOB_DAT(X) */
1980 /* Used to build a map of a section. This is required for mixed-endian
1983 typedef struct elf32_elf_section_map
1988 elf32_arm_section_map
;
1990 typedef struct _arm_elf_section_data
1992 struct bfd_elf_section_data elf
;
1993 unsigned int mapcount
;
1994 elf32_arm_section_map
*map
;
1996 _arm_elf_section_data
;
1998 #define elf32_arm_section_data(sec) \
1999 ((_arm_elf_section_data *) elf_section_data (sec))
2001 /* The size of the thread control block. */
2004 #define NUM_KNOWN_ATTRIBUTES 32
2006 typedef struct aeabi_attribute
2013 typedef struct aeabi_attribute_list
2015 struct aeabi_attribute_list
*next
;
2017 aeabi_attribute attr
;
2018 } aeabi_attribute_list
;
2020 struct elf32_arm_obj_tdata
2022 struct elf_obj_tdata root
;
2024 /* tls_type for each local got entry. */
2025 char *local_got_tls_type
;
2027 aeabi_attribute known_eabi_attributes
[NUM_KNOWN_ATTRIBUTES
];
2028 aeabi_attribute_list
*other_eabi_attributes
;
2031 #define elf32_arm_tdata(abfd) \
2032 ((struct elf32_arm_obj_tdata *) (abfd)->tdata.any)
2034 #define elf32_arm_local_got_tls_type(abfd) \
2035 (elf32_arm_tdata (abfd)->local_got_tls_type)
2038 elf32_arm_mkobject (bfd
*abfd
)
2040 bfd_size_type amt
= sizeof (struct elf32_arm_obj_tdata
);
2041 abfd
->tdata
.any
= bfd_zalloc (abfd
, amt
);
2042 if (abfd
->tdata
.any
== NULL
)
2047 /* The ARM linker needs to keep track of the number of relocs that it
2048 decides to copy in check_relocs for each symbol. This is so that
2049 it can discard PC relative relocs if it doesn't need them when
2050 linking with -Bsymbolic. We store the information in a field
2051 extending the regular ELF linker hash table. */
2053 /* This structure keeps track of the number of relocs we have copied
2054 for a given symbol. */
2055 struct elf32_arm_relocs_copied
2058 struct elf32_arm_relocs_copied
* next
;
2059 /* A section in dynobj. */
2061 /* Number of relocs copied in this section. */
2062 bfd_size_type count
;
2063 /* Number of PC-relative relocs copied in this section. */
2064 bfd_size_type pc_count
;
2067 #define elf32_arm_hash_entry(ent) ((struct elf32_arm_link_hash_entry *)(ent))
2069 /* Arm ELF linker hash entry. */
2070 struct elf32_arm_link_hash_entry
2072 struct elf_link_hash_entry root
;
2074 /* Number of PC relative relocs copied for this symbol. */
2075 struct elf32_arm_relocs_copied
* relocs_copied
;
2077 /* We reference count Thumb references to a PLT entry separately,
2078 so that we can emit the Thumb trampoline only if needed. */
2079 bfd_signed_vma plt_thumb_refcount
;
2081 /* Since PLT entries have variable size if the Thumb prologue is
2082 used, we need to record the index into .got.plt instead of
2083 recomputing it from the PLT offset. */
2084 bfd_signed_vma plt_got_offset
;
2086 #define GOT_UNKNOWN 0
2087 #define GOT_NORMAL 1
2088 #define GOT_TLS_GD 2
2089 #define GOT_TLS_IE 4
2090 unsigned char tls_type
;
2092 /* The symbol marking the real symbol location for exported thumb
2093 symbols with Arm stubs. */
2094 struct elf_link_hash_entry
*export_glue
;
2097 /* Traverse an arm ELF linker hash table. */
2098 #define elf32_arm_link_hash_traverse(table, func, info) \
2099 (elf_link_hash_traverse \
2101 (bfd_boolean (*) (struct elf_link_hash_entry *, void *)) (func), \
2104 /* Get the ARM elf linker hash table from a link_info structure. */
2105 #define elf32_arm_hash_table(info) \
2106 ((struct elf32_arm_link_hash_table *) ((info)->hash))
2108 /* ARM ELF linker hash table. */
2109 struct elf32_arm_link_hash_table
2111 /* The main hash table. */
2112 struct elf_link_hash_table root
;
2114 /* The size in bytes of the section containing the Thumb-to-ARM glue. */
2115 bfd_size_type thumb_glue_size
;
2117 /* The size in bytes of the section containing the ARM-to-Thumb glue. */
2118 bfd_size_type arm_glue_size
;
2120 /* An arbitrary input BFD chosen to hold the glue sections. */
2121 bfd
* bfd_of_glue_owner
;
2123 /* Nonzero to output a BE8 image. */
2126 /* Zero if R_ARM_TARGET1 means R_ARM_ABS32.
2127 Nonzero if R_ARM_TARGET1 means R_ARM_REL32. */
2130 /* The relocation to use for R_ARM_TARGET2 relocations. */
2133 /* Nonzero to fix BX instructions for ARMv4 targets. */
2136 /* Nonzero if the ARM/Thumb BLX instructions are available for use. */
2139 /* The number of bytes in the initial entry in the PLT. */
2140 bfd_size_type plt_header_size
;
2142 /* The number of bytes in the subsequent PLT etries. */
2143 bfd_size_type plt_entry_size
;
2145 /* True if the target system is VxWorks. */
2148 /* True if the target system is Symbian OS. */
2151 /* True if the target uses REL relocations. */
2154 /* Short-cuts to get to dynamic linker sections. */
2163 /* The (unloaded but important) VxWorks .rela.plt.unloaded section. */
2166 /* Data for R_ARM_TLS_LDM32 relocations. */
2168 bfd_signed_vma refcount
;
2172 /* Small local sym to section mapping cache. */
2173 struct sym_sec_cache sym_sec
;
2175 /* For convenience in allocate_dynrelocs. */
2179 /* Create an entry in an ARM ELF linker hash table. */
2181 static struct bfd_hash_entry
*
2182 elf32_arm_link_hash_newfunc (struct bfd_hash_entry
* entry
,
2183 struct bfd_hash_table
* table
,
2184 const char * string
)
2186 struct elf32_arm_link_hash_entry
* ret
=
2187 (struct elf32_arm_link_hash_entry
*) entry
;
2189 /* Allocate the structure if it has not already been allocated by a
2191 if (ret
== (struct elf32_arm_link_hash_entry
*) NULL
)
2192 ret
= bfd_hash_allocate (table
, sizeof (struct elf32_arm_link_hash_entry
));
2194 return (struct bfd_hash_entry
*) ret
;
2196 /* Call the allocation method of the superclass. */
2197 ret
= ((struct elf32_arm_link_hash_entry
*)
2198 _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry
*) ret
,
2202 ret
->relocs_copied
= NULL
;
2203 ret
->tls_type
= GOT_UNKNOWN
;
2204 ret
->plt_thumb_refcount
= 0;
2205 ret
->plt_got_offset
= -1;
2206 ret
->export_glue
= NULL
;
2209 return (struct bfd_hash_entry
*) ret
;
2212 /* Return true if NAME is the name of the relocation section associated
2216 reloc_section_p (struct elf32_arm_link_hash_table
*htab
,
2217 const char *name
, asection
*s
)
2220 return strncmp (name
, ".rel", 4) == 0 && strcmp (s
->name
, name
+ 4) == 0;
2222 return strncmp (name
, ".rela", 5) == 0 && strcmp (s
->name
, name
+ 5) == 0;
2225 /* Create .got, .gotplt, and .rel(a).got sections in DYNOBJ, and set up
2226 shortcuts to them in our hash table. */
2229 create_got_section (bfd
*dynobj
, struct bfd_link_info
*info
)
2231 struct elf32_arm_link_hash_table
*htab
;
2233 htab
= elf32_arm_hash_table (info
);
2234 /* BPABI objects never have a GOT, or associated sections. */
2235 if (htab
->symbian_p
)
2238 if (! _bfd_elf_create_got_section (dynobj
, info
))
2241 htab
->sgot
= bfd_get_section_by_name (dynobj
, ".got");
2242 htab
->sgotplt
= bfd_get_section_by_name (dynobj
, ".got.plt");
2243 if (!htab
->sgot
|| !htab
->sgotplt
)
2246 htab
->srelgot
= bfd_make_section_with_flags (dynobj
,
2247 RELOC_SECTION (htab
, ".got"),
2248 (SEC_ALLOC
| SEC_LOAD
2251 | SEC_LINKER_CREATED
2253 if (htab
->srelgot
== NULL
2254 || ! bfd_set_section_alignment (dynobj
, htab
->srelgot
, 2))
2259 /* Create .plt, .rel(a).plt, .got, .got.plt, .rel(a).got, .dynbss, and
2260 .rel(a).bss sections in DYNOBJ, and set up shortcuts to them in our
2264 elf32_arm_create_dynamic_sections (bfd
*dynobj
, struct bfd_link_info
*info
)
2266 struct elf32_arm_link_hash_table
*htab
;
2268 htab
= elf32_arm_hash_table (info
);
2269 if (!htab
->sgot
&& !create_got_section (dynobj
, info
))
2272 if (!_bfd_elf_create_dynamic_sections (dynobj
, info
))
2275 htab
->splt
= bfd_get_section_by_name (dynobj
, ".plt");
2276 htab
->srelplt
= bfd_get_section_by_name (dynobj
,
2277 RELOC_SECTION (htab
, ".plt"));
2278 htab
->sdynbss
= bfd_get_section_by_name (dynobj
, ".dynbss");
2280 htab
->srelbss
= bfd_get_section_by_name (dynobj
,
2281 RELOC_SECTION (htab
, ".bss"));
2283 if (htab
->vxworks_p
)
2285 if (!elf_vxworks_create_dynamic_sections (dynobj
, info
, &htab
->srelplt2
))
2290 htab
->plt_header_size
= 0;
2291 htab
->plt_entry_size
2292 = 4 * ARRAY_SIZE (elf32_arm_vxworks_shared_plt_entry
);
2296 htab
->plt_header_size
2297 = 4 * ARRAY_SIZE (elf32_arm_vxworks_exec_plt0_entry
);
2298 htab
->plt_entry_size
2299 = 4 * ARRAY_SIZE (elf32_arm_vxworks_exec_plt_entry
);
2306 || (!info
->shared
&& !htab
->srelbss
))
2312 /* Copy the extra info we tack onto an elf_link_hash_entry. */
2315 elf32_arm_copy_indirect_symbol (struct bfd_link_info
*info
,
2316 struct elf_link_hash_entry
*dir
,
2317 struct elf_link_hash_entry
*ind
)
2319 struct elf32_arm_link_hash_entry
*edir
, *eind
;
2321 edir
= (struct elf32_arm_link_hash_entry
*) dir
;
2322 eind
= (struct elf32_arm_link_hash_entry
*) ind
;
2324 if (eind
->relocs_copied
!= NULL
)
2326 if (edir
->relocs_copied
!= NULL
)
2328 struct elf32_arm_relocs_copied
**pp
;
2329 struct elf32_arm_relocs_copied
*p
;
2331 /* Add reloc counts against the indirect sym to the direct sym
2332 list. Merge any entries against the same section. */
2333 for (pp
= &eind
->relocs_copied
; (p
= *pp
) != NULL
; )
2335 struct elf32_arm_relocs_copied
*q
;
2337 for (q
= edir
->relocs_copied
; q
!= NULL
; q
= q
->next
)
2338 if (q
->section
== p
->section
)
2340 q
->pc_count
+= p
->pc_count
;
2341 q
->count
+= p
->count
;
2348 *pp
= edir
->relocs_copied
;
2351 edir
->relocs_copied
= eind
->relocs_copied
;
2352 eind
->relocs_copied
= NULL
;
2355 /* Copy over PLT info. */
2356 edir
->plt_thumb_refcount
+= eind
->plt_thumb_refcount
;
2357 eind
->plt_thumb_refcount
= 0;
2359 if (ind
->root
.type
== bfd_link_hash_indirect
2360 && dir
->got
.refcount
<= 0)
2362 edir
->tls_type
= eind
->tls_type
;
2363 eind
->tls_type
= GOT_UNKNOWN
;
2366 _bfd_elf_link_hash_copy_indirect (info
, dir
, ind
);
2369 /* Create an ARM elf linker hash table. */
2371 static struct bfd_link_hash_table
*
2372 elf32_arm_link_hash_table_create (bfd
*abfd
)
2374 struct elf32_arm_link_hash_table
*ret
;
2375 bfd_size_type amt
= sizeof (struct elf32_arm_link_hash_table
);
2377 ret
= bfd_malloc (amt
);
2381 if (!_bfd_elf_link_hash_table_init (& ret
->root
, abfd
,
2382 elf32_arm_link_hash_newfunc
,
2383 sizeof (struct elf32_arm_link_hash_entry
)))
2390 ret
->sgotplt
= NULL
;
2391 ret
->srelgot
= NULL
;
2393 ret
->srelplt
= NULL
;
2394 ret
->sdynbss
= NULL
;
2395 ret
->srelbss
= NULL
;
2396 ret
->srelplt2
= NULL
;
2397 ret
->thumb_glue_size
= 0;
2398 ret
->arm_glue_size
= 0;
2399 ret
->bfd_of_glue_owner
= NULL
;
2400 ret
->byteswap_code
= 0;
2401 ret
->target1_is_rel
= 0;
2402 ret
->target2_reloc
= R_ARM_NONE
;
2403 #ifdef FOUR_WORD_PLT
2404 ret
->plt_header_size
= 16;
2405 ret
->plt_entry_size
= 16;
2407 ret
->plt_header_size
= 20;
2408 ret
->plt_entry_size
= 12;
2415 ret
->sym_sec
.abfd
= NULL
;
2417 ret
->tls_ldm_got
.refcount
= 0;
2419 return &ret
->root
.root
;
2422 /* Locate the Thumb encoded calling stub for NAME. */
2424 static struct elf_link_hash_entry
*
2425 find_thumb_glue (struct bfd_link_info
*link_info
,
2430 struct elf_link_hash_entry
*hash
;
2431 struct elf32_arm_link_hash_table
*hash_table
;
2433 /* We need a pointer to the armelf specific hash table. */
2434 hash_table
= elf32_arm_hash_table (link_info
);
2436 tmp_name
= bfd_malloc ((bfd_size_type
) strlen (name
)
2437 + strlen (THUMB2ARM_GLUE_ENTRY_NAME
) + 1);
2439 BFD_ASSERT (tmp_name
);
2441 sprintf (tmp_name
, THUMB2ARM_GLUE_ENTRY_NAME
, name
);
2443 hash
= elf_link_hash_lookup
2444 (&(hash_table
)->root
, tmp_name
, FALSE
, FALSE
, TRUE
);
2447 /* xgettext:c-format */
2448 (*_bfd_error_handler
) (_("%B: unable to find THUMB glue '%s' for `%s'"),
2449 input_bfd
, tmp_name
, name
);
2456 /* Locate the ARM encoded calling stub for NAME. */
2458 static struct elf_link_hash_entry
*
2459 find_arm_glue (struct bfd_link_info
*link_info
,
2464 struct elf_link_hash_entry
*myh
;
2465 struct elf32_arm_link_hash_table
*hash_table
;
2467 /* We need a pointer to the elfarm specific hash table. */
2468 hash_table
= elf32_arm_hash_table (link_info
);
2470 tmp_name
= bfd_malloc ((bfd_size_type
) strlen (name
)
2471 + strlen (ARM2THUMB_GLUE_ENTRY_NAME
) + 1);
2473 BFD_ASSERT (tmp_name
);
2475 sprintf (tmp_name
, ARM2THUMB_GLUE_ENTRY_NAME
, name
);
2477 myh
= elf_link_hash_lookup
2478 (&(hash_table
)->root
, tmp_name
, FALSE
, FALSE
, TRUE
);
2481 /* xgettext:c-format */
2482 (*_bfd_error_handler
) (_("%B: unable to find ARM glue '%s' for `%s'"),
2483 input_bfd
, tmp_name
, name
);
2490 /* ARM->Thumb glue (static images):
2494 ldr r12, __func_addr
2497 .word func @ behave as if you saw a ARM_32 reloc.
2499 (relocatable images)
2502 ldr r12, __func_offset
2509 #define ARM2THUMB_STATIC_GLUE_SIZE 12
2510 static const insn32 a2t1_ldr_insn
= 0xe59fc000;
2511 static const insn32 a2t2_bx_r12_insn
= 0xe12fff1c;
2512 static const insn32 a2t3_func_addr_insn
= 0x00000001;
2514 #define ARM2THUMB_PIC_GLUE_SIZE 16
2515 static const insn32 a2t1p_ldr_insn
= 0xe59fc004;
2516 static const insn32 a2t2p_add_pc_insn
= 0xe08cc00f;
2517 static const insn32 a2t3p_bx_r12_insn
= 0xe12fff1c;
2519 /* Thumb->ARM: Thumb->(non-interworking aware) ARM
2523 __func_from_thumb: __func_from_thumb:
2525 nop ldr r6, __func_addr
2527 __func_change_to_arm: bx r6
2529 __func_back_to_thumb:
2535 #define THUMB2ARM_GLUE_SIZE 8
2536 static const insn16 t2a1_bx_pc_insn
= 0x4778;
2537 static const insn16 t2a2_noop_insn
= 0x46c0;
2538 static const insn32 t2a3_b_insn
= 0xea000000;
2540 #ifndef ELFARM_NABI_C_INCLUDED
2542 bfd_elf32_arm_allocate_interworking_sections (struct bfd_link_info
* info
)
2546 struct elf32_arm_link_hash_table
* globals
;
2548 globals
= elf32_arm_hash_table (info
);
2550 BFD_ASSERT (globals
!= NULL
);
2552 if (globals
->arm_glue_size
!= 0)
2554 BFD_ASSERT (globals
->bfd_of_glue_owner
!= NULL
);
2556 s
= bfd_get_section_by_name (globals
->bfd_of_glue_owner
,
2557 ARM2THUMB_GLUE_SECTION_NAME
);
2559 BFD_ASSERT (s
!= NULL
);
2561 foo
= bfd_alloc (globals
->bfd_of_glue_owner
, globals
->arm_glue_size
);
2563 s
->size
= globals
->arm_glue_size
;
2567 if (globals
->thumb_glue_size
!= 0)
2569 BFD_ASSERT (globals
->bfd_of_glue_owner
!= NULL
);
2571 s
= bfd_get_section_by_name
2572 (globals
->bfd_of_glue_owner
, THUMB2ARM_GLUE_SECTION_NAME
);
2574 BFD_ASSERT (s
!= NULL
);
2576 foo
= bfd_alloc (globals
->bfd_of_glue_owner
, globals
->thumb_glue_size
);
2578 s
->size
= globals
->thumb_glue_size
;
2585 /* Allocate space and symbols for calling a Thumb function from Arm mode.
2586 returns the symbol identifying teh stub. */
2587 static struct elf_link_hash_entry
*
2588 record_arm_to_thumb_glue (struct bfd_link_info
* link_info
,
2589 struct elf_link_hash_entry
* h
)
2591 const char * name
= h
->root
.root
.string
;
2594 struct elf_link_hash_entry
* myh
;
2595 struct bfd_link_hash_entry
* bh
;
2596 struct elf32_arm_link_hash_table
* globals
;
2599 globals
= elf32_arm_hash_table (link_info
);
2601 BFD_ASSERT (globals
!= NULL
);
2602 BFD_ASSERT (globals
->bfd_of_glue_owner
!= NULL
);
2604 s
= bfd_get_section_by_name
2605 (globals
->bfd_of_glue_owner
, ARM2THUMB_GLUE_SECTION_NAME
);
2607 BFD_ASSERT (s
!= NULL
);
2609 tmp_name
= bfd_malloc ((bfd_size_type
) strlen (name
) + strlen (ARM2THUMB_GLUE_ENTRY_NAME
) + 1);
2611 BFD_ASSERT (tmp_name
);
2613 sprintf (tmp_name
, ARM2THUMB_GLUE_ENTRY_NAME
, name
);
2615 myh
= elf_link_hash_lookup
2616 (&(globals
)->root
, tmp_name
, FALSE
, FALSE
, TRUE
);
2620 /* We've already seen this guy. */
2625 /* The only trick here is using hash_table->arm_glue_size as the value.
2626 Even though the section isn't allocated yet, this is where we will be
2629 val
= globals
->arm_glue_size
+ 1;
2630 _bfd_generic_link_add_one_symbol (link_info
, globals
->bfd_of_glue_owner
,
2631 tmp_name
, BSF_GLOBAL
, s
, val
,
2632 NULL
, TRUE
, FALSE
, &bh
);
2634 myh
= (struct elf_link_hash_entry
*) bh
;
2635 myh
->type
= ELF_ST_INFO (STB_LOCAL
, STT_FUNC
);
2636 myh
->forced_local
= 1;
2640 if ((link_info
->shared
|| globals
->root
.is_relocatable_executable
))
2641 globals
->arm_glue_size
+= ARM2THUMB_PIC_GLUE_SIZE
;
2643 globals
->arm_glue_size
+= ARM2THUMB_STATIC_GLUE_SIZE
;
2649 record_thumb_to_arm_glue (struct bfd_link_info
*link_info
,
2650 struct elf_link_hash_entry
*h
)
2652 const char *name
= h
->root
.root
.string
;
2655 struct elf_link_hash_entry
*myh
;
2656 struct bfd_link_hash_entry
*bh
;
2657 struct elf32_arm_link_hash_table
*hash_table
;
2660 hash_table
= elf32_arm_hash_table (link_info
);
2662 BFD_ASSERT (hash_table
!= NULL
);
2663 BFD_ASSERT (hash_table
->bfd_of_glue_owner
!= NULL
);
2665 s
= bfd_get_section_by_name
2666 (hash_table
->bfd_of_glue_owner
, THUMB2ARM_GLUE_SECTION_NAME
);
2668 BFD_ASSERT (s
!= NULL
);
2670 tmp_name
= bfd_malloc ((bfd_size_type
) strlen (name
)
2671 + strlen (THUMB2ARM_GLUE_ENTRY_NAME
) + 1);
2673 BFD_ASSERT (tmp_name
);
2675 sprintf (tmp_name
, THUMB2ARM_GLUE_ENTRY_NAME
, name
);
2677 myh
= elf_link_hash_lookup
2678 (&(hash_table
)->root
, tmp_name
, FALSE
, FALSE
, TRUE
);
2682 /* We've already seen this guy. */
2688 val
= hash_table
->thumb_glue_size
+ 1;
2689 _bfd_generic_link_add_one_symbol (link_info
, hash_table
->bfd_of_glue_owner
,
2690 tmp_name
, BSF_GLOBAL
, s
, val
,
2691 NULL
, TRUE
, FALSE
, &bh
);
2693 /* If we mark it 'Thumb', the disassembler will do a better job. */
2694 myh
= (struct elf_link_hash_entry
*) bh
;
2695 myh
->type
= ELF_ST_INFO (STB_LOCAL
, STT_ARM_TFUNC
);
2696 myh
->forced_local
= 1;
2700 #define CHANGE_TO_ARM "__%s_change_to_arm"
2701 #define BACK_FROM_ARM "__%s_back_from_arm"
2703 /* Allocate another symbol to mark where we switch to Arm mode. */
2704 tmp_name
= bfd_malloc ((bfd_size_type
) strlen (name
)
2705 + strlen (CHANGE_TO_ARM
) + 1);
2707 BFD_ASSERT (tmp_name
);
2709 sprintf (tmp_name
, CHANGE_TO_ARM
, name
);
2712 val
= hash_table
->thumb_glue_size
+ 4,
2713 _bfd_generic_link_add_one_symbol (link_info
, hash_table
->bfd_of_glue_owner
,
2714 tmp_name
, BSF_LOCAL
, s
, val
,
2715 NULL
, TRUE
, FALSE
, &bh
);
2719 hash_table
->thumb_glue_size
+= THUMB2ARM_GLUE_SIZE
;
2724 /* Add the glue sections to ABFD. This function is called from the
2725 linker scripts in ld/emultempl/{armelf}.em. */
2728 bfd_elf32_arm_add_glue_sections_to_bfd (bfd
*abfd
,
2729 struct bfd_link_info
*info
)
2734 /* If we are only performing a partial
2735 link do not bother adding the glue. */
2736 if (info
->relocatable
)
2739 sec
= bfd_get_section_by_name (abfd
, ARM2THUMB_GLUE_SECTION_NAME
);
2743 /* Note: we do not include the flag SEC_LINKER_CREATED, as this
2744 will prevent elf_link_input_bfd() from processing the contents
2746 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_IN_MEMORY
| SEC_CODE
| SEC_READONLY
;
2748 sec
= bfd_make_section_with_flags (abfd
,
2749 ARM2THUMB_GLUE_SECTION_NAME
,
2753 || !bfd_set_section_alignment (abfd
, sec
, 2))
2756 /* Set the gc mark to prevent the section from being removed by garbage
2757 collection, despite the fact that no relocs refer to this section. */
2761 sec
= bfd_get_section_by_name (abfd
, THUMB2ARM_GLUE_SECTION_NAME
);
2765 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_IN_MEMORY
2766 | SEC_CODE
| SEC_READONLY
;
2768 sec
= bfd_make_section_with_flags (abfd
,
2769 THUMB2ARM_GLUE_SECTION_NAME
,
2773 || !bfd_set_section_alignment (abfd
, sec
, 2))
2782 /* Select a BFD to be used to hold the sections used by the glue code.
2783 This function is called from the linker scripts in ld/emultempl/
2787 bfd_elf32_arm_get_bfd_for_interworking (bfd
*abfd
, struct bfd_link_info
*info
)
2789 struct elf32_arm_link_hash_table
*globals
;
2791 /* If we are only performing a partial link
2792 do not bother getting a bfd to hold the glue. */
2793 if (info
->relocatable
)
2796 /* Make sure we don't attach the glue sections to a dynamic object. */
2797 BFD_ASSERT (!(abfd
->flags
& DYNAMIC
));
2799 globals
= elf32_arm_hash_table (info
);
2801 BFD_ASSERT (globals
!= NULL
);
2803 if (globals
->bfd_of_glue_owner
!= NULL
)
2806 /* Save the bfd for later use. */
2807 globals
->bfd_of_glue_owner
= abfd
;
2812 static void check_use_blx(struct elf32_arm_link_hash_table
*globals
)
2814 if (elf32_arm_get_eabi_attr_int (globals
->obfd
, Tag_CPU_arch
) > 2)
2815 globals
->use_blx
= 1;
2819 bfd_elf32_arm_process_before_allocation (bfd
*abfd
,
2820 struct bfd_link_info
*link_info
,
2823 Elf_Internal_Shdr
*symtab_hdr
;
2824 Elf_Internal_Rela
*internal_relocs
= NULL
;
2825 Elf_Internal_Rela
*irel
, *irelend
;
2826 bfd_byte
*contents
= NULL
;
2829 struct elf32_arm_link_hash_table
*globals
;
2831 /* If we are only performing a partial link do not bother
2832 to construct any glue. */
2833 if (link_info
->relocatable
)
2836 /* Here we have a bfd that is to be included on the link. We have a hook
2837 to do reloc rummaging, before section sizes are nailed down. */
2838 globals
= elf32_arm_hash_table (link_info
);
2839 check_use_blx (globals
);
2841 BFD_ASSERT (globals
!= NULL
);
2842 BFD_ASSERT (globals
->bfd_of_glue_owner
!= NULL
);
2844 if (byteswap_code
&& !bfd_big_endian (abfd
))
2846 _bfd_error_handler (_("%B: BE8 images only valid in big-endian mode."),
2850 globals
->byteswap_code
= byteswap_code
;
2852 /* Rummage around all the relocs and map the glue vectors. */
2853 sec
= abfd
->sections
;
2858 for (; sec
!= NULL
; sec
= sec
->next
)
2860 if (sec
->reloc_count
== 0)
2863 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
2865 /* Load the relocs. */
2867 = _bfd_elf_link_read_relocs (abfd
, sec
, (void *) NULL
,
2868 (Elf_Internal_Rela
*) NULL
, FALSE
);
2870 if (internal_relocs
== NULL
)
2873 irelend
= internal_relocs
+ sec
->reloc_count
;
2874 for (irel
= internal_relocs
; irel
< irelend
; irel
++)
2877 unsigned long r_index
;
2879 struct elf_link_hash_entry
*h
;
2881 r_type
= ELF32_R_TYPE (irel
->r_info
);
2882 r_index
= ELF32_R_SYM (irel
->r_info
);
2884 /* These are the only relocation types we care about. */
2885 if ( r_type
!= R_ARM_PC24
2886 && r_type
!= R_ARM_PLT32
2887 && r_type
!= R_ARM_CALL
2888 && r_type
!= R_ARM_JUMP24
2889 && r_type
!= R_ARM_THM_CALL
)
2892 /* Get the section contents if we haven't done so already. */
2893 if (contents
== NULL
)
2895 /* Get cached copy if it exists. */
2896 if (elf_section_data (sec
)->this_hdr
.contents
!= NULL
)
2897 contents
= elf_section_data (sec
)->this_hdr
.contents
;
2900 /* Go get them off disk. */
2901 if (! bfd_malloc_and_get_section (abfd
, sec
, &contents
))
2906 /* If the relocation is not against a symbol it cannot concern us. */
2909 /* We don't care about local symbols. */
2910 if (r_index
< symtab_hdr
->sh_info
)
2913 /* This is an external symbol. */
2914 r_index
-= symtab_hdr
->sh_info
;
2915 h
= (struct elf_link_hash_entry
*)
2916 elf_sym_hashes (abfd
)[r_index
];
2918 /* If the relocation is against a static symbol it must be within
2919 the current section and so cannot be a cross ARM/Thumb relocation. */
2923 /* If the call will go through a PLT entry then we do not need
2925 if (globals
->splt
!= NULL
&& h
->plt
.offset
!= (bfd_vma
) -1)
2934 /* This one is a call from arm code. We need to look up
2935 the target of the call. If it is a thumb target, we
2937 if (ELF_ST_TYPE(h
->type
) == STT_ARM_TFUNC
2938 && !(r_type
== R_ARM_CALL
&& globals
->use_blx
))
2939 record_arm_to_thumb_glue (link_info
, h
);
2942 case R_ARM_THM_CALL
:
2943 /* This one is a call from thumb code. We look
2944 up the target of the call. If it is not a thumb
2945 target, we insert glue. */
2946 if (ELF_ST_TYPE (h
->type
) != STT_ARM_TFUNC
&& !globals
->use_blx
)
2947 record_thumb_to_arm_glue (link_info
, h
);
2955 if (contents
!= NULL
2956 && elf_section_data (sec
)->this_hdr
.contents
!= contents
)
2960 if (internal_relocs
!= NULL
2961 && elf_section_data (sec
)->relocs
!= internal_relocs
)
2962 free (internal_relocs
);
2963 internal_relocs
= NULL
;
2969 if (contents
!= NULL
2970 && elf_section_data (sec
)->this_hdr
.contents
!= contents
)
2972 if (internal_relocs
!= NULL
2973 && elf_section_data (sec
)->relocs
!= internal_relocs
)
2974 free (internal_relocs
);
2981 /* Set target relocation values needed during linking. */
2984 bfd_elf32_arm_set_target_relocs (struct bfd_link_info
*link_info
,
2986 char * target2_type
,
2990 struct elf32_arm_link_hash_table
*globals
;
2992 globals
= elf32_arm_hash_table (link_info
);
2994 globals
->target1_is_rel
= target1_is_rel
;
2995 if (strcmp (target2_type
, "rel") == 0)
2996 globals
->target2_reloc
= R_ARM_REL32
;
2997 else if (strcmp (target2_type
, "abs") == 0)
2998 globals
->target2_reloc
= R_ARM_ABS32
;
2999 else if (strcmp (target2_type
, "got-rel") == 0)
3000 globals
->target2_reloc
= R_ARM_GOT_PREL
;
3003 _bfd_error_handler (_("Invalid TARGET2 relocation type '%s'."),
3006 globals
->fix_v4bx
= fix_v4bx
;
3007 globals
->use_blx
|= use_blx
;
3010 /* The thumb form of a long branch is a bit finicky, because the offset
3011 encoding is split over two fields, each in it's own instruction. They
3012 can occur in any order. So given a thumb form of long branch, and an
3013 offset, insert the offset into the thumb branch and return finished
3016 It takes two thumb instructions to encode the target address. Each has
3017 11 bits to invest. The upper 11 bits are stored in one (identified by
3018 H-0.. see below), the lower 11 bits are stored in the other (identified
3021 Combine together and shifted left by 1 (it's a half word address) and
3025 H-0, upper address-0 = 000
3027 H-1, lower address-0 = 800
3029 They can be ordered either way, but the arm tools I've seen always put
3030 the lower one first. It probably doesn't matter. krk@cygnus.com
3032 XXX: Actually the order does matter. The second instruction (H-1)
3033 moves the computed address into the PC, so it must be the second one
3034 in the sequence. The problem, however is that whilst little endian code
3035 stores the instructions in HI then LOW order, big endian code does the
3036 reverse. nickc@cygnus.com. */
3038 #define LOW_HI_ORDER 0xF800F000
3039 #define HI_LOW_ORDER 0xF000F800
3042 insert_thumb_branch (insn32 br_insn
, int rel_off
)
3044 unsigned int low_bits
;
3045 unsigned int high_bits
;
3047 BFD_ASSERT ((rel_off
& 1) != 1);
3049 rel_off
>>= 1; /* Half word aligned address. */
3050 low_bits
= rel_off
& 0x000007FF; /* The bottom 11 bits. */
3051 high_bits
= (rel_off
>> 11) & 0x000007FF; /* The top 11 bits. */
3053 if ((br_insn
& LOW_HI_ORDER
) == LOW_HI_ORDER
)
3054 br_insn
= LOW_HI_ORDER
| (low_bits
<< 16) | high_bits
;
3055 else if ((br_insn
& HI_LOW_ORDER
) == HI_LOW_ORDER
)
3056 br_insn
= HI_LOW_ORDER
| (high_bits
<< 16) | low_bits
;
3058 /* FIXME: abort is probably not the right call. krk@cygnus.com */
3059 abort (); /* Error - not a valid branch instruction form. */
3065 /* Store an Arm insn into an output section not processed by
3066 elf32_arm_write_section. */
3069 put_arm_insn (struct elf32_arm_link_hash_table
*htab
,
3070 bfd
* output_bfd
, bfd_vma val
, void * ptr
)
3072 if (htab
->byteswap_code
!= bfd_little_endian (output_bfd
))
3073 bfd_putl32 (val
, ptr
);
3075 bfd_putb32 (val
, ptr
);
3079 /* Store a 16-bit Thumb insn into an output section not processed by
3080 elf32_arm_write_section. */
3083 put_thumb_insn (struct elf32_arm_link_hash_table
*htab
,
3084 bfd
* output_bfd
, bfd_vma val
, void * ptr
)
3086 if (htab
->byteswap_code
!= bfd_little_endian (output_bfd
))
3087 bfd_putl16 (val
, ptr
);
3089 bfd_putb16 (val
, ptr
);
3093 /* Thumb code calling an ARM function. */
3096 elf32_thumb_to_arm_stub (struct bfd_link_info
* info
,
3100 asection
* input_section
,
3101 bfd_byte
* hit_data
,
3104 bfd_signed_vma addend
,
3109 unsigned long int tmp
;
3110 long int ret_offset
;
3111 struct elf_link_hash_entry
* myh
;
3112 struct elf32_arm_link_hash_table
* globals
;
3114 myh
= find_thumb_glue (info
, name
, input_bfd
);
3118 globals
= elf32_arm_hash_table (info
);
3120 BFD_ASSERT (globals
!= NULL
);
3121 BFD_ASSERT (globals
->bfd_of_glue_owner
!= NULL
);
3123 my_offset
= myh
->root
.u
.def
.value
;
3125 s
= bfd_get_section_by_name (globals
->bfd_of_glue_owner
,
3126 THUMB2ARM_GLUE_SECTION_NAME
);
3128 BFD_ASSERT (s
!= NULL
);
3129 BFD_ASSERT (s
->contents
!= NULL
);
3130 BFD_ASSERT (s
->output_section
!= NULL
);
3132 if ((my_offset
& 0x01) == 0x01)
3135 && sym_sec
->owner
!= NULL
3136 && !INTERWORK_FLAG (sym_sec
->owner
))
3138 (*_bfd_error_handler
)
3139 (_("%B(%s): warning: interworking not enabled.\n"
3140 " first occurrence: %B: thumb call to arm"),
3141 sym_sec
->owner
, input_bfd
, name
);
3147 myh
->root
.u
.def
.value
= my_offset
;
3149 put_thumb_insn (globals
, output_bfd
, (bfd_vma
) t2a1_bx_pc_insn
,
3150 s
->contents
+ my_offset
);
3152 put_thumb_insn (globals
, output_bfd
, (bfd_vma
) t2a2_noop_insn
,
3153 s
->contents
+ my_offset
+ 2);
3156 /* Address of destination of the stub. */
3157 ((bfd_signed_vma
) val
)
3159 /* Offset from the start of the current section
3160 to the start of the stubs. */
3162 /* Offset of the start of this stub from the start of the stubs. */
3164 /* Address of the start of the current section. */
3165 + s
->output_section
->vma
)
3166 /* The branch instruction is 4 bytes into the stub. */
3168 /* ARM branches work from the pc of the instruction + 8. */
3171 put_arm_insn (globals
, output_bfd
,
3172 (bfd_vma
) t2a3_b_insn
| ((ret_offset
>> 2) & 0x00FFFFFF),
3173 s
->contents
+ my_offset
+ 4);
3176 BFD_ASSERT (my_offset
<= globals
->thumb_glue_size
);
3178 /* Now go back and fix up the original BL insn to point to here. */
3180 /* Address of where the stub is located. */
3181 (s
->output_section
->vma
+ s
->output_offset
+ my_offset
)
3182 /* Address of where the BL is located. */
3183 - (input_section
->output_section
->vma
+ input_section
->output_offset
3185 /* Addend in the relocation. */
3187 /* Biassing for PC-relative addressing. */
3190 tmp
= bfd_get_32 (input_bfd
, hit_data
3191 - input_section
->vma
);
3193 bfd_put_32 (output_bfd
,
3194 (bfd_vma
) insert_thumb_branch (tmp
, ret_offset
),
3195 hit_data
- input_section
->vma
);
3200 /* Populate an Arm to Thumb stub. Returns the stub symbol. */
3202 static struct elf_link_hash_entry
*
3203 elf32_arm_create_thumb_stub (struct bfd_link_info
* info
,
3212 long int ret_offset
;
3213 struct elf_link_hash_entry
* myh
;
3214 struct elf32_arm_link_hash_table
* globals
;
3216 myh
= find_arm_glue (info
, name
, input_bfd
);
3220 globals
= elf32_arm_hash_table (info
);
3222 BFD_ASSERT (globals
!= NULL
);
3223 BFD_ASSERT (globals
->bfd_of_glue_owner
!= NULL
);
3225 my_offset
= myh
->root
.u
.def
.value
;
3227 if ((my_offset
& 0x01) == 0x01)
3230 && sym_sec
->owner
!= NULL
3231 && !INTERWORK_FLAG (sym_sec
->owner
))
3233 (*_bfd_error_handler
)
3234 (_("%B(%s): warning: interworking not enabled.\n"
3235 " first occurrence: %B: arm call to thumb"),
3236 sym_sec
->owner
, input_bfd
, name
);
3240 myh
->root
.u
.def
.value
= my_offset
;
3242 if ((info
->shared
|| globals
->root
.is_relocatable_executable
))
3244 /* For relocatable objects we can't use absolute addresses,
3245 so construct the address from a relative offset. */
3246 /* TODO: If the offset is small it's probably worth
3247 constructing the address with adds. */
3248 put_arm_insn (globals
, output_bfd
, (bfd_vma
) a2t1p_ldr_insn
,
3249 s
->contents
+ my_offset
);
3250 put_arm_insn (globals
, output_bfd
, (bfd_vma
) a2t2p_add_pc_insn
,
3251 s
->contents
+ my_offset
+ 4);
3252 put_arm_insn (globals
, output_bfd
, (bfd_vma
) a2t3p_bx_r12_insn
,
3253 s
->contents
+ my_offset
+ 8);
3254 /* Adjust the offset by 4 for the position of the add,
3255 and 8 for the pipeline offset. */
3256 ret_offset
= (val
- (s
->output_offset
3257 + s
->output_section
->vma
3260 bfd_put_32 (output_bfd
, ret_offset
,
3261 s
->contents
+ my_offset
+ 12);
3265 put_arm_insn (globals
, output_bfd
, (bfd_vma
) a2t1_ldr_insn
,
3266 s
->contents
+ my_offset
);
3268 put_arm_insn (globals
, output_bfd
, (bfd_vma
) a2t2_bx_r12_insn
,
3269 s
->contents
+ my_offset
+ 4);
3271 /* It's a thumb address. Add the low order bit. */
3272 bfd_put_32 (output_bfd
, val
| a2t3_func_addr_insn
,
3273 s
->contents
+ my_offset
+ 8);
3277 BFD_ASSERT (my_offset
<= globals
->arm_glue_size
);
3282 /* Arm code calling a Thumb function. */
3285 elf32_arm_to_thumb_stub (struct bfd_link_info
* info
,
3289 asection
* input_section
,
3290 bfd_byte
* hit_data
,
3293 bfd_signed_vma addend
,
3296 unsigned long int tmp
;
3299 long int ret_offset
;
3300 struct elf_link_hash_entry
* myh
;
3301 struct elf32_arm_link_hash_table
* globals
;
3303 globals
= elf32_arm_hash_table (info
);
3305 BFD_ASSERT (globals
!= NULL
);
3306 BFD_ASSERT (globals
->bfd_of_glue_owner
!= NULL
);
3308 s
= bfd_get_section_by_name (globals
->bfd_of_glue_owner
,
3309 ARM2THUMB_GLUE_SECTION_NAME
);
3310 BFD_ASSERT (s
!= NULL
);
3311 BFD_ASSERT (s
->contents
!= NULL
);
3312 BFD_ASSERT (s
->output_section
!= NULL
);
3314 myh
= elf32_arm_create_thumb_stub (info
, name
, input_bfd
, output_bfd
,
3319 my_offset
= myh
->root
.u
.def
.value
;
3320 tmp
= bfd_get_32 (input_bfd
, hit_data
);
3321 tmp
= tmp
& 0xFF000000;
3323 /* Somehow these are both 4 too far, so subtract 8. */
3324 ret_offset
= (s
->output_offset
3326 + s
->output_section
->vma
3327 - (input_section
->output_offset
3328 + input_section
->output_section
->vma
3332 tmp
= tmp
| ((ret_offset
>> 2) & 0x00FFFFFF);
3334 bfd_put_32 (output_bfd
, (bfd_vma
) tmp
, hit_data
- input_section
->vma
);
3339 /* Populate Arm stub for an exported Thumb function. */
3342 elf32_arm_to_thumb_export_stub (struct elf_link_hash_entry
*h
, void * inf
)
3344 struct bfd_link_info
* info
= (struct bfd_link_info
*) inf
;
3346 struct elf_link_hash_entry
* myh
;
3347 struct elf32_arm_link_hash_entry
*eh
;
3348 struct elf32_arm_link_hash_table
* globals
;
3352 eh
= elf32_arm_hash_entry(h
);
3353 /* Allocate stubs for exported Thumb functions on v4t. */
3354 if (eh
->export_glue
== NULL
)
3357 globals
= elf32_arm_hash_table (info
);
3359 BFD_ASSERT (globals
!= NULL
);
3360 BFD_ASSERT (globals
->bfd_of_glue_owner
!= NULL
);
3362 s
= bfd_get_section_by_name (globals
->bfd_of_glue_owner
,
3363 ARM2THUMB_GLUE_SECTION_NAME
);
3364 BFD_ASSERT (s
!= NULL
);
3365 BFD_ASSERT (s
->contents
!= NULL
);
3366 BFD_ASSERT (s
->output_section
!= NULL
);
3368 sec
= eh
->export_glue
->root
.u
.def
.section
;
3369 val
= eh
->export_glue
->root
.u
.def
.value
+ sec
->output_offset
3370 + sec
->output_section
->vma
;
3371 myh
= elf32_arm_create_thumb_stub (info
, h
->root
.root
.string
,
3372 h
->root
.u
.def
.section
->owner
,
3373 globals
->obfd
, sec
, val
, s
);
3378 /* Generate Arm stubs for exported Thumb symbols. */
3380 elf32_arm_begin_write_processing (bfd
*abfd ATTRIBUTE_UNUSED
,
3381 struct bfd_link_info
*link_info
)
3383 struct elf32_arm_link_hash_table
* globals
;
3388 globals
= elf32_arm_hash_table (link_info
);
3389 if (globals
->use_blx
)
3392 elf_link_hash_traverse (&globals
->root
, elf32_arm_to_thumb_export_stub
,
3396 /* Some relocations map to different relocations depending on the
3397 target. Return the real relocation. */
3399 arm_real_reloc_type (struct elf32_arm_link_hash_table
* globals
,
3405 if (globals
->target1_is_rel
)
3411 return globals
->target2_reloc
;
3418 /* Return the base VMA address which should be subtracted from real addresses
3419 when resolving @dtpoff relocation.
3420 This is PT_TLS segment p_vaddr. */
3423 dtpoff_base (struct bfd_link_info
*info
)
3425 /* If tls_sec is NULL, we should have signalled an error already. */
3426 if (elf_hash_table (info
)->tls_sec
== NULL
)
3428 return elf_hash_table (info
)->tls_sec
->vma
;
3431 /* Return the relocation value for @tpoff relocation
3432 if STT_TLS virtual address is ADDRESS. */
3435 tpoff (struct bfd_link_info
*info
, bfd_vma address
)
3437 struct elf_link_hash_table
*htab
= elf_hash_table (info
);
3440 /* If tls_sec is NULL, we should have signalled an error already. */
3441 if (htab
->tls_sec
== NULL
)
3443 base
= align_power ((bfd_vma
) TCB_SIZE
, htab
->tls_sec
->alignment_power
);
3444 return address
- htab
->tls_sec
->vma
+ base
;
3447 /* Perform an R_ARM_ABS12 relocation on the field pointed to by DATA.
3448 VALUE is the relocation value. */
3450 static bfd_reloc_status_type
3451 elf32_arm_abs12_reloc (bfd
*abfd
, void *data
, bfd_vma value
)
3454 return bfd_reloc_overflow
;
3456 value
|= bfd_get_32 (abfd
, data
) & 0xfffff000;
3457 bfd_put_32 (abfd
, value
, data
);
3458 return bfd_reloc_ok
;
3461 /* For a given value of n, calculate the value of G_n as required to
3462 deal with group relocations. We return it in the form of an
3463 encoded constant-and-rotation, together with the final residual. If n is
3464 specified as less than zero, then final_residual is filled with the
3465 input value and no further action is performed. */
3468 calculate_group_reloc_mask (bfd_vma value
, int n
, bfd_vma
*final_residual
)
3472 bfd_vma encoded_g_n
= 0;
3473 bfd_vma residual
= value
; /* Also known as Y_n. */
3475 for (current_n
= 0; current_n
<= n
; current_n
++)
3479 /* Calculate which part of the value to mask. */
3486 /* Determine the most significant bit in the residual and
3487 align the resulting value to a 2-bit boundary. */
3488 for (msb
= 30; msb
>= 0; msb
-= 2)
3489 if (residual
& (3 << msb
))
3492 /* The desired shift is now (msb - 6), or zero, whichever
3499 /* Calculate g_n in 32-bit as well as encoded constant+rotation form. */
3500 g_n
= residual
& (0xff << shift
);
3501 encoded_g_n
= (g_n
>> shift
)
3502 | ((g_n
<= 0xff ? 0 : (32 - shift
) / 2) << 8);
3504 /* Calculate the residual for the next time around. */
3508 *final_residual
= residual
;
3513 /* Given an ARM instruction, determine whether it is an ADD or a SUB.
3514 Returns 1 if it is an ADD, -1 if it is a SUB, and 0 otherwise. */
3516 identify_add_or_sub(bfd_vma insn
)
3518 int opcode
= insn
& 0x1e00000;
3520 if (opcode
== 1 << 23) /* ADD */
3523 if (opcode
== 1 << 22) /* SUB */
3529 /* Determine if we're dealing with a Thumb-2 object. */
3531 static int using_thumb2 (struct elf32_arm_link_hash_table
*globals
)
3533 int arch
= elf32_arm_get_eabi_attr_int (globals
->obfd
, Tag_CPU_arch
);
3534 return arch
== 8 || arch
>= 10;
3537 /* Perform a relocation as part of a final link. */
3539 static bfd_reloc_status_type
3540 elf32_arm_final_link_relocate (reloc_howto_type
* howto
,
3543 asection
* input_section
,
3544 bfd_byte
* contents
,
3545 Elf_Internal_Rela
* rel
,
3547 struct bfd_link_info
* info
,
3549 const char * sym_name
,
3551 struct elf_link_hash_entry
* h
,
3552 bfd_boolean
* unresolved_reloc_p
)
3554 unsigned long r_type
= howto
->type
;
3555 unsigned long r_symndx
;
3556 bfd_byte
* hit_data
= contents
+ rel
->r_offset
;
3557 bfd
* dynobj
= NULL
;
3558 Elf_Internal_Shdr
* symtab_hdr
;
3559 struct elf_link_hash_entry
** sym_hashes
;
3560 bfd_vma
* local_got_offsets
;
3561 asection
* sgot
= NULL
;
3562 asection
* splt
= NULL
;
3563 asection
* sreloc
= NULL
;
3565 bfd_signed_vma signed_addend
;
3566 struct elf32_arm_link_hash_table
* globals
;
3568 globals
= elf32_arm_hash_table (info
);
3570 /* Some relocation type map to different relocations depending on the
3571 target. We pick the right one here. */
3572 r_type
= arm_real_reloc_type (globals
, r_type
);
3573 if (r_type
!= howto
->type
)
3574 howto
= elf32_arm_howto_from_type (r_type
);
3576 /* If the start address has been set, then set the EF_ARM_HASENTRY
3577 flag. Setting this more than once is redundant, but the cost is
3578 not too high, and it keeps the code simple.
3580 The test is done here, rather than somewhere else, because the
3581 start address is only set just before the final link commences.
3583 Note - if the user deliberately sets a start address of 0, the
3584 flag will not be set. */
3585 if (bfd_get_start_address (output_bfd
) != 0)
3586 elf_elfheader (output_bfd
)->e_flags
|= EF_ARM_HASENTRY
;
3588 dynobj
= elf_hash_table (info
)->dynobj
;
3591 sgot
= bfd_get_section_by_name (dynobj
, ".got");
3592 splt
= bfd_get_section_by_name (dynobj
, ".plt");
3594 symtab_hdr
= & elf_tdata (input_bfd
)->symtab_hdr
;
3595 sym_hashes
= elf_sym_hashes (input_bfd
);
3596 local_got_offsets
= elf_local_got_offsets (input_bfd
);
3597 r_symndx
= ELF32_R_SYM (rel
->r_info
);
3599 if (globals
->use_rel
)
3601 addend
= bfd_get_32 (input_bfd
, hit_data
) & howto
->src_mask
;
3603 if (addend
& ((howto
->src_mask
+ 1) >> 1))
3606 signed_addend
&= ~ howto
->src_mask
;
3607 signed_addend
|= addend
;
3610 signed_addend
= addend
;
3613 addend
= signed_addend
= rel
->r_addend
;
3618 /* We don't need to find a value for this symbol. It's just a
3620 *unresolved_reloc_p
= FALSE
;
3621 return bfd_reloc_ok
;
3624 if (!globals
->vxworks_p
)
3625 return elf32_arm_abs12_reloc (input_bfd
, hit_data
, value
+ addend
);
3629 case R_ARM_ABS32_NOI
:
3631 case R_ARM_REL32_NOI
:
3637 /* r_symndx will be zero only for relocs against symbols
3638 from removed linkonce sections, or sections discarded by
3641 return bfd_reloc_ok
;
3643 /* Handle relocations which should use the PLT entry. ABS32/REL32
3644 will use the symbol's value, which may point to a PLT entry, but we
3645 don't need to handle that here. If we created a PLT entry, all
3646 branches in this object should go to it. */
3647 if ((r_type
!= R_ARM_ABS32
&& r_type
!= R_ARM_REL32
3648 && r_type
!= R_ARM_ABS32_NOI
&& r_type
!= R_ARM_REL32_NOI
)
3651 && h
->plt
.offset
!= (bfd_vma
) -1)
3653 /* If we've created a .plt section, and assigned a PLT entry to
3654 this function, it should not be known to bind locally. If
3655 it were, we would have cleared the PLT entry. */
3656 BFD_ASSERT (!SYMBOL_CALLS_LOCAL (info
, h
));
3658 value
= (splt
->output_section
->vma
3659 + splt
->output_offset
3661 *unresolved_reloc_p
= FALSE
;
3662 return _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
3663 contents
, rel
->r_offset
, value
,
3667 /* When generating a shared object or relocatable executable, these
3668 relocations are copied into the output file to be resolved at
3670 if ((info
->shared
|| globals
->root
.is_relocatable_executable
)
3671 && (input_section
->flags
& SEC_ALLOC
)
3672 && ((r_type
!= R_ARM_REL32
&& r_type
!= R_ARM_REL32_NOI
)
3673 || !SYMBOL_CALLS_LOCAL (info
, h
))
3675 || ELF_ST_VISIBILITY (h
->other
) == STV_DEFAULT
3676 || h
->root
.type
!= bfd_link_hash_undefweak
)
3677 && r_type
!= R_ARM_PC24
3678 && r_type
!= R_ARM_CALL
3679 && r_type
!= R_ARM_JUMP24
3680 && r_type
!= R_ARM_PREL31
3681 && r_type
!= R_ARM_PLT32
)
3683 Elf_Internal_Rela outrel
;
3685 bfd_boolean skip
, relocate
;
3687 *unresolved_reloc_p
= FALSE
;
3693 name
= (bfd_elf_string_from_elf_section
3695 elf_elfheader (input_bfd
)->e_shstrndx
,
3696 elf_section_data (input_section
)->rel_hdr
.sh_name
));
3698 return bfd_reloc_notsupported
;
3700 BFD_ASSERT (reloc_section_p (globals
, name
, input_section
));
3702 sreloc
= bfd_get_section_by_name (dynobj
, name
);
3703 BFD_ASSERT (sreloc
!= NULL
);
3709 outrel
.r_addend
= addend
;
3711 _bfd_elf_section_offset (output_bfd
, info
, input_section
,
3713 if (outrel
.r_offset
== (bfd_vma
) -1)
3715 else if (outrel
.r_offset
== (bfd_vma
) -2)
3716 skip
= TRUE
, relocate
= TRUE
;
3717 outrel
.r_offset
+= (input_section
->output_section
->vma
3718 + input_section
->output_offset
);
3721 memset (&outrel
, 0, sizeof outrel
);
3726 || !h
->def_regular
))
3727 outrel
.r_info
= ELF32_R_INFO (h
->dynindx
, r_type
);
3732 /* This symbol is local, or marked to become local. */
3733 if (sym_flags
== STT_ARM_TFUNC
)
3735 if (globals
->symbian_p
)
3737 /* On Symbian OS, the data segment and text segement
3738 can be relocated independently. Therefore, we
3739 must indicate the segment to which this
3740 relocation is relative. The BPABI allows us to
3741 use any symbol in the right segment; we just use
3742 the section symbol as it is convenient. (We
3743 cannot use the symbol given by "h" directly as it
3744 will not appear in the dynamic symbol table.) */
3746 symbol
= elf_section_data (sym_sec
->output_section
)->dynindx
;
3748 symbol
= elf_section_data (input_section
->output_section
)->dynindx
;
3749 BFD_ASSERT (symbol
!= 0);
3752 /* On SVR4-ish systems, the dynamic loader cannot
3753 relocate the text and data segments independently,
3754 so the symbol does not matter. */
3756 outrel
.r_info
= ELF32_R_INFO (symbol
, R_ARM_RELATIVE
);
3757 if (globals
->use_rel
)
3760 outrel
.r_addend
+= value
;
3763 loc
= sreloc
->contents
;
3764 loc
+= sreloc
->reloc_count
++ * RELOC_SIZE (globals
);
3765 SWAP_RELOC_OUT (globals
) (output_bfd
, &outrel
, loc
);
3767 /* If this reloc is against an external symbol, we do not want to
3768 fiddle with the addend. Otherwise, we need to include the symbol
3769 value so that it becomes an addend for the dynamic reloc. */
3771 return bfd_reloc_ok
;
3773 return _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
3774 contents
, rel
->r_offset
, value
,
3777 else switch (r_type
)
3780 return elf32_arm_abs12_reloc (input_bfd
, hit_data
, value
+ addend
);
3782 case R_ARM_XPC25
: /* Arm BLX instruction. */
3785 case R_ARM_PC24
: /* Arm B/BL instruction */
3787 if (r_type
== R_ARM_XPC25
)
3789 /* Check for Arm calling Arm function. */
3790 /* FIXME: Should we translate the instruction into a BL
3791 instruction instead ? */
3792 if (sym_flags
!= STT_ARM_TFUNC
)
3793 (*_bfd_error_handler
)
3794 (_("\%B: Warning: Arm BLX instruction targets Arm function '%s'."),
3796 h
? h
->root
.root
.string
: "(local)");
3798 else if (r_type
!= R_ARM_CALL
|| !globals
->use_blx
)
3800 /* Check for Arm calling Thumb function. */
3801 if (sym_flags
== STT_ARM_TFUNC
)
3803 elf32_arm_to_thumb_stub (info
, sym_name
, input_bfd
,
3804 output_bfd
, input_section
,
3805 hit_data
, sym_sec
, rel
->r_offset
,
3806 signed_addend
, value
);
3807 return bfd_reloc_ok
;
3811 /* The ARM ELF ABI says that this reloc is computed as: S - P + A
3813 S is the address of the symbol in the relocation.
3814 P is address of the instruction being relocated.
3815 A is the addend (extracted from the instruction) in bytes.
3817 S is held in 'value'.
3818 P is the base address of the section containing the
3819 instruction plus the offset of the reloc into that
3821 (input_section->output_section->vma +
3822 input_section->output_offset +
3824 A is the addend, converted into bytes, ie:
3827 Note: None of these operations have knowledge of the pipeline
3828 size of the processor, thus it is up to the assembler to
3829 encode this information into the addend. */
3830 value
-= (input_section
->output_section
->vma
3831 + input_section
->output_offset
);
3832 value
-= rel
->r_offset
;
3833 if (globals
->use_rel
)
3834 value
+= (signed_addend
<< howto
->size
);
3836 /* RELA addends do not have to be adjusted by howto->size. */
3837 value
+= signed_addend
;
3839 signed_addend
= value
;
3840 signed_addend
>>= howto
->rightshift
;
3842 /* It is not an error for an undefined weak reference to be
3843 out of range. Any program that branches to such a symbol
3844 is going to crash anyway, so there is no point worrying
3845 about getting the destination exactly right. */
3846 if (! h
|| h
->root
.type
!= bfd_link_hash_undefweak
)
3848 /* Perform a signed range check. */
3849 if ( signed_addend
> ((bfd_signed_vma
) (howto
->dst_mask
>> 1))
3850 || signed_addend
< - ((bfd_signed_vma
) ((howto
->dst_mask
+ 1) >> 1)))
3851 return bfd_reloc_overflow
;
3854 addend
= (value
& 2);
3856 value
= (signed_addend
& howto
->dst_mask
)
3857 | (bfd_get_32 (input_bfd
, hit_data
) & (~ howto
->dst_mask
));
3859 /* Set the H bit in the BLX instruction. */
3860 if (sym_flags
== STT_ARM_TFUNC
)
3865 value
&= ~(bfd_vma
)(1 << 24);
3867 if (r_type
== R_ARM_CALL
)
3869 /* Select the correct instruction (BL or BLX). */
3870 if (sym_flags
== STT_ARM_TFUNC
)
3874 value
&= ~(bfd_vma
)(1 << 28);
3882 if (sym_flags
== STT_ARM_TFUNC
)
3886 case R_ARM_ABS32_NOI
:
3892 if (sym_flags
== STT_ARM_TFUNC
)
3894 value
-= (input_section
->output_section
->vma
3895 + input_section
->output_offset
+ rel
->r_offset
);
3898 case R_ARM_REL32_NOI
:
3900 value
-= (input_section
->output_section
->vma
3901 + input_section
->output_offset
+ rel
->r_offset
);
3905 value
-= (input_section
->output_section
->vma
3906 + input_section
->output_offset
+ rel
->r_offset
);
3907 value
+= signed_addend
;
3908 if (! h
|| h
->root
.type
!= bfd_link_hash_undefweak
)
3910 /* Check for overflow */
3911 if ((value
^ (value
>> 1)) & (1 << 30))
3912 return bfd_reloc_overflow
;
3914 value
&= 0x7fffffff;
3915 value
|= (bfd_get_32 (input_bfd
, hit_data
) & 0x80000000);
3916 if (sym_flags
== STT_ARM_TFUNC
)
3921 bfd_put_32 (input_bfd
, value
, hit_data
);
3922 return bfd_reloc_ok
;
3926 if ((long) value
> 0x7f || (long) value
< -0x80)
3927 return bfd_reloc_overflow
;
3929 bfd_put_8 (input_bfd
, value
, hit_data
);
3930 return bfd_reloc_ok
;
3935 if ((long) value
> 0x7fff || (long) value
< -0x8000)
3936 return bfd_reloc_overflow
;
3938 bfd_put_16 (input_bfd
, value
, hit_data
);
3939 return bfd_reloc_ok
;
3941 case R_ARM_THM_ABS5
:
3942 /* Support ldr and str instructions for the thumb. */
3943 if (globals
->use_rel
)
3945 /* Need to refetch addend. */
3946 addend
= bfd_get_16 (input_bfd
, hit_data
) & howto
->src_mask
;
3947 /* ??? Need to determine shift amount from operand size. */
3948 addend
>>= howto
->rightshift
;
3952 /* ??? Isn't value unsigned? */
3953 if ((long) value
> 0x1f || (long) value
< -0x10)
3954 return bfd_reloc_overflow
;
3956 /* ??? Value needs to be properly shifted into place first. */
3957 value
|= bfd_get_16 (input_bfd
, hit_data
) & 0xf83f;
3958 bfd_put_16 (input_bfd
, value
, hit_data
);
3959 return bfd_reloc_ok
;
3961 case R_ARM_THM_XPC22
:
3962 case R_ARM_THM_CALL
:
3963 /* Thumb BL (branch long instruction). */
3967 bfd_boolean overflow
= FALSE
;
3968 bfd_vma upper_insn
= bfd_get_16 (input_bfd
, hit_data
);
3969 bfd_vma lower_insn
= bfd_get_16 (input_bfd
, hit_data
+ 2);
3970 bfd_signed_vma reloc_signed_max
;
3971 bfd_signed_vma reloc_signed_min
;
3973 bfd_signed_vma signed_check
;
3975 int thumb2
= using_thumb2 (globals
);
3977 /* Fetch the addend. We use the Thumb-2 encoding (backwards compatible
3978 with Thumb-1) involving the J1 and J2 bits. */
3979 if (globals
->use_rel
)
3981 bfd_vma s
= (upper_insn
& (1 << 10)) >> 10;
3982 bfd_vma upper
= upper_insn
& 0x3ff;
3983 bfd_vma lower
= lower_insn
& 0x7ff;
3984 bfd_vma j1
= (lower_insn
& (1 << 13)) >> 13;
3985 bfd_vma j2
= (lower_insn
& (1 << 11)) >> 11;
3986 bfd_vma i1
= j1
^ s
? 0 : 1;
3987 bfd_vma i2
= j2
^ s
? 0 : 1;
3989 addend
= (i1
<< 23) | (i2
<< 22) | (upper
<< 12) | (lower
<< 1);
3991 addend
= (addend
| ((s
? 0 : 1) << 24)) - (1 << 24);
3993 signed_addend
= addend
;
3996 if (r_type
== R_ARM_THM_XPC22
)
3998 /* Check for Thumb to Thumb call. */
3999 /* FIXME: Should we translate the instruction into a BL
4000 instruction instead ? */
4001 if (sym_flags
== STT_ARM_TFUNC
)
4002 (*_bfd_error_handler
)
4003 (_("%B: Warning: Thumb BLX instruction targets thumb function '%s'."),
4005 h
? h
->root
.root
.string
: "(local)");
4009 /* If it is not a call to Thumb, assume call to Arm.
4010 If it is a call relative to a section name, then it is not a
4011 function call at all, but rather a long jump. Calls through
4012 the PLT do not require stubs. */
4013 if (sym_flags
!= STT_ARM_TFUNC
&& sym_flags
!= STT_SECTION
4014 && (h
== NULL
|| splt
== NULL
4015 || h
->plt
.offset
== (bfd_vma
) -1))
4017 if (globals
->use_blx
)
4019 /* Convert BL to BLX. */
4020 lower_insn
= (lower_insn
& ~0x1000) | 0x0800;
4022 else if (elf32_thumb_to_arm_stub
4023 (info
, sym_name
, input_bfd
, output_bfd
, input_section
,
4024 hit_data
, sym_sec
, rel
->r_offset
, signed_addend
, value
))
4025 return bfd_reloc_ok
;
4027 return bfd_reloc_dangerous
;
4029 else if (sym_flags
== STT_ARM_TFUNC
&& globals
->use_blx
)
4031 /* Make sure this is a BL. */
4032 lower_insn
|= 0x1800;
4036 /* Handle calls via the PLT. */
4037 if (h
!= NULL
&& splt
!= NULL
&& h
->plt
.offset
!= (bfd_vma
) -1)
4039 value
= (splt
->output_section
->vma
4040 + splt
->output_offset
4042 if (globals
->use_blx
)
4044 /* If the Thumb BLX instruction is available, convert the
4045 BL to a BLX instruction to call the ARM-mode PLT entry. */
4046 lower_insn
= (lower_insn
& ~0x1000) | 0x0800;
4049 /* Target the Thumb stub before the ARM PLT entry. */
4050 value
-= PLT_THUMB_STUB_SIZE
;
4051 *unresolved_reloc_p
= FALSE
;
4054 relocation
= value
+ signed_addend
;
4056 relocation
-= (input_section
->output_section
->vma
4057 + input_section
->output_offset
4060 check
= relocation
>> howto
->rightshift
;
4062 /* If this is a signed value, the rightshift just dropped
4063 leading 1 bits (assuming twos complement). */
4064 if ((bfd_signed_vma
) relocation
>= 0)
4065 signed_check
= check
;
4067 signed_check
= check
| ~((bfd_vma
) -1 >> howto
->rightshift
);
4069 /* Calculate the permissable maximum and minimum values for
4070 this relocation according to whether we're relocating for
4072 bitsize
= howto
->bitsize
;
4075 reloc_signed_max
= ((1 << (bitsize
- 1)) - 1) >> howto
->rightshift
;
4076 reloc_signed_min
= ~reloc_signed_max
;
4078 /* Assumes two's complement. */
4079 if (signed_check
> reloc_signed_max
|| signed_check
< reloc_signed_min
)
4082 if ((lower_insn
& 0x1800) == 0x0800)
4083 /* For a BLX instruction, make sure that the relocation is rounded up
4084 to a word boundary. This follows the semantics of the instruction
4085 which specifies that bit 1 of the target address will come from bit
4086 1 of the base address. */
4087 relocation
= (relocation
+ 2) & ~ 3;
4089 /* Put RELOCATION back into the insn. Assumes two's complement.
4090 We use the Thumb-2 encoding, which is safe even if dealing with
4091 a Thumb-1 instruction by virtue of our overflow check above. */
4092 reloc_sign
= (signed_check
< 0) ? 1 : 0;
4093 upper_insn
= (upper_insn
& ~(bfd_vma
) 0x7ff)
4094 | ((relocation
>> 12) & 0x3ff)
4095 | (reloc_sign
<< 10);
4096 lower_insn
= (lower_insn
& ~(bfd_vma
) 0x2fff)
4097 | (((!((relocation
>> 23) & 1)) ^ reloc_sign
) << 13)
4098 | (((!((relocation
>> 22) & 1)) ^ reloc_sign
) << 11)
4099 | ((relocation
>> 1) & 0x7ff);
4101 /* Put the relocated value back in the object file: */
4102 bfd_put_16 (input_bfd
, upper_insn
, hit_data
);
4103 bfd_put_16 (input_bfd
, lower_insn
, hit_data
+ 2);
4105 return (overflow
? bfd_reloc_overflow
: bfd_reloc_ok
);
4109 case R_ARM_THM_JUMP24
:
4110 /* Thumb32 unconditional branch instruction. */
4113 bfd_boolean overflow
= FALSE
;
4114 bfd_vma upper_insn
= bfd_get_16 (input_bfd
, hit_data
);
4115 bfd_vma lower_insn
= bfd_get_16 (input_bfd
, hit_data
+ 2);
4116 bfd_signed_vma reloc_signed_max
= ((1 << (howto
->bitsize
- 1)) - 1) >> howto
->rightshift
;
4117 bfd_signed_vma reloc_signed_min
= ~ reloc_signed_max
;
4119 bfd_signed_vma signed_check
;
4121 /* Need to refetch the addend, reconstruct the top three bits, and glue the
4122 two pieces together. */
4123 if (globals
->use_rel
)
4125 bfd_vma S
= (upper_insn
& 0x0400) >> 10;
4126 bfd_vma hi
= (upper_insn
& 0x03ff);
4127 bfd_vma I1
= (lower_insn
& 0x2000) >> 13;
4128 bfd_vma I2
= (lower_insn
& 0x0800) >> 11;
4129 bfd_vma lo
= (lower_insn
& 0x07ff);
4135 signed_addend
= (S
<< 24) | (I1
<< 23) | (I2
<< 22) | (hi
<< 12) | (lo
<< 1);
4136 signed_addend
-= (1 << 24); /* Sign extend. */
4139 /* ??? Should handle interworking? GCC might someday try to
4140 use this for tail calls. */
4142 relocation
= value
+ signed_addend
;
4143 relocation
-= (input_section
->output_section
->vma
4144 + input_section
->output_offset
4147 check
= relocation
>> howto
->rightshift
;
4149 /* If this is a signed value, the rightshift just dropped
4150 leading 1 bits (assuming twos complement). */
4151 if ((bfd_signed_vma
) relocation
>= 0)
4152 signed_check
= check
;
4154 signed_check
= check
| ~((bfd_vma
) -1 >> howto
->rightshift
);
4156 /* Assumes two's complement. */
4157 if (signed_check
> reloc_signed_max
|| signed_check
< reloc_signed_min
)
4160 /* Put RELOCATION back into the insn. */
4162 bfd_vma S
= (relocation
& 0x01000000) >> 24;
4163 bfd_vma I1
= (relocation
& 0x00800000) >> 23;
4164 bfd_vma I2
= (relocation
& 0x00400000) >> 22;
4165 bfd_vma hi
= (relocation
& 0x003ff000) >> 12;
4166 bfd_vma lo
= (relocation
& 0x00000ffe) >> 1;
4171 upper_insn
= (upper_insn
& (bfd_vma
) 0xf800) | (S
<< 10) | hi
;
4172 lower_insn
= (lower_insn
& (bfd_vma
) 0xd000) | (I1
<< 13) | (I2
<< 11) | lo
;
4175 /* Put the relocated value back in the object file: */
4176 bfd_put_16 (input_bfd
, upper_insn
, hit_data
);
4177 bfd_put_16 (input_bfd
, lower_insn
, hit_data
+ 2);
4179 return (overflow
? bfd_reloc_overflow
: bfd_reloc_ok
);
4182 case R_ARM_THM_JUMP19
:
4183 /* Thumb32 conditional branch instruction. */
4186 bfd_boolean overflow
= FALSE
;
4187 bfd_vma upper_insn
= bfd_get_16 (input_bfd
, hit_data
);
4188 bfd_vma lower_insn
= bfd_get_16 (input_bfd
, hit_data
+ 2);
4189 bfd_signed_vma reloc_signed_max
= ((1 << (howto
->bitsize
- 1)) - 1) >> howto
->rightshift
;
4190 bfd_signed_vma reloc_signed_min
= ~ reloc_signed_max
;
4192 bfd_signed_vma signed_check
;
4194 /* Need to refetch the addend, reconstruct the top three bits,
4195 and squish the two 11 bit pieces together. */
4196 if (globals
->use_rel
)
4198 bfd_vma S
= (upper_insn
& 0x0400) >> 10;
4199 bfd_vma upper
= (upper_insn
& 0x001f);
4200 bfd_vma J1
= (lower_insn
& 0x2000) >> 13;
4201 bfd_vma J2
= (lower_insn
& 0x0800) >> 11;
4202 bfd_vma lower
= (lower_insn
& 0x07ff);
4207 upper
-= 0x0100; /* Sign extend. */
4209 addend
= (upper
<< 12) | (lower
<< 1);
4210 signed_addend
= addend
;
4213 /* ??? Should handle interworking? GCC might someday try to
4214 use this for tail calls. */
4216 relocation
= value
+ signed_addend
;
4217 relocation
-= (input_section
->output_section
->vma
4218 + input_section
->output_offset
4221 check
= relocation
>> howto
->rightshift
;
4223 /* If this is a signed value, the rightshift just dropped
4224 leading 1 bits (assuming twos complement). */
4225 if ((bfd_signed_vma
) relocation
>= 0)
4226 signed_check
= check
;
4228 signed_check
= check
| ~((bfd_vma
) -1 >> howto
->rightshift
);
4230 /* Assumes two's complement. */
4231 if (signed_check
> reloc_signed_max
|| signed_check
< reloc_signed_min
)
4234 /* Put RELOCATION back into the insn. */
4236 bfd_vma S
= (relocation
& 0x00100000) >> 20;
4237 bfd_vma J2
= (relocation
& 0x00080000) >> 19;
4238 bfd_vma J1
= (relocation
& 0x00040000) >> 18;
4239 bfd_vma hi
= (relocation
& 0x0003f000) >> 12;
4240 bfd_vma lo
= (relocation
& 0x00000ffe) >> 1;
4242 upper_insn
= (upper_insn
& 0xfb30) | (S
<< 10) | hi
;
4243 lower_insn
= (lower_insn
& 0xd000) | (J1
<< 13) | (J2
<< 11) | lo
;
4246 /* Put the relocated value back in the object file: */
4247 bfd_put_16 (input_bfd
, upper_insn
, hit_data
);
4248 bfd_put_16 (input_bfd
, lower_insn
, hit_data
+ 2);
4250 return (overflow
? bfd_reloc_overflow
: bfd_reloc_ok
);
4253 case R_ARM_THM_JUMP11
:
4254 case R_ARM_THM_JUMP8
:
4255 case R_ARM_THM_JUMP6
:
4256 /* Thumb B (branch) instruction). */
4258 bfd_signed_vma relocation
;
4259 bfd_signed_vma reloc_signed_max
= (1 << (howto
->bitsize
- 1)) - 1;
4260 bfd_signed_vma reloc_signed_min
= ~ reloc_signed_max
;
4261 bfd_signed_vma signed_check
;
4263 /* CZB cannot jump backward. */
4264 if (r_type
== R_ARM_THM_JUMP6
)
4265 reloc_signed_min
= 0;
4267 if (globals
->use_rel
)
4269 /* Need to refetch addend. */
4270 addend
= bfd_get_16 (input_bfd
, hit_data
) & howto
->src_mask
;
4271 if (addend
& ((howto
->src_mask
+ 1) >> 1))
4274 signed_addend
&= ~ howto
->src_mask
;
4275 signed_addend
|= addend
;
4278 signed_addend
= addend
;
4279 /* The value in the insn has been right shifted. We need to
4280 undo this, so that we can perform the address calculation
4281 in terms of bytes. */
4282 signed_addend
<<= howto
->rightshift
;
4284 relocation
= value
+ signed_addend
;
4286 relocation
-= (input_section
->output_section
->vma
4287 + input_section
->output_offset
4290 relocation
>>= howto
->rightshift
;
4291 signed_check
= relocation
;
4293 if (r_type
== R_ARM_THM_JUMP6
)
4294 relocation
= ((relocation
& 0x0020) << 4) | ((relocation
& 0x001f) << 3);
4296 relocation
&= howto
->dst_mask
;
4297 relocation
|= (bfd_get_16 (input_bfd
, hit_data
) & (~ howto
->dst_mask
));
4299 bfd_put_16 (input_bfd
, relocation
, hit_data
);
4301 /* Assumes two's complement. */
4302 if (signed_check
> reloc_signed_max
|| signed_check
< reloc_signed_min
)
4303 return bfd_reloc_overflow
;
4305 return bfd_reloc_ok
;
4308 case R_ARM_ALU_PCREL7_0
:
4309 case R_ARM_ALU_PCREL15_8
:
4310 case R_ARM_ALU_PCREL23_15
:
4315 insn
= bfd_get_32 (input_bfd
, hit_data
);
4316 if (globals
->use_rel
)
4318 /* Extract the addend. */
4319 addend
= (insn
& 0xff) << ((insn
& 0xf00) >> 7);
4320 signed_addend
= addend
;
4322 relocation
= value
+ signed_addend
;
4324 relocation
-= (input_section
->output_section
->vma
4325 + input_section
->output_offset
4327 insn
= (insn
& ~0xfff)
4328 | ((howto
->bitpos
<< 7) & 0xf00)
4329 | ((relocation
>> howto
->bitpos
) & 0xff);
4330 bfd_put_32 (input_bfd
, value
, hit_data
);
4332 return bfd_reloc_ok
;
4334 case R_ARM_GNU_VTINHERIT
:
4335 case R_ARM_GNU_VTENTRY
:
4336 return bfd_reloc_ok
;
4338 case R_ARM_GOTOFF32
:
4339 /* Relocation is relative to the start of the
4340 global offset table. */
4342 BFD_ASSERT (sgot
!= NULL
);
4344 return bfd_reloc_notsupported
;
4346 /* If we are addressing a Thumb function, we need to adjust the
4347 address by one, so that attempts to call the function pointer will
4348 correctly interpret it as Thumb code. */
4349 if (sym_flags
== STT_ARM_TFUNC
)
4352 /* Note that sgot->output_offset is not involved in this
4353 calculation. We always want the start of .got. If we
4354 define _GLOBAL_OFFSET_TABLE in a different way, as is
4355 permitted by the ABI, we might have to change this
4357 value
-= sgot
->output_section
->vma
;
4358 return _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
4359 contents
, rel
->r_offset
, value
,
4363 /* Use global offset table as symbol value. */
4364 BFD_ASSERT (sgot
!= NULL
);
4367 return bfd_reloc_notsupported
;
4369 *unresolved_reloc_p
= FALSE
;
4370 value
= sgot
->output_section
->vma
;
4371 return _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
4372 contents
, rel
->r_offset
, value
,
4376 case R_ARM_GOT_PREL
:
4377 /* Relocation is to the entry for this symbol in the
4378 global offset table. */
4380 return bfd_reloc_notsupported
;
4387 off
= h
->got
.offset
;
4388 BFD_ASSERT (off
!= (bfd_vma
) -1);
4389 dyn
= globals
->root
.dynamic_sections_created
;
4391 if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn
, info
->shared
, h
)
4393 && SYMBOL_REFERENCES_LOCAL (info
, h
))
4394 || (ELF_ST_VISIBILITY (h
->other
)
4395 && h
->root
.type
== bfd_link_hash_undefweak
))
4397 /* This is actually a static link, or it is a -Bsymbolic link
4398 and the symbol is defined locally. We must initialize this
4399 entry in the global offset table. Since the offset must
4400 always be a multiple of 4, we use the least significant bit
4401 to record whether we have initialized it already.
4403 When doing a dynamic link, we create a .rel(a).got relocation
4404 entry to initialize the value. This is done in the
4405 finish_dynamic_symbol routine. */
4410 /* If we are addressing a Thumb function, we need to
4411 adjust the address by one, so that attempts to
4412 call the function pointer will correctly
4413 interpret it as Thumb code. */
4414 if (sym_flags
== STT_ARM_TFUNC
)
4417 bfd_put_32 (output_bfd
, value
, sgot
->contents
+ off
);
4422 *unresolved_reloc_p
= FALSE
;
4424 value
= sgot
->output_offset
+ off
;
4430 BFD_ASSERT (local_got_offsets
!= NULL
&&
4431 local_got_offsets
[r_symndx
] != (bfd_vma
) -1);
4433 off
= local_got_offsets
[r_symndx
];
4435 /* The offset must always be a multiple of 4. We use the
4436 least significant bit to record whether we have already
4437 generated the necessary reloc. */
4442 /* If we are addressing a Thumb function, we need to
4443 adjust the address by one, so that attempts to
4444 call the function pointer will correctly
4445 interpret it as Thumb code. */
4446 if (sym_flags
== STT_ARM_TFUNC
)
4449 if (globals
->use_rel
)
4450 bfd_put_32 (output_bfd
, value
, sgot
->contents
+ off
);
4455 Elf_Internal_Rela outrel
;
4458 srelgot
= (bfd_get_section_by_name
4459 (dynobj
, RELOC_SECTION (globals
, ".got")));
4460 BFD_ASSERT (srelgot
!= NULL
);
4462 outrel
.r_addend
= addend
+ value
;
4463 outrel
.r_offset
= (sgot
->output_section
->vma
4464 + sgot
->output_offset
4466 outrel
.r_info
= ELF32_R_INFO (0, R_ARM_RELATIVE
);
4467 loc
= srelgot
->contents
;
4468 loc
+= srelgot
->reloc_count
++ * RELOC_SIZE (globals
);
4469 SWAP_RELOC_OUT (globals
) (output_bfd
, &outrel
, loc
);
4472 local_got_offsets
[r_symndx
] |= 1;
4475 value
= sgot
->output_offset
+ off
;
4477 if (r_type
!= R_ARM_GOT32
)
4478 value
+= sgot
->output_section
->vma
;
4480 return _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
4481 contents
, rel
->r_offset
, value
,
4484 case R_ARM_TLS_LDO32
:
4485 value
= value
- dtpoff_base (info
);
4487 return _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
4488 contents
, rel
->r_offset
, value
,
4491 case R_ARM_TLS_LDM32
:
4495 if (globals
->sgot
== NULL
)
4498 off
= globals
->tls_ldm_got
.offset
;
4504 /* If we don't know the module number, create a relocation
4508 Elf_Internal_Rela outrel
;
4511 if (globals
->srelgot
== NULL
)
4514 outrel
.r_addend
= 0;
4515 outrel
.r_offset
= (globals
->sgot
->output_section
->vma
4516 + globals
->sgot
->output_offset
+ off
);
4517 outrel
.r_info
= ELF32_R_INFO (0, R_ARM_TLS_DTPMOD32
);
4519 if (globals
->use_rel
)
4520 bfd_put_32 (output_bfd
, outrel
.r_addend
,
4521 globals
->sgot
->contents
+ off
);
4523 loc
= globals
->srelgot
->contents
;
4524 loc
+= globals
->srelgot
->reloc_count
++ * RELOC_SIZE (globals
);
4525 SWAP_RELOC_OUT (globals
) (output_bfd
, &outrel
, loc
);
4528 bfd_put_32 (output_bfd
, 1, globals
->sgot
->contents
+ off
);
4530 globals
->tls_ldm_got
.offset
|= 1;
4533 value
= globals
->sgot
->output_section
->vma
+ globals
->sgot
->output_offset
+ off
4534 - (input_section
->output_section
->vma
+ input_section
->output_offset
+ rel
->r_offset
);
4536 return _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
4537 contents
, rel
->r_offset
, value
,
4541 case R_ARM_TLS_GD32
:
4542 case R_ARM_TLS_IE32
:
4548 if (globals
->sgot
== NULL
)
4555 dyn
= globals
->root
.dynamic_sections_created
;
4556 if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn
, info
->shared
, h
)
4558 || !SYMBOL_REFERENCES_LOCAL (info
, h
)))
4560 *unresolved_reloc_p
= FALSE
;
4563 off
= h
->got
.offset
;
4564 tls_type
= ((struct elf32_arm_link_hash_entry
*) h
)->tls_type
;
4568 if (local_got_offsets
== NULL
)
4570 off
= local_got_offsets
[r_symndx
];
4571 tls_type
= elf32_arm_local_got_tls_type (input_bfd
)[r_symndx
];
4574 if (tls_type
== GOT_UNKNOWN
)
4581 bfd_boolean need_relocs
= FALSE
;
4582 Elf_Internal_Rela outrel
;
4583 bfd_byte
*loc
= NULL
;
4586 /* The GOT entries have not been initialized yet. Do it
4587 now, and emit any relocations. If both an IE GOT and a
4588 GD GOT are necessary, we emit the GD first. */
4590 if ((info
->shared
|| indx
!= 0)
4592 || ELF_ST_VISIBILITY (h
->other
) == STV_DEFAULT
4593 || h
->root
.type
!= bfd_link_hash_undefweak
))
4596 if (globals
->srelgot
== NULL
)
4598 loc
= globals
->srelgot
->contents
;
4599 loc
+= globals
->srelgot
->reloc_count
* RELOC_SIZE (globals
);
4602 if (tls_type
& GOT_TLS_GD
)
4606 outrel
.r_addend
= 0;
4607 outrel
.r_offset
= (globals
->sgot
->output_section
->vma
4608 + globals
->sgot
->output_offset
4610 outrel
.r_info
= ELF32_R_INFO (indx
, R_ARM_TLS_DTPMOD32
);
4612 if (globals
->use_rel
)
4613 bfd_put_32 (output_bfd
, outrel
.r_addend
,
4614 globals
->sgot
->contents
+ cur_off
);
4616 SWAP_RELOC_OUT (globals
) (output_bfd
, &outrel
, loc
);
4617 globals
->srelgot
->reloc_count
++;
4618 loc
+= RELOC_SIZE (globals
);
4621 bfd_put_32 (output_bfd
, value
- dtpoff_base (info
),
4622 globals
->sgot
->contents
+ cur_off
+ 4);
4625 outrel
.r_addend
= 0;
4626 outrel
.r_info
= ELF32_R_INFO (indx
,
4627 R_ARM_TLS_DTPOFF32
);
4628 outrel
.r_offset
+= 4;
4630 if (globals
->use_rel
)
4631 bfd_put_32 (output_bfd
, outrel
.r_addend
,
4632 globals
->sgot
->contents
+ cur_off
+ 4);
4635 SWAP_RELOC_OUT (globals
) (output_bfd
, &outrel
, loc
);
4636 globals
->srelgot
->reloc_count
++;
4637 loc
+= RELOC_SIZE (globals
);
4642 /* If we are not emitting relocations for a
4643 general dynamic reference, then we must be in a
4644 static link or an executable link with the
4645 symbol binding locally. Mark it as belonging
4646 to module 1, the executable. */
4647 bfd_put_32 (output_bfd
, 1,
4648 globals
->sgot
->contents
+ cur_off
);
4649 bfd_put_32 (output_bfd
, value
- dtpoff_base (info
),
4650 globals
->sgot
->contents
+ cur_off
+ 4);
4656 if (tls_type
& GOT_TLS_IE
)
4661 outrel
.r_addend
= value
- dtpoff_base (info
);
4663 outrel
.r_addend
= 0;
4664 outrel
.r_offset
= (globals
->sgot
->output_section
->vma
4665 + globals
->sgot
->output_offset
4667 outrel
.r_info
= ELF32_R_INFO (indx
, R_ARM_TLS_TPOFF32
);
4669 if (globals
->use_rel
)
4670 bfd_put_32 (output_bfd
, outrel
.r_addend
,
4671 globals
->sgot
->contents
+ cur_off
);
4673 SWAP_RELOC_OUT (globals
) (output_bfd
, &outrel
, loc
);
4674 globals
->srelgot
->reloc_count
++;
4675 loc
+= RELOC_SIZE (globals
);
4678 bfd_put_32 (output_bfd
, tpoff (info
, value
),
4679 globals
->sgot
->contents
+ cur_off
);
4686 local_got_offsets
[r_symndx
] |= 1;
4689 if ((tls_type
& GOT_TLS_GD
) && r_type
!= R_ARM_TLS_GD32
)
4691 value
= globals
->sgot
->output_section
->vma
+ globals
->sgot
->output_offset
+ off
4692 - (input_section
->output_section
->vma
+ input_section
->output_offset
+ rel
->r_offset
);
4694 return _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
4695 contents
, rel
->r_offset
, value
,
4699 case R_ARM_TLS_LE32
:
4702 (*_bfd_error_handler
)
4703 (_("%B(%A+0x%lx): R_ARM_TLS_LE32 relocation not permitted in shared object"),
4704 input_bfd
, input_section
,
4705 (long) rel
->r_offset
, howto
->name
);
4709 value
= tpoff (info
, value
);
4711 return _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
4712 contents
, rel
->r_offset
, value
,
4716 if (globals
->fix_v4bx
)
4718 bfd_vma insn
= bfd_get_32 (input_bfd
, hit_data
);
4720 /* Ensure that we have a BX instruction. */
4721 BFD_ASSERT ((insn
& 0x0ffffff0) == 0x012fff10);
4723 /* Preserve Rm (lowest four bits) and the condition code
4724 (highest four bits). Other bits encode MOV PC,Rm. */
4725 insn
= (insn
& 0xf000000f) | 0x01a0f000;
4727 bfd_put_32 (input_bfd
, insn
, hit_data
);
4729 return bfd_reloc_ok
;
4731 case R_ARM_MOVW_ABS_NC
:
4732 case R_ARM_MOVT_ABS
:
4733 case R_ARM_MOVW_PREL_NC
:
4734 case R_ARM_MOVT_PREL
:
4735 /* Until we properly support segment-base-relative addressing then
4736 we assume the segment base to be zero, as for the group relocations.
4737 Thus R_ARM_MOVW_BREL_NC has the same semantics as R_ARM_MOVW_ABS_NC
4738 and R_ARM_MOVT_BREL has the same semantics as R_ARM_MOVT_ABS. */
4739 case R_ARM_MOVW_BREL_NC
:
4740 case R_ARM_MOVW_BREL
:
4741 case R_ARM_MOVT_BREL
:
4743 bfd_vma insn
= bfd_get_32 (input_bfd
, hit_data
);
4745 if (globals
->use_rel
)
4747 addend
= ((insn
>> 4) & 0xf000) | (insn
& 0xfff);
4748 signed_addend
= (addend
^ 0x10000) - 0x10000;
4751 value
+= signed_addend
;
4753 if (r_type
== R_ARM_MOVW_PREL_NC
|| r_type
== R_ARM_MOVT_PREL
)
4754 value
-= (input_section
->output_section
->vma
4755 + input_section
->output_offset
+ rel
->r_offset
);
4757 if (r_type
== R_ARM_MOVW_BREL
&& value
>= 0x10000)
4758 return bfd_reloc_overflow
;
4760 if (sym_flags
== STT_ARM_TFUNC
)
4763 if (r_type
== R_ARM_MOVT_ABS
|| r_type
== R_ARM_MOVT_PREL
4764 || r_type
== R_ARM_MOVT_BREL
)
4768 insn
|= value
& 0xfff;
4769 insn
|= (value
& 0xf000) << 4;
4770 bfd_put_32 (input_bfd
, insn
, hit_data
);
4772 return bfd_reloc_ok
;
4774 case R_ARM_THM_MOVW_ABS_NC
:
4775 case R_ARM_THM_MOVT_ABS
:
4776 case R_ARM_THM_MOVW_PREL_NC
:
4777 case R_ARM_THM_MOVT_PREL
:
4778 /* Until we properly support segment-base-relative addressing then
4779 we assume the segment base to be zero, as for the above relocations.
4780 Thus R_ARM_THM_MOVW_BREL_NC has the same semantics as
4781 R_ARM_THM_MOVW_ABS_NC and R_ARM_THM_MOVT_BREL has the same semantics
4782 as R_ARM_THM_MOVT_ABS. */
4783 case R_ARM_THM_MOVW_BREL_NC
:
4784 case R_ARM_THM_MOVW_BREL
:
4785 case R_ARM_THM_MOVT_BREL
:
4789 insn
= bfd_get_16 (input_bfd
, hit_data
) << 16;
4790 insn
|= bfd_get_16 (input_bfd
, hit_data
+ 2);
4792 if (globals
->use_rel
)
4794 addend
= ((insn
>> 4) & 0xf000)
4795 | ((insn
>> 15) & 0x0800)
4796 | ((insn
>> 4) & 0x0700)
4798 signed_addend
= (addend
^ 0x10000) - 0x10000;
4801 value
+= signed_addend
;
4803 if (r_type
== R_ARM_THM_MOVW_PREL_NC
|| r_type
== R_ARM_THM_MOVT_PREL
)
4804 value
-= (input_section
->output_section
->vma
4805 + input_section
->output_offset
+ rel
->r_offset
);
4807 if (r_type
== R_ARM_THM_MOVW_BREL
&& value
>= 0x10000)
4808 return bfd_reloc_overflow
;
4810 if (sym_flags
== STT_ARM_TFUNC
)
4813 if (r_type
== R_ARM_THM_MOVT_ABS
|| r_type
== R_ARM_THM_MOVT_PREL
4814 || r_type
== R_ARM_THM_MOVT_BREL
)
4818 insn
|= (value
& 0xf000) << 4;
4819 insn
|= (value
& 0x0800) << 15;
4820 insn
|= (value
& 0x0700) << 4;
4821 insn
|= (value
& 0x00ff);
4823 bfd_put_16 (input_bfd
, insn
>> 16, hit_data
);
4824 bfd_put_16 (input_bfd
, insn
& 0xffff, hit_data
+ 2);
4826 return bfd_reloc_ok
;
4828 case R_ARM_ALU_PC_G0_NC
:
4829 case R_ARM_ALU_PC_G1_NC
:
4830 case R_ARM_ALU_PC_G0
:
4831 case R_ARM_ALU_PC_G1
:
4832 case R_ARM_ALU_PC_G2
:
4833 case R_ARM_ALU_SB_G0_NC
:
4834 case R_ARM_ALU_SB_G1_NC
:
4835 case R_ARM_ALU_SB_G0
:
4836 case R_ARM_ALU_SB_G1
:
4837 case R_ARM_ALU_SB_G2
:
4839 bfd_vma insn
= bfd_get_32 (input_bfd
, hit_data
);
4840 bfd_vma pc
= input_section
->output_section
->vma
4841 + input_section
->output_offset
+ rel
->r_offset
;
4842 /* sb should be the origin of the *segment* containing the symbol.
4843 It is not clear how to obtain this OS-dependent value, so we
4844 make an arbitrary choice of zero. */
4848 bfd_signed_vma signed_value
;
4851 /* Determine which group of bits to select. */
4854 case R_ARM_ALU_PC_G0_NC
:
4855 case R_ARM_ALU_PC_G0
:
4856 case R_ARM_ALU_SB_G0_NC
:
4857 case R_ARM_ALU_SB_G0
:
4861 case R_ARM_ALU_PC_G1_NC
:
4862 case R_ARM_ALU_PC_G1
:
4863 case R_ARM_ALU_SB_G1_NC
:
4864 case R_ARM_ALU_SB_G1
:
4868 case R_ARM_ALU_PC_G2
:
4869 case R_ARM_ALU_SB_G2
:
4877 /* If REL, extract the addend from the insn. If RELA, it will
4878 have already been fetched for us. */
4879 if (globals
->use_rel
)
4882 bfd_vma constant
= insn
& 0xff;
4883 bfd_vma rotation
= (insn
& 0xf00) >> 8;
4886 signed_addend
= constant
;
4889 /* Compensate for the fact that in the instruction, the
4890 rotation is stored in multiples of 2 bits. */
4893 /* Rotate "constant" right by "rotation" bits. */
4894 signed_addend
= (constant
>> rotation
) |
4895 (constant
<< (8 * sizeof (bfd_vma
) - rotation
));
4898 /* Determine if the instruction is an ADD or a SUB.
4899 (For REL, this determines the sign of the addend.) */
4900 negative
= identify_add_or_sub (insn
);
4903 (*_bfd_error_handler
)
4904 (_("%B(%A+0x%lx): Only ADD or SUB instructions are allowed for ALU group relocations"),
4905 input_bfd
, input_section
,
4906 (long) rel
->r_offset
, howto
->name
);
4907 return bfd_reloc_overflow
;
4910 signed_addend
*= negative
;
4913 /* Compute the value (X) to go in the place. */
4914 if (r_type
== R_ARM_ALU_PC_G0_NC
4915 || r_type
== R_ARM_ALU_PC_G1_NC
4916 || r_type
== R_ARM_ALU_PC_G0
4917 || r_type
== R_ARM_ALU_PC_G1
4918 || r_type
== R_ARM_ALU_PC_G2
)
4920 signed_value
= value
- pc
+ signed_addend
;
4922 /* Section base relative. */
4923 signed_value
= value
- sb
+ signed_addend
;
4925 /* If the target symbol is a Thumb function, then set the
4926 Thumb bit in the address. */
4927 if (sym_flags
== STT_ARM_TFUNC
)
4930 /* Calculate the value of the relevant G_n, in encoded
4931 constant-with-rotation format. */
4932 g_n
= calculate_group_reloc_mask (abs (signed_value
), group
,
4935 /* Check for overflow if required. */
4936 if ((r_type
== R_ARM_ALU_PC_G0
4937 || r_type
== R_ARM_ALU_PC_G1
4938 || r_type
== R_ARM_ALU_PC_G2
4939 || r_type
== R_ARM_ALU_SB_G0
4940 || r_type
== R_ARM_ALU_SB_G1
4941 || r_type
== R_ARM_ALU_SB_G2
) && residual
!= 0)
4943 (*_bfd_error_handler
)
4944 (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"),
4945 input_bfd
, input_section
,
4946 (long) rel
->r_offset
, abs (signed_value
), howto
->name
);
4947 return bfd_reloc_overflow
;
4950 /* Mask out the value and the ADD/SUB part of the opcode; take care
4951 not to destroy the S bit. */
4954 /* Set the opcode according to whether the value to go in the
4955 place is negative. */
4956 if (signed_value
< 0)
4961 /* Encode the offset. */
4964 bfd_put_32 (input_bfd
, insn
, hit_data
);
4966 return bfd_reloc_ok
;
4968 case R_ARM_LDR_PC_G0
:
4969 case R_ARM_LDR_PC_G1
:
4970 case R_ARM_LDR_PC_G2
:
4971 case R_ARM_LDR_SB_G0
:
4972 case R_ARM_LDR_SB_G1
:
4973 case R_ARM_LDR_SB_G2
:
4975 bfd_vma insn
= bfd_get_32 (input_bfd
, hit_data
);
4976 bfd_vma pc
= input_section
->output_section
->vma
4977 + input_section
->output_offset
+ rel
->r_offset
;
4978 bfd_vma sb
= 0; /* See note above. */
4980 bfd_signed_vma signed_value
;
4983 /* Determine which groups of bits to calculate. */
4986 case R_ARM_LDR_PC_G0
:
4987 case R_ARM_LDR_SB_G0
:
4991 case R_ARM_LDR_PC_G1
:
4992 case R_ARM_LDR_SB_G1
:
4996 case R_ARM_LDR_PC_G2
:
4997 case R_ARM_LDR_SB_G2
:
5005 /* If REL, extract the addend from the insn. If RELA, it will
5006 have already been fetched for us. */
5007 if (globals
->use_rel
)
5009 int negative
= (insn
& (1 << 23)) ? 1 : -1;
5010 signed_addend
= negative
* (insn
& 0xfff);
5013 /* Compute the value (X) to go in the place. */
5014 if (r_type
== R_ARM_LDR_PC_G0
5015 || r_type
== R_ARM_LDR_PC_G1
5016 || r_type
== R_ARM_LDR_PC_G2
)
5018 signed_value
= value
- pc
+ signed_addend
;
5020 /* Section base relative. */
5021 signed_value
= value
- sb
+ signed_addend
;
5023 /* Calculate the value of the relevant G_{n-1} to obtain
5024 the residual at that stage. */
5025 calculate_group_reloc_mask (abs (signed_value
), group
- 1, &residual
);
5027 /* Check for overflow. */
5028 if (residual
>= 0x1000)
5030 (*_bfd_error_handler
)
5031 (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"),
5032 input_bfd
, input_section
,
5033 (long) rel
->r_offset
, abs (signed_value
), howto
->name
);
5034 return bfd_reloc_overflow
;
5037 /* Mask out the value and U bit. */
5040 /* Set the U bit if the value to go in the place is non-negative. */
5041 if (signed_value
>= 0)
5044 /* Encode the offset. */
5047 bfd_put_32 (input_bfd
, insn
, hit_data
);
5049 return bfd_reloc_ok
;
5051 case R_ARM_LDRS_PC_G0
:
5052 case R_ARM_LDRS_PC_G1
:
5053 case R_ARM_LDRS_PC_G2
:
5054 case R_ARM_LDRS_SB_G0
:
5055 case R_ARM_LDRS_SB_G1
:
5056 case R_ARM_LDRS_SB_G2
:
5058 bfd_vma insn
= bfd_get_32 (input_bfd
, hit_data
);
5059 bfd_vma pc
= input_section
->output_section
->vma
5060 + input_section
->output_offset
+ rel
->r_offset
;
5061 bfd_vma sb
= 0; /* See note above. */
5063 bfd_signed_vma signed_value
;
5066 /* Determine which groups of bits to calculate. */
5069 case R_ARM_LDRS_PC_G0
:
5070 case R_ARM_LDRS_SB_G0
:
5074 case R_ARM_LDRS_PC_G1
:
5075 case R_ARM_LDRS_SB_G1
:
5079 case R_ARM_LDRS_PC_G2
:
5080 case R_ARM_LDRS_SB_G2
:
5088 /* If REL, extract the addend from the insn. If RELA, it will
5089 have already been fetched for us. */
5090 if (globals
->use_rel
)
5092 int negative
= (insn
& (1 << 23)) ? 1 : -1;
5093 signed_addend
= negative
* (((insn
& 0xf00) >> 4) + (insn
& 0xf));
5096 /* Compute the value (X) to go in the place. */
5097 if (r_type
== R_ARM_LDRS_PC_G0
5098 || r_type
== R_ARM_LDRS_PC_G1
5099 || r_type
== R_ARM_LDRS_PC_G2
)
5101 signed_value
= value
- pc
+ signed_addend
;
5103 /* Section base relative. */
5104 signed_value
= value
- sb
+ signed_addend
;
5106 /* Calculate the value of the relevant G_{n-1} to obtain
5107 the residual at that stage. */
5108 calculate_group_reloc_mask (abs (signed_value
), group
- 1, &residual
);
5110 /* Check for overflow. */
5111 if (residual
>= 0x100)
5113 (*_bfd_error_handler
)
5114 (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"),
5115 input_bfd
, input_section
,
5116 (long) rel
->r_offset
, abs (signed_value
), howto
->name
);
5117 return bfd_reloc_overflow
;
5120 /* Mask out the value and U bit. */
5123 /* Set the U bit if the value to go in the place is non-negative. */
5124 if (signed_value
>= 0)
5127 /* Encode the offset. */
5128 insn
|= ((residual
& 0xf0) << 4) | (residual
& 0xf);
5130 bfd_put_32 (input_bfd
, insn
, hit_data
);
5132 return bfd_reloc_ok
;
5134 case R_ARM_LDC_PC_G0
:
5135 case R_ARM_LDC_PC_G1
:
5136 case R_ARM_LDC_PC_G2
:
5137 case R_ARM_LDC_SB_G0
:
5138 case R_ARM_LDC_SB_G1
:
5139 case R_ARM_LDC_SB_G2
:
5141 bfd_vma insn
= bfd_get_32 (input_bfd
, hit_data
);
5142 bfd_vma pc
= input_section
->output_section
->vma
5143 + input_section
->output_offset
+ rel
->r_offset
;
5144 bfd_vma sb
= 0; /* See note above. */
5146 bfd_signed_vma signed_value
;
5149 /* Determine which groups of bits to calculate. */
5152 case R_ARM_LDC_PC_G0
:
5153 case R_ARM_LDC_SB_G0
:
5157 case R_ARM_LDC_PC_G1
:
5158 case R_ARM_LDC_SB_G1
:
5162 case R_ARM_LDC_PC_G2
:
5163 case R_ARM_LDC_SB_G2
:
5171 /* If REL, extract the addend from the insn. If RELA, it will
5172 have already been fetched for us. */
5173 if (globals
->use_rel
)
5175 int negative
= (insn
& (1 << 23)) ? 1 : -1;
5176 signed_addend
= negative
* ((insn
& 0xff) << 2);
5179 /* Compute the value (X) to go in the place. */
5180 if (r_type
== R_ARM_LDC_PC_G0
5181 || r_type
== R_ARM_LDC_PC_G1
5182 || r_type
== R_ARM_LDC_PC_G2
)
5184 signed_value
= value
- pc
+ signed_addend
;
5186 /* Section base relative. */
5187 signed_value
= value
- sb
+ signed_addend
;
5189 /* Calculate the value of the relevant G_{n-1} to obtain
5190 the residual at that stage. */
5191 calculate_group_reloc_mask (abs (signed_value
), group
- 1, &residual
);
5193 /* Check for overflow. (The absolute value to go in the place must be
5194 divisible by four and, after having been divided by four, must
5195 fit in eight bits.) */
5196 if ((residual
& 0x3) != 0 || residual
>= 0x400)
5198 (*_bfd_error_handler
)
5199 (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"),
5200 input_bfd
, input_section
,
5201 (long) rel
->r_offset
, abs (signed_value
), howto
->name
);
5202 return bfd_reloc_overflow
;
5205 /* Mask out the value and U bit. */
5208 /* Set the U bit if the value to go in the place is non-negative. */
5209 if (signed_value
>= 0)
5212 /* Encode the offset. */
5213 insn
|= residual
>> 2;
5215 bfd_put_32 (input_bfd
, insn
, hit_data
);
5217 return bfd_reloc_ok
;
5220 return bfd_reloc_notsupported
;
5226 uleb128_size (unsigned int i
)
5238 /* Return TRUE if the attribute has the default value (0/""). */
5240 is_default_attr (aeabi_attribute
*attr
)
5242 if ((attr
->type
& 1) && attr
->i
!= 0)
5244 if ((attr
->type
& 2) && attr
->s
&& *attr
->s
)
5250 /* Return the size of a single attribute. */
5252 eabi_attr_size(int tag
, aeabi_attribute
*attr
)
5256 if (is_default_attr (attr
))
5259 size
= uleb128_size (tag
);
5261 size
+= uleb128_size (attr
->i
);
5263 size
+= strlen ((char *)attr
->s
) + 1;
5267 /* Returns the size of the eabi object attributess section. */
5269 elf32_arm_eabi_attr_size (bfd
*abfd
)
5272 aeabi_attribute
*attr
;
5273 aeabi_attribute_list
*list
;
5276 attr
= elf32_arm_tdata (abfd
)->known_eabi_attributes
;
5277 size
= 16; /* 'A' <size> "aeabi" 0x1 <size>. */
5278 for (i
= 4; i
< NUM_KNOWN_ATTRIBUTES
; i
++)
5279 size
+= eabi_attr_size (i
, &attr
[i
]);
5281 for (list
= elf32_arm_tdata (abfd
)->other_eabi_attributes
;
5284 size
+= eabi_attr_size (list
->tag
, &list
->attr
);
5290 write_uleb128 (bfd_byte
*p
, unsigned int val
)
5305 /* Write attribute ATTR to butter P, and return a pointer to the following
5308 write_eabi_attribute (bfd_byte
*p
, int tag
, aeabi_attribute
*attr
)
5310 /* Suppress default entries. */
5311 if (is_default_attr(attr
))
5314 p
= write_uleb128 (p
, tag
);
5316 p
= write_uleb128 (p
, attr
->i
);
5321 len
= strlen (attr
->s
) + 1;
5322 memcpy (p
, attr
->s
, len
);
5329 /* Write the contents of the eabi attributes section to p. */
5331 elf32_arm_set_eabi_attr_contents (bfd
*abfd
, bfd_byte
*contents
, bfd_vma size
)
5334 aeabi_attribute
*attr
;
5335 aeabi_attribute_list
*list
;
5340 bfd_put_32 (abfd
, size
- 1, p
);
5342 memcpy (p
, "aeabi", 6);
5345 bfd_put_32 (abfd
, size
- 11, p
);
5348 attr
= elf32_arm_tdata (abfd
)->known_eabi_attributes
;
5349 for (i
= 4; i
< NUM_KNOWN_ATTRIBUTES
; i
++)
5350 p
= write_eabi_attribute (p
, i
, &attr
[i
]);
5352 for (list
= elf32_arm_tdata (abfd
)->other_eabi_attributes
;
5355 p
= write_eabi_attribute (p
, list
->tag
, &list
->attr
);
5358 /* Override final_link to handle EABI object attribute sections. */
5361 elf32_arm_bfd_final_link (bfd
*abfd
, struct bfd_link_info
*info
)
5364 struct bfd_link_order
*p
;
5365 asection
*attr_section
= NULL
;
5369 /* elf32_arm_merge_private_bfd_data will already have merged the
5370 object attributes. Remove the input sections from the link, and set
5371 the contents of the output secton. */
5372 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
5374 if (strcmp (o
->name
, ".ARM.attributes") == 0)
5376 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
5378 asection
*input_section
;
5380 if (p
->type
!= bfd_indirect_link_order
)
5382 input_section
= p
->u
.indirect
.section
;
5383 /* Hack: reset the SEC_HAS_CONTENTS flag so that
5384 elf_link_input_bfd ignores this section. */
5385 input_section
->flags
&= ~SEC_HAS_CONTENTS
;
5388 size
= elf32_arm_eabi_attr_size (abfd
);
5389 bfd_set_section_size (abfd
, o
, size
);
5391 /* Skip this section later on. */
5392 o
->map_head
.link_order
= NULL
;
5395 /* Invoke the ELF linker to do all the work. */
5396 if (!bfd_elf_final_link (abfd
, info
))
5401 contents
= bfd_malloc(size
);
5402 if (contents
== NULL
)
5404 elf32_arm_set_eabi_attr_contents (abfd
, contents
, size
);
5405 bfd_set_section_contents (abfd
, attr_section
, contents
, 0, size
);
5412 /* Add INCREMENT to the reloc (of type HOWTO) at ADDRESS. */
5414 arm_add_to_rel (bfd
* abfd
,
5416 reloc_howto_type
* howto
,
5417 bfd_signed_vma increment
)
5419 bfd_signed_vma addend
;
5421 if (howto
->type
== R_ARM_THM_CALL
)
5423 int upper_insn
, lower_insn
;
5426 upper_insn
= bfd_get_16 (abfd
, address
);
5427 lower_insn
= bfd_get_16 (abfd
, address
+ 2);
5428 upper
= upper_insn
& 0x7ff;
5429 lower
= lower_insn
& 0x7ff;
5431 addend
= (upper
<< 12) | (lower
<< 1);
5432 addend
+= increment
;
5435 upper_insn
= (upper_insn
& 0xf800) | ((addend
>> 11) & 0x7ff);
5436 lower_insn
= (lower_insn
& 0xf800) | (addend
& 0x7ff);
5438 bfd_put_16 (abfd
, (bfd_vma
) upper_insn
, address
);
5439 bfd_put_16 (abfd
, (bfd_vma
) lower_insn
, address
+ 2);
5445 contents
= bfd_get_32 (abfd
, address
);
5447 /* Get the (signed) value from the instruction. */
5448 addend
= contents
& howto
->src_mask
;
5449 if (addend
& ((howto
->src_mask
+ 1) >> 1))
5451 bfd_signed_vma mask
;
5454 mask
&= ~ howto
->src_mask
;
5458 /* Add in the increment, (which is a byte value). */
5459 switch (howto
->type
)
5462 addend
+= increment
;
5469 addend
<<= howto
->size
;
5470 addend
+= increment
;
5472 /* Should we check for overflow here ? */
5474 /* Drop any undesired bits. */
5475 addend
>>= howto
->rightshift
;
5479 contents
= (contents
& ~ howto
->dst_mask
) | (addend
& howto
->dst_mask
);
5481 bfd_put_32 (abfd
, contents
, address
);
5485 #define IS_ARM_TLS_RELOC(R_TYPE) \
5486 ((R_TYPE) == R_ARM_TLS_GD32 \
5487 || (R_TYPE) == R_ARM_TLS_LDO32 \
5488 || (R_TYPE) == R_ARM_TLS_LDM32 \
5489 || (R_TYPE) == R_ARM_TLS_DTPOFF32 \
5490 || (R_TYPE) == R_ARM_TLS_DTPMOD32 \
5491 || (R_TYPE) == R_ARM_TLS_TPOFF32 \
5492 || (R_TYPE) == R_ARM_TLS_LE32 \
5493 || (R_TYPE) == R_ARM_TLS_IE32)
5495 /* Relocate an ARM ELF section. */
5497 elf32_arm_relocate_section (bfd
* output_bfd
,
5498 struct bfd_link_info
* info
,
5500 asection
* input_section
,
5501 bfd_byte
* contents
,
5502 Elf_Internal_Rela
* relocs
,
5503 Elf_Internal_Sym
* local_syms
,
5504 asection
** local_sections
)
5506 Elf_Internal_Shdr
*symtab_hdr
;
5507 struct elf_link_hash_entry
**sym_hashes
;
5508 Elf_Internal_Rela
*rel
;
5509 Elf_Internal_Rela
*relend
;
5511 struct elf32_arm_link_hash_table
* globals
;
5513 globals
= elf32_arm_hash_table (info
);
5514 if (info
->relocatable
&& !globals
->use_rel
)
5517 symtab_hdr
= & elf_tdata (input_bfd
)->symtab_hdr
;
5518 sym_hashes
= elf_sym_hashes (input_bfd
);
5521 relend
= relocs
+ input_section
->reloc_count
;
5522 for (; rel
< relend
; rel
++)
5525 reloc_howto_type
* howto
;
5526 unsigned long r_symndx
;
5527 Elf_Internal_Sym
* sym
;
5529 struct elf_link_hash_entry
* h
;
5531 bfd_reloc_status_type r
;
5534 bfd_boolean unresolved_reloc
= FALSE
;
5536 r_symndx
= ELF32_R_SYM (rel
->r_info
);
5537 r_type
= ELF32_R_TYPE (rel
->r_info
);
5538 r_type
= arm_real_reloc_type (globals
, r_type
);
5540 if ( r_type
== R_ARM_GNU_VTENTRY
5541 || r_type
== R_ARM_GNU_VTINHERIT
)
5544 bfd_reloc
.howto
= elf32_arm_howto_from_type (r_type
);
5545 howto
= bfd_reloc
.howto
;
5547 if (info
->relocatable
&& globals
->use_rel
)
5549 /* This is a relocatable link. We don't have to change
5550 anything, unless the reloc is against a section symbol,
5551 in which case we have to adjust according to where the
5552 section symbol winds up in the output section. */
5553 if (r_symndx
< symtab_hdr
->sh_info
)
5555 sym
= local_syms
+ r_symndx
;
5556 if (ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
)
5558 sec
= local_sections
[r_symndx
];
5559 arm_add_to_rel (input_bfd
, contents
+ rel
->r_offset
,
5561 (bfd_signed_vma
) (sec
->output_offset
5569 /* This is a final link. */
5574 if (r_symndx
< symtab_hdr
->sh_info
)
5576 sym
= local_syms
+ r_symndx
;
5577 sym_type
= ELF32_ST_TYPE (sym
->st_info
);
5578 sec
= local_sections
[r_symndx
];
5579 if (globals
->use_rel
)
5581 relocation
= (sec
->output_section
->vma
5582 + sec
->output_offset
5584 if ((sec
->flags
& SEC_MERGE
)
5585 && ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
)
5588 bfd_vma addend
, value
;
5590 if (howto
->rightshift
)
5592 (*_bfd_error_handler
)
5593 (_("%B(%A+0x%lx): %s relocation against SEC_MERGE section"),
5594 input_bfd
, input_section
,
5595 (long) rel
->r_offset
, howto
->name
);
5599 value
= bfd_get_32 (input_bfd
, contents
+ rel
->r_offset
);
5601 /* Get the (signed) value from the instruction. */
5602 addend
= value
& howto
->src_mask
;
5603 if (addend
& ((howto
->src_mask
+ 1) >> 1))
5605 bfd_signed_vma mask
;
5608 mask
&= ~ howto
->src_mask
;
5613 _bfd_elf_rel_local_sym (output_bfd
, sym
, &msec
, addend
)
5615 addend
+= msec
->output_section
->vma
+ msec
->output_offset
;
5616 value
= (value
& ~ howto
->dst_mask
) | (addend
& howto
->dst_mask
);
5617 bfd_put_32 (input_bfd
, value
, contents
+ rel
->r_offset
);
5621 relocation
= _bfd_elf_rela_local_sym (output_bfd
, sym
, &sec
, rel
);
5627 RELOC_FOR_GLOBAL_SYMBOL (info
, input_bfd
, input_section
, rel
,
5628 r_symndx
, symtab_hdr
, sym_hashes
,
5630 unresolved_reloc
, warned
);
5636 name
= h
->root
.root
.string
;
5639 name
= (bfd_elf_string_from_elf_section
5640 (input_bfd
, symtab_hdr
->sh_link
, sym
->st_name
));
5641 if (name
== NULL
|| *name
== '\0')
5642 name
= bfd_section_name (input_bfd
, sec
);
5646 && r_type
!= R_ARM_NONE
5648 || h
->root
.type
== bfd_link_hash_defined
5649 || h
->root
.type
== bfd_link_hash_defweak
)
5650 && IS_ARM_TLS_RELOC (r_type
) != (sym_type
== STT_TLS
))
5652 (*_bfd_error_handler
)
5653 ((sym_type
== STT_TLS
5654 ? _("%B(%A+0x%lx): %s used with TLS symbol %s")
5655 : _("%B(%A+0x%lx): %s used with non-TLS symbol %s")),
5658 (long) rel
->r_offset
,
5663 r
= elf32_arm_final_link_relocate (howto
, input_bfd
, output_bfd
,
5664 input_section
, contents
, rel
,
5665 relocation
, info
, sec
, name
,
5666 (h
? ELF_ST_TYPE (h
->type
) :
5667 ELF_ST_TYPE (sym
->st_info
)), h
,
5670 /* Dynamic relocs are not propagated for SEC_DEBUGGING sections
5671 because such sections are not SEC_ALLOC and thus ld.so will
5672 not process them. */
5673 if (unresolved_reloc
5674 && !((input_section
->flags
& SEC_DEBUGGING
) != 0
5677 (*_bfd_error_handler
)
5678 (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
5681 (long) rel
->r_offset
,
5683 h
->root
.root
.string
);
5687 if (r
!= bfd_reloc_ok
)
5689 const char * msg
= (const char *) 0;
5693 case bfd_reloc_overflow
:
5694 /* If the overflowing reloc was to an undefined symbol,
5695 we have already printed one error message and there
5696 is no point complaining again. */
5698 h
->root
.type
!= bfd_link_hash_undefined
)
5699 && (!((*info
->callbacks
->reloc_overflow
)
5700 (info
, (h
? &h
->root
: NULL
), name
, howto
->name
,
5701 (bfd_vma
) 0, input_bfd
, input_section
,
5706 case bfd_reloc_undefined
:
5707 if (!((*info
->callbacks
->undefined_symbol
)
5708 (info
, name
, input_bfd
, input_section
,
5709 rel
->r_offset
, TRUE
)))
5713 case bfd_reloc_outofrange
:
5714 msg
= _("internal error: out of range error");
5717 case bfd_reloc_notsupported
:
5718 msg
= _("internal error: unsupported relocation error");
5721 case bfd_reloc_dangerous
:
5722 msg
= _("internal error: dangerous error");
5726 msg
= _("internal error: unknown error");
5730 if (!((*info
->callbacks
->warning
)
5731 (info
, msg
, name
, input_bfd
, input_section
,
5742 /* Allocate/find an object attribute. */
5743 static aeabi_attribute
*
5744 elf32_arm_new_eabi_attr (bfd
*abfd
, int tag
)
5746 aeabi_attribute
*attr
;
5747 aeabi_attribute_list
*list
;
5748 aeabi_attribute_list
*p
;
5749 aeabi_attribute_list
**lastp
;
5752 if (tag
< NUM_KNOWN_ATTRIBUTES
)
5754 /* Knwon tags are preallocated. */
5755 attr
= &elf32_arm_tdata (abfd
)->known_eabi_attributes
[tag
];
5759 /* Create a new tag. */
5760 list
= (aeabi_attribute_list
*)
5761 bfd_alloc (abfd
, sizeof (aeabi_attribute_list
));
5762 memset (list
, 0, sizeof (aeabi_attribute_list
));
5764 /* Keep the tag list in order. */
5765 lastp
= &elf32_arm_tdata (abfd
)->other_eabi_attributes
;
5766 for (p
= *lastp
; p
; p
= p
->next
)
5772 list
->next
= *lastp
;
5781 elf32_arm_get_eabi_attr_int (bfd
*abfd
, int tag
)
5783 aeabi_attribute_list
*p
;
5785 if (tag
< NUM_KNOWN_ATTRIBUTES
)
5787 /* Knwon tags are preallocated. */
5788 return elf32_arm_tdata (abfd
)->known_eabi_attributes
[tag
].i
;
5792 for (p
= elf32_arm_tdata (abfd
)->other_eabi_attributes
;
5806 elf32_arm_add_eabi_attr_int (bfd
*abfd
, int tag
, unsigned int i
)
5808 aeabi_attribute
*attr
;
5810 attr
= elf32_arm_new_eabi_attr (abfd
, tag
);
5816 attr_strdup (bfd
*abfd
, const char * s
)
5821 len
= strlen (s
) + 1;
5822 p
= (char *)bfd_alloc(abfd
, len
);
5823 return memcpy (p
, s
, len
);
5827 elf32_arm_add_eabi_attr_string (bfd
*abfd
, int tag
, const char *s
)
5829 aeabi_attribute
*attr
;
5831 attr
= elf32_arm_new_eabi_attr (abfd
, tag
);
5833 attr
->s
= attr_strdup (abfd
, s
);
5837 elf32_arm_add_eabi_attr_compat (bfd
*abfd
, unsigned int i
, const char *s
)
5839 aeabi_attribute_list
*list
;
5840 aeabi_attribute_list
*p
;
5841 aeabi_attribute_list
**lastp
;
5843 list
= (aeabi_attribute_list
*)
5844 bfd_alloc (abfd
, sizeof (aeabi_attribute_list
));
5845 memset (list
, 0, sizeof (aeabi_attribute_list
));
5846 list
->tag
= Tag_compatibility
;
5847 list
->attr
.type
= 3;
5849 list
->attr
.s
= attr_strdup (abfd
, s
);
5851 lastp
= &elf32_arm_tdata (abfd
)->other_eabi_attributes
;
5852 for (p
= *lastp
; p
; p
= p
->next
)
5855 if (p
->tag
!= Tag_compatibility
)
5857 cmp
= strcmp(s
, p
->attr
.s
);
5858 if (cmp
< 0 || (cmp
== 0 && i
< p
->attr
.i
))
5862 list
->next
= *lastp
;
5866 /* Set the right machine number. */
5869 elf32_arm_object_p (bfd
*abfd
)
5873 mach
= bfd_arm_get_mach_from_notes (abfd
, ARM_NOTE_SECTION
);
5875 if (mach
!= bfd_mach_arm_unknown
)
5876 bfd_default_set_arch_mach (abfd
, bfd_arch_arm
, mach
);
5878 else if (elf_elfheader (abfd
)->e_flags
& EF_ARM_MAVERICK_FLOAT
)
5879 bfd_default_set_arch_mach (abfd
, bfd_arch_arm
, bfd_mach_arm_ep9312
);
5882 bfd_default_set_arch_mach (abfd
, bfd_arch_arm
, mach
);
5887 /* Function to keep ARM specific flags in the ELF header. */
5890 elf32_arm_set_private_flags (bfd
*abfd
, flagword flags
)
5892 if (elf_flags_init (abfd
)
5893 && elf_elfheader (abfd
)->e_flags
!= flags
)
5895 if (EF_ARM_EABI_VERSION (flags
) == EF_ARM_EABI_UNKNOWN
)
5897 if (flags
& EF_ARM_INTERWORK
)
5898 (*_bfd_error_handler
)
5899 (_("Warning: Not setting interworking flag of %B since it has already been specified as non-interworking"),
5903 (_("Warning: Clearing the interworking flag of %B due to outside request"),
5909 elf_elfheader (abfd
)->e_flags
= flags
;
5910 elf_flags_init (abfd
) = TRUE
;
5916 /* Copy the eabi object attribute from IBFD to OBFD. */
5918 copy_eabi_attributes (bfd
*ibfd
, bfd
*obfd
)
5920 aeabi_attribute
*in_attr
;
5921 aeabi_attribute
*out_attr
;
5922 aeabi_attribute_list
*list
;
5925 in_attr
= elf32_arm_tdata (ibfd
)->known_eabi_attributes
;
5926 out_attr
= elf32_arm_tdata (obfd
)->known_eabi_attributes
;
5927 for (i
= 4; i
< NUM_KNOWN_ATTRIBUTES
; i
++)
5929 out_attr
->i
= in_attr
->i
;
5930 if (in_attr
->s
&& *in_attr
->s
)
5931 out_attr
->s
= attr_strdup (obfd
, in_attr
->s
);
5936 for (list
= elf32_arm_tdata (ibfd
)->other_eabi_attributes
;
5940 in_attr
= &list
->attr
;
5941 switch (in_attr
->type
)
5944 elf32_arm_add_eabi_attr_int (obfd
, list
->tag
, in_attr
->i
);
5947 elf32_arm_add_eabi_attr_string (obfd
, list
->tag
, in_attr
->s
);
5950 elf32_arm_add_eabi_attr_compat (obfd
, in_attr
->i
, in_attr
->s
);
5959 /* Copy backend specific data from one object module to another. */
5962 elf32_arm_copy_private_bfd_data (bfd
*ibfd
, bfd
*obfd
)
5967 if ( bfd_get_flavour (ibfd
) != bfd_target_elf_flavour
5968 || bfd_get_flavour (obfd
) != bfd_target_elf_flavour
)
5971 in_flags
= elf_elfheader (ibfd
)->e_flags
;
5972 out_flags
= elf_elfheader (obfd
)->e_flags
;
5974 if (elf_flags_init (obfd
)
5975 && EF_ARM_EABI_VERSION (out_flags
) == EF_ARM_EABI_UNKNOWN
5976 && in_flags
!= out_flags
)
5978 /* Cannot mix APCS26 and APCS32 code. */
5979 if ((in_flags
& EF_ARM_APCS_26
) != (out_flags
& EF_ARM_APCS_26
))
5982 /* Cannot mix float APCS and non-float APCS code. */
5983 if ((in_flags
& EF_ARM_APCS_FLOAT
) != (out_flags
& EF_ARM_APCS_FLOAT
))
5986 /* If the src and dest have different interworking flags
5987 then turn off the interworking bit. */
5988 if ((in_flags
& EF_ARM_INTERWORK
) != (out_flags
& EF_ARM_INTERWORK
))
5990 if (out_flags
& EF_ARM_INTERWORK
)
5992 (_("Warning: Clearing the interworking flag of %B because non-interworking code in %B has been linked with it"),
5995 in_flags
&= ~EF_ARM_INTERWORK
;
5998 /* Likewise for PIC, though don't warn for this case. */
5999 if ((in_flags
& EF_ARM_PIC
) != (out_flags
& EF_ARM_PIC
))
6000 in_flags
&= ~EF_ARM_PIC
;
6003 elf_elfheader (obfd
)->e_flags
= in_flags
;
6004 elf_flags_init (obfd
) = TRUE
;
6006 /* Also copy the EI_OSABI field. */
6007 elf_elfheader (obfd
)->e_ident
[EI_OSABI
] =
6008 elf_elfheader (ibfd
)->e_ident
[EI_OSABI
];
6010 /* Copy EABI object attributes. */
6011 copy_eabi_attributes (ibfd
, obfd
);
6016 /* Values for Tag_ABI_PCS_R9_use. */
6025 /* Values for Tag_ABI_PCS_RW_data. */
6028 AEABI_PCS_RW_data_absolute
,
6029 AEABI_PCS_RW_data_PCrel
,
6030 AEABI_PCS_RW_data_SBrel
,
6031 AEABI_PCS_RW_data_unused
6034 /* Values for Tag_ABI_enum_size. */
6040 AEABI_enum_forced_wide
6043 /* Merge EABI object attributes from IBFD into OBFD. Raise an error if there
6044 are conflicting attributes. */
6046 elf32_arm_merge_eabi_attributes (bfd
*ibfd
, bfd
*obfd
)
6048 aeabi_attribute
*in_attr
;
6049 aeabi_attribute
*out_attr
;
6050 aeabi_attribute_list
*in_list
;
6051 aeabi_attribute_list
*out_list
;
6052 /* Some tags have 0 = don't care, 1 = strong requirement,
6053 2 = weak requirement. */
6054 static const int order_312
[3] = {3, 1, 2};
6057 if (!elf32_arm_tdata (ibfd
)->known_eabi_attributes
[0].i
)
6059 /* This is the first object. Copy the attributes. */
6060 copy_eabi_attributes (ibfd
, obfd
);
6064 /* Use the Tag_null value to indicate the attributes have been
6066 elf32_arm_tdata (ibfd
)->known_eabi_attributes
[0].i
= 1;
6068 in_attr
= elf32_arm_tdata (ibfd
)->known_eabi_attributes
;
6069 out_attr
= elf32_arm_tdata (obfd
)->known_eabi_attributes
;
6070 /* This needs to happen before Tag_ABI_FP_number_model is merged. */
6071 if (in_attr
[Tag_ABI_VFP_args
].i
!= out_attr
[Tag_ABI_VFP_args
].i
)
6073 /* Ignore mismatches if teh object doesn't use floating point. */
6074 if (out_attr
[Tag_ABI_FP_number_model
].i
== 0)
6075 out_attr
[Tag_ABI_VFP_args
].i
= in_attr
[Tag_ABI_VFP_args
].i
;
6076 else if (in_attr
[Tag_ABI_FP_number_model
].i
!= 0)
6079 (_("ERROR: %B uses VFP register arguments, %B does not"),
6085 for (i
= 4; i
< NUM_KNOWN_ATTRIBUTES
; i
++)
6087 /* Merge this attribute with existing attributes. */
6090 case Tag_CPU_raw_name
:
6092 /* Use whichever has the greatest architecture requirements. */
6093 if (in_attr
[Tag_CPU_arch
].i
> out_attr
[Tag_CPU_arch
].i
)
6094 out_attr
[i
].s
= attr_strdup(obfd
, in_attr
[i
].s
);
6097 case Tag_ABI_optimization_goals
:
6098 case Tag_ABI_FP_optimization_goals
:
6099 /* Use the first value seen. */
6103 case Tag_ARM_ISA_use
:
6104 case Tag_THUMB_ISA_use
:
6108 /* ??? Do NEON and WMMX conflict? */
6109 case Tag_ABI_FP_rounding
:
6110 case Tag_ABI_FP_denormal
:
6111 case Tag_ABI_FP_exceptions
:
6112 case Tag_ABI_FP_user_exceptions
:
6113 case Tag_ABI_FP_number_model
:
6114 case Tag_ABI_align8_preserved
:
6115 case Tag_ABI_HardFP_use
:
6116 /* Use the largest value specified. */
6117 if (in_attr
[i
].i
> out_attr
[i
].i
)
6118 out_attr
[i
].i
= in_attr
[i
].i
;
6121 case Tag_CPU_arch_profile
:
6122 /* Warn if conflicting architecture profiles used. */
6123 if (out_attr
[i
].i
&& in_attr
[i
].i
&& in_attr
[i
].i
!= out_attr
[i
].i
)
6126 (_("ERROR: %B: Conflicting architecture profiles %c/%c"),
6127 ibfd
, in_attr
[i
].i
, out_attr
[i
].i
);
6131 out_attr
[i
].i
= in_attr
[i
].i
;
6133 case Tag_PCS_config
:
6134 if (out_attr
[i
].i
== 0)
6135 out_attr
[i
].i
= in_attr
[i
].i
;
6136 else if (in_attr
[i
].i
!= 0 && out_attr
[i
].i
!= 0)
6138 /* It's sometimes ok to mix different configs, so this is only
6141 (_("Warning: %B: Conflicting platform configuration"), ibfd
);
6144 case Tag_ABI_PCS_R9_use
:
6145 if (out_attr
[i
].i
!= AEABI_R9_unused
6146 && in_attr
[i
].i
!= AEABI_R9_unused
)
6149 (_("ERROR: %B: Conflicting use of R9"), ibfd
);
6152 if (out_attr
[i
].i
== AEABI_R9_unused
)
6153 out_attr
[i
].i
= in_attr
[i
].i
;
6155 case Tag_ABI_PCS_RW_data
:
6156 if (in_attr
[i
].i
== AEABI_PCS_RW_data_SBrel
6157 && out_attr
[Tag_ABI_PCS_R9_use
].i
!= AEABI_R9_SB
6158 && out_attr
[Tag_ABI_PCS_R9_use
].i
!= AEABI_R9_unused
)
6161 (_("ERROR: %B: SB relative addressing conflicts with use of R9"),
6165 /* Use the smallest value specified. */
6166 if (in_attr
[i
].i
< out_attr
[i
].i
)
6167 out_attr
[i
].i
= in_attr
[i
].i
;
6169 case Tag_ABI_PCS_RO_data
:
6170 /* Use the smallest value specified. */
6171 if (in_attr
[i
].i
< out_attr
[i
].i
)
6172 out_attr
[i
].i
= in_attr
[i
].i
;
6174 case Tag_ABI_PCS_GOT_use
:
6175 if (in_attr
[i
].i
> 2 || out_attr
[i
].i
> 2
6176 || order_312
[in_attr
[i
].i
] < order_312
[out_attr
[i
].i
])
6177 out_attr
[i
].i
= in_attr
[i
].i
;
6179 case Tag_ABI_PCS_wchar_t
:
6180 if (out_attr
[i
].i
&& in_attr
[i
].i
&& out_attr
[i
].i
!= in_attr
[i
].i
)
6183 (_("ERROR: %B: Conflicting definitions of wchar_t"), ibfd
);
6187 out_attr
[i
].i
= in_attr
[i
].i
;
6189 case Tag_ABI_align8_needed
:
6190 /* ??? Check against Tag_ABI_align8_preserved. */
6191 if (in_attr
[i
].i
> 2 || out_attr
[i
].i
> 2
6192 || order_312
[in_attr
[i
].i
] < order_312
[out_attr
[i
].i
])
6193 out_attr
[i
].i
= in_attr
[i
].i
;
6195 case Tag_ABI_enum_size
:
6196 if (in_attr
[i
].i
!= AEABI_enum_unused
)
6198 if (out_attr
[i
].i
== AEABI_enum_unused
6199 || out_attr
[i
].i
== AEABI_enum_forced_wide
)
6201 /* The existing object is compatible with anything.
6202 Use whatever requirements the new object has. */
6203 out_attr
[i
].i
= in_attr
[i
].i
;
6205 else if (in_attr
[i
].i
!= AEABI_enum_forced_wide
6206 && out_attr
[i
].i
!= in_attr
[i
].i
)
6209 (_("ERROR: %B: Conflicting enum sizes"), ibfd
);
6213 case Tag_ABI_VFP_args
:
6216 case Tag_ABI_WMMX_args
:
6217 if (in_attr
[i
].i
!= out_attr
[i
].i
)
6220 (_("ERROR: %B uses iWMMXt register arguments, %B does not"),
6225 default: /* All known attributes should be explicitly covered. */
6230 in_list
= elf32_arm_tdata (ibfd
)->other_eabi_attributes
;
6231 out_list
= elf32_arm_tdata (ibfd
)->other_eabi_attributes
;
6232 while (in_list
&& in_list
->tag
== Tag_compatibility
)
6234 in_attr
= &in_list
->attr
;
6235 if (in_attr
->i
== 0)
6237 if (in_attr
->i
== 1)
6240 (_("ERROR: %B: Must be processed by '%s' toolchain"),
6244 if (!out_list
|| out_list
->tag
!= Tag_compatibility
6245 || strcmp (in_attr
->s
, out_list
->attr
.s
) != 0)
6247 /* Add this compatibility tag to the output. */
6248 elf32_arm_add_eabi_attr_compat (obfd
, in_attr
->i
, in_attr
->s
);
6251 out_attr
= &out_list
->attr
;
6252 /* Check all the input tags with the same identifier. */
6255 if (out_list
->tag
!= Tag_compatibility
6256 || in_attr
->i
!= out_attr
->i
6257 || strcmp (in_attr
->s
, out_attr
->s
) != 0)
6260 (_("ERROR: %B: Incompatible object tag '%s':%d"),
6261 ibfd
, in_attr
->s
, in_attr
->i
);
6264 in_list
= in_list
->next
;
6265 if (in_list
->tag
!= Tag_compatibility
6266 || strcmp (in_attr
->s
, in_list
->attr
.s
) != 0)
6268 in_attr
= &in_list
->attr
;
6269 out_list
= out_list
->next
;
6271 out_attr
= &out_list
->attr
;
6274 /* Check the output doesn't have extra tags with this identifier. */
6275 if (out_list
&& out_list
->tag
== Tag_compatibility
6276 && strcmp (in_attr
->s
, out_list
->attr
.s
) == 0)
6279 (_("ERROR: %B: Incompatible object tag '%s':%d"),
6280 ibfd
, in_attr
->s
, out_list
->attr
.i
);
6285 for (; in_list
; in_list
= in_list
->next
)
6287 if ((in_list
->tag
& 128) < 64)
6290 (_("Warning: %B: Unknown EABI object attribute %d"),
6291 ibfd
, in_list
->tag
);
6299 /* Return TRUE if the two EABI versions are incompatible. */
6302 elf32_arm_versions_compatible (unsigned iver
, unsigned over
)
6304 /* v4 and v5 are the same spec before and after it was released,
6305 so allow mixing them. */
6306 if ((iver
== EF_ARM_EABI_VER4
&& over
== EF_ARM_EABI_VER5
)
6307 || (iver
== EF_ARM_EABI_VER5
&& over
== EF_ARM_EABI_VER4
))
6310 return (iver
== over
);
6313 /* Merge backend specific data from an object file to the output
6314 object file when linking. */
6317 elf32_arm_merge_private_bfd_data (bfd
* ibfd
, bfd
* obfd
)
6321 bfd_boolean flags_compatible
= TRUE
;
6324 /* Check if we have the same endianess. */
6325 if (! _bfd_generic_verify_endian_match (ibfd
, obfd
))
6328 if ( bfd_get_flavour (ibfd
) != bfd_target_elf_flavour
6329 || bfd_get_flavour (obfd
) != bfd_target_elf_flavour
)
6332 if (!elf32_arm_merge_eabi_attributes (ibfd
, obfd
))
6335 /* The input BFD must have had its flags initialised. */
6336 /* The following seems bogus to me -- The flags are initialized in
6337 the assembler but I don't think an elf_flags_init field is
6338 written into the object. */
6339 /* BFD_ASSERT (elf_flags_init (ibfd)); */
6341 in_flags
= elf_elfheader (ibfd
)->e_flags
;
6342 out_flags
= elf_elfheader (obfd
)->e_flags
;
6344 if (!elf_flags_init (obfd
))
6346 /* If the input is the default architecture and had the default
6347 flags then do not bother setting the flags for the output
6348 architecture, instead allow future merges to do this. If no
6349 future merges ever set these flags then they will retain their
6350 uninitialised values, which surprise surprise, correspond
6351 to the default values. */
6352 if (bfd_get_arch_info (ibfd
)->the_default
6353 && elf_elfheader (ibfd
)->e_flags
== 0)
6356 elf_flags_init (obfd
) = TRUE
;
6357 elf_elfheader (obfd
)->e_flags
= in_flags
;
6359 if (bfd_get_arch (obfd
) == bfd_get_arch (ibfd
)
6360 && bfd_get_arch_info (obfd
)->the_default
)
6361 return bfd_set_arch_mach (obfd
, bfd_get_arch (ibfd
), bfd_get_mach (ibfd
));
6366 /* Determine what should happen if the input ARM architecture
6367 does not match the output ARM architecture. */
6368 if (! bfd_arm_merge_machines (ibfd
, obfd
))
6371 /* Identical flags must be compatible. */
6372 if (in_flags
== out_flags
)
6375 /* Check to see if the input BFD actually contains any sections. If
6376 not, its flags may not have been initialised either, but it
6377 cannot actually cause any incompatiblity. Do not short-circuit
6378 dynamic objects; their section list may be emptied by
6379 elf_link_add_object_symbols.
6381 Also check to see if there are no code sections in the input.
6382 In this case there is no need to check for code specific flags.
6383 XXX - do we need to worry about floating-point format compatability
6384 in data sections ? */
6385 if (!(ibfd
->flags
& DYNAMIC
))
6387 bfd_boolean null_input_bfd
= TRUE
;
6388 bfd_boolean only_data_sections
= TRUE
;
6390 for (sec
= ibfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
6392 /* Ignore synthetic glue sections. */
6393 if (strcmp (sec
->name
, ".glue_7")
6394 && strcmp (sec
->name
, ".glue_7t"))
6396 if ((bfd_get_section_flags (ibfd
, sec
)
6397 & (SEC_LOAD
| SEC_CODE
| SEC_HAS_CONTENTS
))
6398 == (SEC_LOAD
| SEC_CODE
| SEC_HAS_CONTENTS
))
6399 only_data_sections
= FALSE
;
6401 null_input_bfd
= FALSE
;
6406 if (null_input_bfd
|| only_data_sections
)
6410 /* Complain about various flag mismatches. */
6411 if (!elf32_arm_versions_compatible (EF_ARM_EABI_VERSION (in_flags
),
6412 EF_ARM_EABI_VERSION (out_flags
)))
6415 (_("ERROR: Source object %B has EABI version %d, but target %B has EABI version %d"),
6417 (in_flags
& EF_ARM_EABIMASK
) >> 24,
6418 (out_flags
& EF_ARM_EABIMASK
) >> 24);
6422 /* Not sure what needs to be checked for EABI versions >= 1. */
6423 /* VxWorks libraries do not use these flags. */
6424 if (get_elf_backend_data (obfd
) != &elf32_arm_vxworks_bed
6425 && get_elf_backend_data (ibfd
) != &elf32_arm_vxworks_bed
6426 && EF_ARM_EABI_VERSION (in_flags
) == EF_ARM_EABI_UNKNOWN
)
6428 if ((in_flags
& EF_ARM_APCS_26
) != (out_flags
& EF_ARM_APCS_26
))
6431 (_("ERROR: %B is compiled for APCS-%d, whereas target %B uses APCS-%d"),
6433 in_flags
& EF_ARM_APCS_26
? 26 : 32,
6434 out_flags
& EF_ARM_APCS_26
? 26 : 32);
6435 flags_compatible
= FALSE
;
6438 if ((in_flags
& EF_ARM_APCS_FLOAT
) != (out_flags
& EF_ARM_APCS_FLOAT
))
6440 if (in_flags
& EF_ARM_APCS_FLOAT
)
6442 (_("ERROR: %B passes floats in float registers, whereas %B passes them in integer registers"),
6446 (_("ERROR: %B passes floats in integer registers, whereas %B passes them in float registers"),
6449 flags_compatible
= FALSE
;
6452 if ((in_flags
& EF_ARM_VFP_FLOAT
) != (out_flags
& EF_ARM_VFP_FLOAT
))
6454 if (in_flags
& EF_ARM_VFP_FLOAT
)
6456 (_("ERROR: %B uses VFP instructions, whereas %B does not"),
6460 (_("ERROR: %B uses FPA instructions, whereas %B does not"),
6463 flags_compatible
= FALSE
;
6466 if ((in_flags
& EF_ARM_MAVERICK_FLOAT
) != (out_flags
& EF_ARM_MAVERICK_FLOAT
))
6468 if (in_flags
& EF_ARM_MAVERICK_FLOAT
)
6470 (_("ERROR: %B uses Maverick instructions, whereas %B does not"),
6474 (_("ERROR: %B does not use Maverick instructions, whereas %B does"),
6477 flags_compatible
= FALSE
;
6480 #ifdef EF_ARM_SOFT_FLOAT
6481 if ((in_flags
& EF_ARM_SOFT_FLOAT
) != (out_flags
& EF_ARM_SOFT_FLOAT
))
6483 /* We can allow interworking between code that is VFP format
6484 layout, and uses either soft float or integer regs for
6485 passing floating point arguments and results. We already
6486 know that the APCS_FLOAT flags match; similarly for VFP
6488 if ((in_flags
& EF_ARM_APCS_FLOAT
) != 0
6489 || (in_flags
& EF_ARM_VFP_FLOAT
) == 0)
6491 if (in_flags
& EF_ARM_SOFT_FLOAT
)
6493 (_("ERROR: %B uses software FP, whereas %B uses hardware FP"),
6497 (_("ERROR: %B uses hardware FP, whereas %B uses software FP"),
6500 flags_compatible
= FALSE
;
6505 /* Interworking mismatch is only a warning. */
6506 if ((in_flags
& EF_ARM_INTERWORK
) != (out_flags
& EF_ARM_INTERWORK
))
6508 if (in_flags
& EF_ARM_INTERWORK
)
6511 (_("Warning: %B supports interworking, whereas %B does not"),
6517 (_("Warning: %B does not support interworking, whereas %B does"),
6523 return flags_compatible
;
6526 /* Display the flags field. */
6529 elf32_arm_print_private_bfd_data (bfd
*abfd
, void * ptr
)
6531 FILE * file
= (FILE *) ptr
;
6532 unsigned long flags
;
6534 BFD_ASSERT (abfd
!= NULL
&& ptr
!= NULL
);
6536 /* Print normal ELF private data. */
6537 _bfd_elf_print_private_bfd_data (abfd
, ptr
);
6539 flags
= elf_elfheader (abfd
)->e_flags
;
6540 /* Ignore init flag - it may not be set, despite the flags field
6541 containing valid data. */
6543 /* xgettext:c-format */
6544 fprintf (file
, _("private flags = %lx:"), elf_elfheader (abfd
)->e_flags
);
6546 switch (EF_ARM_EABI_VERSION (flags
))
6548 case EF_ARM_EABI_UNKNOWN
:
6549 /* The following flag bits are GNU extensions and not part of the
6550 official ARM ELF extended ABI. Hence they are only decoded if
6551 the EABI version is not set. */
6552 if (flags
& EF_ARM_INTERWORK
)
6553 fprintf (file
, _(" [interworking enabled]"));
6555 if (flags
& EF_ARM_APCS_26
)
6556 fprintf (file
, " [APCS-26]");
6558 fprintf (file
, " [APCS-32]");
6560 if (flags
& EF_ARM_VFP_FLOAT
)
6561 fprintf (file
, _(" [VFP float format]"));
6562 else if (flags
& EF_ARM_MAVERICK_FLOAT
)
6563 fprintf (file
, _(" [Maverick float format]"));
6565 fprintf (file
, _(" [FPA float format]"));
6567 if (flags
& EF_ARM_APCS_FLOAT
)
6568 fprintf (file
, _(" [floats passed in float registers]"));
6570 if (flags
& EF_ARM_PIC
)
6571 fprintf (file
, _(" [position independent]"));
6573 if (flags
& EF_ARM_NEW_ABI
)
6574 fprintf (file
, _(" [new ABI]"));
6576 if (flags
& EF_ARM_OLD_ABI
)
6577 fprintf (file
, _(" [old ABI]"));
6579 if (flags
& EF_ARM_SOFT_FLOAT
)
6580 fprintf (file
, _(" [software FP]"));
6582 flags
&= ~(EF_ARM_INTERWORK
| EF_ARM_APCS_26
| EF_ARM_APCS_FLOAT
6583 | EF_ARM_PIC
| EF_ARM_NEW_ABI
| EF_ARM_OLD_ABI
6584 | EF_ARM_SOFT_FLOAT
| EF_ARM_VFP_FLOAT
6585 | EF_ARM_MAVERICK_FLOAT
);
6588 case EF_ARM_EABI_VER1
:
6589 fprintf (file
, _(" [Version1 EABI]"));
6591 if (flags
& EF_ARM_SYMSARESORTED
)
6592 fprintf (file
, _(" [sorted symbol table]"));
6594 fprintf (file
, _(" [unsorted symbol table]"));
6596 flags
&= ~ EF_ARM_SYMSARESORTED
;
6599 case EF_ARM_EABI_VER2
:
6600 fprintf (file
, _(" [Version2 EABI]"));
6602 if (flags
& EF_ARM_SYMSARESORTED
)
6603 fprintf (file
, _(" [sorted symbol table]"));
6605 fprintf (file
, _(" [unsorted symbol table]"));
6607 if (flags
& EF_ARM_DYNSYMSUSESEGIDX
)
6608 fprintf (file
, _(" [dynamic symbols use segment index]"));
6610 if (flags
& EF_ARM_MAPSYMSFIRST
)
6611 fprintf (file
, _(" [mapping symbols precede others]"));
6613 flags
&= ~(EF_ARM_SYMSARESORTED
| EF_ARM_DYNSYMSUSESEGIDX
6614 | EF_ARM_MAPSYMSFIRST
);
6617 case EF_ARM_EABI_VER3
:
6618 fprintf (file
, _(" [Version3 EABI]"));
6621 case EF_ARM_EABI_VER4
:
6622 fprintf (file
, _(" [Version4 EABI]"));
6625 case EF_ARM_EABI_VER5
:
6626 fprintf (file
, _(" [Version5 EABI]"));
6628 if (flags
& EF_ARM_BE8
)
6629 fprintf (file
, _(" [BE8]"));
6631 if (flags
& EF_ARM_LE8
)
6632 fprintf (file
, _(" [LE8]"));
6634 flags
&= ~(EF_ARM_LE8
| EF_ARM_BE8
);
6638 fprintf (file
, _(" <EABI version unrecognised>"));
6642 flags
&= ~ EF_ARM_EABIMASK
;
6644 if (flags
& EF_ARM_RELEXEC
)
6645 fprintf (file
, _(" [relocatable executable]"));
6647 if (flags
& EF_ARM_HASENTRY
)
6648 fprintf (file
, _(" [has entry point]"));
6650 flags
&= ~ (EF_ARM_RELEXEC
| EF_ARM_HASENTRY
);
6653 fprintf (file
, _("<Unrecognised flag bits set>"));
6661 elf32_arm_get_symbol_type (Elf_Internal_Sym
* elf_sym
, int type
)
6663 switch (ELF_ST_TYPE (elf_sym
->st_info
))
6666 return ELF_ST_TYPE (elf_sym
->st_info
);
6669 /* If the symbol is not an object, return the STT_ARM_16BIT flag.
6670 This allows us to distinguish between data used by Thumb instructions
6671 and non-data (which is probably code) inside Thumb regions of an
6673 if (type
!= STT_OBJECT
&& type
!= STT_TLS
)
6674 return ELF_ST_TYPE (elf_sym
->st_info
);
6685 elf32_arm_gc_mark_hook (asection
* sec
,
6686 struct bfd_link_info
* info ATTRIBUTE_UNUSED
,
6687 Elf_Internal_Rela
* rel
,
6688 struct elf_link_hash_entry
* h
,
6689 Elf_Internal_Sym
* sym
)
6693 switch (ELF32_R_TYPE (rel
->r_info
))
6695 case R_ARM_GNU_VTINHERIT
:
6696 case R_ARM_GNU_VTENTRY
:
6700 switch (h
->root
.type
)
6702 case bfd_link_hash_defined
:
6703 case bfd_link_hash_defweak
:
6704 return h
->root
.u
.def
.section
;
6706 case bfd_link_hash_common
:
6707 return h
->root
.u
.c
.p
->section
;
6715 return bfd_section_from_elf_index (sec
->owner
, sym
->st_shndx
);
6720 /* Update the got entry reference counts for the section being removed. */
6723 elf32_arm_gc_sweep_hook (bfd
* abfd
,
6724 struct bfd_link_info
* info
,
6726 const Elf_Internal_Rela
* relocs
)
6728 Elf_Internal_Shdr
*symtab_hdr
;
6729 struct elf_link_hash_entry
**sym_hashes
;
6730 bfd_signed_vma
*local_got_refcounts
;
6731 const Elf_Internal_Rela
*rel
, *relend
;
6732 struct elf32_arm_link_hash_table
* globals
;
6734 globals
= elf32_arm_hash_table (info
);
6736 elf_section_data (sec
)->local_dynrel
= NULL
;
6738 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
6739 sym_hashes
= elf_sym_hashes (abfd
);
6740 local_got_refcounts
= elf_local_got_refcounts (abfd
);
6742 relend
= relocs
+ sec
->reloc_count
;
6743 for (rel
= relocs
; rel
< relend
; rel
++)
6745 unsigned long r_symndx
;
6746 struct elf_link_hash_entry
*h
= NULL
;
6749 r_symndx
= ELF32_R_SYM (rel
->r_info
);
6750 if (r_symndx
>= symtab_hdr
->sh_info
)
6752 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
6753 while (h
->root
.type
== bfd_link_hash_indirect
6754 || h
->root
.type
== bfd_link_hash_warning
)
6755 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
6758 r_type
= ELF32_R_TYPE (rel
->r_info
);
6759 r_type
= arm_real_reloc_type (globals
, r_type
);
6763 case R_ARM_GOT_PREL
:
6764 case R_ARM_TLS_GD32
:
6765 case R_ARM_TLS_IE32
:
6768 if (h
->got
.refcount
> 0)
6769 h
->got
.refcount
-= 1;
6771 else if (local_got_refcounts
!= NULL
)
6773 if (local_got_refcounts
[r_symndx
] > 0)
6774 local_got_refcounts
[r_symndx
] -= 1;
6778 case R_ARM_TLS_LDM32
:
6779 elf32_arm_hash_table (info
)->tls_ldm_got
.refcount
-= 1;
6783 case R_ARM_ABS32_NOI
:
6785 case R_ARM_REL32_NOI
:
6791 case R_ARM_THM_CALL
:
6792 case R_ARM_MOVW_ABS_NC
:
6793 case R_ARM_MOVT_ABS
:
6794 case R_ARM_MOVW_PREL_NC
:
6795 case R_ARM_MOVT_PREL
:
6796 case R_ARM_THM_MOVW_ABS_NC
:
6797 case R_ARM_THM_MOVT_ABS
:
6798 case R_ARM_THM_MOVW_PREL_NC
:
6799 case R_ARM_THM_MOVT_PREL
:
6800 /* Should the interworking branches be here also? */
6804 struct elf32_arm_link_hash_entry
*eh
;
6805 struct elf32_arm_relocs_copied
**pp
;
6806 struct elf32_arm_relocs_copied
*p
;
6808 eh
= (struct elf32_arm_link_hash_entry
*) h
;
6810 if (h
->plt
.refcount
> 0)
6812 h
->plt
.refcount
-= 1;
6813 if (ELF32_R_TYPE (rel
->r_info
) == R_ARM_THM_CALL
)
6814 eh
->plt_thumb_refcount
--;
6817 if (r_type
== R_ARM_ABS32
6818 || r_type
== R_ARM_REL32
6819 || r_type
== R_ARM_ABS32_NOI
6820 || r_type
== R_ARM_REL32_NOI
)
6822 for (pp
= &eh
->relocs_copied
; (p
= *pp
) != NULL
;
6824 if (p
->section
== sec
)
6827 if (ELF32_R_TYPE (rel
->r_info
) == R_ARM_REL32
6828 || ELF32_R_TYPE (rel
->r_info
) == R_ARM_REL32_NOI
)
6846 /* Look through the relocs for a section during the first phase. */
6849 elf32_arm_check_relocs (bfd
*abfd
, struct bfd_link_info
*info
,
6850 asection
*sec
, const Elf_Internal_Rela
*relocs
)
6852 Elf_Internal_Shdr
*symtab_hdr
;
6853 struct elf_link_hash_entry
**sym_hashes
;
6854 struct elf_link_hash_entry
**sym_hashes_end
;
6855 const Elf_Internal_Rela
*rel
;
6856 const Elf_Internal_Rela
*rel_end
;
6859 bfd_vma
*local_got_offsets
;
6860 struct elf32_arm_link_hash_table
*htab
;
6862 if (info
->relocatable
)
6865 htab
= elf32_arm_hash_table (info
);
6868 /* Create dynamic sections for relocatable executables so that we can
6869 copy relocations. */
6870 if (htab
->root
.is_relocatable_executable
6871 && ! htab
->root
.dynamic_sections_created
)
6873 if (! _bfd_elf_link_create_dynamic_sections (abfd
, info
))
6877 dynobj
= elf_hash_table (info
)->dynobj
;
6878 local_got_offsets
= elf_local_got_offsets (abfd
);
6880 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
6881 sym_hashes
= elf_sym_hashes (abfd
);
6882 sym_hashes_end
= sym_hashes
6883 + symtab_hdr
->sh_size
/ sizeof (Elf32_External_Sym
);
6885 if (!elf_bad_symtab (abfd
))
6886 sym_hashes_end
-= symtab_hdr
->sh_info
;
6888 rel_end
= relocs
+ sec
->reloc_count
;
6889 for (rel
= relocs
; rel
< rel_end
; rel
++)
6891 struct elf_link_hash_entry
*h
;
6892 struct elf32_arm_link_hash_entry
*eh
;
6893 unsigned long r_symndx
;
6896 r_symndx
= ELF32_R_SYM (rel
->r_info
);
6897 r_type
= ELF32_R_TYPE (rel
->r_info
);
6898 r_type
= arm_real_reloc_type (htab
, r_type
);
6900 if (r_symndx
>= NUM_SHDR_ENTRIES (symtab_hdr
))
6902 (*_bfd_error_handler
) (_("%B: bad symbol index: %d"), abfd
,
6907 if (r_symndx
< symtab_hdr
->sh_info
)
6911 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
6912 while (h
->root
.type
== bfd_link_hash_indirect
6913 || h
->root
.type
== bfd_link_hash_warning
)
6914 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
6917 eh
= (struct elf32_arm_link_hash_entry
*) h
;
6922 case R_ARM_GOT_PREL
:
6923 case R_ARM_TLS_GD32
:
6924 case R_ARM_TLS_IE32
:
6925 /* This symbol requires a global offset table entry. */
6927 int tls_type
, old_tls_type
;
6931 case R_ARM_TLS_GD32
: tls_type
= GOT_TLS_GD
; break;
6932 case R_ARM_TLS_IE32
: tls_type
= GOT_TLS_IE
; break;
6933 default: tls_type
= GOT_NORMAL
; break;
6939 old_tls_type
= elf32_arm_hash_entry (h
)->tls_type
;
6943 bfd_signed_vma
*local_got_refcounts
;
6945 /* This is a global offset table entry for a local symbol. */
6946 local_got_refcounts
= elf_local_got_refcounts (abfd
);
6947 if (local_got_refcounts
== NULL
)
6951 size
= symtab_hdr
->sh_info
;
6952 size
*= (sizeof (bfd_signed_vma
) + sizeof(char));
6953 local_got_refcounts
= bfd_zalloc (abfd
, size
);
6954 if (local_got_refcounts
== NULL
)
6956 elf_local_got_refcounts (abfd
) = local_got_refcounts
;
6957 elf32_arm_local_got_tls_type (abfd
)
6958 = (char *) (local_got_refcounts
+ symtab_hdr
->sh_info
);
6960 local_got_refcounts
[r_symndx
] += 1;
6961 old_tls_type
= elf32_arm_local_got_tls_type (abfd
) [r_symndx
];
6964 /* We will already have issued an error message if there is a
6965 TLS / non-TLS mismatch, based on the symbol type. We don't
6966 support any linker relaxations. So just combine any TLS
6968 if (old_tls_type
!= GOT_UNKNOWN
&& old_tls_type
!= GOT_NORMAL
6969 && tls_type
!= GOT_NORMAL
)
6970 tls_type
|= old_tls_type
;
6972 if (old_tls_type
!= tls_type
)
6975 elf32_arm_hash_entry (h
)->tls_type
= tls_type
;
6977 elf32_arm_local_got_tls_type (abfd
) [r_symndx
] = tls_type
;
6982 case R_ARM_TLS_LDM32
:
6983 if (r_type
== R_ARM_TLS_LDM32
)
6984 htab
->tls_ldm_got
.refcount
++;
6987 case R_ARM_GOTOFF32
:
6989 if (htab
->sgot
== NULL
)
6991 if (htab
->root
.dynobj
== NULL
)
6992 htab
->root
.dynobj
= abfd
;
6993 if (!create_got_section (htab
->root
.dynobj
, info
))
6999 /* VxWorks uses dynamic R_ARM_ABS12 relocations for
7000 ldr __GOTT_INDEX__ offsets. */
7001 if (!htab
->vxworks_p
)
7006 case R_ARM_ABS32_NOI
:
7008 case R_ARM_REL32_NOI
:
7014 case R_ARM_THM_CALL
:
7015 case R_ARM_MOVW_ABS_NC
:
7016 case R_ARM_MOVT_ABS
:
7017 case R_ARM_MOVW_PREL_NC
:
7018 case R_ARM_MOVT_PREL
:
7019 case R_ARM_THM_MOVW_ABS_NC
:
7020 case R_ARM_THM_MOVT_ABS
:
7021 case R_ARM_THM_MOVW_PREL_NC
:
7022 case R_ARM_THM_MOVT_PREL
:
7023 /* Should the interworking branches be listed here? */
7026 /* If this reloc is in a read-only section, we might
7027 need a copy reloc. We can't check reliably at this
7028 stage whether the section is read-only, as input
7029 sections have not yet been mapped to output sections.
7030 Tentatively set the flag for now, and correct in
7031 adjust_dynamic_symbol. */
7035 /* We may need a .plt entry if the function this reloc
7036 refers to is in a different object. We can't tell for
7037 sure yet, because something later might force the
7039 if (r_type
!= R_ARM_ABS32
7040 && r_type
!= R_ARM_REL32
7041 && r_type
!= R_ARM_ABS32_NOI
7042 && r_type
!= R_ARM_REL32_NOI
)
7045 /* If we create a PLT entry, this relocation will reference
7046 it, even if it's an ABS32 relocation. */
7047 h
->plt
.refcount
+= 1;
7049 if (r_type
== R_ARM_THM_CALL
)
7050 eh
->plt_thumb_refcount
+= 1;
7053 /* If we are creating a shared library or relocatable executable,
7054 and this is a reloc against a global symbol, or a non PC
7055 relative reloc against a local symbol, then we need to copy
7056 the reloc into the shared library. However, if we are linking
7057 with -Bsymbolic, we do not need to copy a reloc against a
7058 global symbol which is defined in an object we are
7059 including in the link (i.e., DEF_REGULAR is set). At
7060 this point we have not seen all the input files, so it is
7061 possible that DEF_REGULAR is not set now but will be set
7062 later (it is never cleared). We account for that
7063 possibility below by storing information in the
7064 relocs_copied field of the hash table entry. */
7065 if ((info
->shared
|| htab
->root
.is_relocatable_executable
)
7066 && (sec
->flags
& SEC_ALLOC
) != 0
7067 && ((r_type
== R_ARM_ABS32
|| r_type
== R_ARM_ABS32_NOI
)
7068 || (h
!= NULL
&& ! h
->needs_plt
7069 && (! info
->symbolic
|| ! h
->def_regular
))))
7071 struct elf32_arm_relocs_copied
*p
, **head
;
7073 /* When creating a shared object, we must copy these
7074 reloc types into the output file. We create a reloc
7075 section in dynobj and make room for this reloc. */
7080 name
= (bfd_elf_string_from_elf_section
7082 elf_elfheader (abfd
)->e_shstrndx
,
7083 elf_section_data (sec
)->rel_hdr
.sh_name
));
7087 BFD_ASSERT (reloc_section_p (htab
, name
, sec
));
7089 sreloc
= bfd_get_section_by_name (dynobj
, name
);
7094 flags
= (SEC_HAS_CONTENTS
| SEC_READONLY
7095 | SEC_IN_MEMORY
| SEC_LINKER_CREATED
);
7096 if ((sec
->flags
& SEC_ALLOC
) != 0
7097 /* BPABI objects never have dynamic
7098 relocations mapped. */
7099 && !htab
->symbian_p
)
7100 flags
|= SEC_ALLOC
| SEC_LOAD
;
7101 sreloc
= bfd_make_section_with_flags (dynobj
,
7105 || ! bfd_set_section_alignment (dynobj
, sreloc
, 2))
7109 elf_section_data (sec
)->sreloc
= sreloc
;
7112 /* If this is a global symbol, we count the number of
7113 relocations we need for this symbol. */
7116 head
= &((struct elf32_arm_link_hash_entry
*) h
)->relocs_copied
;
7120 /* Track dynamic relocs needed for local syms too.
7121 We really need local syms available to do this
7127 s
= bfd_section_from_r_symndx (abfd
, &htab
->sym_sec
,
7132 vpp
= &elf_section_data (s
)->local_dynrel
;
7133 head
= (struct elf32_arm_relocs_copied
**) vpp
;
7137 if (p
== NULL
|| p
->section
!= sec
)
7139 bfd_size_type amt
= sizeof *p
;
7141 p
= bfd_alloc (htab
->root
.dynobj
, amt
);
7151 if (r_type
== R_ARM_REL32
|| r_type
== R_ARM_REL32_NOI
)
7157 /* This relocation describes the C++ object vtable hierarchy.
7158 Reconstruct it for later use during GC. */
7159 case R_ARM_GNU_VTINHERIT
:
7160 if (!bfd_elf_gc_record_vtinherit (abfd
, sec
, h
, rel
->r_offset
))
7164 /* This relocation describes which C++ vtable entries are actually
7165 used. Record for later use during GC. */
7166 case R_ARM_GNU_VTENTRY
:
7167 if (!bfd_elf_gc_record_vtentry (abfd
, sec
, h
, rel
->r_offset
))
7176 /* Treat mapping symbols as special target symbols. */
7179 elf32_arm_is_target_special_symbol (bfd
* abfd ATTRIBUTE_UNUSED
, asymbol
* sym
)
7181 return bfd_is_arm_special_symbol_name (sym
->name
,
7182 BFD_ARM_SPECIAL_SYM_TYPE_ANY
);
7185 /* This is a copy of elf_find_function() from elf.c except that
7186 ARM mapping symbols are ignored when looking for function names
7187 and STT_ARM_TFUNC is considered to a function type. */
7190 arm_elf_find_function (bfd
* abfd ATTRIBUTE_UNUSED
,
7194 const char ** filename_ptr
,
7195 const char ** functionname_ptr
)
7197 const char * filename
= NULL
;
7198 asymbol
* func
= NULL
;
7199 bfd_vma low_func
= 0;
7202 for (p
= symbols
; *p
!= NULL
; p
++)
7206 q
= (elf_symbol_type
*) *p
;
7208 switch (ELF_ST_TYPE (q
->internal_elf_sym
.st_info
))
7213 filename
= bfd_asymbol_name (&q
->symbol
);
7218 /* Skip mapping symbols. */
7219 if ((q
->symbol
.flags
& BSF_LOCAL
)
7220 && bfd_is_arm_special_symbol_name (q
->symbol
.name
,
7221 BFD_ARM_SPECIAL_SYM_TYPE_ANY
))
7224 if (bfd_get_section (&q
->symbol
) == section
7225 && q
->symbol
.value
>= low_func
7226 && q
->symbol
.value
<= offset
)
7228 func
= (asymbol
*) q
;
7229 low_func
= q
->symbol
.value
;
7239 *filename_ptr
= filename
;
7240 if (functionname_ptr
)
7241 *functionname_ptr
= bfd_asymbol_name (func
);
7247 /* Find the nearest line to a particular section and offset, for error
7248 reporting. This code is a duplicate of the code in elf.c, except
7249 that it uses arm_elf_find_function. */
7252 elf32_arm_find_nearest_line (bfd
* abfd
,
7256 const char ** filename_ptr
,
7257 const char ** functionname_ptr
,
7258 unsigned int * line_ptr
)
7260 bfd_boolean found
= FALSE
;
7262 /* We skip _bfd_dwarf1_find_nearest_line since no known ARM toolchain uses it. */
7264 if (_bfd_dwarf2_find_nearest_line (abfd
, section
, symbols
, offset
,
7265 filename_ptr
, functionname_ptr
,
7267 & elf_tdata (abfd
)->dwarf2_find_line_info
))
7269 if (!*functionname_ptr
)
7270 arm_elf_find_function (abfd
, section
, symbols
, offset
,
7271 *filename_ptr
? NULL
: filename_ptr
,
7277 if (! _bfd_stab_section_find_nearest_line (abfd
, symbols
, section
, offset
,
7278 & found
, filename_ptr
,
7279 functionname_ptr
, line_ptr
,
7280 & elf_tdata (abfd
)->line_info
))
7283 if (found
&& (*functionname_ptr
|| *line_ptr
))
7286 if (symbols
== NULL
)
7289 if (! arm_elf_find_function (abfd
, section
, symbols
, offset
,
7290 filename_ptr
, functionname_ptr
))
7298 elf32_arm_find_inliner_info (bfd
* abfd
,
7299 const char ** filename_ptr
,
7300 const char ** functionname_ptr
,
7301 unsigned int * line_ptr
)
7304 found
= _bfd_dwarf2_find_inliner_info (abfd
, filename_ptr
,
7305 functionname_ptr
, line_ptr
,
7306 & elf_tdata (abfd
)->dwarf2_find_line_info
);
7310 /* Adjust a symbol defined by a dynamic object and referenced by a
7311 regular object. The current definition is in some section of the
7312 dynamic object, but we're not including those sections. We have to
7313 change the definition to something the rest of the link can
7317 elf32_arm_adjust_dynamic_symbol (struct bfd_link_info
* info
,
7318 struct elf_link_hash_entry
* h
)
7322 unsigned int power_of_two
;
7323 struct elf32_arm_link_hash_entry
* eh
;
7324 struct elf32_arm_link_hash_table
*globals
;
7326 globals
= elf32_arm_hash_table (info
);
7327 dynobj
= elf_hash_table (info
)->dynobj
;
7329 /* Make sure we know what is going on here. */
7330 BFD_ASSERT (dynobj
!= NULL
7332 || h
->u
.weakdef
!= NULL
7335 && !h
->def_regular
)));
7337 eh
= (struct elf32_arm_link_hash_entry
*) h
;
7339 /* If this is a function, put it in the procedure linkage table. We
7340 will fill in the contents of the procedure linkage table later,
7341 when we know the address of the .got section. */
7342 if (h
->type
== STT_FUNC
|| h
->type
== STT_ARM_TFUNC
7345 if (h
->plt
.refcount
<= 0
7346 || SYMBOL_CALLS_LOCAL (info
, h
)
7347 || (ELF_ST_VISIBILITY (h
->other
) != STV_DEFAULT
7348 && h
->root
.type
== bfd_link_hash_undefweak
))
7350 /* This case can occur if we saw a PLT32 reloc in an input
7351 file, but the symbol was never referred to by a dynamic
7352 object, or if all references were garbage collected. In
7353 such a case, we don't actually need to build a procedure
7354 linkage table, and we can just do a PC24 reloc instead. */
7355 h
->plt
.offset
= (bfd_vma
) -1;
7356 eh
->plt_thumb_refcount
= 0;
7364 /* It's possible that we incorrectly decided a .plt reloc was
7365 needed for an R_ARM_PC24 or similar reloc to a non-function sym
7366 in check_relocs. We can't decide accurately between function
7367 and non-function syms in check-relocs; Objects loaded later in
7368 the link may change h->type. So fix it now. */
7369 h
->plt
.offset
= (bfd_vma
) -1;
7370 eh
->plt_thumb_refcount
= 0;
7373 /* If this is a weak symbol, and there is a real definition, the
7374 processor independent code will have arranged for us to see the
7375 real definition first, and we can just use the same value. */
7376 if (h
->u
.weakdef
!= NULL
)
7378 BFD_ASSERT (h
->u
.weakdef
->root
.type
== bfd_link_hash_defined
7379 || h
->u
.weakdef
->root
.type
== bfd_link_hash_defweak
);
7380 h
->root
.u
.def
.section
= h
->u
.weakdef
->root
.u
.def
.section
;
7381 h
->root
.u
.def
.value
= h
->u
.weakdef
->root
.u
.def
.value
;
7385 /* If there are no non-GOT references, we do not need a copy
7387 if (!h
->non_got_ref
)
7390 /* This is a reference to a symbol defined by a dynamic object which
7391 is not a function. */
7393 /* If we are creating a shared library, we must presume that the
7394 only references to the symbol are via the global offset table.
7395 For such cases we need not do anything here; the relocations will
7396 be handled correctly by relocate_section. Relocatable executables
7397 can reference data in shared objects directly, so we don't need to
7398 do anything here. */
7399 if (info
->shared
|| globals
->root
.is_relocatable_executable
)
7404 (*_bfd_error_handler
) (_("dynamic variable `%s' is zero size"),
7405 h
->root
.root
.string
);
7409 /* We must allocate the symbol in our .dynbss section, which will
7410 become part of the .bss section of the executable. There will be
7411 an entry for this symbol in the .dynsym section. The dynamic
7412 object will contain position independent code, so all references
7413 from the dynamic object to this symbol will go through the global
7414 offset table. The dynamic linker will use the .dynsym entry to
7415 determine the address it must put in the global offset table, so
7416 both the dynamic object and the regular object will refer to the
7417 same memory location for the variable. */
7418 s
= bfd_get_section_by_name (dynobj
, ".dynbss");
7419 BFD_ASSERT (s
!= NULL
);
7421 /* We must generate a R_ARM_COPY reloc to tell the dynamic linker to
7422 copy the initial value out of the dynamic object and into the
7423 runtime process image. We need to remember the offset into the
7424 .rel(a).bss section we are going to use. */
7425 if ((h
->root
.u
.def
.section
->flags
& SEC_ALLOC
) != 0)
7429 srel
= bfd_get_section_by_name (dynobj
, RELOC_SECTION (globals
, ".bss"));
7430 BFD_ASSERT (srel
!= NULL
);
7431 srel
->size
+= RELOC_SIZE (globals
);
7435 /* We need to figure out the alignment required for this symbol. I
7436 have no idea how ELF linkers handle this. */
7437 power_of_two
= bfd_log2 (h
->size
);
7438 if (power_of_two
> 3)
7441 /* Apply the required alignment. */
7442 s
->size
= BFD_ALIGN (s
->size
, (bfd_size_type
) (1 << power_of_two
));
7443 if (power_of_two
> bfd_get_section_alignment (dynobj
, s
))
7445 if (! bfd_set_section_alignment (dynobj
, s
, power_of_two
))
7449 /* Define the symbol as being at this point in the section. */
7450 h
->root
.u
.def
.section
= s
;
7451 h
->root
.u
.def
.value
= s
->size
;
7453 /* Increment the section size to make room for the symbol. */
7459 /* Allocate space in .plt, .got and associated reloc sections for
7463 allocate_dynrelocs (struct elf_link_hash_entry
*h
, void * inf
)
7465 struct bfd_link_info
*info
;
7466 struct elf32_arm_link_hash_table
*htab
;
7467 struct elf32_arm_link_hash_entry
*eh
;
7468 struct elf32_arm_relocs_copied
*p
;
7470 eh
= (struct elf32_arm_link_hash_entry
*) h
;
7472 if (h
->root
.type
== bfd_link_hash_indirect
)
7475 if (h
->root
.type
== bfd_link_hash_warning
)
7476 /* When warning symbols are created, they **replace** the "real"
7477 entry in the hash table, thus we never get to see the real
7478 symbol in a hash traversal. So look at it now. */
7479 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
7481 info
= (struct bfd_link_info
*) inf
;
7482 htab
= elf32_arm_hash_table (info
);
7484 if (htab
->root
.dynamic_sections_created
7485 && h
->plt
.refcount
> 0)
7487 /* Make sure this symbol is output as a dynamic symbol.
7488 Undefined weak syms won't yet be marked as dynamic. */
7489 if (h
->dynindx
== -1
7490 && !h
->forced_local
)
7492 if (! bfd_elf_link_record_dynamic_symbol (info
, h
))
7497 || WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, 0, h
))
7499 asection
*s
= htab
->splt
;
7501 /* If this is the first .plt entry, make room for the special
7504 s
->size
+= htab
->plt_header_size
;
7506 h
->plt
.offset
= s
->size
;
7508 /* If we will insert a Thumb trampoline before this PLT, leave room
7510 if (!htab
->use_blx
&& eh
->plt_thumb_refcount
> 0)
7512 h
->plt
.offset
+= PLT_THUMB_STUB_SIZE
;
7513 s
->size
+= PLT_THUMB_STUB_SIZE
;
7516 /* If this symbol is not defined in a regular file, and we are
7517 not generating a shared library, then set the symbol to this
7518 location in the .plt. This is required to make function
7519 pointers compare as equal between the normal executable and
7520 the shared library. */
7524 h
->root
.u
.def
.section
= s
;
7525 h
->root
.u
.def
.value
= h
->plt
.offset
;
7527 /* Make sure the function is not marked as Thumb, in case
7528 it is the target of an ABS32 relocation, which will
7529 point to the PLT entry. */
7530 if (ELF_ST_TYPE (h
->type
) == STT_ARM_TFUNC
)
7531 h
->type
= ELF_ST_INFO (ELF_ST_BIND (h
->type
), STT_FUNC
);
7534 /* Make room for this entry. */
7535 s
->size
+= htab
->plt_entry_size
;
7537 if (!htab
->symbian_p
)
7539 /* We also need to make an entry in the .got.plt section, which
7540 will be placed in the .got section by the linker script. */
7541 eh
->plt_got_offset
= htab
->sgotplt
->size
;
7542 htab
->sgotplt
->size
+= 4;
7545 /* We also need to make an entry in the .rel(a).plt section. */
7546 htab
->srelplt
->size
+= RELOC_SIZE (htab
);
7548 /* VxWorks executables have a second set of relocations for
7549 each PLT entry. They go in a separate relocation section,
7550 which is processed by the kernel loader. */
7551 if (htab
->vxworks_p
&& !info
->shared
)
7553 /* There is a relocation for the initial PLT entry:
7554 an R_ARM_32 relocation for _GLOBAL_OFFSET_TABLE_. */
7555 if (h
->plt
.offset
== htab
->plt_header_size
)
7556 htab
->srelplt2
->size
+= RELOC_SIZE (htab
);
7558 /* There are two extra relocations for each subsequent
7559 PLT entry: an R_ARM_32 relocation for the GOT entry,
7560 and an R_ARM_32 relocation for the PLT entry. */
7561 htab
->srelplt2
->size
+= RELOC_SIZE (htab
) * 2;
7566 h
->plt
.offset
= (bfd_vma
) -1;
7572 h
->plt
.offset
= (bfd_vma
) -1;
7576 if (h
->got
.refcount
> 0)
7580 int tls_type
= elf32_arm_hash_entry (h
)->tls_type
;
7583 /* Make sure this symbol is output as a dynamic symbol.
7584 Undefined weak syms won't yet be marked as dynamic. */
7585 if (h
->dynindx
== -1
7586 && !h
->forced_local
)
7588 if (! bfd_elf_link_record_dynamic_symbol (info
, h
))
7592 if (!htab
->symbian_p
)
7595 h
->got
.offset
= s
->size
;
7597 if (tls_type
== GOT_UNKNOWN
)
7600 if (tls_type
== GOT_NORMAL
)
7601 /* Non-TLS symbols need one GOT slot. */
7605 if (tls_type
& GOT_TLS_GD
)
7606 /* R_ARM_TLS_GD32 needs 2 consecutive GOT slots. */
7608 if (tls_type
& GOT_TLS_IE
)
7609 /* R_ARM_TLS_IE32 needs one GOT slot. */
7613 dyn
= htab
->root
.dynamic_sections_created
;
7616 if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn
, info
->shared
, h
)
7618 || !SYMBOL_REFERENCES_LOCAL (info
, h
)))
7621 if (tls_type
!= GOT_NORMAL
7622 && (info
->shared
|| indx
!= 0)
7623 && (ELF_ST_VISIBILITY (h
->other
) == STV_DEFAULT
7624 || h
->root
.type
!= bfd_link_hash_undefweak
))
7626 if (tls_type
& GOT_TLS_IE
)
7627 htab
->srelgot
->size
+= RELOC_SIZE (htab
);
7629 if (tls_type
& GOT_TLS_GD
)
7630 htab
->srelgot
->size
+= RELOC_SIZE (htab
);
7632 if ((tls_type
& GOT_TLS_GD
) && indx
!= 0)
7633 htab
->srelgot
->size
+= RELOC_SIZE (htab
);
7635 else if ((ELF_ST_VISIBILITY (h
->other
) == STV_DEFAULT
7636 || h
->root
.type
!= bfd_link_hash_undefweak
)
7638 || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn
, 0, h
)))
7639 htab
->srelgot
->size
+= RELOC_SIZE (htab
);
7643 h
->got
.offset
= (bfd_vma
) -1;
7645 /* Allocate stubs for exported Thumb functions on v4t. */
7646 if (!htab
->use_blx
&& h
->dynindx
!= -1
7647 && ELF_ST_TYPE (h
->type
) == STT_ARM_TFUNC
7648 && ELF_ST_VISIBILITY (h
->other
) == STV_DEFAULT
)
7650 struct elf_link_hash_entry
* th
;
7651 struct bfd_link_hash_entry
* bh
;
7652 struct elf_link_hash_entry
* myh
;
7656 /* Create a new symbol to regist the real location of the function. */
7657 s
= h
->root
.u
.def
.section
;
7658 sprintf(name
, "__real_%s", h
->root
.root
.string
);
7659 _bfd_generic_link_add_one_symbol (info
, s
->owner
,
7660 name
, BSF_GLOBAL
, s
,
7661 h
->root
.u
.def
.value
,
7662 NULL
, TRUE
, FALSE
, &bh
);
7664 myh
= (struct elf_link_hash_entry
*) bh
;
7665 myh
->type
= ELF_ST_INFO (STB_LOCAL
, STT_ARM_TFUNC
);
7666 myh
->forced_local
= 1;
7667 eh
->export_glue
= myh
;
7668 th
= record_arm_to_thumb_glue (info
, h
);
7669 /* Point the symbol at the stub. */
7670 h
->type
= ELF_ST_INFO (ELF_ST_BIND (h
->type
), STT_FUNC
);
7671 h
->root
.u
.def
.section
= th
->root
.u
.def
.section
;
7672 h
->root
.u
.def
.value
= th
->root
.u
.def
.value
& ~1;
7675 if (eh
->relocs_copied
== NULL
)
7678 /* In the shared -Bsymbolic case, discard space allocated for
7679 dynamic pc-relative relocs against symbols which turn out to be
7680 defined in regular objects. For the normal shared case, discard
7681 space for pc-relative relocs that have become local due to symbol
7682 visibility changes. */
7684 if (info
->shared
|| htab
->root
.is_relocatable_executable
)
7686 /* The only relocs that use pc_count are R_ARM_REL32 and
7687 R_ARM_REL32_NOI, which will appear on something like
7688 ".long foo - .". We want calls to protected symbols to resolve
7689 directly to the function rather than going via the plt. If people
7690 want function pointer comparisons to work as expected then they
7691 should avoid writing assembly like ".long foo - .". */
7692 if (SYMBOL_CALLS_LOCAL (info
, h
))
7694 struct elf32_arm_relocs_copied
**pp
;
7696 for (pp
= &eh
->relocs_copied
; (p
= *pp
) != NULL
; )
7698 p
->count
-= p
->pc_count
;
7707 /* Also discard relocs on undefined weak syms with non-default
7709 if (eh
->relocs_copied
!= NULL
7710 && h
->root
.type
== bfd_link_hash_undefweak
)
7712 if (ELF_ST_VISIBILITY (h
->other
) != STV_DEFAULT
)
7713 eh
->relocs_copied
= NULL
;
7715 /* Make sure undefined weak symbols are output as a dynamic
7717 else if (h
->dynindx
== -1
7718 && !h
->forced_local
)
7720 if (! bfd_elf_link_record_dynamic_symbol (info
, h
))
7725 else if (htab
->root
.is_relocatable_executable
&& h
->dynindx
== -1
7726 && h
->root
.type
== bfd_link_hash_new
)
7728 /* Output absolute symbols so that we can create relocations
7729 against them. For normal symbols we output a relocation
7730 against the section that contains them. */
7731 if (! bfd_elf_link_record_dynamic_symbol (info
, h
))
7738 /* For the non-shared case, discard space for relocs against
7739 symbols which turn out to need copy relocs or are not
7745 || (htab
->root
.dynamic_sections_created
7746 && (h
->root
.type
== bfd_link_hash_undefweak
7747 || h
->root
.type
== bfd_link_hash_undefined
))))
7749 /* Make sure this symbol is output as a dynamic symbol.
7750 Undefined weak syms won't yet be marked as dynamic. */
7751 if (h
->dynindx
== -1
7752 && !h
->forced_local
)
7754 if (! bfd_elf_link_record_dynamic_symbol (info
, h
))
7758 /* If that succeeded, we know we'll be keeping all the
7760 if (h
->dynindx
!= -1)
7764 eh
->relocs_copied
= NULL
;
7769 /* Finally, allocate space. */
7770 for (p
= eh
->relocs_copied
; p
!= NULL
; p
= p
->next
)
7772 asection
*sreloc
= elf_section_data (p
->section
)->sreloc
;
7773 sreloc
->size
+= p
->count
* RELOC_SIZE (htab
);
7779 /* Find any dynamic relocs that apply to read-only sections. */
7782 elf32_arm_readonly_dynrelocs (struct elf_link_hash_entry
*h
, PTR inf
)
7784 struct elf32_arm_link_hash_entry
*eh
;
7785 struct elf32_arm_relocs_copied
*p
;
7787 if (h
->root
.type
== bfd_link_hash_warning
)
7788 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
7790 eh
= (struct elf32_arm_link_hash_entry
*) h
;
7791 for (p
= eh
->relocs_copied
; p
!= NULL
; p
= p
->next
)
7793 asection
*s
= p
->section
;
7795 if (s
!= NULL
&& (s
->flags
& SEC_READONLY
) != 0)
7797 struct bfd_link_info
*info
= (struct bfd_link_info
*) inf
;
7799 info
->flags
|= DF_TEXTREL
;
7801 /* Not an error, just cut short the traversal. */
7808 /* Set the sizes of the dynamic sections. */
7811 elf32_arm_size_dynamic_sections (bfd
* output_bfd ATTRIBUTE_UNUSED
,
7812 struct bfd_link_info
* info
)
7819 struct elf32_arm_link_hash_table
*htab
;
7821 htab
= elf32_arm_hash_table (info
);
7822 dynobj
= elf_hash_table (info
)->dynobj
;
7823 BFD_ASSERT (dynobj
!= NULL
);
7824 check_use_blx (htab
);
7826 if (elf_hash_table (info
)->dynamic_sections_created
)
7828 /* Set the contents of the .interp section to the interpreter. */
7829 if (info
->executable
)
7831 s
= bfd_get_section_by_name (dynobj
, ".interp");
7832 BFD_ASSERT (s
!= NULL
);
7833 s
->size
= sizeof ELF_DYNAMIC_INTERPRETER
;
7834 s
->contents
= (unsigned char *) ELF_DYNAMIC_INTERPRETER
;
7838 /* Set up .got offsets for local syms, and space for local dynamic
7840 for (ibfd
= info
->input_bfds
; ibfd
!= NULL
; ibfd
= ibfd
->link_next
)
7842 bfd_signed_vma
*local_got
;
7843 bfd_signed_vma
*end_local_got
;
7844 char *local_tls_type
;
7845 bfd_size_type locsymcount
;
7846 Elf_Internal_Shdr
*symtab_hdr
;
7849 if (bfd_get_flavour (ibfd
) != bfd_target_elf_flavour
)
7852 for (s
= ibfd
->sections
; s
!= NULL
; s
= s
->next
)
7854 struct elf32_arm_relocs_copied
*p
;
7856 for (p
= elf_section_data (s
)->local_dynrel
; p
!= NULL
; p
= p
->next
)
7858 if (!bfd_is_abs_section (p
->section
)
7859 && bfd_is_abs_section (p
->section
->output_section
))
7861 /* Input section has been discarded, either because
7862 it is a copy of a linkonce section or due to
7863 linker script /DISCARD/, so we'll be discarding
7866 else if (p
->count
!= 0)
7868 srel
= elf_section_data (p
->section
)->sreloc
;
7869 srel
->size
+= p
->count
* RELOC_SIZE (htab
);
7870 if ((p
->section
->output_section
->flags
& SEC_READONLY
) != 0)
7871 info
->flags
|= DF_TEXTREL
;
7876 local_got
= elf_local_got_refcounts (ibfd
);
7880 symtab_hdr
= &elf_tdata (ibfd
)->symtab_hdr
;
7881 locsymcount
= symtab_hdr
->sh_info
;
7882 end_local_got
= local_got
+ locsymcount
;
7883 local_tls_type
= elf32_arm_local_got_tls_type (ibfd
);
7885 srel
= htab
->srelgot
;
7886 for (; local_got
< end_local_got
; ++local_got
, ++local_tls_type
)
7890 *local_got
= s
->size
;
7891 if (*local_tls_type
& GOT_TLS_GD
)
7892 /* TLS_GD relocs need an 8-byte structure in the GOT. */
7894 if (*local_tls_type
& GOT_TLS_IE
)
7896 if (*local_tls_type
== GOT_NORMAL
)
7899 if (info
->shared
|| *local_tls_type
== GOT_TLS_GD
)
7900 srel
->size
+= RELOC_SIZE (htab
);
7903 *local_got
= (bfd_vma
) -1;
7907 if (htab
->tls_ldm_got
.refcount
> 0)
7909 /* Allocate two GOT entries and one dynamic relocation (if necessary)
7910 for R_ARM_TLS_LDM32 relocations. */
7911 htab
->tls_ldm_got
.offset
= htab
->sgot
->size
;
7912 htab
->sgot
->size
+= 8;
7914 htab
->srelgot
->size
+= RELOC_SIZE (htab
);
7917 htab
->tls_ldm_got
.offset
= -1;
7919 /* Allocate global sym .plt and .got entries, and space for global
7920 sym dynamic relocs. */
7921 elf_link_hash_traverse (& htab
->root
, allocate_dynrelocs
, info
);
7923 /* The check_relocs and adjust_dynamic_symbol entry points have
7924 determined the sizes of the various dynamic sections. Allocate
7928 for (s
= dynobj
->sections
; s
!= NULL
; s
= s
->next
)
7932 if ((s
->flags
& SEC_LINKER_CREATED
) == 0)
7935 /* It's OK to base decisions on the section name, because none
7936 of the dynobj section names depend upon the input files. */
7937 name
= bfd_get_section_name (dynobj
, s
);
7939 if (strcmp (name
, ".plt") == 0)
7941 /* Remember whether there is a PLT. */
7944 else if (strncmp (name
, ".rel", 4) == 0)
7948 /* Remember whether there are any reloc sections other
7949 than .rel(a).plt and .rela.plt.unloaded. */
7950 if (s
!= htab
->srelplt
&& s
!= htab
->srelplt2
)
7953 /* We use the reloc_count field as a counter if we need
7954 to copy relocs into the output file. */
7958 else if (strncmp (name
, ".got", 4) != 0
7959 && strcmp (name
, ".dynbss") != 0)
7961 /* It's not one of our sections, so don't allocate space. */
7967 /* If we don't need this section, strip it from the
7968 output file. This is mostly to handle .rel(a).bss and
7969 .rel(a).plt. We must create both sections in
7970 create_dynamic_sections, because they must be created
7971 before the linker maps input sections to output
7972 sections. The linker does that before
7973 adjust_dynamic_symbol is called, and it is that
7974 function which decides whether anything needs to go
7975 into these sections. */
7976 s
->flags
|= SEC_EXCLUDE
;
7980 if ((s
->flags
& SEC_HAS_CONTENTS
) == 0)
7983 /* Allocate memory for the section contents. */
7984 s
->contents
= (bfd_byte
*) bfd_zalloc (dynobj
, s
->size
);
7985 if (s
->contents
== NULL
)
7989 if (elf_hash_table (info
)->dynamic_sections_created
)
7991 /* Add some entries to the .dynamic section. We fill in the
7992 values later, in elf32_arm_finish_dynamic_sections, but we
7993 must add the entries now so that we get the correct size for
7994 the .dynamic section. The DT_DEBUG entry is filled in by the
7995 dynamic linker and used by the debugger. */
7996 #define add_dynamic_entry(TAG, VAL) \
7997 _bfd_elf_add_dynamic_entry (info, TAG, VAL)
7999 if (info
->executable
)
8001 if (!add_dynamic_entry (DT_DEBUG
, 0))
8007 if ( !add_dynamic_entry (DT_PLTGOT
, 0)
8008 || !add_dynamic_entry (DT_PLTRELSZ
, 0)
8009 || !add_dynamic_entry (DT_PLTREL
,
8010 htab
->use_rel
? DT_REL
: DT_RELA
)
8011 || !add_dynamic_entry (DT_JMPREL
, 0))
8019 if (!add_dynamic_entry (DT_REL
, 0)
8020 || !add_dynamic_entry (DT_RELSZ
, 0)
8021 || !add_dynamic_entry (DT_RELENT
, RELOC_SIZE (htab
)))
8026 if (!add_dynamic_entry (DT_RELA
, 0)
8027 || !add_dynamic_entry (DT_RELASZ
, 0)
8028 || !add_dynamic_entry (DT_RELAENT
, RELOC_SIZE (htab
)))
8033 /* If any dynamic relocs apply to a read-only section,
8034 then we need a DT_TEXTREL entry. */
8035 if ((info
->flags
& DF_TEXTREL
) == 0)
8036 elf_link_hash_traverse (&htab
->root
, elf32_arm_readonly_dynrelocs
,
8039 if ((info
->flags
& DF_TEXTREL
) != 0)
8041 if (!add_dynamic_entry (DT_TEXTREL
, 0))
8045 #undef add_dynamic_entry
8050 /* Finish up dynamic symbol handling. We set the contents of various
8051 dynamic sections here. */
8054 elf32_arm_finish_dynamic_symbol (bfd
* output_bfd
, struct bfd_link_info
* info
,
8055 struct elf_link_hash_entry
* h
, Elf_Internal_Sym
* sym
)
8058 struct elf32_arm_link_hash_table
*htab
;
8059 struct elf32_arm_link_hash_entry
*eh
;
8061 dynobj
= elf_hash_table (info
)->dynobj
;
8062 htab
= elf32_arm_hash_table (info
);
8063 eh
= (struct elf32_arm_link_hash_entry
*) h
;
8065 if (h
->plt
.offset
!= (bfd_vma
) -1)
8071 Elf_Internal_Rela rel
;
8073 /* This symbol has an entry in the procedure linkage table. Set
8076 BFD_ASSERT (h
->dynindx
!= -1);
8078 splt
= bfd_get_section_by_name (dynobj
, ".plt");
8079 srel
= bfd_get_section_by_name (dynobj
, RELOC_SECTION (htab
, ".plt"));
8080 BFD_ASSERT (splt
!= NULL
&& srel
!= NULL
);
8082 /* Fill in the entry in the procedure linkage table. */
8083 if (htab
->symbian_p
)
8085 put_arm_insn (htab
, output_bfd
,
8086 elf32_arm_symbian_plt_entry
[0],
8087 splt
->contents
+ h
->plt
.offset
);
8088 bfd_put_32 (output_bfd
,
8089 elf32_arm_symbian_plt_entry
[1],
8090 splt
->contents
+ h
->plt
.offset
+ 4);
8092 /* Fill in the entry in the .rel.plt section. */
8093 rel
.r_offset
= (splt
->output_section
->vma
8094 + splt
->output_offset
8095 + h
->plt
.offset
+ 4);
8096 rel
.r_info
= ELF32_R_INFO (h
->dynindx
, R_ARM_GLOB_DAT
);
8098 /* Get the index in the procedure linkage table which
8099 corresponds to this symbol. This is the index of this symbol
8100 in all the symbols for which we are making plt entries. The
8101 first entry in the procedure linkage table is reserved. */
8102 plt_index
= ((h
->plt
.offset
- htab
->plt_header_size
)
8103 / htab
->plt_entry_size
);
8107 bfd_vma got_offset
, got_address
, plt_address
;
8108 bfd_vma got_displacement
;
8112 sgot
= bfd_get_section_by_name (dynobj
, ".got.plt");
8113 BFD_ASSERT (sgot
!= NULL
);
8115 /* Get the offset into the .got.plt table of the entry that
8116 corresponds to this function. */
8117 got_offset
= eh
->plt_got_offset
;
8119 /* Get the index in the procedure linkage table which
8120 corresponds to this symbol. This is the index of this symbol
8121 in all the symbols for which we are making plt entries. The
8122 first three entries in .got.plt are reserved; after that
8123 symbols appear in the same order as in .plt. */
8124 plt_index
= (got_offset
- 12) / 4;
8126 /* Calculate the address of the GOT entry. */
8127 got_address
= (sgot
->output_section
->vma
8128 + sgot
->output_offset
8131 /* ...and the address of the PLT entry. */
8132 plt_address
= (splt
->output_section
->vma
8133 + splt
->output_offset
8136 ptr
= htab
->splt
->contents
+ h
->plt
.offset
;
8137 if (htab
->vxworks_p
&& info
->shared
)
8142 for (i
= 0; i
!= htab
->plt_entry_size
/ 4; i
++, ptr
+= 4)
8144 val
= elf32_arm_vxworks_shared_plt_entry
[i
];
8146 val
|= got_address
- sgot
->output_section
->vma
;
8148 val
|= plt_index
* RELOC_SIZE (htab
);
8149 if (i
== 2 || i
== 5)
8150 bfd_put_32 (output_bfd
, val
, ptr
);
8152 put_arm_insn (htab
, output_bfd
, val
, ptr
);
8155 else if (htab
->vxworks_p
)
8160 for (i
= 0; i
!= htab
->plt_entry_size
/ 4; i
++)
8162 val
= elf32_arm_vxworks_exec_plt_entry
[i
];
8166 val
|= 0xffffff & -((h
->plt
.offset
+ i
* 4 + 8) >> 2);
8168 val
|= plt_index
* RELOC_SIZE (htab
);
8169 if (i
== 2 || i
== 5)
8170 bfd_put_32 (output_bfd
, val
, ptr
);
8172 put_arm_insn (htab
, output_bfd
, val
, ptr
);
8175 loc
= (htab
->srelplt2
->contents
8176 + (plt_index
* 2 + 1) * RELOC_SIZE (htab
));
8178 /* Create the .rela.plt.unloaded R_ARM_ABS32 relocation
8179 referencing the GOT for this PLT entry. */
8180 rel
.r_offset
= plt_address
+ 8;
8181 rel
.r_info
= ELF32_R_INFO (htab
->root
.hgot
->indx
, R_ARM_ABS32
);
8182 rel
.r_addend
= got_offset
;
8183 SWAP_RELOC_OUT (htab
) (output_bfd
, &rel
, loc
);
8184 loc
+= RELOC_SIZE (htab
);
8186 /* Create the R_ARM_ABS32 relocation referencing the
8187 beginning of the PLT for this GOT entry. */
8188 rel
.r_offset
= got_address
;
8189 rel
.r_info
= ELF32_R_INFO (htab
->root
.hplt
->indx
, R_ARM_ABS32
);
8191 SWAP_RELOC_OUT (htab
) (output_bfd
, &rel
, loc
);
8195 /* Calculate the displacement between the PLT slot and the
8196 entry in the GOT. The eight-byte offset accounts for the
8197 value produced by adding to pc in the first instruction
8199 got_displacement
= got_address
- (plt_address
+ 8);
8201 BFD_ASSERT ((got_displacement
& 0xf0000000) == 0);
8203 if (!htab
->use_blx
&& eh
->plt_thumb_refcount
> 0)
8205 put_thumb_insn (htab
, output_bfd
,
8206 elf32_arm_plt_thumb_stub
[0], ptr
- 4);
8207 put_thumb_insn (htab
, output_bfd
,
8208 elf32_arm_plt_thumb_stub
[1], ptr
- 2);
8211 put_arm_insn (htab
, output_bfd
,
8212 elf32_arm_plt_entry
[0]
8213 | ((got_displacement
& 0x0ff00000) >> 20),
8215 put_arm_insn (htab
, output_bfd
,
8216 elf32_arm_plt_entry
[1]
8217 | ((got_displacement
& 0x000ff000) >> 12),
8219 put_arm_insn (htab
, output_bfd
,
8220 elf32_arm_plt_entry
[2]
8221 | (got_displacement
& 0x00000fff),
8223 #ifdef FOUR_WORD_PLT
8224 bfd_put_32 (output_bfd
, elf32_arm_plt_entry
[3], ptr
+ 12);
8228 /* Fill in the entry in the global offset table. */
8229 bfd_put_32 (output_bfd
,
8230 (splt
->output_section
->vma
8231 + splt
->output_offset
),
8232 sgot
->contents
+ got_offset
);
8234 /* Fill in the entry in the .rel(a).plt section. */
8236 rel
.r_offset
= got_address
;
8237 rel
.r_info
= ELF32_R_INFO (h
->dynindx
, R_ARM_JUMP_SLOT
);
8240 loc
= srel
->contents
+ plt_index
* RELOC_SIZE (htab
);
8241 SWAP_RELOC_OUT (htab
) (output_bfd
, &rel
, loc
);
8243 if (!h
->def_regular
)
8245 /* Mark the symbol as undefined, rather than as defined in
8246 the .plt section. Leave the value alone. */
8247 sym
->st_shndx
= SHN_UNDEF
;
8248 /* If the symbol is weak, we do need to clear the value.
8249 Otherwise, the PLT entry would provide a definition for
8250 the symbol even if the symbol wasn't defined anywhere,
8251 and so the symbol would never be NULL. */
8252 if (!h
->ref_regular_nonweak
)
8257 if (h
->got
.offset
!= (bfd_vma
) -1
8258 && (elf32_arm_hash_entry (h
)->tls_type
& GOT_TLS_GD
) == 0
8259 && (elf32_arm_hash_entry (h
)->tls_type
& GOT_TLS_IE
) == 0)
8263 Elf_Internal_Rela rel
;
8267 /* This symbol has an entry in the global offset table. Set it
8269 sgot
= bfd_get_section_by_name (dynobj
, ".got");
8270 srel
= bfd_get_section_by_name (dynobj
, RELOC_SECTION (htab
, ".got"));
8271 BFD_ASSERT (sgot
!= NULL
&& srel
!= NULL
);
8273 offset
= (h
->got
.offset
& ~(bfd_vma
) 1);
8275 rel
.r_offset
= (sgot
->output_section
->vma
8276 + sgot
->output_offset
8279 /* If this is a static link, or it is a -Bsymbolic link and the
8280 symbol is defined locally or was forced to be local because
8281 of a version file, we just want to emit a RELATIVE reloc.
8282 The entry in the global offset table will already have been
8283 initialized in the relocate_section function. */
8285 && SYMBOL_REFERENCES_LOCAL (info
, h
))
8287 BFD_ASSERT((h
->got
.offset
& 1) != 0);
8288 rel
.r_info
= ELF32_R_INFO (0, R_ARM_RELATIVE
);
8291 rel
.r_addend
= bfd_get_32 (output_bfd
, sgot
->contents
+ offset
);
8292 bfd_put_32 (output_bfd
, (bfd_vma
) 0, sgot
->contents
+ offset
);
8297 BFD_ASSERT((h
->got
.offset
& 1) == 0);
8298 bfd_put_32 (output_bfd
, (bfd_vma
) 0, sgot
->contents
+ offset
);
8299 rel
.r_info
= ELF32_R_INFO (h
->dynindx
, R_ARM_GLOB_DAT
);
8302 loc
= srel
->contents
+ srel
->reloc_count
++ * RELOC_SIZE (htab
);
8303 SWAP_RELOC_OUT (htab
) (output_bfd
, &rel
, loc
);
8309 Elf_Internal_Rela rel
;
8312 /* This symbol needs a copy reloc. Set it up. */
8313 BFD_ASSERT (h
->dynindx
!= -1
8314 && (h
->root
.type
== bfd_link_hash_defined
8315 || h
->root
.type
== bfd_link_hash_defweak
));
8317 s
= bfd_get_section_by_name (h
->root
.u
.def
.section
->owner
,
8318 RELOC_SECTION (htab
, ".bss"));
8319 BFD_ASSERT (s
!= NULL
);
8322 rel
.r_offset
= (h
->root
.u
.def
.value
8323 + h
->root
.u
.def
.section
->output_section
->vma
8324 + h
->root
.u
.def
.section
->output_offset
);
8325 rel
.r_info
= ELF32_R_INFO (h
->dynindx
, R_ARM_COPY
);
8326 loc
= s
->contents
+ s
->reloc_count
++ * RELOC_SIZE (htab
);
8327 SWAP_RELOC_OUT (htab
) (output_bfd
, &rel
, loc
);
8330 /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. On VxWorks,
8331 the _GLOBAL_OFFSET_TABLE_ symbol is not absolute: it is relative
8332 to the ".got" section. */
8333 if (strcmp (h
->root
.root
.string
, "_DYNAMIC") == 0
8334 || (!htab
->vxworks_p
&& h
== htab
->root
.hgot
))
8335 sym
->st_shndx
= SHN_ABS
;
8340 /* Finish up the dynamic sections. */
8343 elf32_arm_finish_dynamic_sections (bfd
* output_bfd
, struct bfd_link_info
* info
)
8349 dynobj
= elf_hash_table (info
)->dynobj
;
8351 sgot
= bfd_get_section_by_name (dynobj
, ".got.plt");
8352 BFD_ASSERT (elf32_arm_hash_table (info
)->symbian_p
|| sgot
!= NULL
);
8353 sdyn
= bfd_get_section_by_name (dynobj
, ".dynamic");
8355 if (elf_hash_table (info
)->dynamic_sections_created
)
8358 Elf32_External_Dyn
*dyncon
, *dynconend
;
8359 struct elf32_arm_link_hash_table
*htab
;
8361 htab
= elf32_arm_hash_table (info
);
8362 splt
= bfd_get_section_by_name (dynobj
, ".plt");
8363 BFD_ASSERT (splt
!= NULL
&& sdyn
!= NULL
);
8365 dyncon
= (Elf32_External_Dyn
*) sdyn
->contents
;
8366 dynconend
= (Elf32_External_Dyn
*) (sdyn
->contents
+ sdyn
->size
);
8368 for (; dyncon
< dynconend
; dyncon
++)
8370 Elf_Internal_Dyn dyn
;
8374 bfd_elf32_swap_dyn_in (dynobj
, dyncon
, &dyn
);
8385 goto get_vma_if_bpabi
;
8388 goto get_vma_if_bpabi
;
8391 goto get_vma_if_bpabi
;
8393 name
= ".gnu.version";
8394 goto get_vma_if_bpabi
;
8396 name
= ".gnu.version_d";
8397 goto get_vma_if_bpabi
;
8399 name
= ".gnu.version_r";
8400 goto get_vma_if_bpabi
;
8406 name
= RELOC_SECTION (htab
, ".plt");
8408 s
= bfd_get_section_by_name (output_bfd
, name
);
8409 BFD_ASSERT (s
!= NULL
);
8410 if (!htab
->symbian_p
)
8411 dyn
.d_un
.d_ptr
= s
->vma
;
8413 /* In the BPABI, tags in the PT_DYNAMIC section point
8414 at the file offset, not the memory address, for the
8415 convenience of the post linker. */
8416 dyn
.d_un
.d_ptr
= s
->filepos
;
8417 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
8421 if (htab
->symbian_p
)
8426 s
= bfd_get_section_by_name (output_bfd
,
8427 RELOC_SECTION (htab
, ".plt"));
8428 BFD_ASSERT (s
!= NULL
);
8429 dyn
.d_un
.d_val
= s
->size
;
8430 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
8435 if (!htab
->symbian_p
)
8437 /* My reading of the SVR4 ABI indicates that the
8438 procedure linkage table relocs (DT_JMPREL) should be
8439 included in the overall relocs (DT_REL). This is
8440 what Solaris does. However, UnixWare can not handle
8441 that case. Therefore, we override the DT_RELSZ entry
8442 here to make it not include the JMPREL relocs. Since
8443 the linker script arranges for .rel(a).plt to follow all
8444 other relocation sections, we don't have to worry
8445 about changing the DT_REL entry. */
8446 s
= bfd_get_section_by_name (output_bfd
,
8447 RELOC_SECTION (htab
, ".plt"));
8449 dyn
.d_un
.d_val
-= s
->size
;
8450 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
8457 /* In the BPABI, the DT_REL tag must point at the file
8458 offset, not the VMA, of the first relocation
8459 section. So, we use code similar to that in
8460 elflink.c, but do not check for SHF_ALLOC on the
8461 relcoation section, since relocations sections are
8462 never allocated under the BPABI. The comments above
8463 about Unixware notwithstanding, we include all of the
8464 relocations here. */
8465 if (htab
->symbian_p
)
8468 type
= ((dyn
.d_tag
== DT_REL
|| dyn
.d_tag
== DT_RELSZ
)
8469 ? SHT_REL
: SHT_RELA
);
8471 for (i
= 1; i
< elf_numsections (output_bfd
); i
++)
8473 Elf_Internal_Shdr
*hdr
8474 = elf_elfsections (output_bfd
)[i
];
8475 if (hdr
->sh_type
== type
)
8477 if (dyn
.d_tag
== DT_RELSZ
8478 || dyn
.d_tag
== DT_RELASZ
)
8479 dyn
.d_un
.d_val
+= hdr
->sh_size
;
8480 else if ((ufile_ptr
) hdr
->sh_offset
8481 <= dyn
.d_un
.d_val
- 1)
8482 dyn
.d_un
.d_val
= hdr
->sh_offset
;
8485 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
8489 /* Set the bottom bit of DT_INIT/FINI if the
8490 corresponding function is Thumb. */
8492 name
= info
->init_function
;
8495 name
= info
->fini_function
;
8497 /* If it wasn't set by elf_bfd_final_link
8498 then there is nothing to adjust. */
8499 if (dyn
.d_un
.d_val
!= 0)
8501 struct elf_link_hash_entry
* eh
;
8503 eh
= elf_link_hash_lookup (elf_hash_table (info
), name
,
8504 FALSE
, FALSE
, TRUE
);
8505 if (eh
!= (struct elf_link_hash_entry
*) NULL
8506 && ELF_ST_TYPE (eh
->type
) == STT_ARM_TFUNC
)
8508 dyn
.d_un
.d_val
|= 1;
8509 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
8516 /* Fill in the first entry in the procedure linkage table. */
8517 if (splt
->size
> 0 && elf32_arm_hash_table (info
)->plt_header_size
)
8519 const bfd_vma
*plt0_entry
;
8520 bfd_vma got_address
, plt_address
, got_displacement
;
8522 /* Calculate the addresses of the GOT and PLT. */
8523 got_address
= sgot
->output_section
->vma
+ sgot
->output_offset
;
8524 plt_address
= splt
->output_section
->vma
+ splt
->output_offset
;
8526 if (htab
->vxworks_p
)
8528 /* The VxWorks GOT is relocated by the dynamic linker.
8529 Therefore, we must emit relocations rather than simply
8530 computing the values now. */
8531 Elf_Internal_Rela rel
;
8533 plt0_entry
= elf32_arm_vxworks_exec_plt0_entry
;
8534 put_arm_insn (htab
, output_bfd
, plt0_entry
[0],
8535 splt
->contents
+ 0);
8536 put_arm_insn (htab
, output_bfd
, plt0_entry
[1],
8537 splt
->contents
+ 4);
8538 put_arm_insn (htab
, output_bfd
, plt0_entry
[2],
8539 splt
->contents
+ 8);
8540 bfd_put_32 (output_bfd
, got_address
, splt
->contents
+ 12);
8542 /* Generate a relocation for _GLOBAL_OFFSET_TABLE_. */
8543 rel
.r_offset
= plt_address
+ 12;
8544 rel
.r_info
= ELF32_R_INFO (htab
->root
.hgot
->indx
, R_ARM_ABS32
);
8546 SWAP_RELOC_OUT (htab
) (output_bfd
, &rel
,
8547 htab
->srelplt2
->contents
);
8551 got_displacement
= got_address
- (plt_address
+ 16);
8553 plt0_entry
= elf32_arm_plt0_entry
;
8554 put_arm_insn (htab
, output_bfd
, plt0_entry
[0],
8555 splt
->contents
+ 0);
8556 put_arm_insn (htab
, output_bfd
, plt0_entry
[1],
8557 splt
->contents
+ 4);
8558 put_arm_insn (htab
, output_bfd
, plt0_entry
[2],
8559 splt
->contents
+ 8);
8560 put_arm_insn (htab
, output_bfd
, plt0_entry
[3],
8561 splt
->contents
+ 12);
8563 #ifdef FOUR_WORD_PLT
8564 /* The displacement value goes in the otherwise-unused
8565 last word of the second entry. */
8566 bfd_put_32 (output_bfd
, got_displacement
, splt
->contents
+ 28);
8568 bfd_put_32 (output_bfd
, got_displacement
, splt
->contents
+ 16);
8573 /* UnixWare sets the entsize of .plt to 4, although that doesn't
8574 really seem like the right value. */
8575 elf_section_data (splt
->output_section
)->this_hdr
.sh_entsize
= 4;
8577 if (htab
->vxworks_p
&& !info
->shared
&& htab
->splt
->size
> 0)
8579 /* Correct the .rel(a).plt.unloaded relocations. They will have
8580 incorrect symbol indexes. */
8584 num_plts
= ((htab
->splt
->size
- htab
->plt_header_size
)
8585 / htab
->plt_entry_size
);
8586 p
= htab
->srelplt2
->contents
+ RELOC_SIZE (htab
);
8588 for (; num_plts
; num_plts
--)
8590 Elf_Internal_Rela rel
;
8592 SWAP_RELOC_IN (htab
) (output_bfd
, p
, &rel
);
8593 rel
.r_info
= ELF32_R_INFO (htab
->root
.hgot
->indx
, R_ARM_ABS32
);
8594 SWAP_RELOC_OUT (htab
) (output_bfd
, &rel
, p
);
8595 p
+= RELOC_SIZE (htab
);
8597 SWAP_RELOC_IN (htab
) (output_bfd
, p
, &rel
);
8598 rel
.r_info
= ELF32_R_INFO (htab
->root
.hplt
->indx
, R_ARM_ABS32
);
8599 SWAP_RELOC_OUT (htab
) (output_bfd
, &rel
, p
);
8600 p
+= RELOC_SIZE (htab
);
8605 /* Fill in the first three entries in the global offset table. */
8611 bfd_put_32 (output_bfd
, (bfd_vma
) 0, sgot
->contents
);
8613 bfd_put_32 (output_bfd
,
8614 sdyn
->output_section
->vma
+ sdyn
->output_offset
,
8616 bfd_put_32 (output_bfd
, (bfd_vma
) 0, sgot
->contents
+ 4);
8617 bfd_put_32 (output_bfd
, (bfd_vma
) 0, sgot
->contents
+ 8);
8620 elf_section_data (sgot
->output_section
)->this_hdr
.sh_entsize
= 4;
8627 elf32_arm_post_process_headers (bfd
* abfd
, struct bfd_link_info
* link_info ATTRIBUTE_UNUSED
)
8629 Elf_Internal_Ehdr
* i_ehdrp
; /* ELF file header, internal form. */
8630 struct elf32_arm_link_hash_table
*globals
;
8632 i_ehdrp
= elf_elfheader (abfd
);
8634 if (EF_ARM_EABI_VERSION (i_ehdrp
->e_flags
) == EF_ARM_EABI_UNKNOWN
)
8635 i_ehdrp
->e_ident
[EI_OSABI
] = ELFOSABI_ARM
;
8637 i_ehdrp
->e_ident
[EI_OSABI
] = 0;
8638 i_ehdrp
->e_ident
[EI_ABIVERSION
] = ARM_ELF_ABI_VERSION
;
8642 globals
= elf32_arm_hash_table (link_info
);
8643 if (globals
->byteswap_code
)
8644 i_ehdrp
->e_flags
|= EF_ARM_BE8
;
8648 static enum elf_reloc_type_class
8649 elf32_arm_reloc_type_class (const Elf_Internal_Rela
*rela
)
8651 switch ((int) ELF32_R_TYPE (rela
->r_info
))
8653 case R_ARM_RELATIVE
:
8654 return reloc_class_relative
;
8655 case R_ARM_JUMP_SLOT
:
8656 return reloc_class_plt
;
8658 return reloc_class_copy
;
8660 return reloc_class_normal
;
8664 /* Set the right machine number for an Arm ELF file. */
8667 elf32_arm_section_flags (flagword
*flags
, const Elf_Internal_Shdr
*hdr
)
8669 if (hdr
->sh_type
== SHT_NOTE
)
8670 *flags
|= SEC_LINK_ONCE
| SEC_LINK_DUPLICATES_SAME_CONTENTS
;
8676 elf32_arm_final_write_processing (bfd
*abfd
, bfd_boolean linker ATTRIBUTE_UNUSED
)
8678 bfd_arm_update_notes (abfd
, ARM_NOTE_SECTION
);
8681 /* Return TRUE if this is an unwinding table entry. */
8684 is_arm_elf_unwind_section_name (bfd
* abfd ATTRIBUTE_UNUSED
, const char * name
)
8688 len1
= sizeof (ELF_STRING_ARM_unwind
) - 1;
8689 len2
= sizeof (ELF_STRING_ARM_unwind_once
) - 1;
8690 return (strncmp (name
, ELF_STRING_ARM_unwind
, len1
) == 0
8691 || strncmp (name
, ELF_STRING_ARM_unwind_once
, len2
) == 0);
8695 /* Set the type and flags for an ARM section. We do this by
8696 the section name, which is a hack, but ought to work. */
8699 elf32_arm_fake_sections (bfd
* abfd
, Elf_Internal_Shdr
* hdr
, asection
* sec
)
8703 name
= bfd_get_section_name (abfd
, sec
);
8705 if (is_arm_elf_unwind_section_name (abfd
, name
))
8707 hdr
->sh_type
= SHT_ARM_EXIDX
;
8708 hdr
->sh_flags
|= SHF_LINK_ORDER
;
8710 else if (strcmp(name
, ".ARM.attributes") == 0)
8712 hdr
->sh_type
= SHT_ARM_ATTRIBUTES
;
8717 /* Parse an Arm EABI attributes section. */
8719 elf32_arm_parse_attributes (bfd
*abfd
, Elf_Internal_Shdr
* hdr
)
8725 contents
= bfd_malloc (hdr
->sh_size
);
8728 if (!bfd_get_section_contents (abfd
, hdr
->bfd_section
, contents
, 0,
8737 len
= hdr
->sh_size
- 1;
8741 bfd_vma section_len
;
8743 section_len
= bfd_get_32 (abfd
, p
);
8745 if (section_len
> len
)
8748 namelen
= strlen ((char *)p
) + 1;
8749 section_len
-= namelen
+ 4;
8750 if (strcmp((char *)p
, "aeabi") != 0)
8752 /* Vendor section. Ignore it. */
8753 p
+= namelen
+ section_len
;
8758 while (section_len
> 0)
8763 bfd_vma subsection_len
;
8766 tag
= read_unsigned_leb128 (abfd
, p
, &n
);
8768 subsection_len
= bfd_get_32 (abfd
, p
);
8770 if (subsection_len
> section_len
)
8771 subsection_len
= section_len
;
8772 section_len
-= subsection_len
;
8773 subsection_len
-= n
+ 4;
8774 end
= p
+ subsection_len
;
8780 bfd_boolean is_string
;
8782 tag
= read_unsigned_leb128 (abfd
, p
, &n
);
8784 if (tag
== 4 || tag
== 5)
8789 is_string
= (tag
& 1) != 0;
8790 if (tag
== Tag_compatibility
)
8792 val
= read_unsigned_leb128 (abfd
, p
, &n
);
8794 elf32_arm_add_eabi_attr_compat (abfd
, val
,
8796 p
+= strlen ((char *)p
) + 1;
8800 elf32_arm_add_eabi_attr_string (abfd
, tag
,
8802 p
+= strlen ((char *)p
) + 1;
8806 val
= read_unsigned_leb128 (abfd
, p
, &n
);
8808 elf32_arm_add_eabi_attr_int (abfd
, tag
, val
);
8814 /* Don't have anywhere convenient to attach these.
8815 Fall through for now. */
8817 /* Ignore things we don't kow about. */
8818 p
+= subsection_len
;
8829 /* Handle an ARM specific section when reading an object file. This is
8830 called when bfd_section_from_shdr finds a section with an unknown
8834 elf32_arm_section_from_shdr (bfd
*abfd
,
8835 Elf_Internal_Shdr
* hdr
,
8839 /* There ought to be a place to keep ELF backend specific flags, but
8840 at the moment there isn't one. We just keep track of the
8841 sections by their name, instead. Fortunately, the ABI gives
8842 names for all the ARM specific sections, so we will probably get
8844 switch (hdr
->sh_type
)
8847 case SHT_ARM_PREEMPTMAP
:
8848 case SHT_ARM_ATTRIBUTES
:
8855 if (! _bfd_elf_make_section_from_shdr (abfd
, hdr
, name
, shindex
))
8858 if (hdr
->sh_type
== SHT_ARM_ATTRIBUTES
)
8859 elf32_arm_parse_attributes(abfd
, hdr
);
8863 /* A structure used to record a list of sections, independently
8864 of the next and prev fields in the asection structure. */
8865 typedef struct section_list
8868 struct section_list
* next
;
8869 struct section_list
* prev
;
8873 /* Unfortunately we need to keep a list of sections for which
8874 an _arm_elf_section_data structure has been allocated. This
8875 is because it is possible for functions like elf32_arm_write_section
8876 to be called on a section which has had an elf_data_structure
8877 allocated for it (and so the used_by_bfd field is valid) but
8878 for which the ARM extended version of this structure - the
8879 _arm_elf_section_data structure - has not been allocated. */
8880 static section_list
* sections_with_arm_elf_section_data
= NULL
;
8883 record_section_with_arm_elf_section_data (asection
* sec
)
8885 struct section_list
* entry
;
8887 entry
= bfd_malloc (sizeof (* entry
));
8891 entry
->next
= sections_with_arm_elf_section_data
;
8893 if (entry
->next
!= NULL
)
8894 entry
->next
->prev
= entry
;
8895 sections_with_arm_elf_section_data
= entry
;
8898 static struct section_list
*
8899 find_arm_elf_section_entry (asection
* sec
)
8901 struct section_list
* entry
;
8902 static struct section_list
* last_entry
= NULL
;
8904 /* This is a short cut for the typical case where the sections are added
8905 to the sections_with_arm_elf_section_data list in forward order and
8906 then looked up here in backwards order. This makes a real difference
8907 to the ld-srec/sec64k.exp linker test. */
8908 entry
= sections_with_arm_elf_section_data
;
8909 if (last_entry
!= NULL
)
8911 if (last_entry
->sec
== sec
)
8913 else if (last_entry
->next
!= NULL
8914 && last_entry
->next
->sec
== sec
)
8915 entry
= last_entry
->next
;
8918 for (; entry
; entry
= entry
->next
)
8919 if (entry
->sec
== sec
)
8923 /* Record the entry prior to this one - it is the entry we are most
8924 likely to want to locate next time. Also this way if we have been
8925 called from unrecord_section_with_arm_elf_section_data() we will not
8926 be caching a pointer that is about to be freed. */
8927 last_entry
= entry
->prev
;
8932 static _arm_elf_section_data
*
8933 get_arm_elf_section_data (asection
* sec
)
8935 struct section_list
* entry
;
8937 entry
= find_arm_elf_section_entry (sec
);
8940 return elf32_arm_section_data (entry
->sec
);
8946 unrecord_section_with_arm_elf_section_data (asection
* sec
)
8948 struct section_list
* entry
;
8950 entry
= find_arm_elf_section_entry (sec
);
8954 if (entry
->prev
!= NULL
)
8955 entry
->prev
->next
= entry
->next
;
8956 if (entry
->next
!= NULL
)
8957 entry
->next
->prev
= entry
->prev
;
8958 if (entry
== sections_with_arm_elf_section_data
)
8959 sections_with_arm_elf_section_data
= entry
->next
;
8964 /* Called for each symbol. Builds a section map based on mapping symbols.
8965 Does not alter any of the symbols. */
8968 elf32_arm_output_symbol_hook (struct bfd_link_info
*info
,
8970 Elf_Internal_Sym
*elfsym
,
8971 asection
*input_sec
,
8972 struct elf_link_hash_entry
*h
)
8975 elf32_arm_section_map
*map
;
8976 elf32_arm_section_map
*newmap
;
8977 _arm_elf_section_data
*arm_data
;
8978 struct elf32_arm_link_hash_table
*globals
;
8980 globals
= elf32_arm_hash_table (info
);
8981 if (globals
->vxworks_p
8982 && !elf_vxworks_link_output_symbol_hook (info
, name
, elfsym
,
8986 /* Only do this on final link. */
8987 if (info
->relocatable
)
8990 /* Only build a map if we need to byteswap code. */
8991 if (!globals
->byteswap_code
)
8994 /* We only want mapping symbols. */
8995 if (!bfd_is_arm_special_symbol_name (name
, BFD_ARM_SPECIAL_SYM_TYPE_MAP
))
8998 /* If this section has not been allocated an _arm_elf_section_data
8999 structure then we cannot record anything. */
9000 arm_data
= get_arm_elf_section_data (input_sec
);
9001 if (arm_data
== NULL
)
9004 mapcount
= arm_data
->mapcount
+ 1;
9005 map
= arm_data
->map
;
9007 /* TODO: This may be inefficient, but we probably don't usually have many
9008 mapping symbols per section. */
9009 newmap
= bfd_realloc (map
, mapcount
* sizeof (* map
));
9012 arm_data
->map
= newmap
;
9013 arm_data
->mapcount
= mapcount
;
9015 newmap
[mapcount
- 1].vma
= elfsym
->st_value
;
9016 newmap
[mapcount
- 1].type
= name
[1];
9025 struct bfd_link_info
*info
;
9028 bfd_boolean (*func
) (void *, const char *, Elf_Internal_Sym
*,
9029 asection
*, struct elf_link_hash_entry
*);
9030 } output_arch_syminfo
;
9032 enum map_symbol_type
9040 /* Output a single PLT mapping symbol. */
9043 elf32_arm_ouput_plt_map_sym (output_arch_syminfo
*osi
,
9044 enum map_symbol_type type
,
9047 static const char *names
[3] = {"$a", "$t", "$d"};
9048 struct elf32_arm_link_hash_table
*htab
;
9049 Elf_Internal_Sym sym
;
9051 htab
= elf32_arm_hash_table (osi
->info
);
9052 sym
.st_value
= osi
->plt_offset
+ offset
;
9055 sym
.st_info
= ELF_ST_INFO (STB_LOCAL
, STT_NOTYPE
);
9056 sym
.st_shndx
= osi
->plt_shndx
;
9057 if (!osi
->func (osi
->finfo
, names
[type
], &sym
, htab
->splt
, NULL
))
9063 /* Output mapping symbols for PLT entries associated with H. */
9066 elf32_arm_output_plt_map (struct elf_link_hash_entry
*h
, void *inf
)
9068 output_arch_syminfo
*osi
= (output_arch_syminfo
*) inf
;
9069 struct elf32_arm_link_hash_table
*htab
;
9070 struct elf32_arm_link_hash_entry
*eh
;
9073 htab
= elf32_arm_hash_table (osi
->info
);
9075 if (h
->root
.type
== bfd_link_hash_indirect
)
9078 if (h
->root
.type
== bfd_link_hash_warning
)
9079 /* When warning symbols are created, they **replace** the "real"
9080 entry in the hash table, thus we never get to see the real
9081 symbol in a hash traversal. So look at it now. */
9082 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
9084 if (h
->plt
.offset
== (bfd_vma
) -1)
9087 eh
= (struct elf32_arm_link_hash_entry
*) h
;
9088 addr
= h
->plt
.offset
;
9089 if (htab
->symbian_p
)
9091 if (!elf32_arm_ouput_plt_map_sym (osi
, ARM_MAP_ARM
, addr
))
9093 if (!elf32_arm_ouput_plt_map_sym (osi
, ARM_MAP_DATA
, addr
+ 4))
9096 else if (htab
->vxworks_p
)
9098 if (!elf32_arm_ouput_plt_map_sym (osi
, ARM_MAP_ARM
, addr
))
9100 if (!elf32_arm_ouput_plt_map_sym (osi
, ARM_MAP_DATA
, addr
+ 8))
9102 if (!elf32_arm_ouput_plt_map_sym (osi
, ARM_MAP_ARM
, addr
+ 12))
9104 if (!elf32_arm_ouput_plt_map_sym (osi
, ARM_MAP_DATA
, addr
+ 20))
9109 bfd_boolean thumb_stub
;
9111 thumb_stub
= eh
->plt_thumb_refcount
> 0 && !htab
->use_blx
;
9114 if (!elf32_arm_ouput_plt_map_sym (osi
, ARM_MAP_THUMB
, addr
- 4))
9117 #ifdef FOUR_WORD_PLT
9118 if (!elf32_arm_ouput_plt_map_sym (osi
, ARM_MAP_ARM
, addr
))
9120 if (!elf32_arm_ouput_plt_map_sym (osi
, ARM_MAP_DATA
, addr
+ 12))
9123 /* A three-word PLT with no Thumb thunk contains only Arm code,
9124 so only need to output a mapping symbol for the first PLT entry and
9125 entries with thumb thunks. */
9126 if (thumb_stub
|| addr
== 20)
9128 if (!elf32_arm_ouput_plt_map_sym (osi
, ARM_MAP_ARM
, addr
))
9138 /* Output mapping symbols for the PLT. */
9141 elf32_arm_output_arch_local_syms (bfd
*output_bfd
,
9142 struct bfd_link_info
*info
,
9143 void *finfo
, bfd_boolean (*func
) (void *, const char *,
9146 struct elf_link_hash_entry
*))
9148 output_arch_syminfo osi
;
9149 struct elf32_arm_link_hash_table
*htab
;
9151 htab
= elf32_arm_hash_table (info
);
9152 if (!htab
->splt
|| htab
->splt
->size
== 0)
9155 check_use_blx(htab
);
9159 osi
.plt_shndx
= _bfd_elf_section_from_bfd_section (output_bfd
,
9160 htab
->splt
->output_section
);
9161 osi
.plt_offset
= htab
->splt
->output_section
->vma
;
9163 /* Output mapping symbols for the plt header. SymbianOS does not have a
9165 if (htab
->vxworks_p
)
9167 /* VxWorks shared libraries have no PLT header. */
9170 if (!elf32_arm_ouput_plt_map_sym (&osi
, ARM_MAP_ARM
, 0))
9172 if (!elf32_arm_ouput_plt_map_sym (&osi
, ARM_MAP_DATA
, 12))
9176 else if (!htab
->symbian_p
)
9178 if (!elf32_arm_ouput_plt_map_sym (&osi
, ARM_MAP_ARM
, 0))
9180 #ifndef FOUR_WORD_PLT
9181 if (!elf32_arm_ouput_plt_map_sym (&osi
, ARM_MAP_DATA
, 16))
9186 elf_link_hash_traverse (&htab
->root
, elf32_arm_output_plt_map
, (void *) &osi
);
9190 /* Allocate target specific section data. */
9193 elf32_arm_new_section_hook (bfd
*abfd
, asection
*sec
)
9195 _arm_elf_section_data
*sdata
;
9196 bfd_size_type amt
= sizeof (*sdata
);
9198 sdata
= bfd_zalloc (abfd
, amt
);
9201 sec
->used_by_bfd
= sdata
;
9203 record_section_with_arm_elf_section_data (sec
);
9205 return _bfd_elf_new_section_hook (abfd
, sec
);
9209 /* Used to order a list of mapping symbols by address. */
9212 elf32_arm_compare_mapping (const void * a
, const void * b
)
9214 return ((const elf32_arm_section_map
*) a
)->vma
9215 > ((const elf32_arm_section_map
*) b
)->vma
;
9219 /* Do code byteswapping. Return FALSE afterwards so that the section is
9220 written out as normal. */
9223 elf32_arm_write_section (bfd
*output_bfd ATTRIBUTE_UNUSED
, asection
*sec
,
9227 _arm_elf_section_data
*arm_data
;
9228 elf32_arm_section_map
*map
;
9235 /* If this section has not been allocated an _arm_elf_section_data
9236 structure then we cannot record anything. */
9237 arm_data
= get_arm_elf_section_data (sec
);
9238 if (arm_data
== NULL
)
9241 mapcount
= arm_data
->mapcount
;
9242 map
= arm_data
->map
;
9247 qsort (map
, mapcount
, sizeof (* map
), elf32_arm_compare_mapping
);
9249 offset
= sec
->output_section
->vma
+ sec
->output_offset
;
9250 ptr
= map
[0].vma
- offset
;
9251 for (i
= 0; i
< mapcount
; i
++)
9253 if (i
== mapcount
- 1)
9256 end
= map
[i
+ 1].vma
- offset
;
9258 switch (map
[i
].type
)
9261 /* Byte swap code words. */
9262 while (ptr
+ 3 < end
)
9264 tmp
= contents
[ptr
];
9265 contents
[ptr
] = contents
[ptr
+ 3];
9266 contents
[ptr
+ 3] = tmp
;
9267 tmp
= contents
[ptr
+ 1];
9268 contents
[ptr
+ 1] = contents
[ptr
+ 2];
9269 contents
[ptr
+ 2] = tmp
;
9275 /* Byte swap code halfwords. */
9276 while (ptr
+ 1 < end
)
9278 tmp
= contents
[ptr
];
9279 contents
[ptr
] = contents
[ptr
+ 1];
9280 contents
[ptr
+ 1] = tmp
;
9286 /* Leave data alone. */
9293 arm_data
->mapcount
= 0;
9294 arm_data
->map
= NULL
;
9295 unrecord_section_with_arm_elf_section_data (sec
);
9301 unrecord_section_via_map_over_sections (bfd
* abfd ATTRIBUTE_UNUSED
,
9303 void * ignore ATTRIBUTE_UNUSED
)
9305 unrecord_section_with_arm_elf_section_data (sec
);
9309 elf32_arm_close_and_cleanup (bfd
* abfd
)
9311 bfd_map_over_sections (abfd
, unrecord_section_via_map_over_sections
, NULL
);
9313 return _bfd_elf_close_and_cleanup (abfd
);
9316 /* Display STT_ARM_TFUNC symbols as functions. */
9319 elf32_arm_symbol_processing (bfd
*abfd ATTRIBUTE_UNUSED
,
9322 elf_symbol_type
*elfsym
= (elf_symbol_type
*) asym
;
9324 if (ELF_ST_TYPE (elfsym
->internal_elf_sym
.st_info
) == STT_ARM_TFUNC
)
9325 elfsym
->symbol
.flags
|= BSF_FUNCTION
;
9329 /* Mangle thumb function symbols as we read them in. */
9332 elf32_arm_swap_symbol_in (bfd
* abfd
,
9335 Elf_Internal_Sym
*dst
)
9337 bfd_elf32_swap_symbol_in (abfd
, psrc
, pshn
, dst
);
9339 /* New EABI objects mark thumb function symbols by setting the low bit of
9340 the address. Turn these into STT_ARM_TFUNC. */
9341 if (ELF_ST_TYPE (dst
->st_info
) == STT_FUNC
9342 && (dst
->st_value
& 1))
9344 dst
->st_info
= ELF_ST_INFO (ELF_ST_BIND (dst
->st_info
), STT_ARM_TFUNC
);
9345 dst
->st_value
&= ~(bfd_vma
) 1;
9350 /* Mangle thumb function symbols as we write them out. */
9353 elf32_arm_swap_symbol_out (bfd
*abfd
,
9354 const Elf_Internal_Sym
*src
,
9358 Elf_Internal_Sym newsym
;
9360 /* We convert STT_ARM_TFUNC symbols into STT_FUNC with the low bit
9361 of the address set, as per the new EABI. We do this unconditionally
9362 because objcopy does not set the elf header flags until after
9363 it writes out the symbol table. */
9364 if (ELF_ST_TYPE (src
->st_info
) == STT_ARM_TFUNC
)
9367 newsym
.st_info
= ELF_ST_INFO (ELF_ST_BIND (src
->st_info
), STT_FUNC
);
9368 if (newsym
.st_shndx
!= SHN_UNDEF
)
9370 /* Do this only for defined symbols. At link type, the static
9371 linker will simulate the work of dynamic linker of resolving
9372 symbols and will carry over the thumbness of found symbols to
9373 the output symbol table. It's not clear how it happens, but
9374 the thumbness of underfined symbols can well be different at
9375 runtime, and writing '1' for them will be confusing for users
9376 and possibly for dynamic linker itself.
9378 newsym
.st_value
|= 1;
9381 newsym
.st_value
|= 1;
9385 bfd_elf32_swap_symbol_out (abfd
, src
, cdst
, shndx
);
9388 /* Add the PT_ARM_EXIDX program header. */
9391 elf32_arm_modify_segment_map (bfd
*abfd
,
9392 struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
9394 struct elf_segment_map
*m
;
9397 sec
= bfd_get_section_by_name (abfd
, ".ARM.exidx");
9398 if (sec
!= NULL
&& (sec
->flags
& SEC_LOAD
) != 0)
9400 /* If there is already a PT_ARM_EXIDX header, then we do not
9401 want to add another one. This situation arises when running
9402 "strip"; the input binary already has the header. */
9403 m
= elf_tdata (abfd
)->segment_map
;
9404 while (m
&& m
->p_type
!= PT_ARM_EXIDX
)
9408 m
= bfd_zalloc (abfd
, sizeof (struct elf_segment_map
));
9411 m
->p_type
= PT_ARM_EXIDX
;
9413 m
->sections
[0] = sec
;
9415 m
->next
= elf_tdata (abfd
)->segment_map
;
9416 elf_tdata (abfd
)->segment_map
= m
;
9423 /* We may add a PT_ARM_EXIDX program header. */
9426 elf32_arm_additional_program_headers (bfd
*abfd
)
9430 sec
= bfd_get_section_by_name (abfd
, ".ARM.exidx");
9431 if (sec
!= NULL
&& (sec
->flags
& SEC_LOAD
) != 0)
9437 /* We use this to override swap_symbol_in and swap_symbol_out. */
9438 const struct elf_size_info elf32_arm_size_info
= {
9439 sizeof (Elf32_External_Ehdr
),
9440 sizeof (Elf32_External_Phdr
),
9441 sizeof (Elf32_External_Shdr
),
9442 sizeof (Elf32_External_Rel
),
9443 sizeof (Elf32_External_Rela
),
9444 sizeof (Elf32_External_Sym
),
9445 sizeof (Elf32_External_Dyn
),
9446 sizeof (Elf_External_Note
),
9450 ELFCLASS32
, EV_CURRENT
,
9451 bfd_elf32_write_out_phdrs
,
9452 bfd_elf32_write_shdrs_and_ehdr
,
9453 bfd_elf32_write_relocs
,
9454 elf32_arm_swap_symbol_in
,
9455 elf32_arm_swap_symbol_out
,
9456 bfd_elf32_slurp_reloc_table
,
9457 bfd_elf32_slurp_symbol_table
,
9458 bfd_elf32_swap_dyn_in
,
9459 bfd_elf32_swap_dyn_out
,
9460 bfd_elf32_swap_reloc_in
,
9461 bfd_elf32_swap_reloc_out
,
9462 bfd_elf32_swap_reloca_in
,
9463 bfd_elf32_swap_reloca_out
9466 #define ELF_ARCH bfd_arch_arm
9467 #define ELF_MACHINE_CODE EM_ARM
9468 #ifdef __QNXTARGET__
9469 #define ELF_MAXPAGESIZE 0x1000
9471 #define ELF_MAXPAGESIZE 0x8000
9473 #define ELF_MINPAGESIZE 0x1000
9475 #define bfd_elf32_mkobject elf32_arm_mkobject
9477 #define bfd_elf32_bfd_copy_private_bfd_data elf32_arm_copy_private_bfd_data
9478 #define bfd_elf32_bfd_merge_private_bfd_data elf32_arm_merge_private_bfd_data
9479 #define bfd_elf32_bfd_set_private_flags elf32_arm_set_private_flags
9480 #define bfd_elf32_bfd_print_private_bfd_data elf32_arm_print_private_bfd_data
9481 #define bfd_elf32_bfd_link_hash_table_create elf32_arm_link_hash_table_create
9482 #define bfd_elf32_bfd_reloc_type_lookup elf32_arm_reloc_type_lookup
9483 #define bfd_elf32_find_nearest_line elf32_arm_find_nearest_line
9484 #define bfd_elf32_find_inliner_info elf32_arm_find_inliner_info
9485 #define bfd_elf32_new_section_hook elf32_arm_new_section_hook
9486 #define bfd_elf32_bfd_is_target_special_symbol elf32_arm_is_target_special_symbol
9487 #define bfd_elf32_close_and_cleanup elf32_arm_close_and_cleanup
9488 #define bfd_elf32_bfd_final_link elf32_arm_bfd_final_link
9490 #define elf_backend_get_symbol_type elf32_arm_get_symbol_type
9491 #define elf_backend_gc_mark_hook elf32_arm_gc_mark_hook
9492 #define elf_backend_gc_sweep_hook elf32_arm_gc_sweep_hook
9493 #define elf_backend_check_relocs elf32_arm_check_relocs
9494 #define elf_backend_relocate_section elf32_arm_relocate_section
9495 #define elf_backend_write_section elf32_arm_write_section
9496 #define elf_backend_adjust_dynamic_symbol elf32_arm_adjust_dynamic_symbol
9497 #define elf_backend_create_dynamic_sections elf32_arm_create_dynamic_sections
9498 #define elf_backend_finish_dynamic_symbol elf32_arm_finish_dynamic_symbol
9499 #define elf_backend_finish_dynamic_sections elf32_arm_finish_dynamic_sections
9500 #define elf_backend_link_output_symbol_hook elf32_arm_output_symbol_hook
9501 #define elf_backend_size_dynamic_sections elf32_arm_size_dynamic_sections
9502 #define elf_backend_post_process_headers elf32_arm_post_process_headers
9503 #define elf_backend_reloc_type_class elf32_arm_reloc_type_class
9504 #define elf_backend_object_p elf32_arm_object_p
9505 #define elf_backend_section_flags elf32_arm_section_flags
9506 #define elf_backend_fake_sections elf32_arm_fake_sections
9507 #define elf_backend_section_from_shdr elf32_arm_section_from_shdr
9508 #define elf_backend_final_write_processing elf32_arm_final_write_processing
9509 #define elf_backend_copy_indirect_symbol elf32_arm_copy_indirect_symbol
9510 #define elf_backend_symbol_processing elf32_arm_symbol_processing
9511 #define elf_backend_size_info elf32_arm_size_info
9512 #define elf_backend_modify_segment_map elf32_arm_modify_segment_map
9513 #define elf_backend_additional_program_headers \
9514 elf32_arm_additional_program_headers
9515 #define elf_backend_output_arch_local_syms \
9516 elf32_arm_output_arch_local_syms
9517 #define elf_backend_begin_write_processing \
9518 elf32_arm_begin_write_processing
9520 #define elf_backend_can_refcount 1
9521 #define elf_backend_can_gc_sections 1
9522 #define elf_backend_plt_readonly 1
9523 #define elf_backend_want_got_plt 1
9524 #define elf_backend_want_plt_sym 0
9525 #define elf_backend_may_use_rel_p 1
9526 #define elf_backend_may_use_rela_p 0
9527 #define elf_backend_default_use_rela_p 0
9528 #define elf_backend_rela_normal 0
9530 #define elf_backend_got_header_size 12
9532 #include "elf32-target.h"
9534 /* VxWorks Targets */
9536 #undef TARGET_LITTLE_SYM
9537 #define TARGET_LITTLE_SYM bfd_elf32_littlearm_vxworks_vec
9538 #undef TARGET_LITTLE_NAME
9539 #define TARGET_LITTLE_NAME "elf32-littlearm-vxworks"
9540 #undef TARGET_BIG_SYM
9541 #define TARGET_BIG_SYM bfd_elf32_bigarm_vxworks_vec
9542 #undef TARGET_BIG_NAME
9543 #define TARGET_BIG_NAME "elf32-bigarm-vxworks"
9545 /* Like elf32_arm_link_hash_table_create -- but overrides
9546 appropriately for VxWorks. */
9547 static struct bfd_link_hash_table
*
9548 elf32_arm_vxworks_link_hash_table_create (bfd
*abfd
)
9550 struct bfd_link_hash_table
*ret
;
9552 ret
= elf32_arm_link_hash_table_create (abfd
);
9555 struct elf32_arm_link_hash_table
*htab
9556 = (struct elf32_arm_link_hash_table
*) ret
;
9558 htab
->vxworks_p
= 1;
9564 elf32_arm_vxworks_final_write_processing (bfd
*abfd
, bfd_boolean linker
)
9566 elf32_arm_final_write_processing (abfd
, linker
);
9567 elf_vxworks_final_write_processing (abfd
, linker
);
9571 #define elf32_bed elf32_arm_vxworks_bed
9573 #undef bfd_elf32_bfd_link_hash_table_create
9574 #define bfd_elf32_bfd_link_hash_table_create \
9575 elf32_arm_vxworks_link_hash_table_create
9576 #undef elf_backend_add_symbol_hook
9577 #define elf_backend_add_symbol_hook \
9578 elf_vxworks_add_symbol_hook
9579 #undef elf_backend_final_write_processing
9580 #define elf_backend_final_write_processing \
9581 elf32_arm_vxworks_final_write_processing
9582 #undef elf_backend_emit_relocs
9583 #define elf_backend_emit_relocs \
9584 elf_vxworks_emit_relocs
9586 #undef elf_backend_may_use_rel_p
9587 #define elf_backend_may_use_rel_p 0
9588 #undef elf_backend_may_use_rela_p
9589 #define elf_backend_may_use_rela_p 1
9590 #undef elf_backend_default_use_rela_p
9591 #define elf_backend_default_use_rela_p 1
9592 #undef elf_backend_rela_normal
9593 #define elf_backend_rela_normal 1
9594 #undef elf_backend_want_plt_sym
9595 #define elf_backend_want_plt_sym 1
9596 #undef ELF_MAXPAGESIZE
9597 #define ELF_MAXPAGESIZE 0x1000
9599 #include "elf32-target.h"
9602 /* Symbian OS Targets */
9604 #undef TARGET_LITTLE_SYM
9605 #define TARGET_LITTLE_SYM bfd_elf32_littlearm_symbian_vec
9606 #undef TARGET_LITTLE_NAME
9607 #define TARGET_LITTLE_NAME "elf32-littlearm-symbian"
9608 #undef TARGET_BIG_SYM
9609 #define TARGET_BIG_SYM bfd_elf32_bigarm_symbian_vec
9610 #undef TARGET_BIG_NAME
9611 #define TARGET_BIG_NAME "elf32-bigarm-symbian"
9613 /* Like elf32_arm_link_hash_table_create -- but overrides
9614 appropriately for Symbian OS. */
9615 static struct bfd_link_hash_table
*
9616 elf32_arm_symbian_link_hash_table_create (bfd
*abfd
)
9618 struct bfd_link_hash_table
*ret
;
9620 ret
= elf32_arm_link_hash_table_create (abfd
);
9623 struct elf32_arm_link_hash_table
*htab
9624 = (struct elf32_arm_link_hash_table
*)ret
;
9625 /* There is no PLT header for Symbian OS. */
9626 htab
->plt_header_size
= 0;
9627 /* The PLT entries are each three instructions. */
9628 htab
->plt_entry_size
= 4 * NUM_ELEM (elf32_arm_symbian_plt_entry
);
9629 htab
->symbian_p
= 1;
9630 /* Symbian uses armv5t or above, so use_blx is always true. */
9632 htab
->root
.is_relocatable_executable
= 1;
9637 static const struct bfd_elf_special_section
9638 elf32_arm_symbian_special_sections
[] =
9640 /* In a BPABI executable, the dynamic linking sections do not go in
9641 the loadable read-only segment. The post-linker may wish to
9642 refer to these sections, but they are not part of the final
9644 { ".dynamic", 8, 0, SHT_DYNAMIC
, 0 },
9645 { ".dynstr", 7, 0, SHT_STRTAB
, 0 },
9646 { ".dynsym", 7, 0, SHT_DYNSYM
, 0 },
9647 { ".got", 4, 0, SHT_PROGBITS
, 0 },
9648 { ".hash", 5, 0, SHT_HASH
, 0 },
9649 /* These sections do not need to be writable as the SymbianOS
9650 postlinker will arrange things so that no dynamic relocation is
9652 { ".init_array", 11, 0, SHT_INIT_ARRAY
, SHF_ALLOC
},
9653 { ".fini_array", 11, 0, SHT_FINI_ARRAY
, SHF_ALLOC
},
9654 { ".preinit_array", 14, 0, SHT_PREINIT_ARRAY
, SHF_ALLOC
},
9655 { NULL
, 0, 0, 0, 0 }
9659 elf32_arm_symbian_begin_write_processing (bfd
*abfd
,
9660 struct bfd_link_info
*link_info
)
9662 /* BPABI objects are never loaded directly by an OS kernel; they are
9663 processed by a postlinker first, into an OS-specific format. If
9664 the D_PAGED bit is set on the file, BFD will align segments on
9665 page boundaries, so that an OS can directly map the file. With
9666 BPABI objects, that just results in wasted space. In addition,
9667 because we clear the D_PAGED bit, map_sections_to_segments will
9668 recognize that the program headers should not be mapped into any
9669 loadable segment. */
9670 abfd
->flags
&= ~D_PAGED
;
9671 elf32_arm_begin_write_processing(abfd
, link_info
);
9675 elf32_arm_symbian_modify_segment_map (bfd
*abfd
,
9676 struct bfd_link_info
*info
)
9678 struct elf_segment_map
*m
;
9681 /* BPABI shared libraries and executables should have a PT_DYNAMIC
9682 segment. However, because the .dynamic section is not marked
9683 with SEC_LOAD, the generic ELF code will not create such a
9685 dynsec
= bfd_get_section_by_name (abfd
, ".dynamic");
9688 m
= _bfd_elf_make_dynamic_segment (abfd
, dynsec
);
9689 m
->next
= elf_tdata (abfd
)->segment_map
;
9690 elf_tdata (abfd
)->segment_map
= m
;
9693 /* Also call the generic arm routine. */
9694 return elf32_arm_modify_segment_map (abfd
, info
);
9698 #define elf32_bed elf32_arm_symbian_bed
9700 /* The dynamic sections are not allocated on SymbianOS; the postlinker
9701 will process them and then discard them. */
9702 #undef ELF_DYNAMIC_SEC_FLAGS
9703 #define ELF_DYNAMIC_SEC_FLAGS \
9704 (SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED)
9706 #undef bfd_elf32_bfd_link_hash_table_create
9707 #define bfd_elf32_bfd_link_hash_table_create \
9708 elf32_arm_symbian_link_hash_table_create
9709 #undef elf_backend_add_symbol_hook
9711 #undef elf_backend_special_sections
9712 #define elf_backend_special_sections elf32_arm_symbian_special_sections
9714 #undef elf_backend_begin_write_processing
9715 #define elf_backend_begin_write_processing \
9716 elf32_arm_symbian_begin_write_processing
9717 #undef elf_backend_final_write_processing
9718 #define elf_backend_final_write_processing \
9719 elf32_arm_final_write_processing
9720 #undef elf_backend_emit_relocs
9722 #undef elf_backend_modify_segment_map
9723 #define elf_backend_modify_segment_map elf32_arm_symbian_modify_segment_map
9725 /* There is no .got section for BPABI objects, and hence no header. */
9726 #undef elf_backend_got_header_size
9727 #define elf_backend_got_header_size 0
9729 /* Similarly, there is no .got.plt section. */
9730 #undef elf_backend_want_got_plt
9731 #define elf_backend_want_got_plt 0
9733 #undef elf_backend_may_use_rel_p
9734 #define elf_backend_may_use_rel_p 1
9735 #undef elf_backend_may_use_rela_p
9736 #define elf_backend_may_use_rela_p 0
9737 #undef elf_backend_default_use_rela_p
9738 #define elf_backend_default_use_rela_p 0
9739 #undef elf_backend_rela_normal
9740 #define elf_backend_rela_normal 0
9741 #undef elf_backend_want_plt_sym
9742 #define elf_backend_want_plt_sym 0
9743 #undef ELF_MAXPAGESIZE
9744 #define ELF_MAXPAGESIZE 0x8000
9746 #include "elf32-target.h"