1 /* M16C/M32C specific support for 32-bit ELF.
3 Free Software Foundation, Inc.
5 This file is part of BFD, the Binary File Descriptor library.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
26 #include "libiberty.h"
28 /* Forward declarations. */
29 static reloc_howto_type
* m32c_reloc_type_lookup
30 (bfd
*, bfd_reloc_code_real_type
);
31 static void m32c_info_to_howto_rela
32 (bfd
*, arelent
*, Elf_Internal_Rela
*);
33 static bfd_boolean m32c_elf_relocate_section
34 (bfd
*, struct bfd_link_info
*, bfd
*, asection
*, bfd_byte
*, Elf_Internal_Rela
*, Elf_Internal_Sym
*, asection
**);
35 static bfd_boolean m32c_elf_gc_sweep_hook
36 (bfd
*, struct bfd_link_info
*, asection
*, const Elf_Internal_Rela
*);
37 static asection
* m32c_elf_gc_mark_hook
38 (asection
*, struct bfd_link_info
*, Elf_Internal_Rela
*, struct elf_link_hash_entry
*, Elf_Internal_Sym
*);
39 static bfd_boolean m32c_elf_check_relocs
40 (bfd
*, struct bfd_link_info
*, asection
*, const Elf_Internal_Rela
*);
41 static bfd_boolean
m32c_elf_relax_delete_bytes (bfd
*, asection
*, bfd_vma
, int);
43 static char * m32c_get_reloc (long reloc
);
45 static bfd_boolean m32c_elf_relax_section
46 (bfd
*abfd
, asection
*sec
, struct bfd_link_info
*link_info
, bfd_boolean
*again
);
49 static reloc_howto_type m32c_elf_howto_table
[] =
51 /* This reloc does nothing. */
52 HOWTO (R_M32C_NONE
, /* type */
54 0, /* size (0 = byte, 1 = short, 2 = long) */
56 FALSE
, /* pc_relative */
58 complain_overflow_bitfield
, /* complain_on_overflow */
59 bfd_elf_generic_reloc
, /* special_function */
60 "R_M32C_NONE", /* name */
61 FALSE
, /* partial_inplace */
64 FALSE
), /* pcrel_offset */
66 HOWTO (R_M32C_16
, /* type */
68 1, /* 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_M32C_16", /* name */
75 FALSE
, /* partial_inplace */
77 0x0000ffff, /* dst_mask */
78 FALSE
), /* pcrel_offset */
80 HOWTO (R_M32C_24
, /* type */
82 2, /* size (0 = byte, 1 = short, 2 = long) */
84 FALSE
, /* pc_relative */
86 complain_overflow_bitfield
, /* complain_on_overflow */
87 bfd_elf_generic_reloc
, /* special_function */
88 "R_M32C_24", /* name */
89 FALSE
, /* partial_inplace */
91 0x00ffffff, /* dst_mask */
92 FALSE
), /* pcrel_offset */
94 HOWTO (R_M32C_32
, /* type */
96 2, /* size (0 = byte, 1 = short, 2 = long) */
98 FALSE
, /* pc_relative */
100 complain_overflow_bitfield
, /* complain_on_overflow */
101 bfd_elf_generic_reloc
, /* special_function */
102 "R_M32C_32", /* name */
103 FALSE
, /* partial_inplace */
105 0xffffffff, /* dst_mask */
106 FALSE
), /* pcrel_offset */
108 HOWTO (R_M32C_8_PCREL
, /* type */
110 0, /* size (0 = byte, 1 = short, 2 = long) */
112 TRUE
, /* pc_relative */
114 complain_overflow_signed
, /* complain_on_overflow */
115 bfd_elf_generic_reloc
, /* special_function */
116 "R_M32C_8_PCREL", /* name */
117 FALSE
, /* partial_inplace */
119 0x000000ff, /* dst_mask */
120 TRUE
), /* pcrel_offset */
122 HOWTO (R_M32C_16_PCREL
, /* type */
124 1, /* size (0 = byte, 1 = short, 2 = long) */
126 TRUE
, /* pc_relative */
128 complain_overflow_signed
, /* complain_on_overflow */
129 bfd_elf_generic_reloc
, /* special_function */
130 "R_M32C_16_PCREL", /* name */
131 FALSE
, /* partial_inplace */
134 TRUE
), /* pcrel_offset */
136 HOWTO (R_M32C_8
, /* type */
138 0, /* size (0 = byte, 1 = short, 2 = long) */
140 FALSE
, /* pc_relative */
142 complain_overflow_unsigned
, /* complain_on_overflow */
143 bfd_elf_generic_reloc
, /* special_function */
144 "R_M32C_8", /* name */
145 FALSE
, /* partial_inplace */
147 0x000000ff, /* dst_mask */
148 FALSE
), /* pcrel_offset */
150 HOWTO (R_M32C_LO16
, /* type */
152 1, /* size (0 = byte, 1 = short, 2 = long) */
154 FALSE
, /* pc_relative */
156 complain_overflow_dont
, /* complain_on_overflow */
157 bfd_elf_generic_reloc
, /* special_function */
158 "R_M32C_LO16", /* name */
159 FALSE
, /* partial_inplace */
161 0x0000ffff, /* dst_mask */
162 FALSE
), /* pcrel_offset */
164 HOWTO (R_M32C_HI8
, /* type */
166 0, /* size (0 = byte, 1 = short, 2 = long) */
168 FALSE
, /* pc_relative */
170 complain_overflow_dont
, /* complain_on_overflow */
171 bfd_elf_generic_reloc
, /* special_function */
172 "R_M32C_HI8", /* name */
173 FALSE
, /* partial_inplace */
175 0x000000ff, /* dst_mask */
176 FALSE
), /* pcrel_offset */
178 HOWTO (R_M32C_HI16
, /* type */
180 1, /* size (0 = byte, 1 = short, 2 = long) */
182 FALSE
, /* pc_relative */
184 complain_overflow_dont
, /* complain_on_overflow */
185 bfd_elf_generic_reloc
, /* special_function */
186 "R_M32C_HI16", /* name */
187 FALSE
, /* partial_inplace */
189 0x0000ffff, /* dst_mask */
190 FALSE
), /* pcrel_offset */
193 /* Map BFD reloc types to M32C ELF reloc types. */
195 struct m32c_reloc_map
197 bfd_reloc_code_real_type bfd_reloc_val
;
198 unsigned int m32c_reloc_val
;
201 static const struct m32c_reloc_map m32c_reloc_map
[] =
203 { BFD_RELOC_NONE
, R_M32C_NONE
},
204 { BFD_RELOC_16
, R_M32C_16
},
205 { BFD_RELOC_24
, R_M32C_24
},
206 { BFD_RELOC_32
, R_M32C_32
},
207 { BFD_RELOC_8_PCREL
, R_M32C_8_PCREL
},
208 { BFD_RELOC_16_PCREL
, R_M32C_16_PCREL
},
209 { BFD_RELOC_8
, R_M32C_8
},
210 { BFD_RELOC_LO16
, R_M32C_LO16
},
211 { BFD_RELOC_HI16
, R_M32C_HI16
},
212 { BFD_RELOC_M32C_HI8
, R_M32C_HI8
}
215 static reloc_howto_type
*
216 m32c_reloc_type_lookup
217 (bfd
* abfd ATTRIBUTE_UNUSED
,
218 bfd_reloc_code_real_type code
)
222 for (i
= ARRAY_SIZE (m32c_reloc_map
); --i
;)
223 if (m32c_reloc_map
[i
].bfd_reloc_val
== code
)
224 return & m32c_elf_howto_table
[m32c_reloc_map
[i
].m32c_reloc_val
];
229 /* Set the howto pointer for an M32C ELF reloc. */
232 m32c_info_to_howto_rela
233 (bfd
* abfd ATTRIBUTE_UNUSED
,
235 Elf_Internal_Rela
* dst
)
239 r_type
= ELF32_R_TYPE (dst
->r_info
);
240 BFD_ASSERT (r_type
< (unsigned int) R_M32C_max
);
241 cache_ptr
->howto
= & m32c_elf_howto_table
[r_type
];
246 /* Relocate an M32C ELF section.
247 There is some attempt to make this function usable for many architectures,
248 both USE_REL and USE_RELA ['twould be nice if such a critter existed],
249 if only to serve as a learning tool.
251 The RELOCATE_SECTION function is called by the new ELF backend linker
252 to handle the relocations for a section.
254 The relocs are always passed as Rela structures; if the section
255 actually uses Rel structures, the r_addend field will always be
258 This function is responsible for adjusting the section contents as
259 necessary, and (if using Rela relocs and generating a relocatable
260 output file) adjusting the reloc addend as necessary.
262 This function does not have to worry about setting the reloc
263 address or the reloc symbol index.
265 LOCAL_SYMS is a pointer to the swapped in local symbols.
267 LOCAL_SECTIONS is an array giving the section in the input file
268 corresponding to the st_shndx field of each local symbol.
270 The global hash table entry for the global symbols can be found
271 via elf_sym_hashes (input_bfd).
273 When generating relocatable output, this function must handle
274 STB_LOCAL/STT_SECTION symbols specially. The output symbol is
275 going to be the section symbol corresponding to the output
276 section, which means that the addend must be adjusted
280 m32c_elf_relocate_section
281 (bfd
* output_bfd ATTRIBUTE_UNUSED
,
282 struct bfd_link_info
* info
,
284 asection
* input_section
,
286 Elf_Internal_Rela
* relocs
,
287 Elf_Internal_Sym
* local_syms
,
288 asection
** local_sections
)
290 Elf_Internal_Shdr
* symtab_hdr
;
291 struct elf_link_hash_entry
** sym_hashes
;
292 Elf_Internal_Rela
* rel
;
293 Elf_Internal_Rela
* relend
;
297 symtab_hdr
= & elf_tdata (input_bfd
)->symtab_hdr
;
298 sym_hashes
= elf_sym_hashes (input_bfd
);
299 relend
= relocs
+ input_section
->reloc_count
;
301 dynobj
= elf_hash_table (info
)->dynobj
;
304 splt
= bfd_get_section_by_name (dynobj
, ".plt");
306 for (rel
= relocs
; rel
< relend
; rel
++)
308 reloc_howto_type
* howto
;
309 unsigned long r_symndx
;
310 Elf_Internal_Sym
* sym
;
312 struct elf_link_hash_entry
* h
;
314 bfd_reloc_status_type r
;
315 const char * name
= NULL
;
318 r_type
= ELF32_R_TYPE (rel
->r_info
);
320 r_symndx
= ELF32_R_SYM (rel
->r_info
);
322 if (info
->relocatable
)
324 /* This is a relocatable link. We don't have to change
325 anything, unless the reloc is against a section symbol,
326 in which case we have to adjust according to where the
327 section symbol winds up in the output section. */
328 if (r_symndx
< symtab_hdr
->sh_info
)
330 sym
= local_syms
+ r_symndx
;
332 if (ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
)
334 sec
= local_sections
[r_symndx
];
335 rel
->r_addend
+= sec
->output_offset
+ sym
->st_value
;
342 /* This is a final link. */
343 howto
= m32c_elf_howto_table
+ ELF32_R_TYPE (rel
->r_info
);
348 if (r_symndx
< symtab_hdr
->sh_info
)
350 sym
= local_syms
+ r_symndx
;
351 sec
= local_sections
[r_symndx
];
352 relocation
= (sec
->output_section
->vma
356 name
= bfd_elf_string_from_elf_section
357 (input_bfd
, symtab_hdr
->sh_link
, sym
->st_name
);
358 name
= (name
== NULL
) ? bfd_section_name (input_bfd
, sec
) : name
;
362 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
364 while (h
->root
.type
== bfd_link_hash_indirect
365 || h
->root
.type
== bfd_link_hash_warning
)
366 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
368 name
= h
->root
.root
.string
;
370 if (h
->root
.type
== bfd_link_hash_defined
371 || h
->root
.type
== bfd_link_hash_defweak
)
373 sec
= h
->root
.u
.def
.section
;
374 relocation
= (h
->root
.u
.def
.value
375 + sec
->output_section
->vma
376 + sec
->output_offset
);
378 else if (h
->root
.type
== bfd_link_hash_undefweak
)
384 if (! ((*info
->callbacks
->undefined_symbol
)
385 (info
, h
->root
.root
.string
, input_bfd
,
386 input_section
, rel
->r_offset
, TRUE
)))
392 switch (ELF32_R_TYPE (rel
->r_info
))
399 plt_offset
= &h
->plt
.offset
;
401 plt_offset
= elf_local_got_offsets (input_bfd
) + r_symndx
;
403 /* printf("%s: rel %x plt %d\n", h ? h->root.root.string : "(none)",
404 relocation, *plt_offset);*/
405 if (relocation
<= 0xffff)
407 /* If the symbol is in range for a 16-bit address, we should
408 have deallocated the plt entry in relax_section. */
409 BFD_ASSERT (*plt_offset
== (bfd_vma
) -1);
413 /* If the symbol is out of range for a 16-bit address,
414 we must have allocated a plt entry. */
415 BFD_ASSERT (*plt_offset
!= (bfd_vma
) -1);
417 /* If this is the first time we've processed this symbol,
418 fill in the plt entry with the correct symbol address. */
419 if ((*plt_offset
& 1) == 0)
423 x
= 0x000000fc; /* jmpf */
424 x
|= (relocation
<< 8) & 0xffffff00;
425 bfd_put_32 (input_bfd
, x
, splt
->contents
+ *plt_offset
);
429 relocation
= (splt
->output_section
->vma
430 + splt
->output_offset
431 + (*plt_offset
& -2));
442 r
= _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
443 contents
, rel
->r_offset
, relocation
,
446 if (r
!= bfd_reloc_ok
)
448 const char * msg
= (const char *) NULL
;
452 case bfd_reloc_overflow
:
453 r
= info
->callbacks
->reloc_overflow
454 (info
, (h
? &h
->root
: NULL
), name
, howto
->name
, (bfd_vma
) 0,
455 input_bfd
, input_section
, rel
->r_offset
);
458 case bfd_reloc_undefined
:
459 r
= info
->callbacks
->undefined_symbol
460 (info
, name
, input_bfd
, input_section
, rel
->r_offset
,
464 case bfd_reloc_outofrange
:
465 msg
= _("internal error: out of range error");
468 case bfd_reloc_notsupported
:
469 msg
= _("internal error: unsupported relocation error");
472 case bfd_reloc_dangerous
:
473 msg
= _("internal error: dangerous relocation");
477 msg
= _("internal error: unknown error");
482 r
= info
->callbacks
->warning
483 (info
, msg
, name
, input_bfd
, input_section
, rel
->r_offset
);
493 /* Return the section that should be marked against GC for a given
497 m32c_elf_gc_mark_hook
499 struct bfd_link_info
* info ATTRIBUTE_UNUSED
,
500 Elf_Internal_Rela
* rel
,
501 struct elf_link_hash_entry
* h
,
502 Elf_Internal_Sym
* sym
)
506 switch (ELF32_R_TYPE (rel
->r_info
))
509 switch (h
->root
.type
)
511 case bfd_link_hash_defined
:
512 case bfd_link_hash_defweak
:
513 return h
->root
.u
.def
.section
;
515 case bfd_link_hash_common
:
516 return h
->root
.u
.c
.p
->section
;
525 if (!(elf_bad_symtab (sec
->owner
)
526 && ELF_ST_BIND (sym
->st_info
) != STB_LOCAL
)
527 && ! ((sym
->st_shndx
<= 0 || sym
->st_shndx
>= SHN_LORESERVE
)
528 && sym
->st_shndx
!= SHN_COMMON
))
530 return bfd_section_from_elf_index (sec
->owner
, sym
->st_shndx
);
537 /* Update the got entry reference counts for the section being removed. */
540 m32c_elf_gc_sweep_hook
541 (bfd
* abfd ATTRIBUTE_UNUSED
,
542 struct bfd_link_info
* info ATTRIBUTE_UNUSED
,
543 asection
* sec ATTRIBUTE_UNUSED
,
544 const Elf_Internal_Rela
* relocs ATTRIBUTE_UNUSED
)
549 /* We support 16-bit pointers to code above 64k by generating a thunk
550 below 64k containing a JMP instruction to the final address. */
553 m32c_elf_check_relocs
555 struct bfd_link_info
* info
,
557 const Elf_Internal_Rela
* relocs
)
559 Elf_Internal_Shdr
* symtab_hdr
;
560 struct elf_link_hash_entry
** sym_hashes
;
561 struct elf_link_hash_entry
** sym_hashes_end
;
562 const Elf_Internal_Rela
* rel
;
563 const Elf_Internal_Rela
* rel_end
;
564 bfd_vma
*local_plt_offsets
;
568 if (info
->relocatable
)
571 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
572 sym_hashes
= elf_sym_hashes (abfd
);
573 local_plt_offsets
= elf_local_got_offsets (abfd
);
575 dynobj
= elf_hash_table(info
)->dynobj
;
577 sym_hashes_end
= sym_hashes
+ symtab_hdr
->sh_size
/sizeof (Elf32_External_Sym
);
578 if (!elf_bad_symtab (abfd
))
579 sym_hashes_end
-= symtab_hdr
->sh_info
;
581 rel_end
= relocs
+ sec
->reloc_count
;
582 for (rel
= relocs
; rel
< rel_end
; rel
++)
584 struct elf_link_hash_entry
*h
;
585 unsigned long r_symndx
;
588 r_symndx
= ELF32_R_SYM (rel
->r_info
);
589 if (r_symndx
< symtab_hdr
->sh_info
)
593 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
594 while (h
->root
.type
== bfd_link_hash_indirect
595 || h
->root
.type
== bfd_link_hash_warning
)
596 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
599 switch (ELF32_R_TYPE (rel
->r_info
))
601 /* This relocation describes a 16-bit pointer to a function.
602 We may need to allocate a thunk in low memory; reserve memory
606 elf_hash_table (info
)->dynobj
= dynobj
= abfd
;
609 splt
= bfd_get_section_by_name (dynobj
, ".plt");
612 splt
= bfd_make_section (dynobj
, ".plt");
614 || ! bfd_set_section_flags (dynobj
, splt
,
622 || ! bfd_set_section_alignment (dynobj
, splt
, 1))
628 offset
= &h
->plt
.offset
;
631 if (local_plt_offsets
== NULL
)
636 size
= symtab_hdr
->sh_info
* sizeof (bfd_vma
);
637 local_plt_offsets
= (bfd_vma
*) bfd_alloc (abfd
, size
);
638 if (local_plt_offsets
== NULL
)
640 elf_local_got_offsets (abfd
) = local_plt_offsets
;
642 for (i
= 0; i
< symtab_hdr
->sh_info
; i
++)
643 local_plt_offsets
[i
] = (bfd_vma
) -1;
645 offset
= &local_plt_offsets
[r_symndx
];
648 if (*offset
== (bfd_vma
) -1)
650 *offset
= splt
->size
;
660 /* This must exist if dynobj is ever set. */
663 m32c_elf_finish_dynamic_sections (bfd
*abfd ATTRIBUTE_UNUSED
,
664 struct bfd_link_info
*info
)
669 /* As an extra sanity check, verify that all plt entries have
672 if ((dynobj
= elf_hash_table (info
)->dynobj
) != NULL
673 && (splt
= bfd_get_section_by_name (dynobj
, ".plt")) != NULL
)
675 bfd_byte
*contents
= splt
->contents
;
676 unsigned int i
, size
= splt
->size
;
677 for (i
= 0; i
< size
; i
+= 4)
679 unsigned int x
= bfd_get_32 (dynobj
, contents
+ i
);
688 m32c_elf_always_size_sections (bfd
*output_bfd ATTRIBUTE_UNUSED
,
689 struct bfd_link_info
*info
)
694 if (info
->relocatable
)
697 dynobj
= elf_hash_table (info
)->dynobj
;
701 splt
= bfd_get_section_by_name (dynobj
, ".plt");
702 BFD_ASSERT (splt
!= NULL
);
704 splt
->contents
= (bfd_byte
*) bfd_zalloc (dynobj
, splt
->size
);
705 if (splt
->contents
== NULL
)
711 /* Function to set the ELF flag bits. */
714 m32c_elf_set_private_flags (bfd
*abfd
, flagword flags
)
716 elf_elfheader (abfd
)->e_flags
= flags
;
717 elf_flags_init (abfd
) = TRUE
;
721 /* Merge backend specific data from an object file to the output
722 object file when linking. */
725 m32c_elf_merge_private_bfd_data (bfd
*ibfd
, bfd
*obfd
)
727 flagword old_flags
, old_partial
;
728 flagword new_flags
, new_partial
;
729 bfd_boolean error
= FALSE
;
733 new_opt
[0] = old_opt
[0] = '\0';
734 new_flags
= elf_elfheader (ibfd
)->e_flags
;
735 old_flags
= elf_elfheader (obfd
)->e_flags
;
738 (*_bfd_error_handler
) ("old_flags = 0x%.8lx, new_flags = 0x%.8lx, init = %s, filename = %s",
739 old_flags
, new_flags
, elf_flags_init (obfd
) ? "yes" : "no",
740 bfd_get_filename (ibfd
));
743 if (!elf_flags_init (obfd
))
745 /* First call, no flags set. */
746 elf_flags_init (obfd
) = TRUE
;
747 elf_elfheader (obfd
)->e_flags
= new_flags
;
750 else if (new_flags
== old_flags
)
751 /* Compatible flags are ok. */
754 else /* Possibly incompatible flags. */
756 /* Warn if different cpu is used (allow a specific cpu to override
758 new_partial
= (new_flags
& EF_M32C_CPU_MASK
);
759 old_partial
= (old_flags
& EF_M32C_CPU_MASK
);
760 if (new_partial
== old_partial
)
767 default: strcat (new_opt
, " -m16c"); break;
768 case EF_M32C_CPU_M16C
: strcat (new_opt
, " -m16c"); break;
769 case EF_M32C_CPU_M32C
: strcat (new_opt
, " -m32c"); break;
774 default: strcat (old_opt
, " -m16c"); break;
775 case EF_M32C_CPU_M16C
: strcat (old_opt
, " -m16c"); break;
776 case EF_M32C_CPU_M32C
: strcat (old_opt
, " -m32c"); break;
780 /* Print out any mismatches from above. */
784 (*_bfd_error_handler
)
785 (_("%s: compiled with %s and linked with modules compiled with %s"),
786 bfd_get_filename (ibfd
), new_opt
, old_opt
);
789 new_flags
&= ~ EF_M32C_ALL_FLAGS
;
790 old_flags
&= ~ EF_M32C_ALL_FLAGS
;
792 /* Warn about any other mismatches. */
793 if (new_flags
!= old_flags
)
796 (*_bfd_error_handler
)
797 (_("%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)"),
798 bfd_get_filename (ibfd
), (long)new_flags
, (long)old_flags
);
803 bfd_set_error (bfd_error_bad_value
);
810 m32c_elf_print_private_bfd_data (bfd
*abfd
, PTR ptr
)
812 FILE *file
= (FILE *) ptr
;
815 BFD_ASSERT (abfd
!= NULL
&& ptr
!= NULL
);
817 /* Print normal ELF private data. */
818 _bfd_elf_print_private_bfd_data (abfd
, ptr
);
820 flags
= elf_elfheader (abfd
)->e_flags
;
821 fprintf (file
, _("private flags = 0x%lx:"), (long)flags
);
823 switch (flags
& EF_M32C_CPU_MASK
)
826 case EF_M32C_CPU_M16C
: fprintf (file
, " -m16c"); break;
827 case EF_M32C_CPU_M32C
: fprintf (file
, " -m32c"); break;
834 /* Return the MACH for an e_flags value. */
837 elf32_m32c_machine (bfd
*abfd
)
839 switch (elf_elfheader (abfd
)->e_flags
& EF_M32C_CPU_MASK
)
841 case EF_M32C_CPU_M16C
: return bfd_mach_m16c
;
842 case EF_M32C_CPU_M32C
: return bfd_mach_m32c
;
845 return bfd_mach_m16c
;
849 m32c_elf_object_p (bfd
*abfd
)
851 bfd_default_set_arch_mach (abfd
, bfd_arch_m32c
,
852 elf32_m32c_machine (abfd
));
859 dump_symtab (bfd
* abfd
, void *internal_syms
, void *external_syms
)
862 Elf_Internal_Sym
*isymbuf
;
863 Elf_Internal_Sym
*isymend
;
864 Elf_Internal_Sym
*isym
;
865 Elf_Internal_Shdr
*symtab_hdr
;
866 bfd_boolean free_internal
= 0, free_external
= 0;
868 char * st_info_stb_str
;
874 internal_syms
= bfd_malloc (1000);
879 external_syms
= bfd_malloc (1000);
883 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
884 locsymcount
= symtab_hdr
->sh_size
/ get_elf_backend_data(abfd
)->s
->sizeof_sym
;
886 isymbuf
= bfd_elf_get_elf_syms (abfd
, symtab_hdr
,
887 symtab_hdr
->sh_info
, 0,
888 internal_syms
, external_syms
, NULL
);
890 isymbuf
= internal_syms
;
891 isymend
= isymbuf
+ locsymcount
;
893 for (isym
= isymbuf
; isym
< isymend
; isym
++)
895 switch (ELF_ST_TYPE (isym
->st_info
))
897 case STT_FUNC
: st_info_str
= "STT_FUNC";
898 case STT_SECTION
: st_info_str
= "STT_SECTION";
899 case STT_SRELC
: st_info_str
= "STT_SRELC";
900 case STT_FILE
: st_info_str
= "STT_FILE";
901 case STT_OBJECT
: st_info_str
= "STT_OBJECT";
902 case STT_TLS
: st_info_str
= "STT_TLS";
903 default: st_info_str
= "";
905 switch (ELF_ST_BIND (isym
->st_info
))
907 case STB_LOCAL
: st_info_stb_str
= "STB_LOCAL";
908 case STB_GLOBAL
: st_info_stb_str
= "STB_GLOBAL";
909 default: st_info_stb_str
= "";
911 switch (ELF_ST_VISIBILITY (isym
->st_other
))
913 case STV_DEFAULT
: st_other_str
= "STV_DEFAULT";
914 case STV_INTERNAL
: st_other_str
= "STV_INTERNAL";
915 case STV_PROTECTED
: st_other_str
= "STV_PROTECTED";
916 default: st_other_str
= "";
918 switch (isym
->st_shndx
)
920 case SHN_ABS
: st_shndx_str
= "SHN_ABS";
921 case SHN_COMMON
: st_shndx_str
= "SHN_COMMON";
922 case SHN_UNDEF
: st_shndx_str
= "SHN_UNDEF";
923 default: st_shndx_str
= "";
926 printf ("isym = %p st_value = %lx st_size = %lx st_name = (%lu) %s "
927 "st_info = (%d) %s %s st_other = (%d) %s st_shndx = (%d) %s\n",
929 (unsigned long) isym
->st_value
,
930 (unsigned long) isym
->st_size
,
932 bfd_elf_string_from_elf_section (abfd
, symtab_hdr
->sh_link
,
934 isym
->st_info
, st_info_str
, st_info_stb_str
,
935 isym
->st_other
, st_other_str
,
936 isym
->st_shndx
, st_shndx_str
);
939 free (internal_syms
);
941 free (external_syms
);
945 m32c_get_reloc (long reloc
)
947 if (0 <= reloc
&& reloc
< R_M32C_max
)
948 return m32c_elf_howto_table
[reloc
].name
;
954 /* Handle relaxing. */
956 /* A subroutine of m32c_elf_relax_section. If the global symbol H
957 is within the low 64k, remove any entry for it in the plt. */
959 struct relax_plt_data
966 m32c_relax_plt_check (struct elf_link_hash_entry
*h
,
969 struct relax_plt_data
*data
= (struct relax_plt_data
*) xdata
;
971 if (h
->root
.type
== bfd_link_hash_warning
)
972 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
974 if (h
->plt
.offset
!= (bfd_vma
) -1)
978 if (h
->root
.type
== bfd_link_hash_undefined
979 || h
->root
.type
== bfd_link_hash_undefweak
)
982 address
= (h
->root
.u
.def
.section
->output_section
->vma
983 + h
->root
.u
.def
.section
->output_offset
984 + h
->root
.u
.def
.value
);
986 if (address
<= 0xffff)
989 data
->splt
->size
-= 4;
997 /* A subroutine of m32c_elf_relax_section. If the global symbol H
998 previously had a plt entry, give it a new entry offset. */
1001 m32c_relax_plt_realloc (struct elf_link_hash_entry
*h
,
1004 bfd_vma
*entry
= (bfd_vma
*) xdata
;
1006 if (h
->root
.type
== bfd_link_hash_warning
)
1007 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
1009 if (h
->plt
.offset
!= (bfd_vma
) -1)
1011 h
->plt
.offset
= *entry
;
1019 m32c_elf_relax_plt_section (bfd
*dynobj
,
1021 struct bfd_link_info
*info
,
1024 struct relax_plt_data relax_plt_data
;
1027 /* Assume nothing changes. */
1030 if (info
->relocatable
)
1033 /* We only relax the .plt section at the moment. */
1034 if (dynobj
!= elf_hash_table (info
)->dynobj
1035 || strcmp (splt
->name
, ".plt") != 0)
1038 /* Quick check for an empty plt. */
1039 if (splt
->size
== 0)
1042 /* Map across all global symbols; see which ones happen to
1043 fall in the low 64k. */
1044 relax_plt_data
.splt
= splt
;
1045 relax_plt_data
.again
= again
;
1046 elf_link_hash_traverse (elf_hash_table (info
), m32c_relax_plt_check
,
1049 /* Likewise for local symbols, though that's somewhat less convenient
1050 as we have to walk the list of input bfds and swap in symbol data. */
1051 for (ibfd
= info
->input_bfds
; ibfd
; ibfd
= ibfd
->link_next
)
1053 bfd_vma
*local_plt_offsets
= elf_local_got_offsets (ibfd
);
1054 Elf_Internal_Shdr
*symtab_hdr
;
1055 Elf_Internal_Sym
*isymbuf
= NULL
;
1058 if (! local_plt_offsets
)
1061 symtab_hdr
= &elf_tdata (ibfd
)->symtab_hdr
;
1062 if (symtab_hdr
->sh_info
!= 0)
1064 isymbuf
= (Elf_Internal_Sym
*) symtab_hdr
->contents
;
1065 if (isymbuf
== NULL
)
1066 isymbuf
= bfd_elf_get_elf_syms (ibfd
, symtab_hdr
,
1067 symtab_hdr
->sh_info
, 0,
1069 if (isymbuf
== NULL
)
1073 for (idx
= 0; idx
< symtab_hdr
->sh_info
; ++idx
)
1075 Elf_Internal_Sym
*isym
;
1079 if (local_plt_offsets
[idx
] == (bfd_vma
) -1)
1082 isym
= &isymbuf
[idx
];
1083 if (isym
->st_shndx
== SHN_UNDEF
)
1085 else if (isym
->st_shndx
== SHN_ABS
)
1086 tsec
= bfd_abs_section_ptr
;
1087 else if (isym
->st_shndx
== SHN_COMMON
)
1088 tsec
= bfd_com_section_ptr
;
1090 tsec
= bfd_section_from_elf_index (ibfd
, isym
->st_shndx
);
1092 address
= (tsec
->output_section
->vma
1093 + tsec
->output_offset
1095 if (address
<= 0xffff)
1097 local_plt_offsets
[idx
] = -1;
1104 && symtab_hdr
->contents
!= (unsigned char *) isymbuf
)
1106 if (! info
->keep_memory
)
1110 /* Cache the symbols for elf_link_input_bfd. */
1111 symtab_hdr
->contents
= (unsigned char *) isymbuf
;
1116 /* If we changed anything, walk the symbols again to reallocate
1117 .plt entry addresses. */
1118 if (*again
&& splt
->size
> 0)
1122 elf_link_hash_traverse (elf_hash_table (info
),
1123 m32c_relax_plt_realloc
, &entry
);
1125 for (ibfd
= info
->input_bfds
; ibfd
; ibfd
= ibfd
->link_next
)
1127 bfd_vma
*local_plt_offsets
= elf_local_got_offsets (ibfd
);
1128 unsigned int nlocals
= elf_tdata (ibfd
)->symtab_hdr
.sh_info
;
1131 if (! local_plt_offsets
)
1134 for (idx
= 0; idx
< nlocals
; ++idx
)
1135 if (local_plt_offsets
[idx
] != (bfd_vma
) -1)
1137 local_plt_offsets
[idx
] = entry
;
1146 struct relax_reloc_s
1150 bfd_vma opcode
; /* original opcode or insn part */
1151 int relax_backward
; /* lbound */
1152 int relax_forward
; /* hbound */
1155 int new_opcode
; /* new opcode */
1156 int old_reloc
; /* old relocation */
1157 int new_reloc
; /* new relocation */
1159 int delete_n
; /* # bytes differ between original and new */
1161 static struct relax_reloc_s relax_reloc
[] =
1306 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1310 m32c_elf_relax_section
1313 struct bfd_link_info
* link_info
,
1314 bfd_boolean
* again
)
1316 Elf_Internal_Shdr
*symtab_hdr
;
1317 Elf_Internal_Shdr
*shndx_hdr
;
1318 Elf_Internal_Rela
*internal_relocs
;
1319 Elf_Internal_Rela
*free_relocs
= NULL
;
1320 Elf_Internal_Rela
*irel
, *irelend
;
1321 bfd_byte
* contents
= NULL
;
1322 bfd_byte
* free_contents
= NULL
;
1323 Elf32_External_Sym
*extsyms
= NULL
;
1324 Elf32_External_Sym
*free_extsyms
= NULL
;
1325 Elf_External_Sym_Shndx
*shndx_buf
= NULL
;
1328 if (abfd
== elf_hash_table (link_info
)->dynobj
1329 && strcmp (sec
->name
, ".plt") == 0)
1330 return m32c_elf_relax_plt_section (abfd
, sec
, link_info
, again
);
1332 /* Assume nothing changes. */
1335 machine
= elf32_m32c_machine (abfd
);
1337 /* We don't have to do anything for a relocatable link, if
1338 this section does not have relocs, or if this is not a
1340 if (link_info
->relocatable
1341 || (sec
->flags
& SEC_RELOC
) == 0
1342 || sec
->reloc_count
== 0
1343 || (sec
->flags
& SEC_CODE
) == 0)
1346 /* Relaxing doesn't quite work right yet. */
1349 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
1350 shndx_hdr
= &elf_tdata (abfd
)->symtab_shndx_hdr
;
1352 /* Get a copy of the native relocations. */
1353 internal_relocs
= (_bfd_elf_link_read_relocs
1354 (abfd
, sec
, (PTR
) NULL
, (Elf_Internal_Rela
*) NULL
,
1355 link_info
->keep_memory
));
1356 if (internal_relocs
== NULL
)
1358 if (! link_info
->keep_memory
)
1359 free_relocs
= internal_relocs
;
1361 /* Walk through them looking for relaxing opportunities. */
1362 irelend
= internal_relocs
+ sec
->reloc_count
;
1364 for (irel
= internal_relocs
; irel
< irelend
; irel
++)
1369 bfd_signed_vma pcrel_value
;
1374 /* Get the section contents. */
1375 if (contents
== NULL
)
1377 if (elf_section_data (sec
)->this_hdr
.contents
!= NULL
)
1378 contents
= elf_section_data (sec
)->this_hdr
.contents
;
1379 /* Go get them off disk. */
1380 else if (!bfd_malloc_and_get_section (abfd
, sec
, &contents
))
1384 /* Read this BFD's symbols if we haven't done so already. */
1385 if (extsyms
== NULL
)
1387 /* Get cached copy if it exists. */
1388 if (symtab_hdr
->contents
!= NULL
)
1389 extsyms
= (Elf32_External_Sym
*) symtab_hdr
->contents
;
1392 bfd_size_type amt
= symtab_hdr
->sh_size
;
1394 /* Go get them off disk. */
1395 extsyms
= (Elf32_External_Sym
*) bfd_malloc (amt
);
1396 if (extsyms
== NULL
)
1398 free_extsyms
= extsyms
;
1399 if (bfd_seek (abfd
, symtab_hdr
->sh_offset
, SEEK_SET
) != 0
1400 || bfd_bread (extsyms
, amt
, abfd
) != amt
)
1402 symtab_hdr
->contents
= (bfd_byte
*) extsyms
;
1405 if (shndx_hdr
->sh_size
!= 0)
1409 amt
= symtab_hdr
->sh_info
;
1410 amt
*= sizeof (Elf_External_Sym_Shndx
);
1411 shndx_buf
= (Elf_External_Sym_Shndx
*) bfd_malloc (amt
);
1412 if (shndx_buf
== NULL
)
1414 if (bfd_seek (abfd
, shndx_hdr
->sh_offset
, SEEK_SET
) != 0
1415 || bfd_bread ((PTR
) shndx_buf
, amt
, abfd
) != amt
)
1417 shndx_hdr
->contents
= (bfd_byte
*) shndx_buf
;
1421 /* Get the value of the symbol referred to by the reloc. */
1422 if (ELF32_R_SYM (irel
->r_info
) < symtab_hdr
->sh_info
)
1424 /* A local symbol. */
1425 Elf32_External_Sym
*esym
;
1426 Elf_External_Sym_Shndx
*shndx
;
1427 Elf_Internal_Sym isym
;
1429 esym
= extsyms
+ ELF32_R_SYM (irel
->r_info
);
1430 shndx
= shndx_buf
+ (shndx_buf
? ELF32_R_SYM (irel
->r_info
) : 0);
1431 bfd_elf32_swap_symbol_in (abfd
, esym
, shndx
, &isym
);
1433 symval
= (isym
.st_value
1434 + sec
->output_section
->vma
1435 + sec
->output_offset
);
1440 struct elf_link_hash_entry
*h
;
1442 /* An external symbol. */
1443 indx
= ELF32_R_SYM (irel
->r_info
) - symtab_hdr
->sh_info
;
1444 h
= elf_sym_hashes (abfd
)[indx
];
1445 BFD_ASSERT (h
!= NULL
);
1447 if (h
->root
.type
!= bfd_link_hash_defined
1448 && h
->root
.type
!= bfd_link_hash_defweak
)
1449 /* This appears to be a reference to an undefined
1450 symbol. Just ignore it--it will be caught by the
1451 regular reloc processing. */
1454 symval
= (h
->root
.u
.def
.value
1455 + h
->root
.u
.def
.section
->output_section
->vma
1456 + h
->root
.u
.def
.section
->output_offset
);
1459 /* There will always be room for the relaxed insn, since it is smaller
1460 than the one it would replace. */
1461 BFD_ASSERT (irel
->r_offset
<= sec
->size
- 2);
1463 insn
= bfd_get_16 (abfd
, contents
+ irel
->r_offset
+ 0);
1465 addend
= irel
->r_addend
;
1466 for (i
= 0; relax_reloc
[i
].machine
; i
++)
1469 _bfd_error_handler ("insn %x %d mask %x opcode %x =%x\n",
1470 insn
, i
, relax_reloc
[i
].opcode_mask
,
1471 relax_reloc
[i
].opcode
,
1472 (insn
& relax_reloc
[i
].opcode_mask
) == relax_reloc
[i
].opcode
);
1474 if (!(machine
== relax_reloc
[i
].machine
1475 && (insn
& relax_reloc
[i
].opcode_mask
) == relax_reloc
[i
].opcode
1476 && (relax_reloc
[i
].old_reloc
1477 == (int) ELF32_R_TYPE(irel
->r_info
))))
1480 /* At this point we've confirmed we have a matching insn. Now
1481 ensure the operand is in range. */
1482 if (relax_reloc
[i
].use_pcrel
)
1484 pc
= sec
->output_section
->vma
+ sec
->output_offset
1486 pcrel_value
= symval
- pc
;
1487 #ifndef USE_REL /* put in for learning purposes */
1488 pcrel_value
+= addend
;
1490 addend
= bfd_get_signed_16 (abfd
, contents
+ irel
->r_offset
+ 2);
1491 pcrel_value
+= addend
;
1495 pcrel_value
= symval
;
1497 if (pcrel_value
>= relax_reloc
[i
].relax_backward
1498 && pcrel_value
< relax_reloc
[i
].relax_forward
+ 2)
1500 /* We can relax to a shorter operand. */
1501 insn
= (insn
& relax_reloc
[i
].mask
) | relax_reloc
[i
].new_opcode
;
1503 to_delete
= relax_reloc
[i
].delete_n
;
1505 /* Rewrite the insn. */
1506 bfd_put_16 (abfd
, insn
, contents
+ irel
->r_offset
);
1508 /* Set the new reloc type. */
1509 irel
->r_info
= ELF32_R_INFO (ELF32_R_SYM (irel
->r_info
),
1510 relax_reloc
[i
].new_reloc
);
1511 irel
->r_addend
= pcrel_value
;
1517 _bfd_error_handler ("insn %x pc %x index %d mask %x shift %d delete %d\n"
1518 "old reloc %s new reloc %s",
1519 insn
, sec
->output_section
->vma
1520 + sec
->output_offset
+ irel
->r_offset
+ 2,
1521 i
, relax_reloc
[i
].opcode_mask
,
1522 relax_reloc
[i
].value_shift
, to_delete
,
1523 m32c_get_reloc (relax_reloc
[i
].old_reloc
),
1524 m32c_get_reloc (relax_reloc
[i
].new_reloc
));
1527 /* Note that we've changed the relocs, section contents, etc. */
1528 elf_section_data (sec
)->relocs
= internal_relocs
;
1531 elf_section_data (sec
)->this_hdr
.contents
= contents
;
1532 free_contents
= NULL
;
1534 symtab_hdr
->contents
= (bfd_byte
*) extsyms
;
1535 free_extsyms
= NULL
;
1537 /* Delete TO_DELETE bytes of data. */
1538 if (! m32c_elf_relax_delete_bytes
1539 (abfd
, sec
, irel
->r_offset
+ relax_reloc
[i
].value_shift
,
1542 } /* next relax_reloc */
1543 } /* next relocation */
1545 if (free_relocs
!= NULL
)
1551 if (free_contents
!= NULL
)
1553 if (! link_info
->keep_memory
)
1554 free (free_contents
);
1555 /* Cache the section contents for elf_link_input_bfd. */
1557 elf_section_data (sec
)->this_hdr
.contents
= contents
;
1559 free_contents
= NULL
;
1562 if (shndx_buf
!= NULL
)
1564 shndx_hdr
->contents
= NULL
;
1568 if (free_extsyms
!= NULL
)
1570 if (! link_info
->keep_memory
)
1571 free (free_extsyms
);
1572 /* Cache the symbols for elf_link_input_bfd. */
1574 symtab_hdr
->contents
= NULL
/* (unsigned char *) extsyms*/;
1576 free_extsyms
= NULL
;
1578 /* elf_link_input_bfd expects internal syms. */
1579 symtab_hdr
->contents
= NULL
;
1584 if (free_relocs
!= NULL
)
1586 if (free_contents
!= NULL
)
1587 free (free_contents
);
1588 if (shndx_buf
!= NULL
)
1590 shndx_hdr
->contents
= NULL
;
1593 if (free_extsyms
!= NULL
)
1594 free (free_extsyms
);
1598 /* Delete some bytes from a section while relaxing. */
1601 m32c_elf_relax_delete_bytes
1607 Elf_Internal_Shdr
*symtab_hdr
;
1608 Elf_Internal_Shdr
*shndx_hdr
;
1611 Elf_Internal_Rela
*irel
;
1612 Elf_Internal_Rela
*irelend
;
1613 Elf_Internal_Rela
*irelalign
;
1615 Elf32_External_Sym
*esym
;
1616 Elf32_External_Sym
*esymend
;
1617 Elf32_External_Sym
*extsyms
;
1618 Elf_External_Sym_Shndx
*shndx_buf
;
1619 Elf_External_Sym_Shndx
*shndx
;
1620 struct elf_link_hash_entry
** sym_hashes
;
1621 struct elf_link_hash_entry
** end_hashes
;
1622 unsigned int symcount
;
1624 symtab_hdr
= & elf_tdata (abfd
)->symtab_hdr
;
1625 extsyms
= (Elf32_External_Sym
*) symtab_hdr
->contents
;
1626 shndx_hdr
= & elf_tdata (abfd
)->symtab_shndx_hdr
;
1627 shndx_buf
= (Elf_External_Sym_Shndx
*) shndx_hdr
->contents
;
1628 sec_shndx
= _bfd_elf_section_from_bfd_section (abfd
, sec
);
1629 contents
= elf_section_data (sec
)->this_hdr
.contents
;
1631 /* The deletion must stop at the next ALIGN reloc for an aligment
1632 power larger than the number of bytes we are deleting. */
1636 irel
= elf_section_data (sec
)->relocs
;
1637 irelend
= irel
+ sec
->reloc_count
;
1639 /* Actually delete the bytes. */
1640 memmove (contents
+ addr
, contents
+ addr
+ count
, (size_t) (toaddr
- addr
- count
));
1643 /* Adjust all the relocs. */
1644 for (irel
= elf_section_data (sec
)->relocs
; irel
< irelend
; irel
++)
1646 /* Get the new reloc address. */
1647 if (irel
->r_offset
> addr
&& irel
->r_offset
< toaddr
)
1648 irel
->r_offset
-= count
;
1649 if (irel
->r_addend
> addr
&& irel
->r_addend
< toaddr
)
1650 irel
->r_addend
-= count
;
1653 /* Adjust the local symbols defined in this section. */
1656 esymend
= esym
+ symtab_hdr
->sh_info
;
1657 for (; esym
< esymend
; esym
++, shndx
= (shndx
? shndx
+ 1 : NULL
))
1659 Elf_Internal_Sym isym
;
1660 Elf_External_Sym_Shndx dummy
;
1662 bfd_elf32_swap_symbol_in (abfd
, esym
, shndx
, &isym
);
1664 if ((int) isym
.st_shndx
== sec_shndx
1665 && isym
.st_value
> addr
1666 && isym
.st_value
< toaddr
)
1668 isym
.st_value
-= count
;
1669 bfd_elf32_swap_symbol_out (abfd
, &isym
, (PTR
) esym
, (PTR
) & dummy
);
1673 /* Now adjust the global symbols defined in this section. */
1674 symcount
= (symtab_hdr
->sh_size
/ sizeof (Elf32_External_Sym
)
1675 - symtab_hdr
->sh_info
);
1676 sym_hashes
= elf_sym_hashes (abfd
);
1677 // sym_hashes += symtab_hdr->sh_info;
1678 end_hashes
= sym_hashes
+ symcount
;
1680 for (; sym_hashes
< end_hashes
; sym_hashes
++)
1682 struct elf_link_hash_entry
* sym_hash
= * sym_hashes
;
1685 ( sym_hash
->root
.type
== bfd_link_hash_defined
1686 || sym_hash
->root
.type
== bfd_link_hash_defweak
)
1687 && sym_hash
->root
.u
.def
.section
== sec
1688 && sym_hash
->root
.u
.def
.value
> addr
1689 && sym_hash
->root
.u
.def
.value
< toaddr
)
1690 sym_hash
->root
.u
.def
.value
-= count
;
1697 #define ELF_ARCH bfd_arch_m32c
1698 #define ELF_MACHINE_CODE EM_M32C
1699 #define ELF_MAXPAGESIZE 0x1000
1702 #define TARGET_BIG_SYM bfd_elf32_m32c_vec
1703 #define TARGET_BIG_NAME "elf32-m32c"
1705 #define TARGET_LITTLE_SYM bfd_elf32_m32c_vec
1706 #define TARGET_LITTLE_NAME "elf32-m32c"
1709 #define elf_info_to_howto_rel NULL
1710 #define elf_info_to_howto m32c_info_to_howto_rela
1711 #define elf_backend_object_p m32c_elf_object_p
1712 #define elf_backend_relocate_section m32c_elf_relocate_section
1713 #define elf_backend_gc_mark_hook m32c_elf_gc_mark_hook
1714 #define elf_backend_gc_sweep_hook m32c_elf_gc_sweep_hook
1715 #define elf_backend_check_relocs m32c_elf_check_relocs
1716 #define elf_backend_object_p m32c_elf_object_p
1717 #define elf_symbol_leading_char ('_')
1718 #define elf_backend_always_size_sections \
1719 m32c_elf_always_size_sections
1720 #define elf_backend_finish_dynamic_sections \
1721 m32c_elf_finish_dynamic_sections
1723 #define elf_backend_can_gc_sections 1
1725 #define bfd_elf32_bfd_reloc_type_lookup m32c_reloc_type_lookup
1726 #define bfd_elf32_bfd_relax_section m32c_elf_relax_section
1727 #define bfd_elf32_bfd_set_private_flags m32c_elf_set_private_flags
1728 #define bfd_elf32_bfd_merge_private_bfd_data m32c_elf_merge_private_bfd_data
1729 #define bfd_elf32_bfd_print_private_bfd_data m32c_elf_print_private_bfd_data
1731 #include "elf32-target.h"