1 /* Intel i860 specific support for 32-bit ELF.
2 Copyright 1993, 1995, 1999, 2000, 2001, 2002
3 Free Software Foundation, Inc.
5 Full i860 support contributed by Jason Eckhardt <jle@cygnus.com>.
7 This file is part of BFD, the Binary File Descriptor library.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
30 static reloc_howto_type
*lookup_howto
31 PARAMS ((unsigned int));
33 static reloc_howto_type
*elf32_i860_reloc_type_lookup
34 PARAMS ((bfd
*abfd
, bfd_reloc_code_real_type code
));
36 static void elf32_i860_info_to_howto_rela
37 PARAMS ((bfd
*, arelent
*, Elf32_Internal_Rela
*));
39 static bfd_reloc_status_type elf32_i860_relocate_splitn
40 PARAMS ((bfd
*, Elf_Internal_Rela
*, bfd_byte
*, bfd_vma
));
42 static bfd_reloc_status_type elf32_i860_relocate_pc16
43 PARAMS ((bfd
*, asection
*, Elf_Internal_Rela
*, bfd_byte
*, bfd_vma
));
45 static bfd_reloc_status_type elf32_i860_relocate_pc26
46 PARAMS ((bfd
*, asection
*, Elf_Internal_Rela
*, bfd_byte
*, bfd_vma
));
48 static bfd_reloc_status_type elf32_i860_relocate_highadj
49 PARAMS ((bfd
*, Elf_Internal_Rela
*, bfd_byte
*, bfd_vma
));
51 static boolean elf32_i860_relocate_section
52 PARAMS ((bfd
*, struct bfd_link_info
*, bfd
*, asection
*, bfd_byte
*,
53 Elf_Internal_Rela
*, Elf_Internal_Sym
*, asection
**));
55 static bfd_reloc_status_type i860_final_link_relocate
56 PARAMS ((reloc_howto_type
*, bfd
*, asection
*, bfd_byte
*,
57 Elf_Internal_Rela
*, bfd_vma
));
59 static boolean elf32_i860_is_local_label_name
60 PARAMS ((bfd
*, const char *));
62 /* This howto table is preliminary. */
63 static reloc_howto_type elf32_i860_howto_table
[] =
65 /* This relocation does nothing. */
66 HOWTO (R_860_NONE
, /* type */
68 2, /* size (0 = byte, 1 = short, 2 = long) */
70 false, /* pc_relative */
72 complain_overflow_bitfield
, /* complain_on_overflow */
73 bfd_elf_generic_reloc
, /* special_function */
74 "R_860_NONE", /* name */
75 false, /* partial_inplace */
78 false), /* pcrel_offset */
80 /* A 32-bit absolute relocation. */
81 HOWTO (R_860_32
, /* type */
83 2, /* size (0 = byte, 1 = short, 2 = long) */
85 false, /* pc_relative */
87 complain_overflow_bitfield
, /* complain_on_overflow */
88 bfd_elf_generic_reloc
, /* special_function */
89 "R_860_32", /* name */
90 false, /* partial_inplace */
91 0xffffffff, /* src_mask */
92 0xffffffff, /* dst_mask */
93 false), /* pcrel_offset */
95 HOWTO (R_860_COPY
, /* type */
97 2, /* size (0 = byte, 1 = short, 2 = long) */
99 false, /* pc_relative */
101 complain_overflow_bitfield
, /* complain_on_overflow */
102 bfd_elf_generic_reloc
, /* special_function */
103 "R_860_COPY", /* name */
104 true, /* partial_inplace */
105 0xffffffff, /* src_mask */
106 0xffffffff, /* dst_mask */
107 false), /* pcrel_offset */
109 HOWTO (R_860_GLOB_DAT
, /* type */
111 2, /* size (0 = byte, 1 = short, 2 = long) */
113 false, /* pc_relative */
115 complain_overflow_bitfield
, /* complain_on_overflow */
116 bfd_elf_generic_reloc
, /* special_function */
117 "R_860_GLOB_DAT", /* name */
118 true, /* partial_inplace */
119 0xffffffff, /* src_mask */
120 0xffffffff, /* dst_mask */
121 false), /* pcrel_offset */
123 HOWTO (R_860_JUMP_SLOT
, /* type */
125 2, /* size (0 = byte, 1 = short, 2 = long) */
127 false, /* pc_relative */
129 complain_overflow_bitfield
, /* complain_on_overflow */
130 bfd_elf_generic_reloc
, /* special_function */
131 "R_860_JUMP_SLOT", /* name */
132 true, /* partial_inplace */
133 0xffffffff, /* src_mask */
134 0xffffffff, /* dst_mask */
135 false), /* pcrel_offset */
137 HOWTO (R_860_RELATIVE
, /* type */
139 2, /* size (0 = byte, 1 = short, 2 = long) */
141 false, /* pc_relative */
143 complain_overflow_bitfield
, /* complain_on_overflow */
144 bfd_elf_generic_reloc
, /* special_function */
145 "R_860_RELATIVE", /* name */
146 true, /* partial_inplace */
147 0xffffffff, /* src_mask */
148 0xffffffff, /* dst_mask */
149 false), /* pcrel_offset */
151 /* A 26-bit PC-relative relocation. */
152 HOWTO (R_860_PC26
, /* type */
154 2, /* size (0 = byte, 1 = short, 2 = long) */
156 true, /* pc_relative */
158 complain_overflow_bitfield
, /* complain_on_overflow */
159 bfd_elf_generic_reloc
, /* special_function */
160 "R_860_PC26", /* name */
161 false, /* partial_inplace */
162 0x3ffffff, /* src_mask */
163 0x3ffffff, /* dst_mask */
164 true), /* pcrel_offset */
166 HOWTO (R_860_PLT26
, /* type */
168 2, /* size (0 = byte, 1 = short, 2 = long) */
170 true, /* pc_relative */
172 complain_overflow_bitfield
, /* complain_on_overflow */
173 bfd_elf_generic_reloc
, /* special_function */
174 "R_860_PLT26", /* name */
175 true, /* partial_inplace */
176 0xffffffff, /* src_mask */
177 0xffffffff, /* dst_mask */
178 true), /* pcrel_offset */
180 /* A 16-bit PC-relative relocation. */
181 HOWTO (R_860_PC16
, /* type */
183 2, /* size (0 = byte, 1 = short, 2 = long) */
185 true, /* pc_relative */
187 complain_overflow_bitfield
, /* complain_on_overflow */
188 bfd_elf_generic_reloc
, /* special_function */
189 "R_860_PC16", /* name */
190 false, /* partial_inplace */
191 0x1f07ff, /* src_mask */
192 0x1f07ff, /* dst_mask */
193 true), /* pcrel_offset */
195 HOWTO (R_860_LOW0
, /* type */
197 2, /* size (0 = byte, 1 = short, 2 = long) */
199 false, /* pc_relative */
201 complain_overflow_dont
, /* complain_on_overflow */
202 bfd_elf_generic_reloc
, /* special_function */
203 "R_860_LOW0", /* name */
204 false, /* partial_inplace */
205 0xffff, /* src_mask */
206 0xffff, /* dst_mask */
207 false), /* pcrel_offset */
209 HOWTO (R_860_SPLIT0
, /* type */
211 2, /* size (0 = byte, 1 = short, 2 = long) */
213 false, /* pc_relative */
215 complain_overflow_dont
, /* complain_on_overflow */
216 bfd_elf_generic_reloc
, /* special_function */
217 "R_860_SPLIT0", /* name */
218 false, /* partial_inplace */
219 0x1f07ff, /* src_mask */
220 0x1f07ff, /* dst_mask */
221 false), /* pcrel_offset */
223 HOWTO (R_860_LOW1
, /* type */
225 2, /* size (0 = byte, 1 = short, 2 = long) */
227 false, /* pc_relative */
229 complain_overflow_dont
, /* complain_on_overflow */
230 bfd_elf_generic_reloc
, /* special_function */
231 "R_860_LOW1", /* name */
232 false, /* partial_inplace */
233 0xfffe, /* src_mask */
234 0xfffe, /* dst_mask */
235 false), /* pcrel_offset */
237 HOWTO (R_860_SPLIT1
, /* type */
239 2, /* size (0 = byte, 1 = short, 2 = long) */
241 false, /* pc_relative */
243 complain_overflow_dont
, /* complain_on_overflow */
244 bfd_elf_generic_reloc
, /* special_function */
245 "R_860_SPLIT1", /* name */
246 false, /* partial_inplace */
247 0x1f07fe, /* src_mask */
248 0x1f07fe, /* dst_mask */
249 false), /* pcrel_offset */
251 HOWTO (R_860_LOW2
, /* type */
253 2, /* size (0 = byte, 1 = short, 2 = long) */
255 false, /* pc_relative */
257 complain_overflow_dont
, /* complain_on_overflow */
258 bfd_elf_generic_reloc
, /* special_function */
259 "R_860_LOW2", /* name */
260 false, /* partial_inplace */
261 0xfffc, /* src_mask */
262 0xfffc, /* dst_mask */
263 false), /* pcrel_offset */
265 HOWTO (R_860_SPLIT2
, /* type */
267 2, /* size (0 = byte, 1 = short, 2 = long) */
269 false, /* pc_relative */
271 complain_overflow_dont
, /* complain_on_overflow */
272 bfd_elf_generic_reloc
, /* special_function */
273 "R_860_SPLIT2", /* name */
274 false, /* partial_inplace */
275 0x1f07fc, /* src_mask */
276 0x1f07fc, /* dst_mask */
277 false), /* pcrel_offset */
279 HOWTO (R_860_LOW3
, /* type */
281 2, /* size (0 = byte, 1 = short, 2 = long) */
283 false, /* pc_relative */
285 complain_overflow_dont
, /* complain_on_overflow */
286 bfd_elf_generic_reloc
, /* special_function */
287 "R_860_LOW3", /* name */
288 false, /* partial_inplace */
289 0xfff8, /* src_mask */
290 0xfff8, /* dst_mask */
291 false), /* pcrel_offset */
293 HOWTO (R_860_LOGOT0
, /* type */
295 2, /* size (0 = byte, 1 = short, 2 = long) */
297 false, /* pc_relative */
299 complain_overflow_dont
, /* complain_on_overflow */
300 bfd_elf_generic_reloc
, /* special_function */
301 "R_860_LOGOT0", /* name */
302 false, /* partial_inplace */
304 0xffff, /* dst_mask */
305 true), /* pcrel_offset */
307 HOWTO (R_860_SPGOT0
, /* type */
309 2, /* size (0 = byte, 1 = short, 2 = long) */
311 false, /* pc_relative */
313 complain_overflow_dont
, /* complain_on_overflow */
314 bfd_elf_generic_reloc
, /* special_function */
315 "R_860_SPGOT0", /* name */
316 false, /* partial_inplace */
318 0xffff, /* dst_mask */
319 true), /* pcrel_offset */
321 HOWTO (R_860_LOGOT1
, /* type */
323 2, /* size (0 = byte, 1 = short, 2 = long) */
325 false, /* pc_relative */
327 complain_overflow_dont
, /* complain_on_overflow */
328 bfd_elf_generic_reloc
, /* special_function */
329 "R_860_LOGOT1", /* name */
330 false, /* partial_inplace */
332 0xffff, /* dst_mask */
333 true), /* pcrel_offset */
335 HOWTO (R_860_SPGOT1
, /* type */
337 2, /* size (0 = byte, 1 = short, 2 = long) */
339 false, /* pc_relative */
341 complain_overflow_dont
, /* complain_on_overflow */
342 bfd_elf_generic_reloc
, /* special_function */
343 "R_860_SPGOT1", /* name */
344 false, /* partial_inplace */
346 0xffff, /* dst_mask */
347 true), /* pcrel_offset */
349 HOWTO (R_860_LOGOTOFF0
, /* type */
351 2, /* size (0 = byte, 1 = short, 2 = long) */
353 false, /* pc_relative */
355 complain_overflow_dont
, /* complain_on_overflow */
356 bfd_elf_generic_reloc
, /* special_function */
357 "R_860_LOGOTOFF0", /* name */
358 true, /* partial_inplace */
359 0xffffffff, /* src_mask */
360 0xffffffff, /* dst_mask */
361 false), /* pcrel_offset */
363 HOWTO (R_860_SPGOTOFF0
, /* type */
365 2, /* size (0 = byte, 1 = short, 2 = long) */
367 false, /* pc_relative */
369 complain_overflow_dont
, /* complain_on_overflow */
370 bfd_elf_generic_reloc
, /* special_function */
371 "R_860_SPGOTOFF0", /* name */
372 true, /* partial_inplace */
373 0xffffffff, /* src_mask */
374 0xffffffff, /* dst_mask */
375 false), /* pcrel_offset */
377 HOWTO (R_860_LOGOTOFF1
, /* type */
379 2, /* size (0 = byte, 1 = short, 2 = long) */
381 false, /* pc_relative */
383 complain_overflow_dont
, /* complain_on_overflow */
384 bfd_elf_generic_reloc
, /* special_function */
385 "R_860_LOGOTOFF1", /* name */
386 true, /* partial_inplace */
387 0xffffffff, /* src_mask */
388 0xffffffff, /* dst_mask */
389 false), /* pcrel_offset */
391 HOWTO (R_860_SPGOTOFF1
, /* type */
393 2, /* size (0 = byte, 1 = short, 2 = long) */
395 false, /* pc_relative */
397 complain_overflow_dont
, /* complain_on_overflow */
398 bfd_elf_generic_reloc
, /* special_function */
399 "R_860_SPGOTOFF1", /* name */
400 true, /* partial_inplace */
401 0xffffffff, /* src_mask */
402 0xffffffff, /* dst_mask */
403 false), /* pcrel_offset */
405 HOWTO (R_860_LOGOTOFF2
, /* type */
407 2, /* size (0 = byte, 1 = short, 2 = long) */
409 false, /* pc_relative */
411 complain_overflow_dont
, /* complain_on_overflow */
412 bfd_elf_generic_reloc
, /* special_function */
413 "R_860_LOGOTOFF2", /* name */
414 true, /* partial_inplace */
415 0xffffffff, /* src_mask */
416 0xffffffff, /* dst_mask */
417 false), /* pcrel_offset */
419 HOWTO (R_860_LOGOTOFF3
, /* type */
421 2, /* size (0 = byte, 1 = short, 2 = long) */
423 false, /* pc_relative */
425 complain_overflow_dont
, /* complain_on_overflow */
426 bfd_elf_generic_reloc
, /* special_function */
427 "R_860_LOGOTOFF3", /* name */
428 true, /* partial_inplace */
429 0xffffffff, /* src_mask */
430 0xffffffff, /* dst_mask */
431 false), /* pcrel_offset */
433 HOWTO (R_860_LOPC
, /* type */
435 2, /* size (0 = byte, 1 = short, 2 = long) */
437 true, /* pc_relative */
439 complain_overflow_bitfield
, /* complain_on_overflow */
440 bfd_elf_generic_reloc
, /* special_function */
441 "R_860_LOPC", /* name */
442 false, /* partial_inplace */
443 0xffff, /* src_mask */
444 0xffff, /* dst_mask */
445 true), /* pcrel_offset */
447 HOWTO (R_860_HIGHADJ
, /* type */
449 2, /* size (0 = byte, 1 = short, 2 = long) */
451 false, /* pc_relative */
453 complain_overflow_dont
, /* complain_on_overflow */
454 bfd_elf_generic_reloc
, /* special_function */
455 "R_860_HIGHADJ", /* name */
456 false, /* partial_inplace */
457 0xffff, /* src_mask */
458 0xffff, /* dst_mask */
459 false), /* pcrel_offset */
461 HOWTO (R_860_HAGOT
, /* type */
463 2, /* size (0 = byte, 1 = short, 2 = long) */
465 false, /* pc_relative */
467 complain_overflow_dont
, /* complain_on_overflow */
468 bfd_elf_generic_reloc
, /* special_function */
469 "R_860_HAGOT", /* name */
470 false, /* partial_inplace */
472 0xffff, /* dst_mask */
473 true), /* pcrel_offset */
475 HOWTO (R_860_HAGOTOFF
, /* type */
477 2, /* size (0 = byte, 1 = short, 2 = long) */
479 false, /* pc_relative */
481 complain_overflow_dont
, /* complain_on_overflow */
482 bfd_elf_generic_reloc
, /* special_function */
483 "R_860_HAGOTOFF", /* name */
484 true, /* partial_inplace */
485 0xffffffff, /* src_mask */
486 0xffffffff, /* dst_mask */
487 false), /* pcrel_offset */
489 HOWTO (R_860_HAPC
, /* type */
491 2, /* size (0 = byte, 1 = short, 2 = long) */
493 true, /* pc_relative */
495 complain_overflow_bitfield
, /* complain_on_overflow */
496 bfd_elf_generic_reloc
, /* special_function */
497 "R_860_HAPC", /* name */
498 false, /* partial_inplace */
499 0xffff, /* src_mask */
500 0xffff, /* dst_mask */
501 true), /* pcrel_offset */
503 HOWTO (R_860_HIGH
, /* type */
505 2, /* size (0 = byte, 1 = short, 2 = long) */
507 false, /* pc_relative */
509 complain_overflow_dont
, /* complain_on_overflow */
510 bfd_elf_generic_reloc
, /* special_function */
511 "R_860_HIGH", /* name */
512 false, /* partial_inplace */
513 0xffff, /* src_mask */
514 0xffff, /* dst_mask */
515 false), /* pcrel_offset */
517 HOWTO (R_860_HIGOT
, /* type */
519 2, /* size (0 = byte, 1 = short, 2 = long) */
521 false, /* pc_relative */
523 complain_overflow_dont
, /* complain_on_overflow */
524 bfd_elf_generic_reloc
, /* special_function */
525 "R_860_HIGOT", /* name */
526 false, /* partial_inplace */
528 0xffff, /* dst_mask */
529 true), /* pcrel_offset */
531 HOWTO (R_860_HIGOTOFF
, /* type */
533 2, /* size (0 = byte, 1 = short, 2 = long) */
535 false, /* pc_relative */
537 complain_overflow_dont
, /* complain_on_overflow */
538 bfd_elf_generic_reloc
, /* special_function */
539 "R_860_HIGOTOFF", /* name */
540 true, /* partial_inplace */
541 0xffffffff, /* src_mask */
542 0xffffffff, /* dst_mask */
543 false), /* pcrel_offset */
546 static unsigned char elf_code_to_howto_index
[R_860_max
+ 1];
548 static reloc_howto_type
*
552 static int initialized
= 0;
554 int howto_tbl_size
= (int) (sizeof (elf32_i860_howto_table
)
555 / sizeof (elf32_i860_howto_table
[0]));
560 memset (elf_code_to_howto_index
, 0xff,
561 sizeof (elf_code_to_howto_index
));
562 for (i
= 0; i
< howto_tbl_size
; i
++)
563 elf_code_to_howto_index
[elf32_i860_howto_table
[i
].type
] = i
;
566 BFD_ASSERT (rtype
<= R_860_max
);
567 i
= elf_code_to_howto_index
[rtype
];
568 if (i
>= howto_tbl_size
)
570 return elf32_i860_howto_table
+ i
;
573 /* Given a BFD reloc, return the matching HOWTO structure. */
574 static reloc_howto_type
*
575 elf32_i860_reloc_type_lookup (abfd
, code
)
576 bfd
* abfd ATTRIBUTE_UNUSED
;
577 bfd_reloc_code_real_type code
;
589 case BFD_RELOC_860_COPY
:
592 case BFD_RELOC_860_GLOB_DAT
:
593 rtype
= R_860_GLOB_DAT
;
595 case BFD_RELOC_860_JUMP_SLOT
:
596 rtype
= R_860_JUMP_SLOT
;
598 case BFD_RELOC_860_RELATIVE
:
599 rtype
= R_860_RELATIVE
;
601 case BFD_RELOC_860_PC26
:
604 case BFD_RELOC_860_PLT26
:
607 case BFD_RELOC_860_PC16
:
610 case BFD_RELOC_860_LOW0
:
613 case BFD_RELOC_860_SPLIT0
:
614 rtype
= R_860_SPLIT0
;
616 case BFD_RELOC_860_LOW1
:
619 case BFD_RELOC_860_SPLIT1
:
620 rtype
= R_860_SPLIT1
;
622 case BFD_RELOC_860_LOW2
:
625 case BFD_RELOC_860_SPLIT2
:
626 rtype
= R_860_SPLIT2
;
628 case BFD_RELOC_860_LOW3
:
631 case BFD_RELOC_860_LOGOT0
:
632 rtype
= R_860_LOGOT0
;
634 case BFD_RELOC_860_SPGOT0
:
635 rtype
= R_860_SPGOT0
;
637 case BFD_RELOC_860_LOGOT1
:
638 rtype
= R_860_LOGOT1
;
640 case BFD_RELOC_860_SPGOT1
:
641 rtype
= R_860_SPGOT1
;
643 case BFD_RELOC_860_LOGOTOFF0
:
644 rtype
= R_860_LOGOTOFF0
;
646 case BFD_RELOC_860_SPGOTOFF0
:
647 rtype
= R_860_SPGOTOFF0
;
649 case BFD_RELOC_860_LOGOTOFF1
:
650 rtype
= R_860_LOGOTOFF1
;
652 case BFD_RELOC_860_SPGOTOFF1
:
653 rtype
= R_860_SPGOTOFF1
;
655 case BFD_RELOC_860_LOGOTOFF2
:
656 rtype
= R_860_LOGOTOFF2
;
658 case BFD_RELOC_860_LOGOTOFF3
:
659 rtype
= R_860_LOGOTOFF3
;
661 case BFD_RELOC_860_LOPC
:
664 case BFD_RELOC_860_HIGHADJ
:
665 rtype
= R_860_HIGHADJ
;
667 case BFD_RELOC_860_HAGOT
:
670 case BFD_RELOC_860_HAGOTOFF
:
671 rtype
= R_860_HAGOTOFF
;
673 case BFD_RELOC_860_HAPC
:
676 case BFD_RELOC_860_HIGH
:
679 case BFD_RELOC_860_HIGOT
:
682 case BFD_RELOC_860_HIGOTOFF
:
683 rtype
= R_860_HIGOTOFF
;
689 return lookup_howto (rtype
);
692 /* Given a ELF reloc, return the matching HOWTO structure. */
694 elf32_i860_info_to_howto_rela (abfd
, bfd_reloc
, elf_reloc
)
695 bfd
*abfd ATTRIBUTE_UNUSED
;
697 Elf64_Internal_Rela
*elf_reloc
;
700 = lookup_howto ((unsigned) ELF32_R_TYPE (elf_reloc
->r_info
));
703 /* Specialized relocation handler for R_860_SPLITn. These relocations
704 involves a 16-bit field that is split into two contiguous parts. */
705 static bfd_reloc_status_type
706 elf32_i860_relocate_splitn (input_bfd
, rello
, contents
, value
)
708 Elf_Internal_Rela
*rello
;
713 reloc_howto_type
*howto
;
714 howto
= lookup_howto ((unsigned) ELF32_R_TYPE (rello
->r_info
));
715 insn
= bfd_get_32 (input_bfd
, contents
+ rello
->r_offset
);
718 value
+= rello
->r_addend
;
720 /* Separate the fields and insert. */
721 value
= (((value
& 0xf8) << 5) | (value
& 0x7ff)) & howto
->dst_mask
;
722 insn
= (insn
& ~howto
->dst_mask
) | value
;
724 bfd_put_32 (input_bfd
, insn
, contents
+ rello
->r_offset
);
728 /* Specialized relocation handler for R_860_PC16. This relocation
729 involves a 16-bit, PC-relative field that is split into two contiguous
731 static bfd_reloc_status_type
732 elf32_i860_relocate_pc16 (input_bfd
, input_section
, rello
, contents
, value
)
734 asection
*input_section
;
735 Elf_Internal_Rela
*rello
;
740 reloc_howto_type
*howto
;
741 howto
= lookup_howto ((unsigned) ELF32_R_TYPE (rello
->r_info
));
742 insn
= bfd_get_32 (input_bfd
, contents
+ rello
->r_offset
);
744 /* Adjust for PC-relative relocation. */
745 value
-= (input_section
->output_section
->vma
746 + input_section
->output_offset
);
747 value
-= rello
->r_offset
;
750 value
+= rello
->r_addend
;
752 /* Separate the fields and insert. */
753 value
= (((value
& 0xf8) << 5) | (value
& 0x7ff)) & howto
->dst_mask
;
754 insn
= (insn
& ~howto
->dst_mask
) | value
;
756 bfd_put_32 (input_bfd
, insn
, contents
+ rello
->r_offset
);
761 /* Specialized relocation handler for R_860_PC26. This relocation
762 involves a 26-bit, PC-relative field which must be adjusted by 4. */
763 static bfd_reloc_status_type
764 elf32_i860_relocate_pc26 (input_bfd
, input_section
, rello
, contents
, value
)
766 asection
*input_section
;
767 Elf_Internal_Rela
*rello
;
772 reloc_howto_type
*howto
;
773 howto
= lookup_howto ((unsigned) ELF32_R_TYPE (rello
->r_info
));
774 insn
= bfd_get_32 (input_bfd
, contents
+ rello
->r_offset
);
776 /* Adjust for PC-relative relocation. */
777 value
-= (input_section
->output_section
->vma
778 + input_section
->output_offset
);
779 value
-= rello
->r_offset
;
782 value
+= rello
->r_addend
;
784 /* Adjust value by 4 and insert the field. */
785 value
= ((value
- 4) >> howto
->rightshift
) & howto
->dst_mask
;
786 insn
= (insn
& ~howto
->dst_mask
) | value
;
788 bfd_put_32 (input_bfd
, insn
, contents
+ rello
->r_offset
);
793 /* Specialized relocation handler for R_860_HIGHADJ. */
794 static bfd_reloc_status_type
795 elf32_i860_relocate_highadj (input_bfd
, rel
, contents
, value
)
797 Elf_Internal_Rela
*rel
;
803 insn
= bfd_get_32 (input_bfd
, contents
+ rel
->r_offset
);
805 value
+= ((rel
->r_addend
& 0x8000) << 1);
806 value
+= rel
->r_addend
;
807 value
= ((value
>> 16) & 0xffff);
809 insn
= (insn
& 0xffff0000) | value
;
811 bfd_put_32 (input_bfd
, insn
, contents
+ rel
->r_offset
);
815 /* Perform a single relocation. By default we use the standard BFD
816 routines. However, we handle some specially. */
817 static bfd_reloc_status_type
818 i860_final_link_relocate (howto
, input_bfd
, input_section
, contents
, rel
, relocation
)
819 reloc_howto_type
* howto
;
821 asection
* input_section
;
823 Elf_Internal_Rela
* rel
;
826 return _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
827 contents
, rel
->r_offset
, relocation
,
831 /* Relocate an i860 ELF section.
833 This is boiler-plate code copied from fr30.
835 The RELOCATE_SECTION function is called by the new ELF backend linker
836 to handle the relocations for a section.
838 The relocs are always passed as Rela structures; if the section
839 actually uses Rel structures, the r_addend field will always be
842 This function is responsible for adjusting the section contents as
843 necessary, and (if using Rela relocs and generating a relocateable
844 output file) adjusting the reloc addend as necessary.
846 This function does not have to worry about setting the reloc
847 address or the reloc symbol index.
849 LOCAL_SYMS is a pointer to the swapped in local symbols.
851 LOCAL_SECTIONS is an array giving the section in the input file
852 corresponding to the st_shndx field of each local symbol.
854 The global hash table entry for the global symbols can be found
855 via elf_sym_hashes (input_bfd).
857 When generating relocateable output, this function must handle
858 STB_LOCAL/STT_SECTION symbols specially. The output symbol is
859 going to be the section symbol corresponding to the output
860 section, which means that the addend must be adjusted
863 elf32_i860_relocate_section (output_bfd
, info
, input_bfd
, input_section
,
864 contents
, relocs
, local_syms
, local_sections
)
865 bfd
* output_bfd ATTRIBUTE_UNUSED
;
866 struct bfd_link_info
* info
;
868 asection
* input_section
;
870 Elf_Internal_Rela
* relocs
;
871 Elf_Internal_Sym
* local_syms
;
872 asection
** local_sections
;
874 Elf_Internal_Shdr
* symtab_hdr
;
875 struct elf_link_hash_entry
** sym_hashes
;
876 Elf_Internal_Rela
* rel
;
877 Elf_Internal_Rela
* relend
;
879 if (info
->relocateable
)
882 symtab_hdr
= & elf_tdata (input_bfd
)->symtab_hdr
;
883 sym_hashes
= elf_sym_hashes (input_bfd
);
884 relend
= relocs
+ input_section
->reloc_count
;
886 for (rel
= relocs
; rel
< relend
; rel
++)
888 reloc_howto_type
* howto
;
889 unsigned long r_symndx
;
890 Elf_Internal_Sym
* sym
;
892 struct elf_link_hash_entry
* h
;
894 bfd_reloc_status_type r
;
895 const char * name
= NULL
;
898 r_type
= ELF32_R_TYPE (rel
->r_info
);
901 if ( r_type
== R_860_GNU_VTINHERIT
902 || r_type
== R_860_GNU_VTENTRY
)
906 r_symndx
= ELF32_R_SYM (rel
->r_info
);
908 howto
= lookup_howto ((unsigned) ELF32_R_TYPE (rel
->r_info
));
913 if (r_symndx
< symtab_hdr
->sh_info
)
915 sym
= local_syms
+ r_symndx
;
916 sec
= local_sections
[r_symndx
];
917 relocation
= _bfd_elf_rela_local_sym (output_bfd
, sym
, sec
, rel
);
919 name
= bfd_elf_string_from_elf_section
920 (input_bfd
, symtab_hdr
->sh_link
, sym
->st_name
);
921 name
= (name
== NULL
) ? bfd_section_name (input_bfd
, sec
) : name
;
925 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
927 while (h
->root
.type
== bfd_link_hash_indirect
928 || h
->root
.type
== bfd_link_hash_warning
)
929 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
931 name
= h
->root
.root
.string
;
933 if (h
->root
.type
== bfd_link_hash_defined
934 || h
->root
.type
== bfd_link_hash_defweak
)
936 sec
= h
->root
.u
.def
.section
;
937 relocation
= (h
->root
.u
.def
.value
938 + sec
->output_section
->vma
939 + sec
->output_offset
);
941 else if (h
->root
.type
== bfd_link_hash_undefweak
)
947 if (! ((*info
->callbacks
->undefined_symbol
)
948 (info
, h
->root
.root
.string
, input_bfd
,
949 input_section
, rel
->r_offset
, true)))
958 r
= i860_final_link_relocate (howto
, input_bfd
, input_section
,
959 contents
, rel
, relocation
);
963 r
= elf32_i860_relocate_highadj (input_bfd
, rel
, contents
,
968 r
= elf32_i860_relocate_pc16 (input_bfd
, input_section
, rel
,
969 contents
, relocation
);
973 r
= elf32_i860_relocate_pc26 (input_bfd
, input_section
, rel
,
974 contents
, relocation
);
980 r
= elf32_i860_relocate_splitn (input_bfd
, rel
, contents
,
984 /* We do not yet handle GOT/PLT/Dynamic relocations. */
987 case R_860_JUMP_SLOT
:
994 case R_860_LOGOTOFF0
:
995 case R_860_SPGOTOFF0
:
996 case R_860_LOGOTOFF1
:
997 case R_860_SPGOTOFF1
:
998 case R_860_LOGOTOFF2
:
999 case R_860_LOGOTOFF3
:
1002 case R_860_HAGOTOFF
:
1005 case R_860_HIGOTOFF
:
1006 r
= bfd_reloc_notsupported
;
1010 if (r
!= bfd_reloc_ok
)
1012 const char * msg
= (const char *) NULL
;
1016 case bfd_reloc_overflow
:
1017 r
= info
->callbacks
->reloc_overflow
1018 (info
, name
, howto
->name
, (bfd_vma
) 0,
1019 input_bfd
, input_section
, rel
->r_offset
);
1022 case bfd_reloc_undefined
:
1023 r
= info
->callbacks
->undefined_symbol
1024 (info
, name
, input_bfd
, input_section
, rel
->r_offset
, true);
1027 case bfd_reloc_outofrange
:
1028 msg
= _("internal error: out of range error");
1031 case bfd_reloc_notsupported
:
1032 msg
= _("internal error: unsupported relocation error");
1035 case bfd_reloc_dangerous
:
1036 msg
= _("internal error: dangerous relocation");
1040 msg
= _("internal error: unknown error");
1045 r
= info
->callbacks
->warning
1046 (info
, msg
, name
, input_bfd
, input_section
, rel
->r_offset
);
1056 /* Return whether a symbol name implies a local label. SVR4/860 compilers
1057 generate labels of the form ".ep.function_name" to denote the end of a
1058 function prolog. These should be local.
1059 ??? Do any other SVR4 compilers have this convention? If so, this should
1060 be added to the generic routine. */
1062 elf32_i860_is_local_label_name (abfd
, name
)
1066 if (name
[0] == '.' && name
[1] == 'e' && name
[2] == 'p' && name
[3] == '.')
1069 return _bfd_elf_is_local_label_name (abfd
, name
);
1072 #define TARGET_BIG_SYM bfd_elf32_i860_vec
1073 #define TARGET_BIG_NAME "elf32-i860"
1074 #define TARGET_LITTLE_SYM bfd_elf32_i860_little_vec
1075 #define TARGET_LITTLE_NAME "elf32-i860-little"
1076 #define ELF_ARCH bfd_arch_i860
1077 #define ELF_MACHINE_CODE EM_860
1078 #define ELF_MAXPAGESIZE 4096
1080 #define elf_backend_rela_normal 1
1081 #define elf_info_to_howto_rel NULL
1082 #define elf_info_to_howto elf32_i860_info_to_howto_rela
1083 #define elf_backend_relocate_section elf32_i860_relocate_section
1084 #define bfd_elf32_bfd_reloc_type_lookup elf32_i860_reloc_type_lookup
1085 #define bfd_elf32_bfd_is_local_label_name elf32_i860_is_local_label_name
1087 #include "elf32-target.h"