1 /* IQ2000-specific support for 32-bit ELF.
2 Copyright (C) 2003-2014 Free Software Foundation, Inc.
4 This file is part of BFD, the Binary File Descriptor library.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
24 #include "elf/iq2000.h"
26 /* Forward declarations. */
28 static bfd_reloc_status_type iq2000_elf_howto_hi16_reloc (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
31 static reloc_howto_type iq2000_elf_howto_table [] =
33 /* This reloc does nothing. */
35 HOWTO (R_IQ2000_NONE, /* type */
37 2, /* size (0 = byte, 1 = short, 2 = long) */
39 FALSE, /* pc_relative */
41 complain_overflow_bitfield, /* complain_on_overflow */
42 bfd_elf_generic_reloc, /* special_function */
43 "R_IQ2000_NONE", /* name */
44 FALSE, /* partial_inplace */
47 FALSE), /* pcrel_offset */
49 /* A 16 bit absolute relocation. */
50 HOWTO (R_IQ2000_16, /* type */
52 1, /* size (0 = byte, 1 = short, 2 = long) */
54 FALSE, /* pc_relative */
56 complain_overflow_bitfield, /* complain_on_overflow */
57 bfd_elf_generic_reloc, /* special_function */
58 "R_IQ2000_16", /* name */
59 FALSE, /* partial_inplace */
60 0x0000, /* src_mask */
61 0xffff, /* dst_mask */
62 FALSE), /* pcrel_offset */
64 /* A 32 bit absolute relocation. */
65 HOWTO (R_IQ2000_32, /* type */
67 2, /* size (0 = byte, 1 = short, 2 = long) */
69 FALSE, /* pc_relative */
71 complain_overflow_bitfield, /* complain_on_overflow */
72 bfd_elf_generic_reloc, /* special_function */
73 "R_IQ2000_32", /* name */
74 FALSE, /* partial_inplace */
75 0x00000000, /* src_mask */
76 0x7fffffff, /* dst_mask */
77 FALSE), /* pcrel_offset */
79 /* 26 bit branch address. */
80 HOWTO (R_IQ2000_26, /* type */
82 2, /* size (0 = byte, 1 = short, 2 = long) */
84 FALSE, /* pc_relative */
86 complain_overflow_dont, /* complain_on_overflow */
87 /* This needs complex overflow
88 detection, because the upper four
89 bits must match the PC. */
90 bfd_elf_generic_reloc, /* special_function */
91 "R_IQ2000_26", /* name */
92 FALSE, /* partial_inplace */
93 0x00000000, /* src_mask */
94 0x03ffffff, /* dst_mask */
95 FALSE), /* pcrel_offset */
97 /* 16 bit PC relative reference. */
98 HOWTO (R_IQ2000_PC16, /* type */
100 2, /* size (0 = byte, 1 = short, 2 = long) */
102 TRUE, /* pc_relative */
104 complain_overflow_signed, /* complain_on_overflow */
105 bfd_elf_generic_reloc, /* special_function */
106 "R_IQ2000_PC16", /* name */
107 FALSE, /* partial_inplace */
108 0x0000, /* src_mask */
109 0xffff, /* dst_mask */
110 TRUE), /* pcrel_offset */
112 /* high 16 bits of symbol value. */
113 HOWTO (R_IQ2000_HI16, /* type */
115 2, /* size (0 = byte, 1 = short, 2 = long) */
117 FALSE, /* pc_relative */
119 complain_overflow_dont, /* complain_on_overflow */
120 iq2000_elf_howto_hi16_reloc, /* special_function */
121 "R_IQ2000_HI16", /* name */
122 FALSE, /* partial_inplace */
123 0x0000, /* src_mask */
124 0x7fff, /* dst_mask */
125 FALSE), /* pcrel_offset */
127 /* Low 16 bits of symbol value. */
128 HOWTO (R_IQ2000_LO16, /* type */
130 2, /* size (0 = byte, 1 = short, 2 = long) */
132 FALSE, /* pc_relative */
134 complain_overflow_dont, /* complain_on_overflow */
135 bfd_elf_generic_reloc, /* special_function */
136 "R_IQ2000_LO16", /* name */
137 FALSE, /* partial_inplace */
138 0x0000, /* src_mask */
139 0xffff, /* dst_mask */
140 FALSE), /* pcrel_offset */
142 /* 16-bit jump offset. */
143 HOWTO (R_IQ2000_OFFSET_16, /* type */
145 2, /* size (0 = byte, 1 = short, 2 = long) */
147 FALSE, /* pc_relative */
149 complain_overflow_dont, /* complain_on_overflow */
150 bfd_elf_generic_reloc, /* special_function */
151 "R_IQ2000_OFFSET_16", /* name */
152 FALSE, /* partial_inplace */
153 0x0000, /* src_mask */
154 0xffff, /* dst_mask */
155 FALSE), /* pcrel_offset */
157 /* 21-bit jump offset. */
158 HOWTO (R_IQ2000_OFFSET_21, /* type */
160 2, /* size (0 = byte, 1 = short, 2 = long) */
162 FALSE, /* pc_relative */
164 complain_overflow_dont, /* complain_on_overflow */
165 bfd_elf_generic_reloc, /* special_function */
166 "R_IQ2000_OFFSET_21", /* name */
167 FALSE, /* partial_inplace */
168 0x000000, /* src_mask */
169 0x1fffff, /* dst_mask */
170 FALSE), /* pcrel_offset */
172 /* unsigned high 16 bits of value. */
173 HOWTO (R_IQ2000_OFFSET_21, /* 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_IQ2000_UHI16", /* name */
182 FALSE, /* partial_inplace */
183 0x0000, /* src_mask */
184 0x7fff, /* dst_mask */
185 FALSE), /* pcrel_offset */
187 /* A 32 bit absolute debug relocation. */
188 HOWTO (R_IQ2000_32_DEBUG, /* type */
190 2, /* size (0 = byte, 1 = short, 2 = long) */
192 FALSE, /* pc_relative */
194 complain_overflow_bitfield, /* complain_on_overflow */
195 bfd_elf_generic_reloc, /* special_function */
196 "R_IQ2000_32", /* name */
197 FALSE, /* partial_inplace */
198 0x00000000, /* src_mask */
199 0xffffffff, /* dst_mask */
200 FALSE), /* pcrel_offset */
204 /* GNU extension to record C++ vtable hierarchy. */
205 static reloc_howto_type iq2000_elf_vtinherit_howto =
206 HOWTO (R_IQ2000_GNU_VTINHERIT, /* type */
208 2, /* size (0 = byte, 1 = short, 2 = long) */
210 FALSE, /* pc_relative */
212 complain_overflow_dont, /* complain_on_overflow */
213 NULL, /* special_function */
214 "R_IQ2000_GNU_VTINHERIT", /* name */
215 FALSE, /* partial_inplace */
218 FALSE); /* pcrel_offset */
220 /* GNU extension to record C++ vtable member usage. */
221 static reloc_howto_type iq2000_elf_vtentry_howto =
222 HOWTO (R_IQ2000_GNU_VTENTRY, /* type */
224 2, /* size (0 = byte, 1 = short, 2 = long) */
226 FALSE, /* pc_relative */
228 complain_overflow_dont, /* complain_on_overflow */
229 NULL, /* special_function */
230 "R_IQ2000_GNU_VTENTRY", /* name */
231 FALSE, /* partial_inplace */
234 FALSE); /* pcrel_offset */
237 static bfd_reloc_status_type
238 iq2000_elf_howto_hi16_reloc (bfd *abfd ATTRIBUTE_UNUSED,
239 arelent *reloc_entry,
242 asection *input_section,
244 char **error_message ATTRIBUTE_UNUSED)
246 bfd_reloc_status_type ret;
249 /* If we're relocating and this an external symbol,
250 we don't want to change anything. */
251 if (output_bfd != (bfd *) NULL
252 && (symbol->flags & BSF_SECTION_SYM) == 0
253 && reloc_entry->addend == 0)
255 reloc_entry->address += input_section->output_offset;
259 if (bfd_is_com_section (symbol->section))
262 relocation = symbol->value;
264 relocation += symbol->section->output_section->vma;
265 relocation += symbol->section->output_offset;
266 relocation += reloc_entry->addend;
268 /* If %lo will have sign-extension, compensate by add 0x10000 to hi portion. */
269 if (relocation & 0x8000)
270 reloc_entry->addend += 0x10000;
272 /* Now do the reloc in the usual way. */
273 ret = bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,
274 input_section, output_bfd, error_message);
276 /* Put it back the way it was. */
277 if (relocation & 0x8000)
278 reloc_entry->addend -= 0x10000;
283 static bfd_reloc_status_type
284 iq2000_elf_relocate_hi16 (bfd *input_bfd,
285 Elf_Internal_Rela *relhi,
291 insn = bfd_get_32 (input_bfd, contents + relhi->r_offset);
293 value += relhi->r_addend;
294 value &= 0x7fffffff; /* Mask off top-bit which is Harvard mask bit. */
296 /* If top-bit of %lo value is on, this means that %lo will
297 sign-propagate and so we compensate by adding 1 to %hi value. */
302 insn = ((insn & ~0xFFFF) | value);
304 bfd_put_32 (input_bfd, insn, contents + relhi->r_offset);
308 static bfd_reloc_status_type
309 iq2000_elf_relocate_offset16 (bfd *input_bfd,
310 Elf_Internal_Rela *rel,
318 insn = bfd_get_32 (input_bfd, contents + rel->r_offset);
320 value += rel->r_addend;
323 return bfd_reloc_dangerous;
325 jtarget = (value & 0x3fffc) | (location & 0xf0000000L);
327 if (jtarget != value)
328 return bfd_reloc_overflow;
330 insn = (insn & ~0xFFFF) | ((value >> 2) & 0xFFFF);
332 bfd_put_32 (input_bfd, insn, contents + rel->r_offset);
336 /* Map BFD reloc types to IQ2000 ELF reloc types. */
338 static reloc_howto_type *
339 iq2000_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
340 bfd_reloc_code_real_type code)
342 /* Note that the iq2000_elf_howto_table is indxed by the R_
343 constants. Thus, the order that the howto records appear in the
344 table *must* match the order of the relocation types defined in
345 include/elf/iq2000.h. */
350 return &iq2000_elf_howto_table[ (int) R_IQ2000_NONE];
352 return &iq2000_elf_howto_table[ (int) R_IQ2000_16];
354 return &iq2000_elf_howto_table[ (int) R_IQ2000_32];
355 case BFD_RELOC_MIPS_JMP:
356 return &iq2000_elf_howto_table[ (int) R_IQ2000_26];
357 case BFD_RELOC_IQ2000_OFFSET_16:
358 return &iq2000_elf_howto_table[ (int) R_IQ2000_OFFSET_16];
359 case BFD_RELOC_IQ2000_OFFSET_21:
360 return &iq2000_elf_howto_table[ (int) R_IQ2000_OFFSET_21];
361 case BFD_RELOC_16_PCREL_S2:
362 return &iq2000_elf_howto_table[ (int) R_IQ2000_PC16];
364 return &iq2000_elf_howto_table[ (int) R_IQ2000_HI16];
365 case BFD_RELOC_IQ2000_UHI16:
366 return &iq2000_elf_howto_table[ (int) R_IQ2000_UHI16];
368 return &iq2000_elf_howto_table[ (int) R_IQ2000_LO16];
369 case BFD_RELOC_VTABLE_INHERIT:
370 return &iq2000_elf_vtinherit_howto;
371 case BFD_RELOC_VTABLE_ENTRY:
372 return &iq2000_elf_vtentry_howto;
374 /* Pacify gcc -Wall. */
380 static reloc_howto_type *
381 iq2000_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name)
386 i < (sizeof (iq2000_elf_howto_table)
387 / sizeof (iq2000_elf_howto_table[0]));
389 if (iq2000_elf_howto_table[i].name != NULL
390 && strcasecmp (iq2000_elf_howto_table[i].name, r_name) == 0)
391 return &iq2000_elf_howto_table[i];
393 if (strcasecmp (iq2000_elf_vtinherit_howto.name, r_name) == 0)
394 return &iq2000_elf_vtinherit_howto;
395 if (strcasecmp (iq2000_elf_vtentry_howto.name, r_name) == 0)
396 return &iq2000_elf_vtentry_howto;
401 /* Perform a single relocation. By default we use the standard BFD
404 static bfd_reloc_status_type
405 iq2000_final_link_relocate (reloc_howto_type * howto,
407 asection * input_section,
409 Elf_Internal_Rela * rel,
412 return _bfd_final_link_relocate (howto, input_bfd, input_section,
413 contents, rel->r_offset,
414 relocation, rel->r_addend);
417 /* Set the howto pointer for a IQ2000 ELF reloc. */
420 iq2000_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED,
422 Elf_Internal_Rela * dst)
426 r_type = ELF32_R_TYPE (dst->r_info);
429 case R_IQ2000_GNU_VTINHERIT:
430 cache_ptr->howto = & iq2000_elf_vtinherit_howto;
433 case R_IQ2000_GNU_VTENTRY:
434 cache_ptr->howto = & iq2000_elf_vtentry_howto;
438 cache_ptr->howto = & iq2000_elf_howto_table [r_type];
443 /* Look through the relocs for a section during the first phase.
444 Since we don't do .gots or .plts, we just need to consider the
445 virtual table relocs for gc. */
448 iq2000_elf_check_relocs (bfd *abfd,
449 struct bfd_link_info *info,
451 const Elf_Internal_Rela *relocs)
453 Elf_Internal_Shdr *symtab_hdr;
454 struct elf_link_hash_entry **sym_hashes;
455 const Elf_Internal_Rela *rel;
456 const Elf_Internal_Rela *rel_end;
457 bfd_boolean changed = FALSE;
459 if (info->relocatable)
462 symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
463 sym_hashes = elf_sym_hashes (abfd);
465 rel_end = relocs + sec->reloc_count;
466 for (rel = relocs; rel < rel_end; rel++)
468 struct elf_link_hash_entry *h;
469 unsigned long r_symndx;
471 r_symndx = ELF32_R_SYM (rel->r_info);
472 if (r_symndx < symtab_hdr->sh_info)
476 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
477 while (h->root.type == bfd_link_hash_indirect
478 || h->root.type == bfd_link_hash_warning)
479 h = (struct elf_link_hash_entry *) h->root.u.i.link;
481 /* PR15323, ref flags aren't set for references in the same
483 h->root.non_ir_ref = 1;
486 switch (ELF32_R_TYPE (rel->r_info))
488 /* This relocation describes the C++ object vtable
489 hierarchy. Reconstruct it for later use during GC. */
490 case R_IQ2000_GNU_VTINHERIT:
491 if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
495 /* This relocation describes which C++ vtable entries
496 are actually used. Record for later use during GC. */
497 case R_IQ2000_GNU_VTENTRY:
498 BFD_ASSERT (h != NULL);
500 && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
505 /* For debug section, change to special harvard-aware relocations. */
506 if (CONST_STRNEQ (sec->name, ".debug")
507 || CONST_STRNEQ (sec->name, ".stab")
508 || CONST_STRNEQ (sec->name, ".eh_frame"))
510 ((Elf_Internal_Rela *) rel)->r_info
511 = ELF32_R_INFO (ELF32_R_SYM (rel->r_info), R_IQ2000_32_DEBUG);
519 /* Note that we've changed relocs, otherwise if !info->keep_memory
520 we'll free the relocs and lose our changes. */
521 elf_section_data (sec)->relocs = (Elf_Internal_Rela *) relocs;
527 /* Relocate a IQ2000 ELF section.
528 There is some attempt to make this function usable for many architectures,
529 both USE_REL and USE_RELA ['twould be nice if such a critter existed],
530 if only to serve as a learning tool.
532 The RELOCATE_SECTION function is called by the new ELF backend linker
533 to handle the relocations for a section.
535 The relocs are always passed as Rela structures; if the section
536 actually uses Rel structures, the r_addend field will always be
539 This function is responsible for adjusting the section contents as
540 necessary, and (if using Rela relocs and generating a relocatable
541 output file) adjusting the reloc addend as necessary.
543 This function does not have to worry about setting the reloc
544 address or the reloc symbol index.
546 LOCAL_SYMS is a pointer to the swapped in local symbols.
548 LOCAL_SECTIONS is an array giving the section in the input file
549 corresponding to the st_shndx field of each local symbol.
551 The global hash table entry for the global symbols can be found
552 via elf_sym_hashes (input_bfd).
554 When generating relocatable output, this function must handle
555 STB_LOCAL/STT_SECTION symbols specially. The output symbol is
556 going to be the section symbol corresponding to the output
557 section, which means that the addend must be adjusted
561 iq2000_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED,
562 struct bfd_link_info * info,
564 asection * input_section,
566 Elf_Internal_Rela * relocs,
567 Elf_Internal_Sym * local_syms,
568 asection ** local_sections)
570 Elf_Internal_Shdr * symtab_hdr;
571 struct elf_link_hash_entry ** sym_hashes;
572 Elf_Internal_Rela * rel;
573 Elf_Internal_Rela * relend;
575 symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
576 sym_hashes = elf_sym_hashes (input_bfd);
577 relend = relocs + input_section->reloc_count;
579 for (rel = relocs; rel < relend; rel ++)
581 reloc_howto_type * howto;
582 unsigned long r_symndx;
583 Elf_Internal_Sym * sym;
585 struct elf_link_hash_entry * h;
587 bfd_reloc_status_type r;
588 const char * name = NULL;
591 r_type = ELF32_R_TYPE (rel->r_info);
593 if ( r_type == R_IQ2000_GNU_VTINHERIT
594 || r_type == R_IQ2000_GNU_VTENTRY)
597 r_symndx = ELF32_R_SYM (rel->r_info);
599 howto = iq2000_elf_howto_table + ELF32_R_TYPE (rel->r_info);
604 if (r_symndx < symtab_hdr->sh_info)
608 sym = local_syms + r_symndx;
609 osec = sec = local_sections [r_symndx];
610 if ((sec->flags & SEC_MERGE)
611 && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
612 /* This relocation is relative to a section symbol that is
613 going to be merged. Change it so that it is relative
614 to the merged section symbol. */
615 rel->r_addend = _bfd_elf_rel_local_sym (output_bfd, sym, &sec,
618 relocation = (sec->output_section->vma
622 name = bfd_elf_string_from_elf_section
623 (input_bfd, symtab_hdr->sh_link, sym->st_name);
624 name = (name == NULL) ? bfd_section_name (input_bfd, osec) : name;
628 bfd_boolean unresolved_reloc;
629 bfd_boolean warned, ignored;
631 RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
632 r_symndx, symtab_hdr, sym_hashes,
634 unresolved_reloc, warned, ignored);
636 name = h->root.root.string;
639 if (sec != NULL && discarded_section (sec))
640 RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
641 rel, 1, relend, howto, 0, contents);
643 if (info->relocatable)
649 r = iq2000_elf_relocate_hi16 (input_bfd, rel, contents, relocation);
652 case R_IQ2000_OFFSET_16:
653 r = iq2000_elf_relocate_offset16 (input_bfd, rel, contents, relocation,
654 input_section->output_section->vma
655 + input_section->output_offset
664 r = iq2000_final_link_relocate (howto, input_bfd, input_section,
665 contents, rel, relocation);
669 if (r != bfd_reloc_ok)
671 const char * msg = (const char *) NULL;
675 case bfd_reloc_overflow:
676 r = info->callbacks->reloc_overflow
677 (info, (h ? &h->root : NULL), name, howto->name,
678 (bfd_vma) 0, input_bfd, input_section, rel->r_offset);
681 case bfd_reloc_undefined:
682 r = info->callbacks->undefined_symbol
683 (info, name, input_bfd, input_section, rel->r_offset, TRUE);
686 case bfd_reloc_outofrange:
687 msg = _("internal error: out of range error");
690 case bfd_reloc_notsupported:
691 msg = _("internal error: unsupported relocation error");
694 case bfd_reloc_dangerous:
695 msg = _("internal error: dangerous relocation");
699 msg = _("internal error: unknown error");
704 r = info->callbacks->warning
705 (info, msg, name, input_bfd, input_section, rel->r_offset);
716 /* Return the section that should be marked against GC for a given
720 iq2000_elf_gc_mark_hook (asection *sec,
721 struct bfd_link_info *info,
722 Elf_Internal_Rela *rel,
723 struct elf_link_hash_entry *h,
724 Elf_Internal_Sym *sym)
727 switch (ELF32_R_TYPE (rel->r_info))
729 case R_IQ2000_GNU_VTINHERIT:
730 case R_IQ2000_GNU_VTENTRY:
734 return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
738 /* Return the MACH for an e_flags value. */
741 elf32_iq2000_machine (bfd *abfd)
743 switch (elf_elfheader (abfd)->e_flags & EF_IQ2000_CPU_MASK)
745 case EF_IQ2000_CPU_IQ10:
746 return bfd_mach_iq10;
748 case EF_IQ2000_CPU_IQ2000:
750 return bfd_mach_iq2000;
755 /* Function to set the ELF flag bits. */
758 iq2000_elf_set_private_flags (bfd *abfd, flagword flags)
760 elf_elfheader (abfd)->e_flags = flags;
761 elf_flags_init (abfd) = TRUE;
765 /* Merge backend specific data from an object
766 file to the output object file when linking. */
769 iq2000_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
771 flagword old_flags, old_partial;
772 flagword new_flags, new_partial;
773 bfd_boolean error = FALSE;
777 new_opt[0] = old_opt[0] = '\0';
778 new_flags = elf_elfheader (ibfd)->e_flags;
779 old_flags = elf_elfheader (obfd)->e_flags;
781 if (!elf_flags_init (obfd))
783 /* First call, no flags set. */
784 elf_flags_init (obfd) = TRUE;
785 elf_elfheader (obfd)->e_flags = new_flags;
788 else if (new_flags != old_flags)
790 /* Warn if different cpu is used, but allow a
791 specific cpu to override the generic cpu. */
792 new_partial = (new_flags & EF_IQ2000_CPU_MASK);
793 old_partial = (old_flags & EF_IQ2000_CPU_MASK);
795 if (new_partial != old_partial)
799 case EF_IQ2000_CPU_IQ10:
800 strcat (new_opt, " -m10");
804 case EF_IQ2000_CPU_IQ2000:
805 strcat (new_opt, " -m2000");
811 case EF_IQ2000_CPU_IQ10:
812 strcat (old_opt, " -m10");
816 case EF_IQ2000_CPU_IQ2000:
817 strcat (old_opt, " -m2000");
822 /* Print out any mismatches from above. */
827 (_("%s: compiled with %s and linked with modules compiled with %s"),
828 bfd_get_filename (ibfd), new_opt, old_opt);
831 new_flags &= ~ EF_IQ2000_ALL_FLAGS;
832 old_flags &= ~ EF_IQ2000_ALL_FLAGS;
834 /* Warn about any other mismatches. */
835 if (new_flags != old_flags)
840 (_("%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)"),
841 bfd_get_filename (ibfd), (long)new_flags, (long)old_flags);
846 bfd_set_error (bfd_error_bad_value);
853 iq2000_elf_print_private_bfd_data (bfd *abfd, void * ptr)
855 FILE *file = (FILE *) ptr;
858 BFD_ASSERT (abfd != NULL && ptr != NULL);
860 /* Print normal ELF private data. */
861 _bfd_elf_print_private_bfd_data (abfd, ptr);
863 flags = elf_elfheader (abfd)->e_flags;
864 fprintf (file, _("private flags = 0x%lx:"), (unsigned long) flags);
866 switch (flags & EF_IQ2000_CPU_MASK)
868 case EF_IQ2000_CPU_IQ10:
869 fprintf (file, " -m10");
871 case EF_IQ2000_CPU_IQ2000:
872 fprintf (file, " -m2000");
884 iq2000_elf_object_p (bfd *abfd)
886 bfd_default_set_arch_mach (abfd, bfd_arch_iq2000,
887 elf32_iq2000_machine (abfd));
892 #define ELF_ARCH bfd_arch_iq2000
893 #define ELF_MACHINE_CODE EM_IQ2000
894 #define ELF_MAXPAGESIZE 0x1000
896 #define TARGET_BIG_SYM iq2000_elf32_vec
897 #define TARGET_BIG_NAME "elf32-iq2000"
899 #define elf_info_to_howto_rel NULL
900 #define elf_info_to_howto iq2000_info_to_howto_rela
901 #define elf_backend_relocate_section iq2000_elf_relocate_section
902 #define elf_backend_gc_mark_hook iq2000_elf_gc_mark_hook
903 #define elf_backend_check_relocs iq2000_elf_check_relocs
904 #define elf_backend_object_p iq2000_elf_object_p
905 #define elf_backend_rela_normal 1
907 #define elf_backend_can_gc_sections 1
909 #define bfd_elf32_bfd_reloc_type_lookup iq2000_reloc_type_lookup
910 #define bfd_elf32_bfd_reloc_name_lookup iq2000_reloc_name_lookup
911 #define bfd_elf32_bfd_set_private_flags iq2000_elf_set_private_flags
912 #define bfd_elf32_bfd_merge_private_bfd_data iq2000_elf_merge_private_bfd_data
913 #define bfd_elf32_bfd_print_private_bfd_data iq2000_elf_print_private_bfd_data
915 #include "elf32-target.h"