+ HOWTO (R_NIOS2_HI16,
+ 0,
+ 2,
+ 32,
+ FALSE,
+ 16,
+ complain_overflow_dont,
+ nios2_elf32_hi16_relocate,
+ "R_NIOS2_HI16",
+ FALSE,
+ 0xffff0000,
+ 0xffff0000,
+ FALSE),
+
+ HOWTO (R_NIOS2_LO16,
+ 0,
+ 2,
+ 32,
+ FALSE,
+ 16,
+ complain_overflow_dont,
+ nios2_elf32_lo16_relocate,
+ "R_NIOS2_LO16",
+ FALSE,
+ 0xffff0000,
+ 0xffff0000,
+ FALSE),
+
+ HOWTO (R_NIOS2_HIADJ16,
+ 0,
+ 2,
+ 32,
+ FALSE,
+ 16,
+ complain_overflow_dont,
+ nios2_elf32_hiadj16_relocate,
+ "R_NIOS2_HIADJ16",
+ FALSE,
+ 0xffff0000,
+ 0xffff0000,
+ FALSE),
+
+ HOWTO (R_NIOS2_BFD_RELOC_32,
+ 0,
+ 2, /* long */
+ 32,
+ FALSE,
+ 0,
+ complain_overflow_dont,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_BFD_RELOC32",
+ FALSE,
+ 0xffffffff,
+ 0xffffffff,
+ FALSE),
+
+ HOWTO (R_NIOS2_BFD_RELOC_16,
+ 0,
+ 1, /* short */
+ 16,
+ FALSE,
+ 0,
+ complain_overflow_bitfield,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_BFD_RELOC16",
+ FALSE,
+ 0x0000ffff,
+ 0x0000ffff,
+ FALSE),
+
+ HOWTO (R_NIOS2_BFD_RELOC_8,
+ 0,
+ 0, /* byte */
+ 8,
+ FALSE,
+ 0,
+ complain_overflow_bitfield,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_BFD_RELOC8",
+ FALSE,
+ 0x000000ff,
+ 0x000000ff,
+ FALSE),
+
+ HOWTO (R_NIOS2_GPREL,
+ 0,
+ 2,
+ 32,
+ FALSE,
+ 16,
+ complain_overflow_dont,
+ nios2_elf32_gprel_relocate,
+ "R_NIOS2_GPREL",
+ FALSE,
+ 0xffff0000,
+ 0xffff0000,
+ FALSE),
+
+ HOWTO (R_NIOS2_GNU_VTINHERIT,
+ 0,
+ 2, /* short */
+ 0,
+ FALSE,
+ 0,
+ complain_overflow_dont,
+ NULL,
+ "R_NIOS2_GNU_VTINHERIT",
+ FALSE,
+ 0,
+ 0,
+ FALSE),
+
+ HOWTO (R_NIOS2_GNU_VTENTRY,
+ 0,
+ 2, /* byte */
+ 0,
+ FALSE,
+ 0,
+ complain_overflow_dont,
+ _bfd_elf_rel_vtable_reloc_fn,
+ "R_NIOS2_GNU_VTENTRY",
+ FALSE,
+ 0,
+ 0,
+ FALSE),
+
+ HOWTO (R_NIOS2_UJMP,
+ 0,
+ 2,
+ 32,
+ FALSE,
+ 16,
+ complain_overflow_dont,
+ nios2_elf32_ujmp_relocate,
+ "R_NIOS2_UJMP",
+ FALSE,
+ 0xffff0000,
+ 0xffff0000,
+ FALSE),
+
+ HOWTO (R_NIOS2_CJMP,
+ 0,
+ 2,
+ 32,
+ FALSE,
+ 16,
+ complain_overflow_dont,
+ nios2_elf32_cjmp_relocate,
+ "R_NIOS2_CJMP",
+ FALSE,
+ 0xffff0000,
+ 0xffff0000,
+ FALSE),
+
+ HOWTO (R_NIOS2_CALLR,
+ 0,
+ 2,
+ 32,
+ FALSE,
+ 16,
+ complain_overflow_dont,
+ nios2_elf32_callr_relocate,
+ "R_NIOS2_CALLR",
+ FALSE,
+ 0xffff0000,
+ 0xffff0000,
+ FALSE),
+
+ HOWTO (R_NIOS2_ALIGN,
+ 0,
+ 2,
+ 0,
+ FALSE,
+ 0,
+ complain_overflow_dont,
+ nios2_elf32_ignore_reloc,
+ "R_NIOS2_ALIGN",
+ FALSE,
+ 0,
+ 0,
+ TRUE),
+
+ HOWTO (R_NIOS2_GOT16,
+ 0,
+ 2,
+ 16,
+ FALSE,
+ 16,
+ complain_overflow_bitfield,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_GOT16",
+ FALSE,
+ 0xffff0000,
+ 0xffff0000,
+ FALSE),
+
+ HOWTO (R_NIOS2_CALL16,
+ 0,
+ 2,
+ 16,
+ FALSE,
+ 16,
+ complain_overflow_bitfield,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_CALL16",
+ FALSE,
+ 0xffff0000,
+ 0xffff0000,
+ FALSE),
+
+ HOWTO (R_NIOS2_GOTOFF_LO,
+ 0,
+ 2,
+ 16,
+ FALSE,
+ 16,
+ complain_overflow_dont,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_GOTOFF_LO",
+ FALSE,
+ 0xffff0000,
+ 0xffff0000,
+ FALSE),
+
+ HOWTO (R_NIOS2_GOTOFF_HA,
+ 0,
+ 2,
+ 16,
+ FALSE,
+ 16,
+ complain_overflow_dont,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_GOTOFF_HA",
+ FALSE,
+ 0xffff0000,
+ 0xffff0000,
+ FALSE),
+
+ HOWTO (R_NIOS2_PCREL_LO,
+ 0,
+ 2,
+ 16,
+ TRUE,
+ 16,
+ complain_overflow_dont,
+ nios2_elf32_pcrel_lo16_relocate,
+ "R_NIOS2_PCREL_LO",
+ FALSE,
+ 0xffff0000,
+ 0xffff0000,
+ TRUE),
+
+ HOWTO (R_NIOS2_PCREL_HA,
+ 0,
+ 2,
+ 16,
+ FALSE, /* This is a PC-relative relocation, but we need to subtract
+ PC ourselves before the HIADJ. */
+ 16,
+ complain_overflow_dont,
+ nios2_elf32_pcrel_hiadj16_relocate,
+ "R_NIOS2_PCREL_HA",
+ FALSE,
+ 0xffff0000,
+ 0xffff0000,
+ TRUE),
+
+ HOWTO (R_NIOS2_TLS_GD16,
+ 0,
+ 2,
+ 16,
+ FALSE,
+ 16,
+ complain_overflow_bitfield,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_TLS_GD16",
+ FALSE,
+ 0xffff0000,
+ 0xffff0000,
+ FALSE),
+
+ HOWTO (R_NIOS2_TLS_LDM16,
+ 0,
+ 2,
+ 16,
+ FALSE,
+ 16,
+ complain_overflow_bitfield,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_TLS_LDM16",
+ FALSE,
+ 0xffff0000,
+ 0xffff0000,
+ FALSE),
+
+ HOWTO (R_NIOS2_TLS_LDO16,
+ 0,
+ 2,
+ 16,
+ FALSE,
+ 16,
+ complain_overflow_bitfield,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_TLS_LDO16",
+ FALSE,
+ 0xffff0000,
+ 0xffff0000,
+ FALSE),
+
+ HOWTO (R_NIOS2_TLS_IE16,
+ 0,
+ 2,
+ 16,
+ FALSE,
+ 16,
+ complain_overflow_bitfield,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_TLS_IE16",
+ FALSE,
+ 0xffff0000,
+ 0xffff0000,
+ FALSE),
+
+ HOWTO (R_NIOS2_TLS_LE16,
+ 0,
+ 2,
+ 16,
+ FALSE,
+ 16,
+ complain_overflow_bitfield,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_TLS_LE16",
+ FALSE,
+ 0xffff0000,
+ 0xffff0000,
+ FALSE),
+
+ HOWTO (R_NIOS2_TLS_DTPMOD,
+ 0,
+ 2,
+ 32,
+ FALSE,
+ 0,
+ complain_overflow_dont,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_TLS_DTPMOD",
+ FALSE,
+ 0xffffffff,
+ 0xffffffff,
+ FALSE),
+
+ HOWTO (R_NIOS2_TLS_DTPREL,
+ 0,
+ 2,
+ 32,
+ FALSE,
+ 0,
+ complain_overflow_dont,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_TLS_DTPREL",
+ FALSE,
+ 0xffffffff,
+ 0xffffffff,
+ FALSE),
+
+ HOWTO (R_NIOS2_TLS_TPREL,
+ 0,
+ 2,
+ 32,
+ FALSE,
+ 0,
+ complain_overflow_dont,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_TLS_TPREL",
+ FALSE,
+ 0xffffffff,
+ 0xffffffff,
+ FALSE),
+
+ HOWTO (R_NIOS2_COPY,
+ 0,
+ 2,
+ 32,
+ FALSE,
+ 0,
+ complain_overflow_dont,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_COPY",
+ FALSE,
+ 0,
+ 0,
+ FALSE),
+
+ HOWTO (R_NIOS2_GLOB_DAT,
+ 0,
+ 2,
+ 32,
+ FALSE,
+ 0,
+ complain_overflow_dont,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_GLOB_DAT",
+ FALSE,
+ 0xffffffff,
+ 0xffffffff,
+ FALSE),
+
+ HOWTO (R_NIOS2_JUMP_SLOT,
+ 0,
+ 2,
+ 32,
+ FALSE,
+ 0,
+ complain_overflow_dont,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_JUMP_SLOT",
+ FALSE,
+ 0xffffffff,
+ 0xffffffff,
+ FALSE),
+
+ HOWTO (R_NIOS2_RELATIVE,
+ 0,
+ 2,
+ 32,
+ FALSE,
+ 0,
+ complain_overflow_dont,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_RELATIVE",
+ FALSE,
+ 0xffffffff,
+ 0xffffffff,
+ FALSE),
+
+ HOWTO (R_NIOS2_GOTOFF,
+ 0,
+ 2,
+ 32,
+ FALSE,
+ 0,
+ complain_overflow_dont,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_GOTOFF",
+ FALSE,
+ 0xffffffff,
+ 0xffffffff,
+ FALSE),
+
+ HOWTO (R_NIOS2_CALL26_NOAT, /* type */
+ 2, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 26, /* bitsize */
+ FALSE, /* pc_relative */
+ 6, /* bitpos */
+ complain_overflow_dont, /* complain on overflow */
+ nios2_elf32_call26_relocate, /* special function */
+ "R_NIOS2_CALL26_NOAT", /* name */
+ FALSE, /* partial_inplace */
+ 0xffffffc0, /* src_mask */
+ 0xffffffc0, /* dst_mask */
+ FALSE), /* pcrel_offset */
+
+ HOWTO (R_NIOS2_GOT_LO,
+ 0,
+ 2,
+ 16,
+ FALSE,
+ 16,
+ complain_overflow_dont,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_GOT_LO",
+ FALSE,
+ 0xffff0000,
+ 0xffff0000,
+ FALSE),
+
+ HOWTO (R_NIOS2_GOT_HA,
+ 0,
+ 2,
+ 16,
+ FALSE,
+ 16,
+ complain_overflow_dont,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_GOT_HA",
+ FALSE,
+ 0xffff0000,
+ 0xffff0000,
+ FALSE),
+
+ HOWTO (R_NIOS2_CALL_LO,
+ 0,
+ 2,
+ 16,
+ FALSE,
+ 16,
+ complain_overflow_dont,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_CALL_LO",
+ FALSE,
+ 0xffff0000,
+ 0xffff0000,
+ FALSE),
+
+ HOWTO (R_NIOS2_CALL_HA,
+ 0,
+ 2,
+ 16,
+ FALSE,
+ 16,
+ complain_overflow_dont,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_CALL_HA",
+ FALSE,
+ 0xffff0000,
+ 0xffff0000,
+ FALSE),
+
+ HOWTO (R_NIOS2_R2_S12,
+ 0,
+ 2,
+ 12,
+ FALSE,
+ 16,
+ complain_overflow_signed,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_R2_S12",
+ FALSE,
+ 0x0fff0000,
+ 0x0fff0000,
+ FALSE),
+
+ HOWTO (R_NIOS2_R2_I10_1_PCREL,
+ 1,
+ 1,
+ 10,
+ TRUE,
+ 6,
+ complain_overflow_signed,
+ bfd_elf_generic_reloc, /* FIXME? */
+ "R_NIOS2_R2_I10_1_PCREL",
+ FALSE,
+ 0xffc0,
+ 0xffc0,
+ TRUE),
+
+ HOWTO (R_NIOS2_R2_T1I7_1_PCREL,
+ 1,
+ 1,
+ 7,
+ TRUE,
+ 9,
+ complain_overflow_signed,
+ bfd_elf_generic_reloc, /* FIXME? */
+ "R_NIOS2_R2_T1I7_1_PCREL",
+ FALSE,
+ 0xfe00,
+ 0xfe00,
+ TRUE),
+
+ HOWTO (R_NIOS2_R2_T1I7_2,
+ 2,
+ 1,
+ 7,
+ FALSE,
+ 9,
+ complain_overflow_unsigned,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_R2_T1I7_2",
+ FALSE,
+ 0xfe00,
+ 0xfe00,
+ FALSE),
+
+ HOWTO (R_NIOS2_R2_T2I4,
+ 0,
+ 1,
+ 4,
+ FALSE,
+ 12,
+ complain_overflow_unsigned,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_R2_T2I4",
+ FALSE,
+ 0xf000,
+ 0xf000,
+ FALSE),
+
+ HOWTO (R_NIOS2_R2_T2I4_1,
+ 1,
+ 1,
+ 4,
+ FALSE,
+ 12,
+ complain_overflow_unsigned,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_R2_T2I4_1",
+ FALSE,
+ 0xf000,
+ 0xf000,
+ FALSE),
+
+ HOWTO (R_NIOS2_R2_T2I4_2,
+ 2,
+ 1,
+ 4,
+ FALSE,
+ 12,
+ complain_overflow_unsigned,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_R2_T2I4_2",
+ FALSE,
+ 0xf000,
+ 0xf000,
+ FALSE),
+
+ HOWTO (R_NIOS2_R2_X1I7_2,
+ 2,
+ 1,
+ 7,
+ FALSE,
+ 6,
+ complain_overflow_unsigned,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_R2_X1I7_2",
+ FALSE,
+ 0x1fc0,
+ 0x1fc0,
+ FALSE),
+
+ HOWTO (R_NIOS2_R2_X2L5,
+ 0,
+ 1,
+ 5,
+ FALSE,
+ 6,
+ complain_overflow_unsigned,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_R2_X2L5",
+ FALSE,
+ 0x07c0,
+ 0x07c0,
+ FALSE),
+
+ HOWTO (R_NIOS2_R2_F1I5_2,
+ 2,
+ 1,
+ 5,
+ FALSE,
+ 6,
+ complain_overflow_unsigned,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_R2_F1L5_2",
+ FALSE,
+ 0x07c0,
+ 0x07c0,
+ FALSE),
+
+ HOWTO (R_NIOS2_R2_L5I4X1,
+ 2,
+ 1,
+ 4,
+ FALSE,
+ 6,
+ complain_overflow_unsigned,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_R2_L5I4X1",
+ FALSE,
+ 0x03c0,
+ 0x03c0,
+ FALSE),
+
+ HOWTO (R_NIOS2_R2_T1X1I6,
+ 0,
+ 1,
+ 6,
+ FALSE,
+ 9,
+ complain_overflow_unsigned,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_R2_T1X1I6",
+ FALSE,
+ 0x7e00,
+ 0x7e00,
+ FALSE),
+
+ HOWTO (R_NIOS2_R2_T1X1I6_2,
+ 2,
+ 2,
+ 6,
+ FALSE,
+ 9,
+ complain_overflow_unsigned,
+ bfd_elf_generic_reloc,
+ "R_NIOS2_R2_T1I1X6_2",
+ FALSE,
+ 0x7e00,
+ 0x7e00,
+ FALSE),
+
+/* Add other relocations here. */
+};
+
+static unsigned char elf_code_to_howto_index[R_NIOS2_ILLEGAL + 1];
+
+
+/* Return true if producing output for a R2 BFD. */
+#define BFD_IS_R2(abfd) (bfd_get_mach (abfd) == bfd_mach_nios2r2)
+
+/* Return the howto for relocation RTYPE. */
+static reloc_howto_type *
+lookup_howto (unsigned int rtype, bfd *abfd)
+{
+ static int initialized = 0;
+ int i;
+ /* R2 relocations are a superset of R1, so use that for the lookup
+ table. */
+ int r1_howto_tbl_size = (int) ARRAY_SIZE (elf_nios2_r1_howto_table_rel);
+ int r2_howto_tbl_size = (int) ARRAY_SIZE (elf_nios2_r2_howto_table_rel);
+
+ if (!initialized)
+ {
+ initialized = 1;
+ memset (elf_code_to_howto_index, 0xff,
+ sizeof (elf_code_to_howto_index));
+ for (i = 0; i < r2_howto_tbl_size; i++)
+ {
+ elf_code_to_howto_index[elf_nios2_r2_howto_table_rel[i].type] = i;
+ if (i < r1_howto_tbl_size)
+ BFD_ASSERT (elf_nios2_r2_howto_table_rel[i].type
+ == elf_nios2_r1_howto_table_rel[i].type);
+ }
+ }
+
+ if (rtype > R_NIOS2_ILLEGAL)
+ return NULL;
+ i = elf_code_to_howto_index[rtype];
+ if (BFD_IS_R2 (abfd))
+ {
+ if (i >= r2_howto_tbl_size)
+ return NULL;
+ return elf_nios2_r2_howto_table_rel + i;
+ }
+ else
+ {
+ if (i >= r1_howto_tbl_size)
+ return NULL;
+ return elf_nios2_r1_howto_table_rel + i;
+ }
+}
+
+/* Map for converting BFD reloc types to Nios II reloc types. */
+struct elf_reloc_map
+{
+ bfd_reloc_code_real_type bfd_val;
+ enum elf_nios2_reloc_type elf_val;
+};
+
+static const struct elf_reloc_map nios2_reloc_map[] =
+{
+ {BFD_RELOC_NONE, R_NIOS2_NONE},
+ {BFD_RELOC_NIOS2_S16, R_NIOS2_S16},
+ {BFD_RELOC_NIOS2_U16, R_NIOS2_U16},
+ {BFD_RELOC_16_PCREL, R_NIOS2_PCREL16},
+ {BFD_RELOC_NIOS2_CALL26, R_NIOS2_CALL26},
+ {BFD_RELOC_NIOS2_IMM5, R_NIOS2_IMM5},
+ {BFD_RELOC_NIOS2_CACHE_OPX, R_NIOS2_CACHE_OPX},
+ {BFD_RELOC_NIOS2_IMM6, R_NIOS2_IMM6},
+ {BFD_RELOC_NIOS2_IMM8, R_NIOS2_IMM8},
+ {BFD_RELOC_NIOS2_HI16, R_NIOS2_HI16},
+ {BFD_RELOC_NIOS2_LO16, R_NIOS2_LO16},
+ {BFD_RELOC_NIOS2_HIADJ16, R_NIOS2_HIADJ16},
+ {BFD_RELOC_32, R_NIOS2_BFD_RELOC_32},
+ {BFD_RELOC_16, R_NIOS2_BFD_RELOC_16},
+ {BFD_RELOC_8, R_NIOS2_BFD_RELOC_8},
+ {BFD_RELOC_NIOS2_GPREL, R_NIOS2_GPREL},
+ {BFD_RELOC_VTABLE_INHERIT, R_NIOS2_GNU_VTINHERIT},
+ {BFD_RELOC_VTABLE_ENTRY, R_NIOS2_GNU_VTENTRY},
+ {BFD_RELOC_NIOS2_UJMP, R_NIOS2_UJMP},
+ {BFD_RELOC_NIOS2_CJMP, R_NIOS2_CJMP},
+ {BFD_RELOC_NIOS2_CALLR, R_NIOS2_CALLR},
+ {BFD_RELOC_NIOS2_ALIGN, R_NIOS2_ALIGN},
+ {BFD_RELOC_NIOS2_GOT16, R_NIOS2_GOT16},
+ {BFD_RELOC_NIOS2_CALL16, R_NIOS2_CALL16},
+ {BFD_RELOC_NIOS2_GOTOFF_LO, R_NIOS2_GOTOFF_LO},
+ {BFD_RELOC_NIOS2_GOTOFF_HA, R_NIOS2_GOTOFF_HA},
+ {BFD_RELOC_NIOS2_PCREL_LO, R_NIOS2_PCREL_LO},
+ {BFD_RELOC_NIOS2_PCREL_HA, R_NIOS2_PCREL_HA},
+ {BFD_RELOC_NIOS2_TLS_GD16, R_NIOS2_TLS_GD16},
+ {BFD_RELOC_NIOS2_TLS_LDM16, R_NIOS2_TLS_LDM16},
+ {BFD_RELOC_NIOS2_TLS_LDO16, R_NIOS2_TLS_LDO16},
+ {BFD_RELOC_NIOS2_TLS_IE16, R_NIOS2_TLS_IE16},
+ {BFD_RELOC_NIOS2_TLS_LE16, R_NIOS2_TLS_LE16},
+ {BFD_RELOC_NIOS2_TLS_DTPMOD, R_NIOS2_TLS_DTPMOD},
+ {BFD_RELOC_NIOS2_TLS_DTPREL, R_NIOS2_TLS_DTPREL},
+ {BFD_RELOC_NIOS2_TLS_TPREL, R_NIOS2_TLS_TPREL},
+ {BFD_RELOC_NIOS2_COPY, R_NIOS2_COPY},
+ {BFD_RELOC_NIOS2_GLOB_DAT, R_NIOS2_GLOB_DAT},
+ {BFD_RELOC_NIOS2_JUMP_SLOT, R_NIOS2_JUMP_SLOT},
+ {BFD_RELOC_NIOS2_RELATIVE, R_NIOS2_RELATIVE},
+ {BFD_RELOC_NIOS2_GOTOFF, R_NIOS2_GOTOFF},
+ {BFD_RELOC_NIOS2_CALL26_NOAT, R_NIOS2_CALL26_NOAT},
+ {BFD_RELOC_NIOS2_GOT_LO, R_NIOS2_GOT_LO},
+ {BFD_RELOC_NIOS2_GOT_HA, R_NIOS2_GOT_HA},
+ {BFD_RELOC_NIOS2_CALL_LO, R_NIOS2_CALL_LO},
+ {BFD_RELOC_NIOS2_CALL_HA, R_NIOS2_CALL_HA},
+ {BFD_RELOC_NIOS2_R2_S12, R_NIOS2_R2_S12},
+ {BFD_RELOC_NIOS2_R2_I10_1_PCREL, R_NIOS2_R2_I10_1_PCREL},
+ {BFD_RELOC_NIOS2_R2_T1I7_1_PCREL, R_NIOS2_R2_T1I7_1_PCREL},
+ {BFD_RELOC_NIOS2_R2_T1I7_2, R_NIOS2_R2_T1I7_2},
+ {BFD_RELOC_NIOS2_R2_T2I4, R_NIOS2_R2_T2I4},
+ {BFD_RELOC_NIOS2_R2_T2I4_1, R_NIOS2_R2_T2I4_1},
+ {BFD_RELOC_NIOS2_R2_T2I4_2, R_NIOS2_R2_T2I4_2},
+ {BFD_RELOC_NIOS2_R2_X1I7_2, R_NIOS2_R2_X1I7_2},
+ {BFD_RELOC_NIOS2_R2_X2L5, R_NIOS2_R2_X2L5},
+ {BFD_RELOC_NIOS2_R2_F1I5_2, R_NIOS2_R2_F1I5_2},
+ {BFD_RELOC_NIOS2_R2_L5I4X1, R_NIOS2_R2_L5I4X1},
+ {BFD_RELOC_NIOS2_R2_T1X1I6, R_NIOS2_R2_T1X1I6},
+ {BFD_RELOC_NIOS2_R2_T1X1I6_2, R_NIOS2_R2_T1X1I6_2},
+};
+
+enum elf32_nios2_stub_type
+{
+ nios2_stub_call26_before,
+ nios2_stub_call26_after,
+ nios2_stub_none
+};
+
+struct elf32_nios2_stub_hash_entry
+{
+ /* Base hash table entry structure. */
+ struct bfd_hash_entry bh_root;
+
+ /* The stub section. */
+ asection *stub_sec;
+
+ /* Offset within stub_sec of the beginning of this stub. */
+ bfd_vma stub_offset;
+
+ /* Given the symbol's value and its section we can determine its final
+ value when building the stubs (so the stub knows where to jump. */
+ bfd_vma target_value;
+ asection *target_section;
+
+ enum elf32_nios2_stub_type stub_type;
+
+ /* The symbol table entry, if any, that this was derived from. */
+ struct elf32_nios2_link_hash_entry *hh;
+
+ /* And the reloc addend that this was derived from. */
+ bfd_vma addend;
+
+ /* Where this stub is being called from, or, in the case of combined
+ stub sections, the first input section in the group. */
+ asection *id_sec;
+};
+
+#define nios2_stub_hash_entry(ent) \
+ ((struct elf32_nios2_stub_hash_entry *)(ent))
+
+#define nios2_stub_hash_lookup(table, string, create, copy) \
+ ((struct elf32_nios2_stub_hash_entry *) \
+ bfd_hash_lookup ((table), (string), (create), (copy)))
+
+
+/* Nios II ELF linker hash entry. */
+
+struct elf32_nios2_link_hash_entry
+{
+ struct elf_link_hash_entry root;
+
+ /* A pointer to the most recently used stub hash entry against this
+ symbol. */
+ struct elf32_nios2_stub_hash_entry *hsh_cache;
+
+ /* Track dynamic relocs copied for this symbol. */
+ struct elf_dyn_relocs *dyn_relocs;
+
+#define GOT_UNKNOWN 0
+#define GOT_NORMAL 1
+#define GOT_TLS_GD 2
+#define GOT_TLS_IE 4
+ unsigned char tls_type;
+
+ /* We need to detect and take special action for symbols which are only
+ referenced with %call() and not with %got(). Such symbols do not need
+ a dynamic GOT reloc in shared objects, only a dynamic PLT reloc. Lazy
+ linking will not work if the dynamic GOT reloc exists.
+ To check for this condition efficiently, we compare got_types_used against
+ CALL_USED, meaning
+ (got_types_used & (GOT_USED | CALL_USED)) == CALL_USED.
+ */
+#define GOT_USED 1
+#define CALL_USED 2
+ unsigned char got_types_used;
+};
+
+#define elf32_nios2_hash_entry(ent) \
+ ((struct elf32_nios2_link_hash_entry *) (ent))
+
+/* Get the Nios II elf linker hash table from a link_info structure. */
+#define elf32_nios2_hash_table(info) \
+ ((struct elf32_nios2_link_hash_table *) ((info)->hash))