1 /* Matsushita 10300 specific support for 32-bit ELF
2 Copyright (C) 1996, 1997, 1998 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 2 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
24 #include "elf/mn10300.h"
26 struct elf32_mn10300_link_hash_entry
28 /* The basic elf link hash table entry. */
29 struct elf_link_hash_entry root;
31 /* For function symbols, the number of times this function is
32 called directly (ie by name). */
33 unsigned int direct_calls;
35 /* For function symbols, the size of this function's stack
36 (if <= 255 bytes). We stuff this into "call" instructions
37 to this target when it's valid and profitable to do so. */
38 unsigned char stack_size;
40 /* For function symbols, arguments (if any) for movm instruction
41 in the prologue. We stuff this value into "call" instructions
42 to the target when it's valid and profitable to do so. */
43 unsigned char movm_args;
45 /* When set, convert all "call" instructions to this target into "calls"
47 #define MN10300_CONVERT_CALL_TO_CALLS 0x1
49 /* Used to mark functions which have had redundant parts of their
51 #define MN10300_DELETED_PROLOGUE_BYTES 0x2
55 /* We derive a hash table from the main elf linker hash table so
56 we can store state variables and a secondary hash table without
57 resorting to global variables. */
58 struct elf32_mn10300_link_hash_table
60 /* The main hash table. */
61 struct elf_link_hash_table root;
63 /* A hash table for static functions. We could derive a new hash table
64 instead of using the full elf32_mn10300_link_hash_table if we wanted
65 to save some memory. */
66 struct elf32_mn10300_link_hash_table *static_hash_table;
68 /* Random linker state flags. */
69 #define MN10300_HASH_ENTRIES_INITIALIZED 0x1
73 /* For MN10300 linker hash table. */
75 /* Get the MN10300 ELF linker hash table from a link_info structure. */
77 #define elf32_mn10300_hash_table(p) \
78 ((struct elf32_mn10300_link_hash_table *) ((p)->hash))
80 #define elf32_mn10300_link_hash_traverse(table, func, info) \
81 (elf_link_hash_traverse \
83 (boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func), \
86 static struct bfd_hash_entry *elf32_mn10300_link_hash_newfunc
87 PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
88 static struct bfd_link_hash_table *elf32_mn10300_link_hash_table_create
91 static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
92 PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
93 static void mn10300_info_to_howto
94 PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
95 static boolean mn10300_elf_relax_delete_bytes
96 PARAMS ((bfd *, asection *, bfd_vma, int));
97 static boolean mn10300_elf_symbol_address_p
98 PARAMS ((bfd *, asection *, Elf32_External_Sym *, bfd_vma));
99 static boolean elf32_mn10300_finish_hash_table_entry
100 PARAMS ((struct bfd_hash_entry *, PTR));
101 static void compute_function_info
102 PARAMS ((bfd *, struct elf32_mn10300_link_hash_entry *,
103 bfd_vma, unsigned char *));
105 /* We have to use RELA instructions since md_apply_fix3 in the assembler
106 does absolutely nothing. */
121 static reloc_howto_type elf_mn10300_howto_table[] =
123 /* Dummy relocation. Does nothing. */
124 HOWTO (R_MN10300_NONE,
130 complain_overflow_bitfield,
131 bfd_elf_generic_reloc,
137 /* Standard 32 bit reloc. */
144 complain_overflow_bitfield,
145 bfd_elf_generic_reloc,
151 /* Standard 16 bit reloc. */
158 complain_overflow_bitfield,
159 bfd_elf_generic_reloc,
165 /* Standard 8 bit reloc. */
172 complain_overflow_bitfield,
173 bfd_elf_generic_reloc,
179 /* Standard 32bit pc-relative reloc. */
180 HOWTO (R_MN10300_PCREL32,
186 complain_overflow_bitfield,
187 bfd_elf_generic_reloc,
193 /* Standard 16bit pc-relative reloc. */
194 HOWTO (R_MN10300_PCREL16,
200 complain_overflow_bitfield,
201 bfd_elf_generic_reloc,
207 /* Standard 8 pc-relative reloc. */
208 HOWTO (R_MN10300_PCREL8,
214 complain_overflow_bitfield,
215 bfd_elf_generic_reloc,
223 struct mn10300_reloc_map
225 unsigned char bfd_reloc_val;
226 unsigned char elf_reloc_val;
229 static const struct mn10300_reloc_map mn10300_reloc_map[] =
231 { BFD_RELOC_NONE, R_MN10300_NONE, },
232 { BFD_RELOC_32, R_MN10300_32, },
233 { BFD_RELOC_16, R_MN10300_16, },
234 { BFD_RELOC_8, R_MN10300_8, },
235 { BFD_RELOC_32_PCREL, R_MN10300_PCREL32, },
236 { BFD_RELOC_16_PCREL, R_MN10300_PCREL16, },
237 { BFD_RELOC_8_PCREL, R_MN10300_PCREL8, },
240 static reloc_howto_type *
241 bfd_elf32_bfd_reloc_type_lookup (abfd, code)
243 bfd_reloc_code_real_type code;
248 i < sizeof (mn10300_reloc_map) / sizeof (struct mn10300_reloc_map);
251 if (mn10300_reloc_map[i].bfd_reloc_val == code)
252 return &elf_mn10300_howto_table[mn10300_reloc_map[i].elf_reloc_val];
258 /* Set the howto pointer for an MN10300 ELF reloc. */
261 mn10300_info_to_howto (abfd, cache_ptr, dst)
264 Elf32_Internal_Rela *dst;
268 r_type = ELF32_R_TYPE (dst->r_info);
269 BFD_ASSERT (r_type < (unsigned int) R_MN10300_MAX);
270 cache_ptr->howto = &elf_mn10300_howto_table[r_type];
273 /* Perform a relocation as part of a final link. */
274 static bfd_reloc_status_type
275 mn10300_elf_final_link_relocate (howto, input_bfd, output_bfd,
276 input_section, contents, offset, value,
277 addend, info, sym_sec, is_local)
278 reloc_howto_type *howto;
281 asection *input_section;
286 struct bfd_link_info *info;
290 unsigned long r_type = howto->type;
291 bfd_byte *hit_data = contents + offset;
301 bfd_put_32 (input_bfd, value, hit_data);
307 if ((long)value > 0x7fff || (long)value < -0x8000)
308 return bfd_reloc_overflow;
310 bfd_put_16 (input_bfd, value, hit_data);
316 if ((long)value > 0x7fff || (long)value < -0x8000)
317 return bfd_reloc_overflow;
319 bfd_put_8 (input_bfd, value, hit_data);
322 case R_MN10300_PCREL8:
323 value -= (input_section->output_section->vma
324 + input_section->output_offset);
328 if ((long)value > 0xff || (long)value < -0x100)
329 return bfd_reloc_overflow;
331 bfd_put_8 (input_bfd, value, hit_data);
334 case R_MN10300_PCREL16:
335 value -= (input_section->output_section->vma
336 + input_section->output_offset);
340 if ((long)value > 0xffff || (long)value < -0x10000)
341 return bfd_reloc_overflow;
343 bfd_put_16 (input_bfd, value, hit_data);
346 case R_MN10300_PCREL32:
347 value -= (input_section->output_section->vma
348 + input_section->output_offset);
352 bfd_put_32 (input_bfd, value, hit_data);
356 return bfd_reloc_notsupported;
361 /* Relocate an MN10300 ELF section. */
363 mn10300_elf_relocate_section (output_bfd, info, input_bfd, input_section,
364 contents, relocs, local_syms, local_sections)
366 struct bfd_link_info *info;
368 asection *input_section;
370 Elf_Internal_Rela *relocs;
371 Elf_Internal_Sym *local_syms;
372 asection **local_sections;
374 Elf_Internal_Shdr *symtab_hdr;
375 struct elf32_mn10300_link_hash_entry **sym_hashes;
376 Elf_Internal_Rela *rel, *relend;
378 symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
379 sym_hashes = (struct elf32_mn10300_link_hash_entry **)
380 (elf_sym_hashes (input_bfd));
383 relend = relocs + input_section->reloc_count;
384 for (; rel < relend; rel++)
387 reloc_howto_type *howto;
388 unsigned long r_symndx;
389 Elf_Internal_Sym *sym;
391 struct elf32_mn10300_link_hash_entry *h;
393 bfd_reloc_status_type r;
395 r_symndx = ELF32_R_SYM (rel->r_info);
396 r_type = ELF32_R_TYPE (rel->r_info);
397 howto = elf_mn10300_howto_table + r_type;
399 if (info->relocateable)
401 /* This is a relocateable link. We don't have to change
402 anything, unless the reloc is against a section symbol,
403 in which case we have to adjust according to where the
404 section symbol winds up in the output section. */
405 if (r_symndx < symtab_hdr->sh_info)
407 sym = local_syms + r_symndx;
408 if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
410 sec = local_sections[r_symndx];
411 rel->r_addend += sec->output_offset + sym->st_value;
418 /* This is a final link. */
422 if (r_symndx < symtab_hdr->sh_info)
424 sym = local_syms + r_symndx;
425 sec = local_sections[r_symndx];
426 relocation = (sec->output_section->vma
432 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
433 while (h->root.type == bfd_link_hash_indirect
434 || h->root.type == bfd_link_hash_warning)
435 h = (struct elf32_mn10300_link_hash_entry *) h->root.root.u.i.link;
436 if (h->root.root.type == bfd_link_hash_defined
437 || h->root.root.type == bfd_link_hash_defweak)
439 sec = h->root.root.u.def.section;
440 relocation = (h->root.root.u.def.value
441 + sec->output_section->vma
442 + sec->output_offset);
444 else if (h->root.root.type == bfd_link_hash_undefweak)
448 if (! ((*info->callbacks->undefined_symbol)
449 (info, h->root.root.root.string, input_bfd,
450 input_section, rel->r_offset)))
456 r = mn10300_elf_final_link_relocate (howto, input_bfd, output_bfd,
458 contents, rel->r_offset,
459 relocation, rel->r_addend,
460 info, sec, h == NULL);
462 if (r != bfd_reloc_ok)
465 const char *msg = (const char *)0;
468 name = h->root.root.root.string;
471 name = (bfd_elf_string_from_elf_section
472 (input_bfd, symtab_hdr->sh_link, sym->st_name));
473 if (name == NULL || *name == '\0')
474 name = bfd_section_name (input_bfd, sec);
479 case bfd_reloc_overflow:
480 if (! ((*info->callbacks->reloc_overflow)
481 (info, name, howto->name, (bfd_vma) 0,
482 input_bfd, input_section, rel->r_offset)))
486 case bfd_reloc_undefined:
487 if (! ((*info->callbacks->undefined_symbol)
488 (info, name, input_bfd, input_section,
493 case bfd_reloc_outofrange:
494 msg = _("internal error: out of range error");
497 case bfd_reloc_notsupported:
498 msg = _("internal error: unsupported relocation error");
501 case bfd_reloc_dangerous:
502 msg = _("internal error: dangerous error");
506 msg = _("internal error: unknown error");
510 if (!((*info->callbacks->warning)
511 (info, msg, name, input_bfd, input_section,
522 /* Finish initializing one hash table entry. */
524 elf32_mn10300_finish_hash_table_entry (gen_entry, in_args)
525 struct bfd_hash_entry *gen_entry;
528 struct elf32_mn10300_link_hash_entry *entry;
529 unsigned int byte_count = 0;
531 entry = (struct elf32_mn10300_link_hash_entry *)gen_entry;
533 /* If we already know we want to convert "call" to "calls" for calls
534 to this symbol, then return now. */
535 if (entry->flags == MN10300_CONVERT_CALL_TO_CALLS)
538 /* If there are no named calls to this symbol, or there's nothing we
539 can move from the function itself into the "call" instruction, then
540 note that all "call" instructions should be converted into "calls"
541 instructions and return. */
542 if (entry->direct_calls == 0
543 || (entry->stack_size == 0 && entry->movm_args == 0))
545 /* Make a note that we should convert "call" instructions to "calls"
546 instructions for calls to this symbol. */
547 entry->flags |= MN10300_CONVERT_CALL_TO_CALLS;
551 /* We may be able to move some instructions from the function itself into
552 the "call" instruction. Count how many bytes we might be able to
553 eliminate in the function itself. */
555 /* A movm instruction is two bytes. */
556 if (entry->movm_args)
559 /* Count the insn to allocate stack space too. */
560 if (entry->stack_size > 0 && entry->stack_size <= 128)
562 else if (entry->stack_size > 0 && entry->stack_size < 256)
565 /* If using "call" will result in larger code, then turn all
566 the associated "call" instructions into "calls" instrutions. */
567 if (byte_count < entry->direct_calls)
568 entry->flags |= MN10300_CONVERT_CALL_TO_CALLS;
570 /* This routine never fails. */
574 /* This function handles relaxing for the mn10300.
576 There's quite a few relaxing opportunites available on the mn10300:
578 * calls:32 -> calls:16 2 bytes
579 * call:32 -> call:16 2 bytes
581 * call:32 -> calls:32 1 byte
582 * call:16 -> calls:16 1 byte
583 * These are done anytime using "calls" would result
584 in smaller code, or when necessary to preserve the
585 meaning of the program.
589 * In some circumstances we can move instructions
590 from a function prologue into a "call" instruction.
591 This is only done if the resulting code is no larger
592 than the original code.
595 * jmp:32 -> jmp:16 2 bytes
596 * jmp:16 -> bra:8 1 byte
598 * If the previous instruction is a conditional branch
599 around the jump/bra, we may be able to reverse its condition
600 and change its target to the jump's target. The jump/bra
601 can then be deleted. 2 bytes
603 * mov abs32 -> mov abs16 1 or 2 bytes
605 * Most instructions which accept imm32 can relax to imm16 1 or 2 bytes
606 - Most instructions which accept imm16 can relax to imm8 1 or 2 bytes
608 * Most instructions which accept d32 can relax to d16 1 or 2 bytes
609 - Most instructions which accept d16 can relax to d8 1 or 2 bytes
611 We don't handle imm16->imm8 or d16->d8 as they're very rare
612 and somewhat more difficult to support. */
615 mn10300_elf_relax_section (abfd, sec, link_info, again)
618 struct bfd_link_info *link_info;
621 Elf_Internal_Shdr *symtab_hdr;
622 Elf_Internal_Rela *internal_relocs = NULL;
623 Elf_Internal_Rela *free_relocs = NULL;
624 Elf_Internal_Rela *irel, *irelend;
625 bfd_byte *contents = NULL;
626 bfd_byte *free_contents = NULL;
627 Elf32_External_Sym *extsyms = NULL;
628 Elf32_External_Sym *free_extsyms = NULL;
629 struct elf32_mn10300_link_hash_table *hash_table;
631 /* Assume nothing changes. */
634 /* We need a pointer to the mn10300 specific hash table. */
635 hash_table = elf32_mn10300_hash_table (link_info);
637 /* Initialize fields in each hash table entry the first time through. */
638 if ((hash_table->flags & MN10300_HASH_ENTRIES_INITIALIZED) == 0)
642 /* Iterate over all the input bfds. */
643 for (input_bfd = link_info->input_bfds;
645 input_bfd = input_bfd->link_next)
649 /* We're going to need all the symbols for each bfd. */
650 symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
652 /* Get cached copy if it exists. */
653 if (symtab_hdr->contents != NULL)
654 extsyms = (Elf32_External_Sym *) symtab_hdr->contents;
657 /* Go get them off disk. */
658 extsyms = ((Elf32_External_Sym *)
659 bfd_malloc (symtab_hdr->sh_size));
662 free_extsyms = extsyms;
663 if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0
664 || (bfd_read (extsyms, 1, symtab_hdr->sh_size, input_bfd)
665 != symtab_hdr->sh_size))
669 /* Iterate over each section in this bfd. */
670 for (section = input_bfd->sections;
672 section = section->next)
674 struct elf32_mn10300_link_hash_entry *hash;
675 Elf_Internal_Sym *sym;
677 const char *sym_name;
679 Elf_Internal_Shdr *hdr;
681 /* Get cached copy of section contents if it exists. */
682 if (elf_section_data (section)->this_hdr.contents != NULL)
683 contents = elf_section_data (section)->this_hdr.contents;
684 else if (section->_raw_size != 0)
686 /* Go get them off disk. */
687 contents = (bfd_byte *)bfd_malloc (section->_raw_size);
688 if (contents == NULL)
690 free_contents = contents;
692 if (!bfd_get_section_contents (input_bfd, section,
693 contents, (file_ptr) 0,
700 free_contents = NULL;
703 /* If there aren't any relocs, then there's nothing to do. */
704 if ((section->flags & SEC_RELOC) != 0
705 && section->reloc_count != 0)
708 /* Get a copy of the native relocations. */
709 internal_relocs = (_bfd_elf32_link_read_relocs
710 (input_bfd, section, (PTR) NULL,
711 (Elf_Internal_Rela *) NULL,
712 link_info->keep_memory));
713 if (internal_relocs == NULL)
715 if (! link_info->keep_memory)
716 free_relocs = internal_relocs;
718 /* Now examine each relocation. */
719 irel = internal_relocs;
720 irelend = irel + section->reloc_count;
721 for (; irel < irelend; irel++)
724 unsigned long r_index;
727 r_type = ELF32_R_TYPE (irel->r_info);
728 r_index = ELF32_R_SYM (irel->r_info);
730 if (r_type < 0 || r_type >= (int)R_MN10300_MAX)
733 /* We need the name and hash table entry of the target
739 if (r_index < symtab_hdr->sh_info)
741 /* A local symbol. */
742 Elf_Internal_Sym isym;
744 bfd_elf32_swap_symbol_in (input_bfd,
745 extsyms + r_index, &isym);
747 if (isym.st_shndx == SHN_UNDEF)
748 sym_sec = bfd_und_section_ptr;
749 else if (isym.st_shndx > 0
750 && isym.st_shndx < SHN_LORESERVE)
752 = bfd_section_from_elf_index (input_bfd,
754 else if (isym.st_shndx == SHN_ABS)
755 sym_sec = bfd_abs_section_ptr;
756 else if (isym.st_shndx == SHN_COMMON)
757 sym_sec = bfd_com_section_ptr;
759 sym_name = bfd_elf_string_from_elf_section (input_bfd,
763 /* If it isn't a function, then we don't care
765 if (r_index < symtab_hdr->sh_info
766 && ELF_ST_TYPE (isym.st_info) != STT_FUNC)
769 /* Tack on an ID so we can uniquely identify this
770 local symbol in the global hash table. */
771 new_name = alloca (strlen (sym_name) + 10);
772 sprintf (new_name, "%s_%08x", sym_name, (int)sym_sec);
775 hash = (struct elf32_mn10300_link_hash_entry *)
776 elf_link_hash_lookup (&hash_table->static_hash_table->root,
782 r_index -= symtab_hdr->sh_info;
783 hash = (struct elf32_mn10300_link_hash_entry *)
784 elf_sym_hashes (input_bfd)[r_index];
787 /* If this is not a "call" instruction, then we
788 should convert "call" instructions to "calls"
790 code = bfd_get_8 (input_bfd,
791 contents + irel->r_offset - 1);
792 if (code != 0xdd && code != 0xcd)
793 hash->flags |= MN10300_CONVERT_CALL_TO_CALLS;
795 /* If this is a jump/call, then bump the direct_calls
796 counter. Else force "call" to "calls" conversions. */
797 if (r_type == R_MN10300_PCREL32
798 || r_type == R_MN10300_PCREL16)
799 hash->direct_calls++;
801 hash->flags |= MN10300_CONVERT_CALL_TO_CALLS;
805 /* Now look at the actual contents to get the stack size,
806 and a list of what registers were saved in the prologue
808 if ((section->flags & SEC_CODE) != 0)
811 Elf32_External_Sym *esym, *esymend;
814 shndx = _bfd_elf_section_from_bfd_section (input_bfd,
818 /* Look at each function defined in this section and
819 update info for that function. */
821 esymend = esym + symtab_hdr->sh_info;
822 for (; esym < esymend; esym++)
824 Elf_Internal_Sym isym;
826 bfd_elf32_swap_symbol_in (input_bfd, esym, &isym);
827 if (isym.st_shndx == shndx
828 && ELF_ST_TYPE (isym.st_info) == STT_FUNC)
830 if (isym.st_shndx == SHN_UNDEF)
831 sym_sec = bfd_und_section_ptr;
832 else if (isym.st_shndx > 0
833 && isym.st_shndx < SHN_LORESERVE)
835 = bfd_section_from_elf_index (input_bfd,
837 else if (isym.st_shndx == SHN_ABS)
838 sym_sec = bfd_abs_section_ptr;
839 else if (isym.st_shndx == SHN_COMMON)
840 sym_sec = bfd_com_section_ptr;
842 sym_name = bfd_elf_string_from_elf_section (input_bfd,
846 /* Tack on an ID so we can uniquely identify this
847 local symbol in the global hash table. */
848 new_name = alloca (strlen (sym_name) + 10);
849 sprintf (new_name, "%s_%08x", sym_name, (int)sym_sec);
852 hash = (struct elf32_mn10300_link_hash_entry *)
853 elf_link_hash_lookup (&hash_table->static_hash_table->root,
856 compute_function_info (input_bfd, hash,
857 isym.st_value, contents);
861 esym = extsyms + symtab_hdr->sh_info;
862 esymend = extsyms + (symtab_hdr->sh_size
863 / sizeof (Elf32_External_Sym));
864 for (idx = 0; esym < esymend; esym++, idx++)
866 Elf_Internal_Sym isym;
868 bfd_elf32_swap_symbol_in (input_bfd, esym, &isym);
869 hash = (struct elf32_mn10300_link_hash_entry *)
870 elf_sym_hashes (input_bfd)[idx];
871 if (isym.st_shndx == shndx
872 && ELF_ST_TYPE (isym.st_info) == STT_FUNC
873 && (hash)->root.root.u.def.section == section
874 && ((hash)->root.root.type == bfd_link_hash_defined
875 || (hash)->root.root.type == bfd_link_hash_defweak))
876 compute_function_info (input_bfd, hash,
877 (hash)->root.root.u.def.value,
882 /* Cache or free any memory we allocated for the relocs. */
883 if (free_relocs != NULL)
889 /* Cache or free any memory we allocated for the contents. */
890 if (free_contents != NULL)
892 if (! link_info->keep_memory)
893 free (free_contents);
896 /* Cache the section contents for elf_link_input_bfd. */
897 elf_section_data (section)->this_hdr.contents = contents;
899 free_contents = NULL;
903 /* Cache or free any memory we allocated for the symbols. */
904 if (free_extsyms != NULL)
906 if (! link_info->keep_memory)
910 /* Cache the symbols for elf_link_input_bfd. */
911 symtab_hdr->contents = extsyms;
917 /* Now iterate on each symbol in the hash table and perform
918 the final initialization steps on each. */
919 elf32_mn10300_link_hash_traverse (hash_table,
920 elf32_mn10300_finish_hash_table_entry,
922 elf32_mn10300_link_hash_traverse (hash_table->static_hash_table,
923 elf32_mn10300_finish_hash_table_entry,
926 /* All entries in the hash table are fully initialized. */
927 hash_table->flags |= MN10300_HASH_ENTRIES_INITIALIZED;
929 /* Now that everything has been initialized, go through each
930 code section and delete any prologue insns which will be
931 redundant because their operations will be performed by
932 a "call" instruction. */
933 for (input_bfd = link_info->input_bfds;
935 input_bfd = input_bfd->link_next)
939 /* We're going to need all the symbols for each bfd. */
940 symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
942 /* Get cached copy if it exists. */
943 if (symtab_hdr->contents != NULL)
944 extsyms = (Elf32_External_Sym *) symtab_hdr->contents;
947 /* Go get them off disk. */
948 extsyms = ((Elf32_External_Sym *)
949 bfd_malloc (symtab_hdr->sh_size));
952 free_extsyms = extsyms;
953 if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0
954 || (bfd_read (extsyms, 1, symtab_hdr->sh_size, input_bfd)
955 != symtab_hdr->sh_size))
959 /* Walk over each section in this bfd. */
960 for (section = input_bfd->sections;
962 section = section->next)
965 Elf32_External_Sym *esym, *esymend;
968 /* Skip non-code sections and empty sections. */
969 if ((section->flags & SEC_CODE) == 0 || section->_raw_size == 0)
972 if (section->reloc_count != 0)
974 /* Get a copy of the native relocations. */
975 internal_relocs = (_bfd_elf32_link_read_relocs
976 (input_bfd, section, (PTR) NULL,
977 (Elf_Internal_Rela *) NULL,
978 link_info->keep_memory));
979 if (internal_relocs == NULL)
981 if (! link_info->keep_memory)
982 free_relocs = internal_relocs;
985 /* Get cached copy of section contents if it exists. */
986 if (elf_section_data (section)->this_hdr.contents != NULL)
987 contents = elf_section_data (section)->this_hdr.contents;
990 /* Go get them off disk. */
991 contents = (bfd_byte *)bfd_malloc (section->_raw_size);
992 if (contents == NULL)
994 free_contents = contents;
996 if (!bfd_get_section_contents (input_bfd, section,
997 contents, (file_ptr) 0,
1003 shndx = _bfd_elf_section_from_bfd_section (input_bfd, section);
1005 /* Now look for any function in this section which needs
1006 insns deleted from its prologue. */
1008 esymend = esym + symtab_hdr->sh_info;
1009 for (; esym < esymend; esym++)
1011 Elf_Internal_Sym isym;
1012 struct elf32_mn10300_link_hash_entry *sym_hash;
1014 const char *sym_name;
1015 Elf_Internal_Shdr *hdr;
1018 bfd_elf32_swap_symbol_in (input_bfd, esym, &isym);
1020 if (isym.st_shndx != shndx)
1023 if (isym.st_shndx == SHN_UNDEF)
1024 sym_sec = bfd_und_section_ptr;
1025 else if (isym.st_shndx > 0 && isym.st_shndx < SHN_LORESERVE)
1027 = bfd_section_from_elf_index (input_bfd, isym.st_shndx);
1028 else if (isym.st_shndx == SHN_ABS)
1029 sym_sec = bfd_abs_section_ptr;
1030 else if (isym.st_shndx == SHN_COMMON)
1031 sym_sec = bfd_com_section_ptr;
1033 sym_name = bfd_elf_string_from_elf_section (input_bfd,
1034 symtab_hdr->sh_link,
1037 /* Tack on an ID so we can uniquely identify this
1038 local symbol in the global hash table. */
1039 new_name = alloca (strlen (sym_name) + 10);
1040 sprintf (new_name, "%s_%08x", sym_name, (int)sym_sec);
1041 sym_name = new_name;
1043 sym_hash = (struct elf32_mn10300_link_hash_entry *)
1044 elf_link_hash_lookup (&hash_table->static_hash_table->root,
1048 if (sym_hash == NULL)
1051 if (! ((sym_hash)->flags & MN10300_CONVERT_CALL_TO_CALLS)
1052 && ! ((sym_hash)->flags & MN10300_DELETED_PROLOGUE_BYTES))
1056 /* Note that we've changed things. */
1057 elf_section_data (section)->relocs = internal_relocs;
1060 elf_section_data (section)->this_hdr.contents = contents;
1061 free_contents = NULL;
1063 symtab_hdr->contents = (bfd_byte *)extsyms;
1064 free_extsyms = NULL;
1066 /* Count how many bytes we're going to delete. */
1067 if (sym_hash->movm_args)
1070 if (sym_hash->stack_size && sym_hash->stack_size <= 128)
1072 else if (sym_hash->stack_size
1073 && sym_hash->stack_size < 256)
1076 /* Note that we've deleted prologue bytes for this
1078 sym_hash->flags |= MN10300_DELETED_PROLOGUE_BYTES;
1080 /* Actually delete the bytes. */
1081 if (!mn10300_elf_relax_delete_bytes (input_bfd,
1087 /* Something changed. Not strictly necessary, but
1088 may lead to more relaxing opportunities. */
1093 /* Look for any global functions in this section which
1094 need insns deleted from their prologues. */
1095 esym = extsyms + symtab_hdr->sh_info;
1096 esymend = extsyms + (symtab_hdr->sh_size
1097 / sizeof (Elf32_External_Sym));
1098 for (idx = 0; esym < esymend; esym++, idx++)
1100 Elf_Internal_Sym isym;
1101 struct elf32_mn10300_link_hash_entry *sym_hash;
1103 bfd_elf32_swap_symbol_in (input_bfd, esym, &isym);
1104 sym_hash = (struct elf32_mn10300_link_hash_entry *)
1105 (elf_sym_hashes (input_bfd)[idx]);
1106 if (isym.st_shndx == shndx
1107 && (sym_hash)->root.root.u.def.section == section
1108 && ! ((sym_hash)->flags & MN10300_CONVERT_CALL_TO_CALLS)
1109 && ! ((sym_hash)->flags & MN10300_DELETED_PROLOGUE_BYTES))
1113 /* Note that we've changed things. */
1114 elf_section_data (section)->relocs = internal_relocs;
1117 elf_section_data (section)->this_hdr.contents = contents;
1118 free_contents = NULL;
1120 symtab_hdr->contents = (bfd_byte *)extsyms;
1121 free_extsyms = NULL;
1123 /* Count how many bytes we're going to delete. */
1124 if (sym_hash->movm_args)
1127 if (sym_hash->stack_size && sym_hash->stack_size <= 128)
1129 else if (sym_hash->stack_size
1130 && sym_hash->stack_size < 256)
1133 /* Note that we've deleted prologue bytes for this
1135 sym_hash->flags |= MN10300_DELETED_PROLOGUE_BYTES;
1137 /* Actually delete the bytes. */
1138 if (!mn10300_elf_relax_delete_bytes (input_bfd,
1140 (sym_hash)->root.root.u.def.value,
1144 /* Something changed. Not strictly necessary, but
1145 may lead to more relaxing opportunities. */
1150 /* Cache or free any memory we allocated for the relocs. */
1151 if (free_relocs != NULL)
1157 /* Cache or free any memory we allocated for the contents. */
1158 if (free_contents != NULL)
1160 if (! link_info->keep_memory)
1161 free (free_contents);
1164 /* Cache the section contents for elf_link_input_bfd. */
1165 elf_section_data (section)->this_hdr.contents = contents;
1167 free_contents = NULL;
1171 /* Cache or free any memory we allocated for the symbols. */
1172 if (free_extsyms != NULL)
1174 if (! link_info->keep_memory)
1175 free (free_extsyms);
1178 /* Cache the symbols for elf_link_input_bfd. */
1179 symtab_hdr->contents = extsyms;
1181 free_extsyms = NULL;
1187 /* (Re)initialize for the basic instruction shortening/relaxing pass. */
1190 internal_relocs = NULL;
1192 free_contents = NULL;
1193 free_extsyms = NULL;
1195 /* We don't have to do anything for a relocateable link, if
1196 this section does not have relocs, or if this is not a
1198 if (link_info->relocateable
1199 || (sec->flags & SEC_RELOC) == 0
1200 || sec->reloc_count == 0
1201 || (sec->flags & SEC_CODE) == 0)
1204 /* If this is the first time we have been called for this section,
1205 initialize the cooked size. */
1206 if (sec->_cooked_size == 0)
1207 sec->_cooked_size = sec->_raw_size;
1209 symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
1211 /* Get a copy of the native relocations. */
1212 internal_relocs = (_bfd_elf32_link_read_relocs
1213 (abfd, sec, (PTR) NULL, (Elf_Internal_Rela *) NULL,
1214 link_info->keep_memory));
1215 if (internal_relocs == NULL)
1217 if (! link_info->keep_memory)
1218 free_relocs = internal_relocs;
1220 /* Walk through them looking for relaxing opportunities. */
1221 irelend = internal_relocs + sec->reloc_count;
1222 for (irel = internal_relocs; irel < irelend; irel++)
1225 struct elf32_mn10300_link_hash_entry *h = NULL;
1227 /* If this isn't something that can be relaxed, then ignore
1229 if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_NONE
1230 || ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_8
1231 || ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_MAX)
1234 /* Get the section contents if we haven't done so already. */
1235 if (contents == NULL)
1237 /* Get cached copy if it exists. */
1238 if (elf_section_data (sec)->this_hdr.contents != NULL)
1239 contents = elf_section_data (sec)->this_hdr.contents;
1242 /* Go get them off disk. */
1243 contents = (bfd_byte *) bfd_malloc (sec->_raw_size);
1244 if (contents == NULL)
1246 free_contents = contents;
1248 if (! bfd_get_section_contents (abfd, sec, contents,
1249 (file_ptr) 0, sec->_raw_size))
1254 /* Read this BFD's symbols if we haven't done so already. */
1255 if (extsyms == NULL)
1257 /* Get cached copy if it exists. */
1258 if (symtab_hdr->contents != NULL)
1259 extsyms = (Elf32_External_Sym *) symtab_hdr->contents;
1262 /* Go get them off disk. */
1263 extsyms = ((Elf32_External_Sym *)
1264 bfd_malloc (symtab_hdr->sh_size));
1265 if (extsyms == NULL)
1267 free_extsyms = extsyms;
1268 if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0
1269 || (bfd_read (extsyms, 1, symtab_hdr->sh_size, abfd)
1270 != symtab_hdr->sh_size))
1275 /* Get the value of the symbol referred to by the reloc. */
1276 if (ELF32_R_SYM (irel->r_info) < symtab_hdr->sh_info)
1278 Elf_Internal_Sym isym;
1280 Elf_Internal_Shdr *hdr;
1281 const char *sym_name;
1284 /* A local symbol. */
1285 bfd_elf32_swap_symbol_in (abfd,
1286 extsyms + ELF32_R_SYM (irel->r_info),
1289 if (isym.st_shndx == SHN_UNDEF)
1290 sym_sec = bfd_und_section_ptr;
1291 else if (isym.st_shndx > 0 && isym.st_shndx < SHN_LORESERVE)
1292 sym_sec = bfd_section_from_elf_index (abfd, isym.st_shndx);
1293 else if (isym.st_shndx == SHN_ABS)
1294 sym_sec = bfd_abs_section_ptr;
1295 else if (isym.st_shndx == SHN_COMMON)
1296 sym_sec = bfd_com_section_ptr;
1298 symval = (isym.st_value
1299 + sym_sec->output_section->vma
1300 + sym_sec->output_offset);
1301 sym_name = bfd_elf_string_from_elf_section (abfd,
1302 symtab_hdr->sh_link,
1305 /* Tack on an ID so we can uniquely identify this
1306 local symbol in the global hash table. */
1307 new_name = alloca (strlen (sym_name) + 10);
1308 sprintf (new_name, "%s_%08x", sym_name, (int)sym_sec);
1309 sym_name = new_name;
1311 h = (struct elf32_mn10300_link_hash_entry *)
1312 elf_link_hash_lookup (&hash_table->static_hash_table->root,
1313 sym_name, false, false, false);
1319 /* An external symbol. */
1320 indx = ELF32_R_SYM (irel->r_info) - symtab_hdr->sh_info;
1321 h = (struct elf32_mn10300_link_hash_entry *)
1322 (elf_sym_hashes (abfd)[indx]);
1323 BFD_ASSERT (h != NULL);
1324 if (h->root.root.type != bfd_link_hash_defined
1325 && h->root.root.type != bfd_link_hash_defweak)
1327 /* This appears to be a reference to an undefined
1328 symbol. Just ignore it--it will be caught by the
1329 regular reloc processing. */
1333 symval = (h->root.root.u.def.value
1334 + h->root.root.u.def.section->output_section->vma
1335 + h->root.root.u.def.section->output_offset);
1338 /* For simplicity of coding, we are going to modify the section
1339 contents, the section relocs, and the BFD symbol table. We
1340 must tell the rest of the code not to free up this
1341 information. It would be possible to instead create a table
1342 of changes which have to be made, as is done in coff-mips.c;
1343 that would be more work, but would require less memory when
1344 the linker is run. */
1346 /* Try to turn a 32bit pc-relative branch/call into a 16bit pc-relative
1347 branch/call, also deal with "call" -> "calls" conversions and
1348 insertion of prologue data into "call" instructions. */
1349 if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_PCREL32)
1351 bfd_vma value = symval;
1353 /* If we've got a "call" instruction that needs to be turned
1354 into a "calls" instruction, do so now. It saves a byte. */
1355 if (h && (h->flags & MN10300_CONVERT_CALL_TO_CALLS))
1359 /* Get the opcode. */
1360 code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
1362 /* Make sure we're working with a "call" instruction! */
1365 /* Note that we've changed the relocs, section contents,
1367 elf_section_data (sec)->relocs = internal_relocs;
1370 elf_section_data (sec)->this_hdr.contents = contents;
1371 free_contents = NULL;
1373 symtab_hdr->contents = (bfd_byte *) extsyms;
1374 free_extsyms = NULL;
1376 /* Fix the opcode. */
1377 bfd_put_8 (abfd, 0xfc, contents + irel->r_offset - 1);
1378 bfd_put_8 (abfd, 0xff, contents + irel->r_offset);
1380 /* Fix irel->r_offset and irel->r_addend. */
1381 irel->r_offset += 1;
1382 irel->r_addend += 1;
1384 /* Delete one byte of data. */
1385 if (!mn10300_elf_relax_delete_bytes (abfd, sec,
1386 irel->r_offset + 3, 1))
1389 /* That will change things, so, we should relax again.
1390 Note that this is not required, and it may be slow. */
1396 /* We've got a "call" instruction which needs some data
1397 from target function filled in. */
1400 /* Get the opcode. */
1401 code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
1403 /* Insert data from the target function into the "call"
1404 instruction if needed. */
1407 bfd_put_8 (abfd, h->movm_args, contents + irel->r_offset + 4);
1408 bfd_put_8 (abfd, h->stack_size,
1409 contents + irel->r_offset + 5);
1413 /* Deal with pc-relative gunk. */
1414 value -= (sec->output_section->vma + sec->output_offset);
1415 value -= irel->r_offset;
1416 value += irel->r_addend;
1418 /* See if the value will fit in 16 bits, note the high value is
1419 0x7fff + 2 as the target will be two bytes closer if we are
1421 if ((long)value < 0x8001 && (long)value > -0x8000)
1425 /* Get the opcode. */
1426 code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
1428 if (code != 0xdc && code != 0xdd && code != 0xff)
1431 /* Note that we've changed the relocs, section contents, etc. */
1432 elf_section_data (sec)->relocs = internal_relocs;
1435 elf_section_data (sec)->this_hdr.contents = contents;
1436 free_contents = NULL;
1438 symtab_hdr->contents = (bfd_byte *) extsyms;
1439 free_extsyms = NULL;
1441 /* Fix the opcode. */
1443 bfd_put_8 (abfd, 0xcc, contents + irel->r_offset - 1);
1444 else if (code == 0xdd)
1445 bfd_put_8 (abfd, 0xcd, contents + irel->r_offset - 1);
1446 else if (code == 0xff)
1447 bfd_put_8 (abfd, 0xfa, contents + irel->r_offset - 2);
1449 /* Fix the relocation's type. */
1450 irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
1453 /* Delete two bytes of data. */
1454 if (!mn10300_elf_relax_delete_bytes (abfd, sec,
1455 irel->r_offset + 1, 2))
1458 /* That will change things, so, we should relax again.
1459 Note that this is not required, and it may be slow. */
1464 /* Try to turn a 16bit pc-relative branch into a 8bit pc-relative
1466 if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_PCREL16)
1468 bfd_vma value = symval;
1470 /* If we've got a "call" instruction that needs to be turned
1471 into a "calls" instruction, do so now. It saves a byte. */
1472 if (h && (h->flags & MN10300_CONVERT_CALL_TO_CALLS))
1476 /* Get the opcode. */
1477 code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
1479 /* Make sure we're working with a "call" instruction! */
1482 /* Note that we've changed the relocs, section contents,
1484 elf_section_data (sec)->relocs = internal_relocs;
1487 elf_section_data (sec)->this_hdr.contents = contents;
1488 free_contents = NULL;
1490 symtab_hdr->contents = (bfd_byte *) extsyms;
1491 free_extsyms = NULL;
1493 /* Fix the opcode. */
1494 bfd_put_8 (abfd, 0xfa, contents + irel->r_offset - 1);
1495 bfd_put_8 (abfd, 0xff, contents + irel->r_offset);
1497 /* Fix irel->r_offset and irel->r_addend. */
1498 irel->r_offset += 1;
1499 irel->r_addend += 1;
1501 /* Delete one byte of data. */
1502 if (!mn10300_elf_relax_delete_bytes (abfd, sec,
1503 irel->r_offset + 1, 1))
1506 /* That will change things, so, we should relax again.
1507 Note that this is not required, and it may be slow. */
1515 /* Get the opcode. */
1516 code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
1518 /* Insert data from the target function into the "call"
1519 instruction if needed. */
1522 bfd_put_8 (abfd, h->movm_args, contents + irel->r_offset + 2);
1523 bfd_put_8 (abfd, h->stack_size,
1524 contents + irel->r_offset + 3);
1528 /* Deal with pc-relative gunk. */
1529 value -= (sec->output_section->vma + sec->output_offset);
1530 value -= irel->r_offset;
1531 value += irel->r_addend;
1533 /* See if the value will fit in 8 bits, note the high value is
1534 0x7f + 1 as the target will be one bytes closer if we are
1536 if ((long)value < 0x80 && (long)value > -0x80)
1540 /* Get the opcode. */
1541 code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
1546 /* Note that we've changed the relocs, section contents, etc. */
1547 elf_section_data (sec)->relocs = internal_relocs;
1550 elf_section_data (sec)->this_hdr.contents = contents;
1551 free_contents = NULL;
1553 symtab_hdr->contents = (bfd_byte *) extsyms;
1554 free_extsyms = NULL;
1556 /* Fix the opcode. */
1557 bfd_put_8 (abfd, 0xca, contents + irel->r_offset - 1);
1559 /* Fix the relocation's type. */
1560 irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
1563 /* Delete one byte of data. */
1564 if (!mn10300_elf_relax_delete_bytes (abfd, sec,
1565 irel->r_offset + 1, 1))
1568 /* That will change things, so, we should relax again.
1569 Note that this is not required, and it may be slow. */
1574 /* Try to eliminate an unconditional 8 bit pc-relative branch
1575 which immediately follows a conditional 8 bit pc-relative
1576 branch around the unconditional branch.
1584 This happens when the bCC can't reach lab2 at assembly time,
1585 but due to other relaxations it can reach at link time. */
1586 if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_PCREL8)
1588 Elf_Internal_Rela *nrel;
1589 bfd_vma value = symval;
1592 /* Deal with pc-relative gunk. */
1593 value -= (sec->output_section->vma + sec->output_offset);
1594 value -= irel->r_offset;
1595 value += irel->r_addend;
1597 /* Do nothing if this reloc is the last byte in the section. */
1598 if (irel->r_offset == sec->_cooked_size)
1601 /* See if the next instruction is an unconditional pc-relative
1602 branch, more often than not this test will fail, so we
1603 test it first to speed things up. */
1604 code = bfd_get_8 (abfd, contents + irel->r_offset + 1);
1608 /* Also make sure the next relocation applies to the next
1609 instruction and that it's a pc-relative 8 bit branch. */
1612 || irel->r_offset + 2 != nrel->r_offset
1613 || ELF32_R_TYPE (nrel->r_info) != (int) R_MN10300_PCREL8)
1616 /* Make sure our destination immediately follows the
1617 unconditional branch. */
1618 if (symval != (sec->output_section->vma + sec->output_offset
1619 + irel->r_offset + 3))
1622 /* Now make sure we are a conditional branch. This may not
1623 be necessary, but why take the chance.
1625 Note these checks assume that R_MN10300_PCREL8 relocs
1626 only occur on bCC and bCCx insns. If they occured
1627 elsewhere, we'd need to know the start of this insn
1628 for this check to be accurate. */
1629 code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
1630 if (code != 0xc0 && code != 0xc1 && code != 0xc2
1631 && code != 0xc3 && code != 0xc4 && code != 0xc5
1632 && code != 0xc6 && code != 0xc7 && code != 0xc8
1633 && code != 0xc9 && code != 0xe8 && code != 0xe9
1634 && code != 0xea && code != 0xeb)
1637 /* We also have to be sure there is no symbol/label
1638 at the unconditional branch. */
1639 if (mn10300_elf_symbol_address_p (abfd, sec, extsyms,
1640 irel->r_offset + 1))
1643 /* Note that we've changed the relocs, section contents, etc. */
1644 elf_section_data (sec)->relocs = internal_relocs;
1647 elf_section_data (sec)->this_hdr.contents = contents;
1648 free_contents = NULL;
1650 symtab_hdr->contents = (bfd_byte *) extsyms;
1651 free_extsyms = NULL;
1653 /* Reverse the condition of the first branch. */
1699 bfd_put_8 (abfd, code, contents + irel->r_offset - 1);
1701 /* Set the reloc type and symbol for the first branch
1702 from the second branch. */
1703 irel->r_info = nrel->r_info;
1705 /* Make the reloc for the second branch a null reloc. */
1706 nrel->r_info = ELF32_R_INFO (ELF32_R_SYM (nrel->r_info),
1709 /* Delete two bytes of data. */
1710 if (!mn10300_elf_relax_delete_bytes (abfd, sec,
1711 irel->r_offset + 1, 2))
1714 /* That will change things, so, we should relax again.
1715 Note that this is not required, and it may be slow. */
1719 /* Try to turn a 32bit immediate, displacement or absolute address
1720 into a 16bit immediate, displacement or absolute address. */
1721 if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_32)
1723 bfd_vma value = symval;
1724 value += irel->r_addend;
1726 /* See if the value will fit in 16 bits.
1727 We allow any 16bit match here. We prune those we can't
1729 if ((long)value < 0x7fff && (long)value > -0x8000)
1733 /* Most insns which have 32bit operands are 6 bytes long;
1734 exceptions are pcrel insns and bit insns.
1736 We handle pcrel insns above. We don't bother trying
1737 to handle the bit insns here.
1739 The first byte of the remaining insns will be 0xfc. */
1741 /* Get the first opcode. */
1742 code = bfd_get_8 (abfd, contents + irel->r_offset - 2);
1747 /* Get the second opcode. */
1748 code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
1750 if ((code & 0xf0) < 0x80)
1751 switch (code & 0xf0)
1753 /* mov (d32,am),dn -> mov (d32,am),dn
1754 mov dm,(d32,am) -> mov dn,(d32,am)
1755 mov (d32,am),an -> mov (d32,am),an
1756 mov dm,(d32,am) -> mov dn,(d32,am)
1757 movbu (d32,am),dn -> movbu (d32,am),dn
1758 movbu dm,(d32,am) -> movbu dn,(d32,am)
1759 movhu (d32,am),dn -> movhu (d32,am),dn
1760 movhu dm,(d32,am) -> movhu dn,(d32,am) */
1769 /* Not safe if the high bit is on as relaxing may
1770 move the value out of high mem and thus not fit
1771 in a signed 16bit value. */
1773 && (value & 0x8000))
1776 /* Note that we've changed the relocation contents, etc. */
1777 elf_section_data (sec)->relocs = internal_relocs;
1780 elf_section_data (sec)->this_hdr.contents = contents;
1781 free_contents = NULL;
1783 symtab_hdr->contents = (bfd_byte *) extsyms;
1784 free_extsyms = NULL;
1786 /* Fix the opcode. */
1787 bfd_put_8 (abfd, 0xfa, contents + irel->r_offset - 2);
1788 bfd_put_8 (abfd, code, contents + irel->r_offset - 1);
1790 /* Fix the relocation's type. */
1791 irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
1794 /* Delete two bytes of data. */
1795 if (!mn10300_elf_relax_delete_bytes (abfd, sec,
1796 irel->r_offset + 2, 2))
1799 /* That will change things, so, we should relax again.
1800 Note that this is not required, and it may be slow. */
1804 else if ((code & 0xf0) == 0x80
1805 || (code & 0xf0) == 0x90)
1806 switch (code & 0xf3)
1808 /* mov dn,(abs32) -> mov dn,(abs16)
1809 movbu dn,(abs32) -> movbu dn,(abs16)
1810 movhu dn,(abs32) -> movhu dn,(abs16) */
1814 /* Note that we've changed the relocation contents, etc. */
1815 elf_section_data (sec)->relocs = internal_relocs;
1818 elf_section_data (sec)->this_hdr.contents = contents;
1819 free_contents = NULL;
1821 symtab_hdr->contents = (bfd_byte *) extsyms;
1822 free_extsyms = NULL;
1824 if ((code & 0xf3) == 0x81)
1825 code = 0x01 + (code & 0x0c);
1826 else if ((code & 0xf3) == 0x82)
1827 code = 0x02 + (code & 0x0c);
1828 else if ((code & 0xf3) == 0x83)
1829 code = 0x03 + (code & 0x0c);
1833 /* Fix the opcode. */
1834 bfd_put_8 (abfd, code, contents + irel->r_offset - 2);
1836 /* Fix the relocation's type. */
1837 irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
1840 /* The opcode got shorter too, so we have to fix the
1841 addend and offset too! */
1842 irel->r_offset -= 1;
1844 /* Delete three bytes of data. */
1845 if (!mn10300_elf_relax_delete_bytes (abfd, sec,
1846 irel->r_offset + 1, 3))
1849 /* That will change things, so, we should relax again.
1850 Note that this is not required, and it may be slow. */
1854 /* mov am,(abs32) -> mov am,(abs16)
1855 mov am,(d32,sp) -> mov am,(d16,sp)
1856 mov dm,(d32,sp) -> mov dm,(d32,sp)
1857 movbu dm,(d32,sp) -> movbu dm,(d32,sp)
1858 movhu dm,(d32,sp) -> movhu dm,(d32,sp) */
1864 /* Note that we've changed the relocation contents, etc. */
1865 elf_section_data (sec)->relocs = internal_relocs;
1868 elf_section_data (sec)->this_hdr.contents = contents;
1869 free_contents = NULL;
1871 symtab_hdr->contents = (bfd_byte *) extsyms;
1872 free_extsyms = NULL;
1874 /* Fix the opcode. */
1875 bfd_put_8 (abfd, 0xfa, contents + irel->r_offset - 2);
1876 bfd_put_8 (abfd, code, contents + irel->r_offset - 1);
1878 /* Fix the relocation's type. */
1879 irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
1882 /* Delete two bytes of data. */
1883 if (!mn10300_elf_relax_delete_bytes (abfd, sec,
1884 irel->r_offset + 2, 2))
1887 /* That will change things, so, we should relax again.
1888 Note that this is not required, and it may be slow. */
1892 else if ((code & 0xf0) < 0xf0)
1893 switch (code & 0xfc)
1895 /* mov imm32,dn -> mov imm16,dn
1896 mov imm32,an -> mov imm16,an
1897 mov (abs32),dn -> mov (abs16),dn
1898 movbu (abs32),dn -> movbu (abs16),dn
1899 movhu (abs32),dn -> movhu (abs16),dn */
1905 /* Not safe if the high bit is on as relaxing may
1906 move the value out of high mem and thus not fit
1907 in a signed 16bit value. */
1909 && (value & 0x8000))
1912 /* Note that we've changed the relocation contents, etc. */
1913 elf_section_data (sec)->relocs = internal_relocs;
1916 elf_section_data (sec)->this_hdr.contents = contents;
1917 free_contents = NULL;
1919 symtab_hdr->contents = (bfd_byte *) extsyms;
1920 free_extsyms = NULL;
1922 if ((code & 0xfc) == 0xcc)
1923 code = 0x2c + (code & 0x03);
1924 else if ((code & 0xfc) == 0xdc)
1925 code = 0x24 + (code & 0x03);
1926 else if ((code & 0xfc) == 0xa4)
1927 code = 0x30 + (code & 0x03);
1928 else if ((code & 0xfc) == 0xa8)
1929 code = 0x34 + (code & 0x03);
1930 else if ((code & 0xfc) == 0xac)
1931 code = 0x38 + (code & 0x03);
1935 /* Fix the opcode. */
1936 bfd_put_8 (abfd, code, contents + irel->r_offset - 2);
1938 /* Fix the relocation's type. */
1939 irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
1942 /* The opcode got shorter too, so we have to fix the
1943 addend and offset too! */
1944 irel->r_offset -= 1;
1946 /* Delete three bytes of data. */
1947 if (!mn10300_elf_relax_delete_bytes (abfd, sec,
1948 irel->r_offset + 1, 3))
1951 /* That will change things, so, we should relax again.
1952 Note that this is not required, and it may be slow. */
1956 /* mov (abs32),an -> mov (abs16),an
1957 mov (d32,sp),an -> mov (d32,sp),an
1958 mov (d32,sp),dn -> mov (d32,sp),dn
1959 movbu (d32,sp),dn -> movbu (d32,sp),dn
1960 movhu (d32,sp),dn -> movhu (d32,sp),dn
1961 add imm32,dn -> add imm16,dn
1962 cmp imm32,dn -> cmp imm16,dn
1963 add imm32,an -> add imm16,an
1964 cmp imm32,an -> cmp imm16,an
1965 and imm32,dn -> and imm32,dn
1966 or imm32,dn -> or imm32,dn
1967 xor imm32,dn -> xor imm32,dn
1968 btst imm32,dn -> btst imm32,dn */
1984 /* Note that we've changed the relocation contents, etc. */
1985 elf_section_data (sec)->relocs = internal_relocs;
1988 elf_section_data (sec)->this_hdr.contents = contents;
1989 free_contents = NULL;
1991 symtab_hdr->contents = (bfd_byte *) extsyms;
1992 free_extsyms = NULL;
1994 /* Fix the opcode. */
1995 bfd_put_8 (abfd, 0xfa, contents + irel->r_offset - 2);
1996 bfd_put_8 (abfd, code, contents + irel->r_offset - 1);
1998 /* Fix the relocation's type. */
1999 irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
2002 /* Delete two bytes of data. */
2003 if (!mn10300_elf_relax_delete_bytes (abfd, sec,
2004 irel->r_offset + 2, 2))
2007 /* That will change things, so, we should relax again.
2008 Note that this is not required, and it may be slow. */
2012 else if (code == 0xfe)
2014 /* add imm32,sp -> add imm16,sp */
2016 /* Note that we've changed the relocation contents, etc. */
2017 elf_section_data (sec)->relocs = internal_relocs;
2020 elf_section_data (sec)->this_hdr.contents = contents;
2021 free_contents = NULL;
2023 symtab_hdr->contents = (bfd_byte *) extsyms;
2024 free_extsyms = NULL;
2026 /* Fix the opcode. */
2027 bfd_put_8 (abfd, 0xfa, contents + irel->r_offset - 2);
2028 bfd_put_8 (abfd, 0xfe, contents + irel->r_offset - 1);
2030 /* Fix the relocation's type. */
2031 irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
2034 /* Delete two bytes of data. */
2035 if (!mn10300_elf_relax_delete_bytes (abfd, sec,
2036 irel->r_offset + 2, 2))
2039 /* That will change things, so, we should relax again.
2040 Note that this is not required, and it may be slow. */
2048 if (free_relocs != NULL)
2054 if (free_contents != NULL)
2056 if (! link_info->keep_memory)
2057 free (free_contents);
2060 /* Cache the section contents for elf_link_input_bfd. */
2061 elf_section_data (sec)->this_hdr.contents = contents;
2063 free_contents = NULL;
2066 if (free_extsyms != NULL)
2068 if (! link_info->keep_memory)
2069 free (free_extsyms);
2072 /* Cache the symbols for elf_link_input_bfd. */
2073 symtab_hdr->contents = extsyms;
2075 free_extsyms = NULL;
2081 if (free_relocs != NULL)
2083 if (free_contents != NULL)
2084 free (free_contents);
2085 if (free_extsyms != NULL)
2086 free (free_extsyms);
2090 /* Compute the stack size and movm arguments for the function
2091 referred to by HASH at address ADDR in section with
2092 contents CONTENTS, store the information in the hash table. */
2094 compute_function_info (abfd, hash, addr, contents)
2096 struct elf32_mn10300_link_hash_entry *hash;
2098 unsigned char *contents;
2100 unsigned char byte1, byte2;
2101 /* We only care about a very small subset of the possible prologue
2102 sequences here. Basically we look for:
2104 movm [d2,d3,a2,a3],sp (optional)
2105 add <size>,sp (optional, and only for sizes which fit in an unsigned
2108 If we find anything else, we quit. */
2110 /* Look for movm [regs],sp */
2111 byte1 = bfd_get_8 (abfd, contents + addr);
2112 byte2 = bfd_get_8 (abfd, contents + addr + 1);
2116 hash->movm_args = byte2;
2118 byte1 = bfd_get_8 (abfd, contents + addr);
2119 byte2 = bfd_get_8 (abfd, contents + addr + 1);
2122 /* Now look for the two stack adjustment variants. */
2123 if (byte1 == 0xf8 && byte2 == 0xfe)
2125 int temp = bfd_get_8 (abfd, contents + addr + 2);
2126 temp = ((temp & 0xff) ^ (~0x7f)) + 0x80;
2128 hash->stack_size = -temp;
2130 else if (byte1 == 0xfa && byte2 == 0xfe)
2132 int temp = bfd_get_16 (abfd, contents + addr + 2);
2133 temp = ((temp & 0xffff) ^ (~0x7fff)) + 0x8000;
2137 hash->stack_size = temp;
2142 /* Delete some bytes from a section while relaxing. */
2145 mn10300_elf_relax_delete_bytes (abfd, sec, addr, count)
2151 Elf_Internal_Shdr *symtab_hdr;
2152 Elf32_External_Sym *extsyms;
2155 Elf_Internal_Rela *irel, *irelend;
2156 Elf_Internal_Rela *irelalign;
2158 Elf32_External_Sym *esym, *esymend;
2159 struct elf32_mn10300_link_hash_entry *sym_hash;
2161 symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
2162 extsyms = (Elf32_External_Sym *) symtab_hdr->contents;
2164 shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
2166 contents = elf_section_data (sec)->this_hdr.contents;
2168 /* The deletion must stop at the next ALIGN reloc for an aligment
2169 power larger than the number of bytes we are deleting. */
2172 toaddr = sec->_cooked_size;
2174 irel = elf_section_data (sec)->relocs;
2175 irelend = irel + sec->reloc_count;
2177 /* Actually delete the bytes. */
2178 memmove (contents + addr, contents + addr + count, toaddr - addr - count);
2179 sec->_cooked_size -= count;
2181 /* Adjust all the relocs. */
2182 for (irel = elf_section_data (sec)->relocs; irel < irelend; irel++)
2184 /* Get the new reloc address. */
2185 if ((irel->r_offset > addr
2186 && irel->r_offset < toaddr))
2187 irel->r_offset -= count;
2190 /* Adjust the local symbols defined in this section. */
2192 esymend = esym + symtab_hdr->sh_info;
2193 for (; esym < esymend; esym++)
2195 Elf_Internal_Sym isym;
2197 bfd_elf32_swap_symbol_in (abfd, esym, &isym);
2199 if (isym.st_shndx == shndx
2200 && isym.st_value > addr
2201 && isym.st_value < toaddr)
2203 isym.st_value -= count;
2204 bfd_elf32_swap_symbol_out (abfd, &isym, esym);
2208 /* Now adjust the global symbols defined in this section. */
2209 esym = extsyms + symtab_hdr->sh_info;
2210 esymend = extsyms + (symtab_hdr->sh_size / sizeof (Elf32_External_Sym));
2211 for (index = 0; esym < esymend; esym++, index++)
2213 Elf_Internal_Sym isym;
2215 bfd_elf32_swap_symbol_in (abfd, esym, &isym);
2216 sym_hash = (struct elf32_mn10300_link_hash_entry *)
2217 (elf_sym_hashes (abfd)[index]);
2218 if (isym.st_shndx == shndx
2219 && ((sym_hash)->root.root.type == bfd_link_hash_defined
2220 || (sym_hash)->root.root.type == bfd_link_hash_defweak)
2221 && (sym_hash)->root.root.u.def.section == sec
2222 && (sym_hash)->root.root.u.def.value > addr
2223 && (sym_hash)->root.root.u.def.value < toaddr)
2225 (sym_hash)->root.root.u.def.value -= count;
2232 /* Return true if a symbol exists at the given address, else return
2235 mn10300_elf_symbol_address_p (abfd, sec, extsyms, addr)
2238 Elf32_External_Sym *extsyms;
2241 Elf_Internal_Shdr *symtab_hdr;
2243 Elf32_External_Sym *esym, *esymend;
2244 struct elf32_mn10300_link_hash_entry **sym_hash, **sym_hash_end;
2246 symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
2247 shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
2249 /* Examine all the symbols. */
2251 esymend = esym + symtab_hdr->sh_info;
2252 for (; esym < esymend; esym++)
2254 Elf_Internal_Sym isym;
2256 bfd_elf32_swap_symbol_in (abfd, esym, &isym);
2258 if (isym.st_shndx == shndx
2259 && isym.st_value == addr)
2263 sym_hash = (struct elf32_mn10300_link_hash_entry **)(elf_sym_hashes (abfd));
2264 sym_hash_end = (sym_hash
2265 + (symtab_hdr->sh_size / sizeof (Elf32_External_Sym)
2266 - symtab_hdr->sh_info));
2267 for (; sym_hash < sym_hash_end; sym_hash++)
2269 if (((*sym_hash)->root.root.type == bfd_link_hash_defined
2270 || (*sym_hash)->root.root.type == bfd_link_hash_defweak)
2271 && (*sym_hash)->root.root.u.def.section == sec
2272 && (*sym_hash)->root.root.u.def.value == addr)
2278 /* This is a version of bfd_generic_get_relocated_section_contents
2279 which uses mn10300_elf_relocate_section. */
2282 mn10300_elf_get_relocated_section_contents (output_bfd, link_info, link_order,
2283 data, relocateable, symbols)
2285 struct bfd_link_info *link_info;
2286 struct bfd_link_order *link_order;
2288 boolean relocateable;
2291 Elf_Internal_Shdr *symtab_hdr;
2292 asection *input_section = link_order->u.indirect.section;
2293 bfd *input_bfd = input_section->owner;
2294 asection **sections = NULL;
2295 Elf_Internal_Rela *internal_relocs = NULL;
2296 Elf32_External_Sym *external_syms = NULL;
2297 Elf_Internal_Sym *internal_syms = NULL;
2299 /* We only need to handle the case of relaxing, or of having a
2300 particular set of section contents, specially. */
2302 || elf_section_data (input_section)->this_hdr.contents == NULL)
2303 return bfd_generic_get_relocated_section_contents (output_bfd, link_info,
2308 symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
2310 memcpy (data, elf_section_data (input_section)->this_hdr.contents,
2311 input_section->_raw_size);
2313 if ((input_section->flags & SEC_RELOC) != 0
2314 && input_section->reloc_count > 0)
2316 Elf_Internal_Sym *isymp;
2318 Elf32_External_Sym *esym, *esymend;
2320 if (symtab_hdr->contents != NULL)
2321 external_syms = (Elf32_External_Sym *) symtab_hdr->contents;
2324 external_syms = ((Elf32_External_Sym *)
2325 bfd_malloc (symtab_hdr->sh_info
2326 * sizeof (Elf32_External_Sym)));
2327 if (external_syms == NULL && symtab_hdr->sh_info > 0)
2329 if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0
2330 || (bfd_read (external_syms, sizeof (Elf32_External_Sym),
2331 symtab_hdr->sh_info, input_bfd)
2332 != (symtab_hdr->sh_info * sizeof (Elf32_External_Sym))))
2336 internal_relocs = (_bfd_elf32_link_read_relocs
2337 (input_bfd, input_section, (PTR) NULL,
2338 (Elf_Internal_Rela *) NULL, false));
2339 if (internal_relocs == NULL)
2342 internal_syms = ((Elf_Internal_Sym *)
2343 bfd_malloc (symtab_hdr->sh_info
2344 * sizeof (Elf_Internal_Sym)));
2345 if (internal_syms == NULL && symtab_hdr->sh_info > 0)
2348 sections = (asection **) bfd_malloc (symtab_hdr->sh_info
2349 * sizeof (asection *));
2350 if (sections == NULL && symtab_hdr->sh_info > 0)
2353 isymp = internal_syms;
2355 esym = external_syms;
2356 esymend = esym + symtab_hdr->sh_info;
2357 for (; esym < esymend; ++esym, ++isymp, ++secpp)
2361 bfd_elf32_swap_symbol_in (input_bfd, esym, isymp);
2363 if (isymp->st_shndx == SHN_UNDEF)
2364 isec = bfd_und_section_ptr;
2365 else if (isymp->st_shndx > 0 && isymp->st_shndx < SHN_LORESERVE)
2366 isec = bfd_section_from_elf_index (input_bfd, isymp->st_shndx);
2367 else if (isymp->st_shndx == SHN_ABS)
2368 isec = bfd_abs_section_ptr;
2369 else if (isymp->st_shndx == SHN_COMMON)
2370 isec = bfd_com_section_ptr;
2380 if (! mn10300_elf_relocate_section (output_bfd, link_info, input_bfd,
2381 input_section, data, internal_relocs,
2382 internal_syms, sections))
2385 if (sections != NULL)
2388 if (internal_syms != NULL)
2389 free (internal_syms);
2390 internal_syms = NULL;
2391 if (external_syms != NULL && symtab_hdr->contents == NULL)
2392 free (external_syms);
2393 external_syms = NULL;
2394 if (internal_relocs != elf_section_data (input_section)->relocs)
2395 free (internal_relocs);
2396 internal_relocs = NULL;
2402 if (internal_relocs != NULL
2403 && internal_relocs != elf_section_data (input_section)->relocs)
2404 free (internal_relocs);
2405 if (external_syms != NULL && symtab_hdr->contents == NULL)
2406 free (external_syms);
2407 if (internal_syms != NULL)
2408 free (internal_syms);
2409 if (sections != NULL)
2414 /* Assorted hash table functions. */
2416 /* Initialize an entry in the link hash table. */
2418 /* Create an entry in an MN10300 ELF linker hash table. */
2420 static struct bfd_hash_entry *
2421 elf32_mn10300_link_hash_newfunc (entry, table, string)
2422 struct bfd_hash_entry *entry;
2423 struct bfd_hash_table *table;
2426 struct elf32_mn10300_link_hash_entry *ret =
2427 (struct elf32_mn10300_link_hash_entry *) entry;
2429 /* Allocate the structure if it has not already been allocated by a
2431 if (ret == (struct elf32_mn10300_link_hash_entry *) NULL)
2432 ret = ((struct elf32_mn10300_link_hash_entry *)
2433 bfd_hash_allocate (table,
2434 sizeof (struct elf32_mn10300_link_hash_entry)));
2435 if (ret == (struct elf32_mn10300_link_hash_entry *) NULL)
2436 return (struct bfd_hash_entry *) ret;
2438 /* Call the allocation method of the superclass. */
2439 ret = ((struct elf32_mn10300_link_hash_entry *)
2440 _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret,
2442 if (ret != (struct elf32_mn10300_link_hash_entry *) NULL)
2444 ret->direct_calls = 0;
2445 ret->stack_size = 0;
2450 return (struct bfd_hash_entry *) ret;
2453 /* Create an mn10300 ELF linker hash table. */
2455 static struct bfd_link_hash_table *
2456 elf32_mn10300_link_hash_table_create (abfd)
2459 struct elf32_mn10300_link_hash_table *ret;
2461 ret = ((struct elf32_mn10300_link_hash_table *)
2462 bfd_alloc (abfd, sizeof (struct elf32_mn10300_link_hash_table)));
2463 if (ret == (struct elf32_mn10300_link_hash_table *) NULL)
2466 if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
2467 elf32_mn10300_link_hash_newfunc))
2469 bfd_release (abfd, ret);
2474 ret->static_hash_table
2475 = ((struct elf32_mn10300_link_hash_table *)
2476 bfd_alloc (abfd, sizeof (struct elf_link_hash_table)));
2477 if (ret->static_hash_table == NULL)
2479 bfd_release (abfd, ret);
2483 if (! _bfd_elf_link_hash_table_init (&ret->static_hash_table->root, abfd,
2484 elf32_mn10300_link_hash_newfunc))
2486 bfd_release (abfd, ret->static_hash_table);
2487 bfd_release (abfd, ret);
2490 return &ret->root.root;
2494 elf_mn10300_mach (flags)
2497 switch (flags & EF_MN10300_MACH)
2499 case E_MN10300_MACH_MN10300:
2501 return bfd_mach_mn10300;
2503 /* start-sanitize-am33 */
2504 case E_MN10300_MACH_AM33:
2505 return bfd_mach_am33;
2506 /* end-sanitize-am33 */
2510 /* The final processing done just before writing out a MN10300 ELF object
2511 file. This gets the MN10300 architecture right based on the machine
2516 _bfd_mn10300_elf_final_write_processing (abfd, linker)
2522 Elf_Internal_Shdr **hdrpp;
2526 switch (bfd_get_mach (abfd))
2529 case bfd_mach_mn10300:
2530 val = E_MN10300_MACH_MN10300;
2533 /* start-sanitize-am33 */
2535 val = E_MN10300_MACH_AM33;
2537 /* end-sanitize-am33 */
2540 elf_elfheader (abfd)->e_flags &= ~ (EF_MN10300_MACH);
2541 elf_elfheader (abfd)->e_flags |= val;
2545 _bfd_mn10300_elf_object_p (abfd)
2548 bfd_default_set_arch_mach (abfd, bfd_arch_mn10300,
2549 elf_mn10300_mach (elf_elfheader (abfd)->e_flags));
2553 #define TARGET_LITTLE_SYM bfd_elf32_mn10300_vec
2554 #define TARGET_LITTLE_NAME "elf32-mn10300"
2555 #define ELF_ARCH bfd_arch_mn10300
2556 #define ELF_MACHINE_CODE EM_CYGNUS_MN10300
2557 #define ELF_MAXPAGESIZE 0x1000
2559 #define elf_info_to_howto mn10300_info_to_howto
2560 #define elf_info_to_howto_rel 0
2561 #define elf_backend_relocate_section mn10300_elf_relocate_section
2562 #define bfd_elf32_bfd_relax_section mn10300_elf_relax_section
2563 #define bfd_elf32_bfd_get_relocated_section_contents \
2564 mn10300_elf_get_relocated_section_contents
2565 #define bfd_elf32_bfd_link_hash_table_create \
2566 elf32_mn10300_link_hash_table_create
2568 #define elf_symbol_leading_char '_'
2570 /* So we can set bits in e_flags. */
2571 #define elf_backend_final_write_processing \
2572 _bfd_mn10300_elf_final_write_processing
2573 #define elf_backend_object_p _bfd_mn10300_elf_object_p
2576 #include "elf32-target.h"