+/* Classify dynamic relocs such that -z combreloc can reorder and combine
+ them. */
+static enum elf_reloc_type_class
+elf32_arc_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+ const asection *rel_sec ATTRIBUTE_UNUSED,
+ const Elf_Internal_Rela *rela)
+{
+ switch ((int) ELF32_R_TYPE (rela->r_info))
+ {
+ case R_ARC_RELATIVE:
+ return reloc_class_relative;
+ case R_ARC_JMP_SLOT:
+ return reloc_class_plt;
+ case R_ARC_COPY:
+ return reloc_class_copy;
+ /* TODO: Needed in future to support ifunc. */
+ /*
+ case R_ARC_IRELATIVE:
+ return reloc_class_ifunc;
+ */
+ default:
+ return reloc_class_normal;
+ }
+}
+
+const struct elf_size_info arc_elf32_size_info =
+{
+ sizeof (Elf32_External_Ehdr),
+ sizeof (Elf32_External_Phdr),
+ sizeof (Elf32_External_Shdr),
+ sizeof (Elf32_External_Rel),
+ sizeof (Elf32_External_Rela),
+ sizeof (Elf32_External_Sym),
+ sizeof (Elf32_External_Dyn),
+ sizeof (Elf_External_Note),
+ 4,
+ 1,
+ 32, 2,
+ ELFCLASS32, EV_CURRENT,
+ bfd_elf32_write_out_phdrs,
+ bfd_elf32_write_shdrs_and_ehdr,
+ bfd_elf32_checksum_contents,
+ bfd_elf32_write_relocs,
+ bfd_elf32_swap_symbol_in,
+ bfd_elf32_swap_symbol_out,
+ bfd_elf32_slurp_reloc_table,
+ bfd_elf32_slurp_symbol_table,
+ bfd_elf32_swap_dyn_in,
+ bfd_elf32_swap_dyn_out,
+ bfd_elf32_swap_reloc_in,
+ bfd_elf32_swap_reloc_out,
+ bfd_elf32_swap_reloca_in,
+ bfd_elf32_swap_reloca_out
+};
+
+#define elf_backend_size_info arc_elf32_size_info
+
+static struct bfd_link_hash_table *
+arc_elf_link_hash_table_create (bfd *abfd)
+{
+ struct elf_link_hash_table *htab;
+
+ htab = bfd_zmalloc (sizeof (*htab));
+ if (htab == NULL)
+ return NULL;
+
+ if (!_bfd_elf_link_hash_table_init (htab, abfd,
+ _bfd_elf_link_hash_newfunc,
+ sizeof (struct elf_link_hash_entry),
+ GENERIC_ELF_DATA))
+ {
+ free (htab);
+ return NULL;
+ }
+
+ htab->init_got_refcount.refcount = 0;
+ htab->init_got_refcount.glist = NULL;
+ htab->init_got_offset.offset = 0;
+ htab->init_got_offset.glist = NULL;
+ return (struct bfd_link_hash_table *) htab;
+}
+
+/* Hook called by the linker routine which adds symbols from an object
+ file. */
+
+static bfd_boolean
+elf_arc_add_symbol_hook (bfd * abfd,
+ struct bfd_link_info * info,
+ Elf_Internal_Sym * sym,
+ const char ** namep ATTRIBUTE_UNUSED,
+ flagword * flagsp ATTRIBUTE_UNUSED,
+ asection ** secp ATTRIBUTE_UNUSED,
+ bfd_vma * valp ATTRIBUTE_UNUSED)
+{
+ if (ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC
+ && (abfd->flags & DYNAMIC) == 0
+ && bfd_get_flavour (info->output_bfd) == bfd_target_elf_flavour)
+ elf_tdata (info->output_bfd)->has_gnu_symbols |= elf_gnu_symbol_ifunc;
+
+ return TRUE;
+}
+