+/*****************************************************************************/
+
+/* s3_s7: backend hooks. */
+static bfd_boolean
+_bfd_score_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
+ arelent *bfd_reloc,
+ Elf_Internal_Rela *elf_reloc)
+{
+ if (bfd_get_mach (abfd) == bfd_mach_score3)
+ return s3_bfd_score_info_to_howto (abfd, bfd_reloc, elf_reloc);
+ else
+ return s7_bfd_score_info_to_howto (abfd, bfd_reloc, elf_reloc);
+}
+
+static bfd_boolean
+_bfd_score_elf_relocate_section (bfd *output_bfd,
+ struct bfd_link_info *info,
+ bfd *input_bfd,
+ asection *input_section,
+ bfd_byte *contents,
+ Elf_Internal_Rela *relocs,
+ Elf_Internal_Sym *local_syms,
+ asection **local_sections)
+{
+ if (bfd_get_mach (output_bfd) == bfd_mach_score3)
+ return s3_bfd_score_elf_relocate_section (output_bfd,
+ info, input_bfd, input_section, contents, relocs,
+ local_syms, local_sections);
+ else
+ return s7_bfd_score_elf_relocate_section (output_bfd,
+ info, input_bfd, input_section, contents, relocs,
+ local_syms, local_sections);
+}
+
+static bfd_boolean
+_bfd_score_elf_check_relocs (bfd *abfd,
+ struct bfd_link_info *info,
+ asection *sec,
+ const Elf_Internal_Rela *relocs)
+{
+ if (bfd_get_mach (abfd) == bfd_mach_score3)
+ return s3_bfd_score_elf_check_relocs (abfd, info, sec, relocs);
+ else
+ return s7_bfd_score_elf_check_relocs (abfd, info, sec, relocs);
+}
+
+static bfd_boolean
+_bfd_score_elf_add_symbol_hook (bfd *abfd,
+ struct bfd_link_info *info ATTRIBUTE_UNUSED,
+ Elf_Internal_Sym *sym,
+ const char **namep ATTRIBUTE_UNUSED,
+ flagword *flagsp ATTRIBUTE_UNUSED,
+ asection **secp,
+ bfd_vma *valp)
+{
+ if (bfd_get_mach (abfd) == bfd_mach_score3)
+ return s3_bfd_score_elf_add_symbol_hook (abfd, info, sym, namep, flagsp,
+ secp, valp);
+ else
+ return s7_bfd_score_elf_add_symbol_hook (abfd, info, sym, namep, flagsp,
+ secp, valp);
+}
+
+static void
+_bfd_score_elf_symbol_processing (bfd *abfd, asymbol *asym)
+{
+ if (bfd_get_mach (abfd) == bfd_mach_score3)
+ return s3_bfd_score_elf_symbol_processing (abfd, asym);
+ else
+ return s7_bfd_score_elf_symbol_processing (abfd, asym);
+}
+
+static int
+_bfd_score_elf_link_output_symbol_hook (struct bfd_link_info *info ATTRIBUTE_UNUSED,
+ const char *name ATTRIBUTE_UNUSED,
+ Elf_Internal_Sym *sym,
+ asection *input_sec,
+ struct elf_link_hash_entry *h ATTRIBUTE_UNUSED)
+{
+ /* If link a empty .o, then this filed is NULL. */
+ if (info->input_bfds == NULL)
+ {
+ /* If we see a common symbol, which implies a relocatable link, then
+ if a symbol was small common in an input file, mark it as small
+ common in the output file. */
+ if (sym->st_shndx == SHN_COMMON && strcmp (input_sec->name, ".scommon") == 0)
+ sym->st_shndx = SHN_SCORE_SCOMMON;
+ return 1;
+ }
+
+ if (bfd_get_mach (info->input_bfds) == bfd_mach_score3)
+ return s3_bfd_score_elf_link_output_symbol_hook (info, name, sym, input_sec, h);
+ else
+ return s7_bfd_score_elf_link_output_symbol_hook (info, name, sym, input_sec, h);
+}
+
+static bfd_boolean
+_bfd_score_elf_section_from_bfd_section (bfd *abfd ATTRIBUTE_UNUSED,
+ asection *sec,
+ int *retval)
+{
+ if (bfd_get_mach (abfd) == bfd_mach_score3)
+ return s3_bfd_score_elf_section_from_bfd_section (abfd, sec, retval);
+ else
+ return s7_bfd_score_elf_section_from_bfd_section (abfd, sec, retval);
+}
+
+static bfd_boolean
+_bfd_score_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
+ struct elf_link_hash_entry *h)
+{
+ if (bfd_get_mach (info->input_bfds) == bfd_mach_score3)
+ return s3_bfd_score_elf_adjust_dynamic_symbol (info, h);
+ else
+ return s7_bfd_score_elf_adjust_dynamic_symbol (info, h);
+}
+
+static bfd_boolean
+_bfd_score_elf_always_size_sections (bfd *output_bfd,
+ struct bfd_link_info *info)
+{
+ if (bfd_get_mach (output_bfd) == bfd_mach_score3)
+ return s3_bfd_score_elf_always_size_sections (output_bfd, info);
+ else
+ return s7_bfd_score_elf_always_size_sections (output_bfd, info);
+}
+
+static bfd_boolean
+_bfd_score_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
+{
+ if (bfd_get_mach (output_bfd) == bfd_mach_score3)
+ return s3_bfd_score_elf_size_dynamic_sections (output_bfd, info);
+ else
+ return s7_bfd_score_elf_size_dynamic_sections (output_bfd, info);
+}
+
+static bfd_boolean
+_bfd_score_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
+{
+ if (bfd_get_mach (abfd) == bfd_mach_score3)
+ return s3_bfd_score_elf_create_dynamic_sections (abfd, info);
+ else
+ return s7_bfd_score_elf_create_dynamic_sections (abfd, info);
+}
+
+static bfd_boolean
+_bfd_score_elf_finish_dynamic_symbol (bfd *output_bfd,
+ struct bfd_link_info *info,
+ struct elf_link_hash_entry *h,
+ Elf_Internal_Sym *sym)
+{
+ if (bfd_get_mach (output_bfd) == bfd_mach_score3)
+ return s3_bfd_score_elf_finish_dynamic_symbol (output_bfd, info, h, sym);
+ else
+ return s7_bfd_score_elf_finish_dynamic_symbol (output_bfd, info, h, sym);
+}
+
+static bfd_boolean
+_bfd_score_elf_finish_dynamic_sections (bfd *output_bfd,
+ struct bfd_link_info *info)
+{
+ if (bfd_get_mach (output_bfd) == bfd_mach_score3)
+ return s3_bfd_score_elf_finish_dynamic_sections (output_bfd, info);
+ else
+ return s7_bfd_score_elf_finish_dynamic_sections (output_bfd, info);
+}
+
+static bfd_boolean
+_bfd_score_elf_fake_sections (bfd *abfd ATTRIBUTE_UNUSED,
+ Elf_Internal_Shdr *hdr,
+ asection *sec)
+{
+ if (bfd_get_mach (abfd) == bfd_mach_score3)
+ return s3_bfd_score_elf_fake_sections (abfd, hdr, sec);
+ else
+ return s7_bfd_score_elf_fake_sections (abfd, hdr, sec);
+}
+
+static bfd_boolean
+_bfd_score_elf_section_processing (bfd *abfd ATTRIBUTE_UNUSED, Elf_Internal_Shdr *hdr)
+{
+ if (bfd_get_mach (abfd) == bfd_mach_score3)
+ return s3_bfd_score_elf_section_processing (abfd, hdr);
+ else
+ return s7_bfd_score_elf_section_processing (abfd, hdr);
+}
+
+static bfd_boolean
+_bfd_score_elf_write_section (bfd *output_bfd,
+ struct bfd_link_info *link_info ATTRIBUTE_UNUSED,
+ asection *sec, bfd_byte *contents)
+{
+ if (bfd_get_mach (output_bfd) == bfd_mach_score3)
+ return s3_bfd_score_elf_write_section (output_bfd, sec, contents);
+ else
+ return s7_bfd_score_elf_write_section (output_bfd, sec, contents);
+}
+
+static void
+_bfd_score_elf_copy_indirect_symbol (struct bfd_link_info *info,
+ struct elf_link_hash_entry *dir,
+ struct elf_link_hash_entry *ind)
+{
+ if (bfd_get_mach (info->input_bfds) == bfd_mach_score3)
+ return s3_bfd_score_elf_copy_indirect_symbol (info, dir, ind);
+ else
+ return s7_bfd_score_elf_copy_indirect_symbol (info, dir, ind);
+}
+
+static void
+_bfd_score_elf_hide_symbol (struct bfd_link_info *info,
+ struct elf_link_hash_entry *entry,
+ bfd_boolean force_local)
+{
+ if (bfd_get_mach (info->input_bfds) == bfd_mach_score3)
+ return s3_bfd_score_elf_hide_symbol (info, entry, force_local);
+ else
+ return s7_bfd_score_elf_hide_symbol (info, entry, force_local);
+}
+
+static bfd_boolean
+_bfd_score_elf_discard_info (bfd *abfd, struct elf_reloc_cookie *cookie,
+ struct bfd_link_info *info)
+{
+ if (bfd_get_mach (abfd) == bfd_mach_score3)
+ return s3_bfd_score_elf_discard_info (abfd, cookie, info);
+ else
+ return s7_bfd_score_elf_discard_info (abfd, cookie, info);
+}
+
+static bfd_boolean
+_bfd_score_elf_ignore_discarded_relocs (asection *sec)
+{
+ if (bfd_get_mach (sec->owner) == bfd_mach_score3)
+ return s3_bfd_score_elf_ignore_discarded_relocs (sec);
+ else
+ return s7_bfd_score_elf_ignore_discarded_relocs (sec);
+}