1 /* Intel i860 specific support for 32-bit ELF.
2 Copyright (C) 1993-2018 Free Software Foundation, Inc.
4 Full i860 support contributed by Jason Eckhardt <jle@cygnus.com>.
6 This file is part of BFD, the Binary File Descriptor library.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 MA 02110-1301, USA. */
29 /* special_function for R_860_PC26 relocation. */
30 static bfd_reloc_status_type
31 i860_howto_pc26_reloc (bfd
*abfd ATTRIBUTE_UNUSED
,
34 void *data ATTRIBUTE_UNUSED
,
35 asection
*input_section
,
37 char **error_message ATTRIBUTE_UNUSED
)
43 if (output_bfd
!= NULL
44 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
45 && (! reloc_entry
->howto
->partial_inplace
46 || reloc_entry
->addend
== 0))
48 reloc_entry
->address
+= input_section
->output_offset
;
52 /* Used elf32-mips.c as an example. */
53 if (bfd_is_und_section (symbol
->section
)
54 && output_bfd
== (bfd
*) NULL
)
55 return bfd_reloc_undefined
;
57 if (bfd_is_com_section (symbol
->section
))
60 relocation
= symbol
->value
;
62 relocation
+= symbol
->section
->output_section
->vma
;
63 relocation
+= symbol
->section
->output_offset
;
64 relocation
+= reloc_entry
->addend
;
66 if (reloc_entry
->address
> bfd_get_section_limit (abfd
, input_section
))
67 return bfd_reloc_outofrange
;
69 /* Adjust for PC-relative relocation. */
70 relocation
-= (input_section
->output_section
->vma
71 + input_section
->output_offset
72 + reloc_entry
->address
75 /* Check for target out of range. */
76 if ((bfd_signed_vma
)relocation
> (0x3ffffff << 2)
77 || (bfd_signed_vma
)relocation
< (-0x4000000 * 4))
78 return bfd_reloc_outofrange
;
80 addr
= (bfd_byte
*) data
+ reloc_entry
->address
;
81 insn
= bfd_get_32 (abfd
, addr
);
83 relocation
>>= reloc_entry
->howto
->rightshift
;
84 insn
= (insn
& ~reloc_entry
->howto
->dst_mask
)
85 | (relocation
& reloc_entry
->howto
->dst_mask
);
87 bfd_put_32 (abfd
, (bfd_vma
) insn
, addr
);
92 /* special_function for R_860_PC16 relocation. */
93 static bfd_reloc_status_type
94 i860_howto_pc16_reloc (bfd
*abfd
,
98 asection
*input_section
,
100 char **error_message ATTRIBUTE_UNUSED
)
106 if (output_bfd
!= NULL
107 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
108 && (! reloc_entry
->howto
->partial_inplace
109 || reloc_entry
->addend
== 0))
111 reloc_entry
->address
+= input_section
->output_offset
;
115 /* Used elf32-mips.c as an example. */
116 if (bfd_is_und_section (symbol
->section
)
117 && output_bfd
== (bfd
*) NULL
)
118 return bfd_reloc_undefined
;
120 if (bfd_is_com_section (symbol
->section
))
123 relocation
= symbol
->value
;
125 relocation
+= symbol
->section
->output_section
->vma
;
126 relocation
+= symbol
->section
->output_offset
;
127 relocation
+= reloc_entry
->addend
;
129 if (reloc_entry
->address
> bfd_get_section_limit (abfd
, input_section
))
130 return bfd_reloc_outofrange
;
132 /* Adjust for PC-relative relocation. */
133 relocation
-= (input_section
->output_section
->vma
134 + input_section
->output_offset
135 + reloc_entry
->address
138 /* Check for target out of range. */
139 if ((bfd_signed_vma
)relocation
> (0x7fff << 2)
140 || (bfd_signed_vma
)relocation
< (-0x8000 * 4))
141 return bfd_reloc_outofrange
;
143 addr
= (bfd_byte
*) data
+ reloc_entry
->address
;
144 insn
= bfd_get_32 (abfd
, addr
);
146 relocation
>>= reloc_entry
->howto
->rightshift
;
147 relocation
= (((relocation
& 0xf800) << 5) | (relocation
& 0x7ff))
148 & reloc_entry
->howto
->dst_mask
;
149 insn
= (insn
& ~reloc_entry
->howto
->dst_mask
) | relocation
;
151 bfd_put_32 (abfd
, (bfd_vma
) insn
, addr
);
156 /* special_function for R_860_HIGHADJ relocation. */
157 static bfd_reloc_status_type
158 i860_howto_highadj_reloc (bfd
*abfd
,
159 arelent
*reloc_entry
,
162 asection
*input_section
,
164 char **error_message ATTRIBUTE_UNUSED
)
170 if (output_bfd
!= NULL
171 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
172 && (! reloc_entry
->howto
->partial_inplace
173 || reloc_entry
->addend
== 0))
175 reloc_entry
->address
+= input_section
->output_offset
;
179 /* Used elf32-mips.c as an example. */
180 if (bfd_is_und_section (symbol
->section
)
181 && output_bfd
== (bfd
*) NULL
)
182 return bfd_reloc_undefined
;
184 if (bfd_is_com_section (symbol
->section
))
187 relocation
= symbol
->value
;
189 relocation
+= symbol
->section
->output_section
->vma
;
190 relocation
+= symbol
->section
->output_offset
;
191 relocation
+= reloc_entry
->addend
;
192 relocation
+= 0x8000;
194 if (reloc_entry
->address
> bfd_get_section_limit (abfd
, input_section
))
195 return bfd_reloc_outofrange
;
197 addr
= (bfd_byte
*) data
+ reloc_entry
->address
;
198 insn
= bfd_get_32 (abfd
, addr
);
200 relocation
= ((relocation
>> 16) & 0xffff);
202 insn
= (insn
& 0xffff0000) | relocation
;
204 bfd_put_32 (abfd
, (bfd_vma
) insn
, addr
);
209 /* special_function for R_860_SPLITn relocations. */
210 static bfd_reloc_status_type
211 i860_howto_splitn_reloc (bfd
*abfd
,
212 arelent
*reloc_entry
,
215 asection
*input_section
,
217 char **error_message ATTRIBUTE_UNUSED
)
223 if (output_bfd
!= NULL
224 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
225 && (! reloc_entry
->howto
->partial_inplace
226 || reloc_entry
->addend
== 0))
228 reloc_entry
->address
+= input_section
->output_offset
;
232 /* Used elf32-mips.c as an example. */
233 if (bfd_is_und_section (symbol
->section
)
234 && output_bfd
== (bfd
*) NULL
)
235 return bfd_reloc_undefined
;
237 if (bfd_is_com_section (symbol
->section
))
240 relocation
= symbol
->value
;
242 relocation
+= symbol
->section
->output_section
->vma
;
243 relocation
+= symbol
->section
->output_offset
;
244 relocation
+= reloc_entry
->addend
;
246 if (reloc_entry
->address
> bfd_get_section_limit (abfd
, input_section
))
247 return bfd_reloc_outofrange
;
249 addr
= (bfd_byte
*) data
+ reloc_entry
->address
;
250 insn
= bfd_get_32 (abfd
, addr
);
252 relocation
= (((relocation
& 0xf800) << 5) | (relocation
& 0x7ff))
253 & reloc_entry
->howto
->dst_mask
;
254 insn
= (insn
& ~reloc_entry
->howto
->dst_mask
) | relocation
;
256 bfd_put_32 (abfd
, (bfd_vma
) insn
, addr
);
261 /* This howto table is preliminary. */
262 static reloc_howto_type elf32_i860_howto_table
[] =
264 /* This relocation does nothing. */
265 HOWTO (R_860_NONE
, /* type */
267 3, /* 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_NONE", /* name */
274 FALSE
, /* partial_inplace */
277 FALSE
), /* pcrel_offset */
279 /* A 32-bit absolute relocation. */
280 HOWTO (R_860_32
, /* type */
282 2, /* size (0 = byte, 1 = short, 2 = long) */
284 FALSE
, /* pc_relative */
286 complain_overflow_bitfield
, /* complain_on_overflow */
287 bfd_elf_generic_reloc
, /* special_function */
288 "R_860_32", /* name */
289 FALSE
, /* partial_inplace */
290 0xffffffff, /* src_mask */
291 0xffffffff, /* dst_mask */
292 FALSE
), /* pcrel_offset */
294 HOWTO (R_860_COPY
, /* type */
296 2, /* size (0 = byte, 1 = short, 2 = long) */
298 FALSE
, /* pc_relative */
300 complain_overflow_bitfield
, /* complain_on_overflow */
301 bfd_elf_generic_reloc
, /* special_function */
302 "R_860_COPY", /* name */
303 TRUE
, /* partial_inplace */
304 0xffffffff, /* src_mask */
305 0xffffffff, /* dst_mask */
306 FALSE
), /* pcrel_offset */
308 HOWTO (R_860_GLOB_DAT
, /* type */
310 2, /* size (0 = byte, 1 = short, 2 = long) */
312 FALSE
, /* pc_relative */
314 complain_overflow_bitfield
, /* complain_on_overflow */
315 bfd_elf_generic_reloc
, /* special_function */
316 "R_860_GLOB_DAT", /* name */
317 TRUE
, /* partial_inplace */
318 0xffffffff, /* src_mask */
319 0xffffffff, /* dst_mask */
320 FALSE
), /* pcrel_offset */
322 HOWTO (R_860_JUMP_SLOT
, /* 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_860_JUMP_SLOT", /* name */
331 TRUE
, /* partial_inplace */
332 0xffffffff, /* src_mask */
333 0xffffffff, /* dst_mask */
334 FALSE
), /* pcrel_offset */
336 HOWTO (R_860_RELATIVE
, /* 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_860_RELATIVE", /* name */
345 TRUE
, /* partial_inplace */
346 0xffffffff, /* src_mask */
347 0xffffffff, /* dst_mask */
348 FALSE
), /* pcrel_offset */
350 /* A 26-bit PC-relative relocation. */
351 HOWTO (R_860_PC26
, /* type */
353 2, /* size (0 = byte, 1 = short, 2 = long) */
355 TRUE
, /* pc_relative */
357 complain_overflow_bitfield
, /* complain_on_overflow */
358 i860_howto_pc26_reloc
, /* special_function */
359 "R_860_PC26", /* name */
360 FALSE
, /* partial_inplace */
361 0x3ffffff, /* src_mask */
362 0x3ffffff, /* dst_mask */
363 TRUE
), /* pcrel_offset */
365 HOWTO (R_860_PLT26
, /* type */
367 2, /* size (0 = byte, 1 = short, 2 = long) */
369 TRUE
, /* pc_relative */
371 complain_overflow_bitfield
, /* complain_on_overflow */
372 bfd_elf_generic_reloc
, /* special_function */
373 "R_860_PLT26", /* name */
374 TRUE
, /* partial_inplace */
375 0xffffffff, /* src_mask */
376 0xffffffff, /* dst_mask */
377 TRUE
), /* pcrel_offset */
379 /* A 16-bit PC-relative relocation. */
380 HOWTO (R_860_PC16
, /* type */
382 2, /* size (0 = byte, 1 = short, 2 = long) */
384 TRUE
, /* pc_relative */
386 complain_overflow_bitfield
, /* complain_on_overflow */
387 i860_howto_pc16_reloc
, /* special_function */
388 "R_860_PC16", /* name */
389 FALSE
, /* partial_inplace */
390 0x1f07ff, /* src_mask */
391 0x1f07ff, /* dst_mask */
392 TRUE
), /* pcrel_offset */
394 HOWTO (R_860_LOW0
, /* type */
396 2, /* size (0 = byte, 1 = short, 2 = long) */
398 FALSE
, /* pc_relative */
400 complain_overflow_dont
, /* complain_on_overflow */
401 bfd_elf_generic_reloc
, /* special_function */
402 "R_860_LOW0", /* name */
403 FALSE
, /* partial_inplace */
404 0xffff, /* src_mask */
405 0xffff, /* dst_mask */
406 FALSE
), /* pcrel_offset */
408 HOWTO (R_860_SPLIT0
, /* type */
410 2, /* size (0 = byte, 1 = short, 2 = long) */
412 FALSE
, /* pc_relative */
414 complain_overflow_dont
, /* complain_on_overflow */
415 i860_howto_splitn_reloc
, /* special_function */
416 "R_860_SPLIT0", /* name */
417 FALSE
, /* partial_inplace */
418 0x1f07ff, /* src_mask */
419 0x1f07ff, /* dst_mask */
420 FALSE
), /* pcrel_offset */
422 HOWTO (R_860_LOW1
, /* type */
424 2, /* size (0 = byte, 1 = short, 2 = long) */
426 FALSE
, /* pc_relative */
428 complain_overflow_dont
, /* complain_on_overflow */
429 bfd_elf_generic_reloc
, /* special_function */
430 "R_860_LOW1", /* name */
431 FALSE
, /* partial_inplace */
432 0xfffe, /* src_mask */
433 0xfffe, /* dst_mask */
434 FALSE
), /* pcrel_offset */
436 HOWTO (R_860_SPLIT1
, /* type */
438 2, /* size (0 = byte, 1 = short, 2 = long) */
440 FALSE
, /* pc_relative */
442 complain_overflow_dont
, /* complain_on_overflow */
443 i860_howto_splitn_reloc
, /* special_function */
444 "R_860_SPLIT1", /* name */
445 FALSE
, /* partial_inplace */
446 0x1f07fe, /* src_mask */
447 0x1f07fe, /* dst_mask */
448 FALSE
), /* pcrel_offset */
450 HOWTO (R_860_LOW2
, /* type */
452 2, /* size (0 = byte, 1 = short, 2 = long) */
454 FALSE
, /* pc_relative */
456 complain_overflow_dont
, /* complain_on_overflow */
457 bfd_elf_generic_reloc
, /* special_function */
458 "R_860_LOW2", /* name */
459 FALSE
, /* partial_inplace */
460 0xfffc, /* src_mask */
461 0xfffc, /* dst_mask */
462 FALSE
), /* pcrel_offset */
464 HOWTO (R_860_SPLIT2
, /* type */
466 2, /* size (0 = byte, 1 = short, 2 = long) */
468 FALSE
, /* pc_relative */
470 complain_overflow_dont
, /* complain_on_overflow */
471 i860_howto_splitn_reloc
, /* special_function */
472 "R_860_SPLIT2", /* name */
473 FALSE
, /* partial_inplace */
474 0x1f07fc, /* src_mask */
475 0x1f07fc, /* dst_mask */
476 FALSE
), /* pcrel_offset */
478 HOWTO (R_860_LOW3
, /* type */
480 2, /* size (0 = byte, 1 = short, 2 = long) */
482 FALSE
, /* pc_relative */
484 complain_overflow_dont
, /* complain_on_overflow */
485 bfd_elf_generic_reloc
, /* special_function */
486 "R_860_LOW3", /* name */
487 FALSE
, /* partial_inplace */
488 0xfff8, /* src_mask */
489 0xfff8, /* dst_mask */
490 FALSE
), /* pcrel_offset */
492 HOWTO (R_860_LOGOT0
, /* type */
494 2, /* size (0 = byte, 1 = short, 2 = long) */
496 FALSE
, /* pc_relative */
498 complain_overflow_dont
, /* complain_on_overflow */
499 bfd_elf_generic_reloc
, /* special_function */
500 "R_860_LOGOT0", /* name */
501 FALSE
, /* partial_inplace */
503 0xffff, /* dst_mask */
504 TRUE
), /* pcrel_offset */
506 HOWTO (R_860_SPGOT0
, /* type */
508 2, /* size (0 = byte, 1 = short, 2 = long) */
510 FALSE
, /* pc_relative */
512 complain_overflow_dont
, /* complain_on_overflow */
513 bfd_elf_generic_reloc
, /* special_function */
514 "R_860_SPGOT0", /* name */
515 FALSE
, /* partial_inplace */
517 0xffff, /* dst_mask */
518 TRUE
), /* pcrel_offset */
520 HOWTO (R_860_LOGOT1
, /* 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_860_LOGOT1", /* name */
529 FALSE
, /* partial_inplace */
531 0xffff, /* dst_mask */
532 TRUE
), /* pcrel_offset */
534 HOWTO (R_860_SPGOT1
, /* type */
536 2, /* size (0 = byte, 1 = short, 2 = long) */
538 FALSE
, /* pc_relative */
540 complain_overflow_dont
, /* complain_on_overflow */
541 bfd_elf_generic_reloc
, /* special_function */
542 "R_860_SPGOT1", /* name */
543 FALSE
, /* partial_inplace */
545 0xffff, /* dst_mask */
546 TRUE
), /* pcrel_offset */
548 HOWTO (R_860_LOGOTOFF0
, /* type */
550 2, /* size (0 = byte, 1 = short, 2 = long) */
552 FALSE
, /* pc_relative */
554 complain_overflow_dont
, /* complain_on_overflow */
555 bfd_elf_generic_reloc
, /* special_function */
556 "R_860_LOGOTOFF0", /* name */
557 TRUE
, /* partial_inplace */
558 0xffffffff, /* src_mask */
559 0xffffffff, /* dst_mask */
560 FALSE
), /* pcrel_offset */
562 HOWTO (R_860_SPGOTOFF0
, /* type */
564 2, /* size (0 = byte, 1 = short, 2 = long) */
566 FALSE
, /* pc_relative */
568 complain_overflow_dont
, /* complain_on_overflow */
569 bfd_elf_generic_reloc
, /* special_function */
570 "R_860_SPGOTOFF0", /* name */
571 TRUE
, /* partial_inplace */
572 0xffffffff, /* src_mask */
573 0xffffffff, /* dst_mask */
574 FALSE
), /* pcrel_offset */
576 HOWTO (R_860_LOGOTOFF1
, /* 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_860_LOGOTOFF1", /* name */
585 TRUE
, /* partial_inplace */
586 0xffffffff, /* src_mask */
587 0xffffffff, /* dst_mask */
588 FALSE
), /* pcrel_offset */
590 HOWTO (R_860_SPGOTOFF1
, /* 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_860_SPGOTOFF1", /* name */
599 TRUE
, /* partial_inplace */
600 0xffffffff, /* src_mask */
601 0xffffffff, /* dst_mask */
602 FALSE
), /* pcrel_offset */
604 HOWTO (R_860_LOGOTOFF2
, /* 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_860_LOGOTOFF2", /* name */
613 TRUE
, /* partial_inplace */
614 0xffffffff, /* src_mask */
615 0xffffffff, /* dst_mask */
616 FALSE
), /* pcrel_offset */
618 HOWTO (R_860_LOGOTOFF3
, /* 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_860_LOGOTOFF3", /* name */
627 TRUE
, /* partial_inplace */
628 0xffffffff, /* src_mask */
629 0xffffffff, /* dst_mask */
630 FALSE
), /* pcrel_offset */
632 HOWTO (R_860_LOPC
, /* type */
634 2, /* size (0 = byte, 1 = short, 2 = long) */
636 TRUE
, /* pc_relative */
638 complain_overflow_bitfield
, /* complain_on_overflow */
639 bfd_elf_generic_reloc
, /* special_function */
640 "R_860_LOPC", /* name */
641 FALSE
, /* partial_inplace */
642 0xffff, /* src_mask */
643 0xffff, /* dst_mask */
644 TRUE
), /* pcrel_offset */
646 HOWTO (R_860_HIGHADJ
, /* type */
648 2, /* size (0 = byte, 1 = short, 2 = long) */
650 FALSE
, /* pc_relative */
652 complain_overflow_dont
, /* complain_on_overflow */
653 i860_howto_highadj_reloc
, /* special_function */
654 "R_860_HIGHADJ", /* name */
655 FALSE
, /* partial_inplace */
656 0xffff, /* src_mask */
657 0xffff, /* dst_mask */
658 FALSE
), /* pcrel_offset */
660 HOWTO (R_860_HAGOT
, /* type */
662 2, /* size (0 = byte, 1 = short, 2 = long) */
664 FALSE
, /* pc_relative */
666 complain_overflow_dont
, /* complain_on_overflow */
667 bfd_elf_generic_reloc
, /* special_function */
668 "R_860_HAGOT", /* name */
669 FALSE
, /* partial_inplace */
671 0xffff, /* dst_mask */
672 TRUE
), /* pcrel_offset */
674 HOWTO (R_860_HAGOTOFF
, /* type */
676 2, /* size (0 = byte, 1 = short, 2 = long) */
678 FALSE
, /* pc_relative */
680 complain_overflow_dont
, /* complain_on_overflow */
681 bfd_elf_generic_reloc
, /* special_function */
682 "R_860_HAGOTOFF", /* name */
683 TRUE
, /* partial_inplace */
684 0xffffffff, /* src_mask */
685 0xffffffff, /* dst_mask */
686 FALSE
), /* pcrel_offset */
688 HOWTO (R_860_HAPC
, /* type */
690 2, /* size (0 = byte, 1 = short, 2 = long) */
692 TRUE
, /* pc_relative */
694 complain_overflow_bitfield
, /* complain_on_overflow */
695 bfd_elf_generic_reloc
, /* special_function */
696 "R_860_HAPC", /* name */
697 FALSE
, /* partial_inplace */
698 0xffff, /* src_mask */
699 0xffff, /* dst_mask */
700 TRUE
), /* pcrel_offset */
702 HOWTO (R_860_HIGH
, /* type */
704 2, /* size (0 = byte, 1 = short, 2 = long) */
706 FALSE
, /* pc_relative */
708 complain_overflow_dont
, /* complain_on_overflow */
709 bfd_elf_generic_reloc
, /* special_function */
710 "R_860_HIGH", /* name */
711 FALSE
, /* partial_inplace */
712 0xffff, /* src_mask */
713 0xffff, /* dst_mask */
714 FALSE
), /* pcrel_offset */
716 HOWTO (R_860_HIGOT
, /* type */
718 2, /* size (0 = byte, 1 = short, 2 = long) */
720 FALSE
, /* pc_relative */
722 complain_overflow_dont
, /* complain_on_overflow */
723 bfd_elf_generic_reloc
, /* special_function */
724 "R_860_HIGOT", /* name */
725 FALSE
, /* partial_inplace */
727 0xffff, /* dst_mask */
728 TRUE
), /* pcrel_offset */
730 HOWTO (R_860_HIGOTOFF
, /* type */
732 2, /* size (0 = byte, 1 = short, 2 = long) */
734 FALSE
, /* pc_relative */
736 complain_overflow_dont
, /* complain_on_overflow */
737 bfd_elf_generic_reloc
, /* special_function */
738 "R_860_HIGOTOFF", /* name */
739 TRUE
, /* partial_inplace */
740 0xffffffff, /* src_mask */
741 0xffffffff, /* dst_mask */
742 FALSE
), /* pcrel_offset */
745 static unsigned char elf_code_to_howto_index
[R_860_max
+ 1];
747 static reloc_howto_type
*
748 lookup_howto (unsigned int rtype
)
750 static int initialized
= 0;
752 int howto_tbl_size
= (int) (sizeof (elf32_i860_howto_table
)
753 / sizeof (elf32_i860_howto_table
[0]));
758 memset (elf_code_to_howto_index
, 0xff,
759 sizeof (elf_code_to_howto_index
));
760 for (i
= 0; i
< howto_tbl_size
; i
++)
761 elf_code_to_howto_index
[elf32_i860_howto_table
[i
].type
] = i
;
764 if (rtype
> R_860_max
)
766 i
= elf_code_to_howto_index
[rtype
];
767 if (i
>= howto_tbl_size
)
769 return elf32_i860_howto_table
+ i
;
772 /* Given a BFD reloc, return the matching HOWTO structure. */
773 static reloc_howto_type
*
774 elf32_i860_reloc_type_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
775 bfd_reloc_code_real_type code
)
787 case BFD_RELOC_860_COPY
:
790 case BFD_RELOC_860_GLOB_DAT
:
791 rtype
= R_860_GLOB_DAT
;
793 case BFD_RELOC_860_JUMP_SLOT
:
794 rtype
= R_860_JUMP_SLOT
;
796 case BFD_RELOC_860_RELATIVE
:
797 rtype
= R_860_RELATIVE
;
799 case BFD_RELOC_860_PC26
:
802 case BFD_RELOC_860_PLT26
:
805 case BFD_RELOC_860_PC16
:
808 case BFD_RELOC_860_LOW0
:
811 case BFD_RELOC_860_SPLIT0
:
812 rtype
= R_860_SPLIT0
;
814 case BFD_RELOC_860_LOW1
:
817 case BFD_RELOC_860_SPLIT1
:
818 rtype
= R_860_SPLIT1
;
820 case BFD_RELOC_860_LOW2
:
823 case BFD_RELOC_860_SPLIT2
:
824 rtype
= R_860_SPLIT2
;
826 case BFD_RELOC_860_LOW3
:
829 case BFD_RELOC_860_LOGOT0
:
830 rtype
= R_860_LOGOT0
;
832 case BFD_RELOC_860_SPGOT0
:
833 rtype
= R_860_SPGOT0
;
835 case BFD_RELOC_860_LOGOT1
:
836 rtype
= R_860_LOGOT1
;
838 case BFD_RELOC_860_SPGOT1
:
839 rtype
= R_860_SPGOT1
;
841 case BFD_RELOC_860_LOGOTOFF0
:
842 rtype
= R_860_LOGOTOFF0
;
844 case BFD_RELOC_860_SPGOTOFF0
:
845 rtype
= R_860_SPGOTOFF0
;
847 case BFD_RELOC_860_LOGOTOFF1
:
848 rtype
= R_860_LOGOTOFF1
;
850 case BFD_RELOC_860_SPGOTOFF1
:
851 rtype
= R_860_SPGOTOFF1
;
853 case BFD_RELOC_860_LOGOTOFF2
:
854 rtype
= R_860_LOGOTOFF2
;
856 case BFD_RELOC_860_LOGOTOFF3
:
857 rtype
= R_860_LOGOTOFF3
;
859 case BFD_RELOC_860_LOPC
:
862 case BFD_RELOC_860_HIGHADJ
:
863 rtype
= R_860_HIGHADJ
;
865 case BFD_RELOC_860_HAGOT
:
868 case BFD_RELOC_860_HAGOTOFF
:
869 rtype
= R_860_HAGOTOFF
;
871 case BFD_RELOC_860_HAPC
:
874 case BFD_RELOC_860_HIGH
:
877 case BFD_RELOC_860_HIGOT
:
880 case BFD_RELOC_860_HIGOTOFF
:
881 rtype
= R_860_HIGOTOFF
;
886 return lookup_howto (rtype
);
889 static reloc_howto_type
*
890 elf32_i860_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
896 i
< (sizeof (elf32_i860_howto_table
)
897 / sizeof (elf32_i860_howto_table
[0]));
899 if (elf32_i860_howto_table
[i
].name
!= NULL
900 && strcasecmp (elf32_i860_howto_table
[i
].name
, r_name
) == 0)
901 return &elf32_i860_howto_table
[i
];
906 /* Given a ELF reloc, return the matching HOWTO structure. */
909 elf32_i860_info_to_howto_rela (bfd
*abfd ATTRIBUTE_UNUSED
,
911 Elf_Internal_Rela
*elf_reloc
)
914 = lookup_howto ((unsigned) ELF32_R_TYPE (elf_reloc
->r_info
));
915 return bfd_reloc
->howto
!= NULL
;
918 /* Specialized relocation handler for R_860_SPLITn. These relocations
919 involves a 16-bit field that is split into two contiguous parts. */
920 static bfd_reloc_status_type
921 elf32_i860_relocate_splitn (bfd
*input_bfd
,
922 Elf_Internal_Rela
*rello
,
927 reloc_howto_type
*howto
;
928 howto
= lookup_howto ((unsigned) ELF32_R_TYPE (rello
->r_info
));
929 insn
= bfd_get_32 (input_bfd
, contents
+ rello
->r_offset
);
932 value
+= rello
->r_addend
;
934 /* Separate the fields and insert. */
935 value
= (((value
& 0xf800) << 5) | (value
& 0x7ff)) & howto
->dst_mask
;
936 insn
= (insn
& ~howto
->dst_mask
) | value
;
938 bfd_put_32 (input_bfd
, insn
, contents
+ rello
->r_offset
);
942 /* Specialized relocation handler for R_860_PC16. This relocation
943 involves a 16-bit, PC-relative field that is split into two contiguous
945 static bfd_reloc_status_type
946 elf32_i860_relocate_pc16 (bfd
*input_bfd
,
947 asection
*input_section
,
948 Elf_Internal_Rela
*rello
,
953 reloc_howto_type
*howto
;
954 howto
= lookup_howto ((unsigned) ELF32_R_TYPE (rello
->r_info
));
955 insn
= bfd_get_32 (input_bfd
, contents
+ rello
->r_offset
);
957 /* Adjust for PC-relative relocation. */
958 value
-= (input_section
->output_section
->vma
959 + input_section
->output_offset
);
960 value
-= rello
->r_offset
;
963 value
+= rello
->r_addend
;
965 /* Adjust the value by 4, then separate the fields and insert. */
966 value
= (value
- 4) >> howto
->rightshift
;
967 value
= (((value
& 0xf800) << 5) | (value
& 0x7ff)) & howto
->dst_mask
;
968 insn
= (insn
& ~howto
->dst_mask
) | value
;
970 bfd_put_32 (input_bfd
, insn
, contents
+ rello
->r_offset
);
975 /* Specialized relocation handler for R_860_PC26. This relocation
976 involves a 26-bit, PC-relative field which must be adjusted by 4. */
977 static bfd_reloc_status_type
978 elf32_i860_relocate_pc26 (bfd
*input_bfd
,
979 asection
*input_section
,
980 Elf_Internal_Rela
*rello
,
985 reloc_howto_type
*howto
;
986 howto
= lookup_howto ((unsigned) ELF32_R_TYPE (rello
->r_info
));
987 insn
= bfd_get_32 (input_bfd
, contents
+ rello
->r_offset
);
989 /* Adjust for PC-relative relocation. */
990 value
-= (input_section
->output_section
->vma
991 + input_section
->output_offset
);
992 value
-= rello
->r_offset
;
995 value
+= rello
->r_addend
;
997 /* Adjust value by 4 and insert the field. */
998 value
= ((value
- 4) >> howto
->rightshift
) & howto
->dst_mask
;
999 insn
= (insn
& ~howto
->dst_mask
) | value
;
1001 bfd_put_32 (input_bfd
, insn
, contents
+ rello
->r_offset
);
1002 return bfd_reloc_ok
;
1006 /* Specialized relocation handler for R_860_HIGHADJ. */
1007 static bfd_reloc_status_type
1008 elf32_i860_relocate_highadj (bfd
*input_bfd
,
1009 Elf_Internal_Rela
*rel
,
1015 insn
= bfd_get_32 (input_bfd
, contents
+ rel
->r_offset
);
1017 value
+= rel
->r_addend
;
1019 value
= ((value
>> 16) & 0xffff);
1021 insn
= (insn
& 0xffff0000) | value
;
1023 bfd_put_32 (input_bfd
, insn
, contents
+ rel
->r_offset
);
1024 return bfd_reloc_ok
;
1027 /* Perform a single relocation. By default we use the standard BFD
1028 routines. However, we handle some specially. */
1029 static bfd_reloc_status_type
1030 i860_final_link_relocate (reloc_howto_type
*howto
,
1032 asection
*input_section
,
1034 Elf_Internal_Rela
*rel
,
1037 return _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
1038 contents
, rel
->r_offset
, relocation
,
1042 /* Relocate an i860 ELF section.
1044 This is boiler-plate code copied from fr30.
1046 The RELOCATE_SECTION function is called by the new ELF backend linker
1047 to handle the relocations for a section.
1049 The relocs are always passed as Rela structures; if the section
1050 actually uses Rel structures, the r_addend field will always be
1053 This function is responsible for adjusting the section contents as
1054 necessary, and (if using Rela relocs and generating a relocatable
1055 output file) adjusting the reloc addend as necessary.
1057 This function does not have to worry about setting the reloc
1058 address or the reloc symbol index.
1060 LOCAL_SYMS is a pointer to the swapped in local symbols.
1062 LOCAL_SECTIONS is an array giving the section in the input file
1063 corresponding to the st_shndx field of each local symbol.
1065 The global hash table entry for the global symbols can be found
1066 via elf_sym_hashes (input_bfd).
1068 When generating relocatable output, this function must handle
1069 STB_LOCAL/STT_SECTION symbols specially. The output symbol is
1070 going to be the section symbol corresponding to the output
1071 section, which means that the addend must be adjusted
1074 elf32_i860_relocate_section (bfd
*output_bfd ATTRIBUTE_UNUSED
,
1075 struct bfd_link_info
*info
,
1077 asection
*input_section
,
1079 Elf_Internal_Rela
*relocs
,
1080 Elf_Internal_Sym
*local_syms
,
1081 asection
**local_sections
)
1083 Elf_Internal_Shdr
*symtab_hdr
;
1084 struct elf_link_hash_entry
**sym_hashes
;
1085 Elf_Internal_Rela
*rel
;
1086 Elf_Internal_Rela
*relend
;
1088 symtab_hdr
= & elf_tdata (input_bfd
)->symtab_hdr
;
1089 sym_hashes
= elf_sym_hashes (input_bfd
);
1090 relend
= relocs
+ input_section
->reloc_count
;
1092 for (rel
= relocs
; rel
< relend
; rel
++)
1094 reloc_howto_type
* howto
;
1095 unsigned long r_symndx
;
1096 Elf_Internal_Sym
* sym
;
1098 struct elf_link_hash_entry
* h
;
1100 bfd_reloc_status_type r
;
1101 const char * name
= NULL
;
1104 r_type
= ELF32_R_TYPE (rel
->r_info
);
1105 r_symndx
= ELF32_R_SYM (rel
->r_info
);
1107 howto
= lookup_howto ((unsigned) ELF32_R_TYPE (rel
->r_info
));
1112 if (r_symndx
< symtab_hdr
->sh_info
)
1114 sym
= local_syms
+ r_symndx
;
1115 sec
= local_sections
[r_symndx
];
1116 relocation
= _bfd_elf_rela_local_sym (output_bfd
, sym
, &sec
, rel
);
1118 name
= bfd_elf_string_from_elf_section
1119 (input_bfd
, symtab_hdr
->sh_link
, sym
->st_name
);
1120 name
= (name
== NULL
) ? bfd_section_name (input_bfd
, sec
) : name
;
1124 bfd_boolean unresolved_reloc
, warned
, ignored
;
1126 RELOC_FOR_GLOBAL_SYMBOL (info
, input_bfd
, input_section
, rel
,
1127 r_symndx
, symtab_hdr
, sym_hashes
,
1129 unresolved_reloc
, warned
, ignored
);
1132 if (sec
!= NULL
&& discarded_section (sec
))
1133 RELOC_AGAINST_DISCARDED_SECTION (info
, input_bfd
, input_section
,
1134 rel
, 1, relend
, howto
, 0, contents
);
1136 if (bfd_link_relocatable (info
))
1142 r
= i860_final_link_relocate (howto
, input_bfd
, input_section
,
1143 contents
, rel
, relocation
);
1147 r
= elf32_i860_relocate_highadj (input_bfd
, rel
, contents
,
1152 r
= elf32_i860_relocate_pc16 (input_bfd
, input_section
, rel
,
1153 contents
, relocation
);
1157 r
= elf32_i860_relocate_pc26 (input_bfd
, input_section
, rel
,
1158 contents
, relocation
);
1164 r
= elf32_i860_relocate_splitn (input_bfd
, rel
, contents
,
1168 /* We do not yet handle GOT/PLT/Dynamic relocations. */
1170 case R_860_GLOB_DAT
:
1171 case R_860_JUMP_SLOT
:
1172 case R_860_RELATIVE
:
1178 case R_860_LOGOTOFF0
:
1179 case R_860_SPGOTOFF0
:
1180 case R_860_LOGOTOFF1
:
1181 case R_860_SPGOTOFF1
:
1182 case R_860_LOGOTOFF2
:
1183 case R_860_LOGOTOFF3
:
1186 case R_860_HAGOTOFF
:
1189 case R_860_HIGOTOFF
:
1190 r
= bfd_reloc_notsupported
;
1194 if (r
!= bfd_reloc_ok
)
1196 const char * msg
= (const char *) NULL
;
1200 case bfd_reloc_overflow
:
1201 (*info
->callbacks
->reloc_overflow
)
1202 (info
, (h
? &h
->root
: NULL
), name
, howto
->name
,
1203 (bfd_vma
) 0, input_bfd
, input_section
, rel
->r_offset
);
1206 case bfd_reloc_undefined
:
1207 (*info
->callbacks
->undefined_symbol
)
1208 (info
, name
, input_bfd
, input_section
, rel
->r_offset
, TRUE
);
1211 case bfd_reloc_outofrange
:
1212 msg
= _("internal error: out of range error");
1215 case bfd_reloc_notsupported
:
1216 msg
= _("internal error: unsupported relocation error");
1219 case bfd_reloc_dangerous
:
1220 msg
= _("internal error: dangerous relocation");
1224 msg
= _("internal error: unknown error");
1229 (*info
->callbacks
->warning
) (info
, msg
, name
, input_bfd
,
1230 input_section
, rel
->r_offset
);
1237 /* Return whether a symbol name implies a local label. SVR4/860 compilers
1238 generate labels of the form ".ep.function_name" to denote the end of a
1239 function prolog. These should be local.
1240 ??? Do any other SVR4 compilers have this convention? If so, this should
1241 be added to the generic routine. */
1243 elf32_i860_is_local_label_name (bfd
*abfd
, const char *name
)
1245 if (name
[0] == '.' && name
[1] == 'e' && name
[2] == 'p' && name
[3] == '.')
1248 return _bfd_elf_is_local_label_name (abfd
, name
);
1251 #define TARGET_BIG_SYM i860_elf32_vec
1252 #define TARGET_BIG_NAME "elf32-i860"
1253 #define TARGET_LITTLE_SYM i860_elf32_le_vec
1254 #define TARGET_LITTLE_NAME "elf32-i860-little"
1255 #define ELF_ARCH bfd_arch_i860
1256 #define ELF_MACHINE_CODE EM_860
1257 #define ELF_MAXPAGESIZE 4096
1259 #define elf_backend_rela_normal 1
1260 #define elf_info_to_howto_rel NULL
1261 #define elf_info_to_howto elf32_i860_info_to_howto_rela
1262 #define elf_backend_relocate_section elf32_i860_relocate_section
1263 #define bfd_elf32_bfd_reloc_type_lookup elf32_i860_reloc_type_lookup
1264 #define bfd_elf32_bfd_reloc_name_lookup elf32_i860_reloc_name_lookup
1265 #define bfd_elf32_bfd_is_local_label_name elf32_i860_is_local_label_name
1267 #include "elf32-target.h"