1 /* Intel i860 specific support for 32-bit ELF.
2 Copyright 1993, 2000 Free Software Foundation, Inc.
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 2 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., 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 *));
40 /* This howto table is preliminary. */
41 static reloc_howto_type elf32_i860_howto_table [] =
43 /* This relocation does nothing. */
44 HOWTO (R_860_NONE, /* type */
46 2, /* size (0 = byte, 1 = short, 2 = long) */
48 false, /* pc_relative */
50 complain_overflow_bitfield, /* complain_on_overflow */
51 bfd_elf_generic_reloc, /* special_function */
52 "R_860_NONE", /* name */
53 false, /* partial_inplace */
56 false), /* pcrel_offset */
58 /* A 32-bit absolute relocation. */
59 HOWTO (R_860_32, /* type */
61 2, /* size (0 = byte, 1 = short, 2 = long) */
63 false, /* pc_relative */
65 complain_overflow_bitfield, /* complain_on_overflow */
66 bfd_elf_generic_reloc, /* special_function */
67 "R_860_32", /* name */
68 false, /* partial_inplace */
69 0xffffffff, /* src_mask */
70 0xffffffff, /* dst_mask */
71 false), /* pcrel_offset */
73 HOWTO (R_860_COPY, /* type */
75 2, /* size (0 = byte, 1 = short, 2 = long) */
77 false, /* pc_relative */
79 complain_overflow_bitfield, /* complain_on_overflow */
80 bfd_elf_generic_reloc, /* special_function */
81 "R_860_COPY", /* name */
82 true, /* partial_inplace */
83 0xffffffff, /* src_mask */
84 0xffffffff, /* dst_mask */
85 false), /* pcrel_offset */
87 HOWTO (R_860_GLOB_DAT, /* type */
89 2, /* size (0 = byte, 1 = short, 2 = long) */
91 false, /* pc_relative */
93 complain_overflow_bitfield, /* complain_on_overflow */
94 bfd_elf_generic_reloc, /* special_function */
95 "R_860_GLOB_DAT", /* name */
96 true, /* partial_inplace */
97 0xffffffff, /* src_mask */
98 0xffffffff, /* dst_mask */
99 false), /* pcrel_offset */
101 HOWTO (R_860_JUMP_SLOT, /* type */
103 2, /* size (0 = byte, 1 = short, 2 = long) */
105 false, /* pc_relative */
107 complain_overflow_bitfield, /* complain_on_overflow */
108 bfd_elf_generic_reloc, /* special_function */
109 "R_860_JUMP_SLOT", /* name */
110 true, /* partial_inplace */
111 0xffffffff, /* src_mask */
112 0xffffffff, /* dst_mask */
113 false), /* pcrel_offset */
115 HOWTO (R_860_RELATIVE, /* type */
117 2, /* size (0 = byte, 1 = short, 2 = long) */
119 false, /* pc_relative */
121 complain_overflow_bitfield, /* complain_on_overflow */
122 bfd_elf_generic_reloc, /* special_function */
123 "R_860_RELATIVE", /* name */
124 true, /* partial_inplace */
125 0xffffffff, /* src_mask */
126 0xffffffff, /* dst_mask */
127 false), /* pcrel_offset */
129 /* A 26-bit PC-relative relocation. */
130 HOWTO (R_860_PC26, /* type */
132 2, /* size (0 = byte, 1 = short, 2 = long) */
134 true, /* pc_relative */
136 complain_overflow_bitfield, /* complain_on_overflow */
137 bfd_elf_generic_reloc, /* special_function */
138 "R_860_PC26", /* name */
139 false, /* partial_inplace */
140 0x3ffffff, /* src_mask */
141 0x3ffffff, /* dst_mask */
142 true), /* pcrel_offset */
144 HOWTO (R_860_PLT26, /* type */
146 2, /* size (0 = byte, 1 = short, 2 = long) */
148 true, /* pc_relative */
150 complain_overflow_bitfield, /* complain_on_overflow */
151 bfd_elf_generic_reloc, /* special_function */
152 "R_860_PLT26", /* name */
153 true, /* partial_inplace */
154 0xffffffff, /* src_mask */
155 0xffffffff, /* dst_mask */
156 true), /* pcrel_offset */
158 /* A 16-bit PC-relative relocation. */
159 HOWTO (R_860_PC16, /* type */
161 2, /* size (0 = byte, 1 = short, 2 = long) */
163 true, /* pc_relative */
165 complain_overflow_bitfield, /* complain_on_overflow */
166 bfd_elf_generic_reloc, /* special_function */
167 "R_860_PC16", /* name */
168 false, /* partial_inplace */
169 0xffff, /* src_mask */
170 0xffff, /* dst_mask */
171 true), /* pcrel_offset */
173 HOWTO (R_860_LOW0, /* type */
175 2, /* size (0 = byte, 1 = short, 2 = long) */
177 false, /* pc_relative */
179 complain_overflow_dont, /* complain_on_overflow */
180 bfd_elf_generic_reloc, /* special_function */
181 "R_860_LOW0", /* name */
182 false, /* partial_inplace */
183 0xffff, /* src_mask */
184 0xffff, /* dst_mask */
185 false), /* pcrel_offset */
187 HOWTO (R_860_SPLIT0, /* type */
189 2, /* size (0 = byte, 1 = short, 2 = long) */
191 false, /* pc_relative */
193 complain_overflow_dont, /* complain_on_overflow */
194 bfd_elf_generic_reloc, /* special_function */
195 "R_860_SPLIT0", /* name */
196 false, /* partial_inplace */
197 0x1f07ff, /* src_mask */
198 0x1f07ff, /* dst_mask */
199 false), /* pcrel_offset */
201 HOWTO (R_860_LOW1, /* type */
203 2, /* size (0 = byte, 1 = short, 2 = long) */
205 false, /* pc_relative */
207 complain_overflow_dont, /* complain_on_overflow */
208 bfd_elf_generic_reloc, /* special_function */
209 "R_860_LOW1", /* name */
210 false, /* partial_inplace */
211 0xfffe, /* src_mask */
212 0xfffe, /* dst_mask */
213 false), /* pcrel_offset */
215 HOWTO (R_860_SPLIT1, /* type */
217 2, /* size (0 = byte, 1 = short, 2 = long) */
219 false, /* pc_relative */
221 complain_overflow_dont, /* complain_on_overflow */
222 bfd_elf_generic_reloc, /* special_function */
223 "R_860_SPLIT1", /* name */
224 false, /* partial_inplace */
225 0x1f07ff, /* src_mask */
226 0x1f07ff, /* dst_mask */
227 false), /* pcrel_offset */
229 HOWTO (R_860_LOW2, /* type */
231 2, /* size (0 = byte, 1 = short, 2 = long) */
233 false, /* pc_relative */
235 complain_overflow_dont, /* complain_on_overflow */
236 bfd_elf_generic_reloc, /* special_function */
237 "R_860_LOW2", /* name */
238 false, /* partial_inplace */
239 0xfffc, /* src_mask */
240 0xfffc, /* dst_mask */
241 false), /* pcrel_offset */
243 HOWTO (R_860_SPLIT2, /* type */
245 2, /* size (0 = byte, 1 = short, 2 = long) */
247 false, /* pc_relative */
249 complain_overflow_dont, /* complain_on_overflow */
250 bfd_elf_generic_reloc, /* special_function */
251 "R_860_SPLIT2", /* name */
252 false, /* partial_inplace */
253 0x1f07ff, /* src_mask */
254 0x1f07ff, /* dst_mask */
255 false), /* pcrel_offset */
257 HOWTO (R_860_LOW3, /* type */
259 2, /* size (0 = byte, 1 = short, 2 = long) */
261 false, /* pc_relative */
263 complain_overflow_dont, /* complain_on_overflow */
264 bfd_elf_generic_reloc, /* special_function */
265 "R_860_LOW3", /* name */
266 false, /* partial_inplace */
267 0xfff8, /* src_mask */
268 0xfff8, /* dst_mask */
269 false), /* pcrel_offset */
271 HOWTO (R_860_LOGOT0, /* type */
273 2, /* size (0 = byte, 1 = short, 2 = long) */
275 false, /* pc_relative */
277 complain_overflow_dont, /* complain_on_overflow */
278 bfd_elf_generic_reloc, /* special_function */
279 "R_860_LOGOT0", /* name */
280 false, /* partial_inplace */
282 0xffff, /* dst_mask */
283 true), /* pcrel_offset */
285 HOWTO (R_860_SPGOT0, /* type */
287 2, /* size (0 = byte, 1 = short, 2 = long) */
289 false, /* pc_relative */
291 complain_overflow_dont, /* complain_on_overflow */
292 bfd_elf_generic_reloc, /* special_function */
293 "R_860_SPGOT0", /* name */
294 false, /* partial_inplace */
296 0xffff, /* dst_mask */
297 true), /* pcrel_offset */
299 HOWTO (R_860_LOGOT1, /* type */
301 2, /* size (0 = byte, 1 = short, 2 = long) */
303 false, /* pc_relative */
305 complain_overflow_dont, /* complain_on_overflow */
306 bfd_elf_generic_reloc, /* special_function */
307 "R_860_LOGOT1", /* name */
308 false, /* partial_inplace */
310 0xffff, /* dst_mask */
311 true), /* pcrel_offset */
313 HOWTO (R_860_SPGOT1, /* type */
315 2, /* size (0 = byte, 1 = short, 2 = long) */
317 false, /* pc_relative */
319 complain_overflow_dont, /* complain_on_overflow */
320 bfd_elf_generic_reloc, /* special_function */
321 "R_860_SPGOT1", /* name */
322 false, /* partial_inplace */
324 0xffff, /* dst_mask */
325 true), /* pcrel_offset */
327 HOWTO (R_860_LOGOTOFF0, /* type */
329 2, /* size (0 = byte, 1 = short, 2 = long) */
331 false, /* pc_relative */
333 complain_overflow_dont, /* complain_on_overflow */
334 bfd_elf_generic_reloc, /* special_function */
335 "R_860_LOGOTOFF0", /* name */
336 true, /* partial_inplace */
337 0xffffffff, /* src_mask */
338 0xffffffff, /* dst_mask */
339 false), /* pcrel_offset */
341 HOWTO (R_860_SPGOTOFF0, /* type */
343 2, /* size (0 = byte, 1 = short, 2 = long) */
345 false, /* pc_relative */
347 complain_overflow_dont, /* complain_on_overflow */
348 bfd_elf_generic_reloc, /* special_function */
349 "R_860_SPGOTOFF0", /* name */
350 true, /* partial_inplace */
351 0xffffffff, /* src_mask */
352 0xffffffff, /* dst_mask */
353 false), /* pcrel_offset */
355 HOWTO (R_860_LOGOTOFF1, /* type */
357 2, /* size (0 = byte, 1 = short, 2 = long) */
359 false, /* pc_relative */
361 complain_overflow_dont, /* complain_on_overflow */
362 bfd_elf_generic_reloc, /* special_function */
363 "R_860_LOGOTOFF1", /* name */
364 true, /* partial_inplace */
365 0xffffffff, /* src_mask */
366 0xffffffff, /* dst_mask */
367 false), /* pcrel_offset */
369 HOWTO (R_860_SPGOTOFF1, /* type */
371 2, /* size (0 = byte, 1 = short, 2 = long) */
373 false, /* pc_relative */
375 complain_overflow_dont, /* complain_on_overflow */
376 bfd_elf_generic_reloc, /* special_function */
377 "R_860_SPGOTOFF1", /* name */
378 true, /* partial_inplace */
379 0xffffffff, /* src_mask */
380 0xffffffff, /* dst_mask */
381 false), /* pcrel_offset */
383 HOWTO (R_860_LOGOTOFF2, /* type */
385 2, /* size (0 = byte, 1 = short, 2 = long) */
387 false, /* pc_relative */
389 complain_overflow_dont, /* complain_on_overflow */
390 bfd_elf_generic_reloc, /* special_function */
391 "R_860_LOGOTOFF2", /* name */
392 true, /* partial_inplace */
393 0xffffffff, /* src_mask */
394 0xffffffff, /* dst_mask */
395 false), /* pcrel_offset */
397 HOWTO (R_860_LOGOTOFF3, /* type */
399 2, /* size (0 = byte, 1 = short, 2 = long) */
401 false, /* pc_relative */
403 complain_overflow_dont, /* complain_on_overflow */
404 bfd_elf_generic_reloc, /* special_function */
405 "R_860_LOGOTOFF3", /* name */
406 true, /* partial_inplace */
407 0xffffffff, /* src_mask */
408 0xffffffff, /* dst_mask */
409 false), /* pcrel_offset */
411 HOWTO (R_860_LOPC, /* type */
413 2, /* size (0 = byte, 1 = short, 2 = long) */
415 true, /* pc_relative */
417 complain_overflow_bitfield, /* complain_on_overflow */
418 bfd_elf_generic_reloc, /* special_function */
419 "R_860_LOPC", /* name */
420 false, /* partial_inplace */
421 0xffff, /* src_mask */
422 0xffff, /* dst_mask */
423 true), /* pcrel_offset */
425 HOWTO (R_860_HIGHADJ, /* type */
427 2, /* size (0 = byte, 1 = short, 2 = long) */
429 false, /* pc_relative */
431 complain_overflow_dont, /* complain_on_overflow */
432 bfd_elf_generic_reloc, /* special_function */
433 "R_860_HIGHADJ", /* name */
434 false, /* partial_inplace */
435 0xffff, /* src_mask */
436 0xffff, /* dst_mask */
437 false), /* pcrel_offset */
439 HOWTO (R_860_HAGOT, /* type */
441 2, /* size (0 = byte, 1 = short, 2 = long) */
443 false, /* pc_relative */
445 complain_overflow_dont, /* complain_on_overflow */
446 bfd_elf_generic_reloc, /* special_function */
447 "R_860_HAGOT", /* name */
448 false, /* partial_inplace */
450 0xffff, /* dst_mask */
451 true), /* pcrel_offset */
453 HOWTO (R_860_HAGOTOFF, /* type */
455 2, /* size (0 = byte, 1 = short, 2 = long) */
457 false, /* pc_relative */
459 complain_overflow_dont, /* complain_on_overflow */
460 bfd_elf_generic_reloc, /* special_function */
461 "R_860_HAGOTOFF", /* name */
462 true, /* partial_inplace */
463 0xffffffff, /* src_mask */
464 0xffffffff, /* dst_mask */
465 false), /* pcrel_offset */
467 HOWTO (R_860_HAPC, /* type */
469 2, /* size (0 = byte, 1 = short, 2 = long) */
471 true, /* pc_relative */
473 complain_overflow_bitfield, /* complain_on_overflow */
474 bfd_elf_generic_reloc, /* special_function */
475 "R_860_HAPC", /* name */
476 false, /* partial_inplace */
477 0xffff, /* src_mask */
478 0xffff, /* dst_mask */
479 true), /* pcrel_offset */
481 HOWTO (R_860_HIGH, /* type */
483 2, /* size (0 = byte, 1 = short, 2 = long) */
485 false, /* pc_relative */
487 complain_overflow_dont, /* complain_on_overflow */
488 bfd_elf_generic_reloc, /* special_function */
489 "R_860_HIGH", /* name */
490 false, /* partial_inplace */
491 0xffff, /* src_mask */
492 0xffff, /* dst_mask */
493 false), /* pcrel_offset */
495 HOWTO (R_860_HIGOT, /* type */
497 2, /* size (0 = byte, 1 = short, 2 = long) */
499 false, /* pc_relative */
501 complain_overflow_dont, /* complain_on_overflow */
502 bfd_elf_generic_reloc, /* special_function */
503 "R_860_HIGOT", /* name */
504 false, /* partial_inplace */
506 0xffff, /* dst_mask */
507 true), /* pcrel_offset */
509 HOWTO (R_860_HIGOTOFF, /* type */
511 2, /* size (0 = byte, 1 = short, 2 = long) */
513 false, /* pc_relative */
515 complain_overflow_dont, /* complain_on_overflow */
516 bfd_elf_generic_reloc, /* special_function */
517 "R_860_HIGOTOFF", /* name */
518 true, /* partial_inplace */
519 0xffffffff, /* src_mask */
520 0xffffffff, /* dst_mask */
521 false), /* pcrel_offset */
525 static unsigned char elf_code_to_howto_index[R_860_max + 1];
527 static reloc_howto_type *
531 static int initialized = 0;
533 int howto_tbl_size = (int) (sizeof (elf32_i860_howto_table)
534 / sizeof (elf32_i860_howto_table[0]));
539 memset (elf_code_to_howto_index, 0xff,
540 sizeof (elf_code_to_howto_index));
541 for (i = 0; i < howto_tbl_size; i++)
542 elf_code_to_howto_index[elf32_i860_howto_table[i].type] = i;
545 BFD_ASSERT (rtype <= R_860_max);
546 i = elf_code_to_howto_index[rtype];
547 if (i >= howto_tbl_size)
549 return elf32_i860_howto_table + i;
553 /* Given a BFD reloc, return the matching HOWTO structure. */
554 static reloc_howto_type *
555 elf32_i860_reloc_type_lookup (abfd, code)
556 bfd * abfd ATTRIBUTE_UNUSED;
557 bfd_reloc_code_real_type code;
569 case BFD_RELOC_860_COPY:
572 case BFD_RELOC_860_GLOB_DAT:
573 rtype = R_860_GLOB_DAT;
575 case BFD_RELOC_860_JUMP_SLOT:
576 rtype = R_860_JUMP_SLOT;
578 case BFD_RELOC_860_RELATIVE:
579 rtype = R_860_RELATIVE;
581 case BFD_RELOC_860_PC26:
584 case BFD_RELOC_860_PLT26:
587 case BFD_RELOC_860_PC16:
590 case BFD_RELOC_860_LOW0:
593 case BFD_RELOC_860_SPLIT0:
594 rtype = R_860_SPLIT0;
596 case BFD_RELOC_860_LOW1:
599 case BFD_RELOC_860_SPLIT1:
600 rtype = R_860_SPLIT1;
602 case BFD_RELOC_860_LOW2:
605 case BFD_RELOC_860_SPLIT2:
606 rtype = R_860_SPLIT2;
608 case BFD_RELOC_860_LOW3:
611 case BFD_RELOC_860_LOGOT0:
612 rtype = R_860_LOGOT0;
614 case BFD_RELOC_860_SPGOT0:
615 rtype = R_860_SPGOT0;
617 case BFD_RELOC_860_LOGOT1:
618 rtype = R_860_LOGOT1;
620 case BFD_RELOC_860_SPGOT1:
621 rtype = R_860_SPGOT1;
623 case BFD_RELOC_860_LOGOTOFF0:
624 rtype = R_860_LOGOTOFF0;
626 case BFD_RELOC_860_SPGOTOFF0:
627 rtype = R_860_SPGOTOFF0;
629 case BFD_RELOC_860_LOGOTOFF1:
630 rtype = R_860_LOGOTOFF1;
632 case BFD_RELOC_860_SPGOTOFF1:
633 rtype = R_860_SPGOTOFF1;
635 case BFD_RELOC_860_LOGOTOFF2:
636 rtype = R_860_LOGOTOFF2;
638 case BFD_RELOC_860_LOGOTOFF3:
639 rtype = R_860_LOGOTOFF3;
641 case BFD_RELOC_860_LOPC:
644 case BFD_RELOC_860_HIGHADJ:
645 rtype = R_860_HIGHADJ;
647 case BFD_RELOC_860_HAGOT:
650 case BFD_RELOC_860_HAGOTOFF:
651 rtype = R_860_HAGOTOFF;
653 case BFD_RELOC_860_HAPC:
656 case BFD_RELOC_860_HIGH:
659 case BFD_RELOC_860_HIGOT:
662 case BFD_RELOC_860_HIGOTOFF:
663 rtype = R_860_HIGOTOFF;
669 return lookup_howto (rtype);
673 /* Given a ELF reloc, return the matching HOWTO structure. */
675 elf32_i860_info_to_howto_rela (abfd, bfd_reloc, elf_reloc)
676 bfd *abfd ATTRIBUTE_UNUSED;
678 Elf64_Internal_Rela *elf_reloc;
680 bfd_reloc->howto = lookup_howto (ELF32_R_TYPE (elf_reloc->r_info));
685 #define TARGET_BIG_SYM bfd_elf32_i860_vec
686 #define TARGET_BIG_NAME "elf32-i860"
687 #define TARGET_LITTLE_SYM bfd_elf32_i860_little_vec
688 #define TARGET_LITTLE_NAME "elf32-i860-little"
689 #define ELF_ARCH bfd_arch_i860
690 #define ELF_MACHINE_CODE EM_860
691 #define ELF_MAXPAGESIZE 4096
694 #define elf_info_to_howto elf32_i860_info_to_howto_rela
695 #define bfd_elf32_bfd_reloc_type_lookup elf32_i860_reloc_type_lookup
697 #include "elf32-target.h"