Home | History | Annotate | Line # | Download | only in bfd
elf64-mips.c revision 1.1.1.4
      1 /* MIPS-specific support for 64-bit ELF
      2    Copyright (C) 1996-2018 Free Software Foundation, Inc.
      3    Ian Lance Taylor, Cygnus Support
      4    Linker support added by Mark Mitchell, CodeSourcery, LLC.
      5    <mark (at) codesourcery.com>
      6 
      7    This file is part of BFD, the Binary File Descriptor library.
      8 
      9    This program is free software; you can redistribute it and/or modify
     10    it under the terms of the GNU General Public License as published by
     11    the Free Software Foundation; either version 3 of the License, or
     12    (at your option) any later version.
     13 
     14    This program is distributed in the hope that it will be useful,
     15    but WITHOUT ANY WARRANTY; without even the implied warranty of
     16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     17    GNU General Public License for more details.
     18 
     19    You should have received a copy of the GNU General Public License
     20    along with this program; if not, write to the Free Software
     21    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
     22    MA 02110-1301, USA.  */
     23 
     24 
     25 /* This file supports the 64-bit MIPS ELF ABI.
     26 
     27    The MIPS 64-bit ELF ABI uses an unusual reloc format.  This file
     28    overrides the usual ELF reloc handling, and handles reading and
     29    writing the relocations here.  */
     30 
     31 /* TODO: Many things are unsupported, even if there is some code for it
     32  .       (which was mostly stolen from elf32-mips.c and slightly adapted).
     33  .
     34  .   - Relocation handling for REL relocs is wrong in many cases and
     35  .     generally untested.
     36  .   - Relocation handling for RELA relocs related to GOT support are
     37  .     also likely to be wrong.
     38  .   - Support for MIPS16 is untested.
     39  .   - Combined relocs with RSS_* entries are unsupported.
     40  .   - The whole GOT handling for NewABI is missing, some parts of
     41  .     the OldABI version is still lying around and should be removed.
     42  */
     43 
     44 #include "sysdep.h"
     45 #include "bfd.h"
     46 #include "libbfd.h"
     47 #include "aout/ar.h"
     48 #include "bfdlink.h"
     49 #include "genlink.h"
     50 #include "elf-bfd.h"
     51 #include "elfxx-mips.h"
     52 #include "elf/mips.h"
     53 
     54 /* Get the ECOFF swapping routines.  The 64-bit ABI is not supposed to
     55    use ECOFF.  However, we support it anyhow for an easier changeover.  */
     56 #include "coff/sym.h"
     57 #include "coff/symconst.h"
     58 #include "coff/internal.h"
     59 #include "coff/ecoff.h"
     60 /* The 64 bit versions of the mdebug data structures are in alpha.h.  */
     61 #include "coff/alpha.h"
     62 #define ECOFF_SIGNED_64
     63 #include "ecoffswap.h"
     64 
     65 static void mips_elf64_swap_reloc_in
     66   (bfd *, const Elf64_Mips_External_Rel *, Elf64_Mips_Internal_Rela *);
     67 static void mips_elf64_swap_reloca_in
     68   (bfd *, const Elf64_Mips_External_Rela *, Elf64_Mips_Internal_Rela *);
     69 static void mips_elf64_swap_reloc_out
     70   (bfd *, const Elf64_Mips_Internal_Rela *, Elf64_Mips_External_Rel *);
     71 static void mips_elf64_swap_reloca_out
     72   (bfd *, const Elf64_Mips_Internal_Rela *, Elf64_Mips_External_Rela *);
     73 static void mips_elf64_be_swap_reloc_in
     74   (bfd *, const bfd_byte *, Elf_Internal_Rela *);
     75 static void mips_elf64_be_swap_reloc_out
     76   (bfd *, const Elf_Internal_Rela *, bfd_byte *);
     77 static void mips_elf64_be_swap_reloca_in
     78   (bfd *, const bfd_byte *, Elf_Internal_Rela *);
     79 static void mips_elf64_be_swap_reloca_out
     80   (bfd *, const Elf_Internal_Rela *, bfd_byte *);
     81 static reloc_howto_type *bfd_elf64_bfd_reloc_type_lookup
     82   (bfd *, bfd_reloc_code_real_type);
     83 static bfd_boolean mips_elf64_info_to_howto_rela
     84   (bfd *, arelent *, Elf_Internal_Rela *);
     85 static long mips_elf64_get_dynamic_reloc_upper_bound
     86   (bfd *);
     87 static bfd_boolean mips_elf64_slurp_one_reloc_table
     88   (bfd *, asection *, Elf_Internal_Shdr *, bfd_size_type, arelent *,
     89    asymbol **, bfd_boolean);
     90 static bfd_boolean mips_elf64_slurp_reloc_table
     91   (bfd *, asection *, asymbol **, bfd_boolean);
     92 static void mips_elf64_write_relocs
     93   (bfd *, asection *, void *);
     94 static void mips_elf64_write_rel
     95   (bfd *, asection *, Elf_Internal_Shdr *, int *, void *);
     96 static void mips_elf64_write_rela
     97   (bfd *, asection *, Elf_Internal_Shdr *, int *, void *);
     98 static bfd_reloc_status_type mips_elf64_gprel16_reloc
     99   (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
    100 static bfd_reloc_status_type mips_elf64_literal_reloc
    101   (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
    102 static bfd_reloc_status_type mips_elf64_gprel32_reloc
    103   (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
    104 static bfd_reloc_status_type mips_elf64_shift6_reloc
    105   (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
    106 static bfd_reloc_status_type mips16_gprel_reloc
    107   (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
    108 static bfd_boolean mips_elf64_assign_gp
    109   (bfd *, bfd_vma *);
    110 static bfd_reloc_status_type mips_elf64_final_gp
    111   (bfd *, asymbol *, bfd_boolean, char **, bfd_vma *);
    112 static bfd_boolean mips_elf64_object_p
    113   (bfd *);
    114 static bfd_boolean mips_elf64_is_local_label_name
    115   (bfd *, const char *);
    116 static irix_compat_t elf64_mips_irix_compat
    117   (bfd *);
    118 static bfd_boolean elf64_mips_grok_prstatus
    119   (bfd *, Elf_Internal_Note *);
    120 static bfd_boolean elf64_mips_grok_psinfo
    121   (bfd *, Elf_Internal_Note *);
    122 
    123 extern const bfd_target mips_elf64_be_vec;
    124 extern const bfd_target mips_elf64_le_vec;
    125 
    126 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
    127    from smaller values.  Start with zero, widen, *then* decrement.  */
    128 #define MINUS_ONE	(((bfd_vma)0) - 1)
    129 
    130 /* The number of local .got entries we reserve.  */
    131 #define MIPS_RESERVED_GOTNO (2)
    132 
    133 /* The relocation table used for SHT_REL sections.  */
    135 
    136 static reloc_howto_type mips_elf64_howto_table_rel[] =
    137 {
    138   /* No relocation.  */
    139   HOWTO (R_MIPS_NONE,		/* type */
    140 	 0,			/* rightshift */
    141 	 3,			/* size (0 = byte, 1 = short, 2 = long) */
    142 	 0,			/* bitsize */
    143 	 FALSE,			/* pc_relative */
    144 	 0,			/* bitpos */
    145 	 complain_overflow_dont, /* complain_on_overflow */
    146 	 _bfd_mips_elf_generic_reloc,	/* special_function */
    147 	 "R_MIPS_NONE",		/* name */
    148 	 FALSE,			/* partial_inplace */
    149 	 0,			/* src_mask */
    150 	 0,			/* dst_mask */
    151 	 FALSE),		/* pcrel_offset */
    152 
    153   /* 16 bit relocation.  */
    154   HOWTO (R_MIPS_16,		/* type */
    155 	 0,			/* rightshift */
    156 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    157 	 16,			/* bitsize */
    158 	 FALSE,			/* pc_relative */
    159 	 0,			/* bitpos */
    160 	 complain_overflow_signed, /* complain_on_overflow */
    161 	 _bfd_mips_elf_generic_reloc,	/* special_function */
    162 	 "R_MIPS_16",		/* name */
    163 	 TRUE,			/* partial_inplace */
    164 	 0x0000ffff,		/* src_mask */
    165 	 0x0000ffff,		/* dst_mask */
    166 	 FALSE),		/* pcrel_offset */
    167 
    168   /* 32 bit relocation.  */
    169   HOWTO (R_MIPS_32,		/* type */
    170 	 0,			/* rightshift */
    171 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    172 	 32,			/* bitsize */
    173 	 FALSE,			/* pc_relative */
    174 	 0,			/* bitpos */
    175 	 complain_overflow_dont, /* complain_on_overflow */
    176 	 _bfd_mips_elf_generic_reloc,	/* special_function */
    177 	 "R_MIPS_32",		/* name */
    178 	 TRUE,			/* partial_inplace */
    179 	 0xffffffff,		/* src_mask */
    180 	 0xffffffff,		/* dst_mask */
    181 	 FALSE),		/* pcrel_offset */
    182 
    183   /* 32 bit symbol relative relocation.  */
    184   HOWTO (R_MIPS_REL32,		/* type */
    185 	 0,			/* rightshift */
    186 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    187 	 32,			/* bitsize */
    188 	 FALSE,			/* pc_relative */
    189 	 0,			/* bitpos */
    190 	 complain_overflow_dont, /* complain_on_overflow */
    191 	 _bfd_mips_elf_generic_reloc,	/* special_function */
    192 	 "R_MIPS_REL32",	/* name */
    193 	 TRUE,			/* partial_inplace */
    194 	 0xffffffff,		/* src_mask */
    195 	 0xffffffff,		/* dst_mask */
    196 	 FALSE),		/* pcrel_offset */
    197 
    198   /* 26 bit jump address.  */
    199   HOWTO (R_MIPS_26,		/* type */
    200 	 2,			/* rightshift */
    201 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    202 	 26,			/* bitsize */
    203 	 FALSE,			/* pc_relative */
    204 	 0,			/* bitpos */
    205 	 complain_overflow_dont, /* complain_on_overflow */
    206 				/* This needs complex overflow
    207 				   detection, because the upper 36
    208 				   bits must match the PC + 4.  */
    209 	 _bfd_mips_elf_generic_reloc,	/* special_function */
    210 	 "R_MIPS_26",		/* name */
    211 	 TRUE,			/* partial_inplace */
    212 	 0x03ffffff,		/* src_mask */
    213 	 0x03ffffff,		/* dst_mask */
    214 	 FALSE),		/* pcrel_offset */
    215 
    216   /* R_MIPS_HI16 and R_MIPS_LO16 are unsupported for NewABI REL.
    217      However, the native IRIX6 tools use them, so we try our best. */
    218 
    219   /* High 16 bits of symbol value.  */
    220   HOWTO (R_MIPS_HI16,		/* type */
    221 	 16,			/* rightshift */
    222 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    223 	 16,			/* bitsize */
    224 	 FALSE,			/* pc_relative */
    225 	 0,			/* bitpos */
    226 	 complain_overflow_dont, /* complain_on_overflow */
    227 	 _bfd_mips_elf_hi16_reloc, /* special_function */
    228 	 "R_MIPS_HI16",		/* name */
    229 	 TRUE,			/* partial_inplace */
    230 	 0x0000ffff,		/* src_mask */
    231 	 0x0000ffff,		/* dst_mask */
    232 	 FALSE),		/* pcrel_offset */
    233 
    234   /* Low 16 bits of symbol value.  */
    235   HOWTO (R_MIPS_LO16,		/* type */
    236 	 0,			/* rightshift */
    237 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    238 	 16,			/* bitsize */
    239 	 FALSE,			/* pc_relative */
    240 	 0,			/* bitpos */
    241 	 complain_overflow_dont, /* complain_on_overflow */
    242 	 _bfd_mips_elf_lo16_reloc, /* special_function */
    243 	 "R_MIPS_LO16",		/* name */
    244 	 TRUE,			/* partial_inplace */
    245 	 0x0000ffff,		/* src_mask */
    246 	 0x0000ffff,		/* dst_mask */
    247 	 FALSE),		/* pcrel_offset */
    248 
    249   /* GP relative reference.  */
    250   HOWTO (R_MIPS_GPREL16,	/* type */
    251 	 0,			/* rightshift */
    252 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    253 	 16,			/* bitsize */
    254 	 FALSE,			/* pc_relative */
    255 	 0,			/* bitpos */
    256 	 complain_overflow_signed, /* complain_on_overflow */
    257 	 mips_elf64_gprel16_reloc, /* special_function */
    258 	 "R_MIPS_GPREL16",	/* name */
    259 	 TRUE,			/* partial_inplace */
    260 	 0x0000ffff,		/* src_mask */
    261 	 0x0000ffff,		/* dst_mask */
    262 	 FALSE),		/* pcrel_offset */
    263 
    264   /* Reference to literal section.  */
    265   HOWTO (R_MIPS_LITERAL,	/* type */
    266 	 0,			/* rightshift */
    267 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    268 	 16,			/* bitsize */
    269 	 FALSE,			/* pc_relative */
    270 	 0,			/* bitpos */
    271 	 complain_overflow_signed, /* complain_on_overflow */
    272 	 mips_elf64_literal_reloc, /* special_function */
    273 	 "R_MIPS_LITERAL",	/* name */
    274 	 TRUE,			/* partial_inplace */
    275 	 0x0000ffff,		/* src_mask */
    276 	 0x0000ffff,		/* dst_mask */
    277 	 FALSE),		/* pcrel_offset */
    278 
    279   /* Reference to global offset table.  */
    280   HOWTO (R_MIPS_GOT16,		/* type */
    281 	 0,			/* rightshift */
    282 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    283 	 16,			/* bitsize */
    284 	 FALSE,			/* pc_relative */
    285 	 0,			/* bitpos */
    286 	 complain_overflow_signed, /* complain_on_overflow */
    287 	 _bfd_mips_elf_got16_reloc, /* special_function */
    288 	 "R_MIPS_GOT16",	/* name */
    289 	 TRUE,			/* partial_inplace */
    290 	 0x0000ffff,		/* src_mask */
    291 	 0x0000ffff,		/* dst_mask */
    292 	 FALSE),		/* pcrel_offset */
    293 
    294   /* 16 bit PC relative reference.  Note that the ABI document has a typo
    295      and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
    296      We do the right thing here.  */
    297   HOWTO (R_MIPS_PC16,		/* type */
    298 	 2,			/* rightshift */
    299 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    300 	 16,			/* bitsize */
    301 	 TRUE,			/* pc_relative */
    302 	 0,			/* bitpos */
    303 	 complain_overflow_signed, /* complain_on_overflow */
    304 	 _bfd_mips_elf_generic_reloc,	/* special_function */
    305 	 "R_MIPS_PC16",		/* name */
    306 	 TRUE,			/* partial_inplace */
    307 	 0x0000ffff,		/* src_mask */
    308 	 0x0000ffff,		/* dst_mask */
    309 	 TRUE),			/* pcrel_offset */
    310 
    311   /* 16 bit call through global offset table.  */
    312   HOWTO (R_MIPS_CALL16,		/* type */
    313 	 0,			/* rightshift */
    314 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    315 	 16,			/* bitsize */
    316 	 FALSE,			/* pc_relative */
    317 	 0,			/* bitpos */
    318 	 complain_overflow_signed, /* complain_on_overflow */
    319 	 _bfd_mips_elf_generic_reloc,	/* special_function */
    320 	 "R_MIPS_CALL16",	/* name */
    321 	 TRUE,			/* partial_inplace */
    322 	 0x0000ffff,		/* src_mask */
    323 	 0x0000ffff,		/* dst_mask */
    324 	 FALSE),		/* pcrel_offset */
    325 
    326   /* 32 bit GP relative reference.  */
    327   HOWTO (R_MIPS_GPREL32,	/* type */
    328 	 0,			/* rightshift */
    329 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    330 	 32,			/* bitsize */
    331 	 FALSE,			/* pc_relative */
    332 	 0,			/* bitpos */
    333 	 complain_overflow_dont, /* complain_on_overflow */
    334 	 mips_elf64_gprel32_reloc, /* special_function */
    335 	 "R_MIPS_GPREL32",	/* name */
    336 	 TRUE,			/* partial_inplace */
    337 	 0xffffffff,		/* src_mask */
    338 	 0xffffffff,		/* dst_mask */
    339 	 FALSE),		/* pcrel_offset */
    340 
    341   EMPTY_HOWTO (13),
    342   EMPTY_HOWTO (14),
    343   EMPTY_HOWTO (15),
    344 
    345   /* A 5 bit shift field.  */
    346   HOWTO (R_MIPS_SHIFT5,		/* type */
    347 	 0,			/* rightshift */
    348 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    349 	 5,			/* bitsize */
    350 	 FALSE,			/* pc_relative */
    351 	 6,			/* bitpos */
    352 	 complain_overflow_bitfield, /* complain_on_overflow */
    353 	 _bfd_mips_elf_generic_reloc,	/* special_function */
    354 	 "R_MIPS_SHIFT5",	/* name */
    355 	 TRUE,			/* partial_inplace */
    356 	 0x000007c0,		/* src_mask */
    357 	 0x000007c0,		/* dst_mask */
    358 	 FALSE),		/* pcrel_offset */
    359 
    360   /* A 6 bit shift field.  */
    361   HOWTO (R_MIPS_SHIFT6,		/* type */
    362 	 0,			/* rightshift */
    363 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    364 	 6,			/* bitsize */
    365 	 FALSE,			/* pc_relative */
    366 	 6,			/* bitpos */
    367 	 complain_overflow_bitfield, /* complain_on_overflow */
    368 	 mips_elf64_shift6_reloc, /* special_function */
    369 	 "R_MIPS_SHIFT6",	/* name */
    370 	 TRUE,			/* partial_inplace */
    371 	 0x000007c4,		/* src_mask */
    372 	 0x000007c4,		/* dst_mask */
    373 	 FALSE),		/* pcrel_offset */
    374 
    375   /* 64 bit relocation.  */
    376   HOWTO (R_MIPS_64,		/* type */
    377 	 0,			/* rightshift */
    378 	 4,			/* size (0 = byte, 1 = short, 2 = long) */
    379 	 64,			/* bitsize */
    380 	 FALSE,			/* pc_relative */
    381 	 0,			/* bitpos */
    382 	 complain_overflow_dont, /* complain_on_overflow */
    383 	 _bfd_mips_elf_generic_reloc,	/* special_function */
    384 	 "R_MIPS_64",		/* name */
    385 	 TRUE,			/* partial_inplace */
    386 	 MINUS_ONE,		/* src_mask */
    387 	 MINUS_ONE,		/* dst_mask */
    388 	 FALSE),		/* pcrel_offset */
    389 
    390   /* Displacement in the global offset table.  */
    391   HOWTO (R_MIPS_GOT_DISP,	/* type */
    392 	 0,			/* rightshift */
    393 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    394 	 16,			/* bitsize */
    395 	 FALSE,			/* pc_relative */
    396 	 0,			/* bitpos */
    397 	 complain_overflow_signed, /* complain_on_overflow */
    398 	 _bfd_mips_elf_generic_reloc,	/* special_function */
    399 	 "R_MIPS_GOT_DISP",	/* name */
    400 	 TRUE,			/* partial_inplace */
    401 	 0x0000ffff,		/* src_mask */
    402 	 0x0000ffff,		/* dst_mask */
    403 	 FALSE),		/* pcrel_offset */
    404 
    405   /* Displacement to page pointer in the global offset table.  */
    406   HOWTO (R_MIPS_GOT_PAGE,	/* type */
    407 	 0,			/* rightshift */
    408 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    409 	 16,			/* bitsize */
    410 	 FALSE,			/* pc_relative */
    411 	 0,			/* bitpos */
    412 	 complain_overflow_signed, /* complain_on_overflow */
    413 	 _bfd_mips_elf_generic_reloc,	/* special_function */
    414 	 "R_MIPS_GOT_PAGE",	/* name */
    415 	 TRUE,			/* partial_inplace */
    416 	 0x0000ffff,		/* src_mask */
    417 	 0x0000ffff,		/* dst_mask */
    418 	 FALSE),		/* pcrel_offset */
    419 
    420   /* Offset from page pointer in the global offset table.  */
    421   HOWTO (R_MIPS_GOT_OFST,	/* type */
    422 	 0,			/* rightshift */
    423 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    424 	 16,			/* bitsize */
    425 	 FALSE,			/* pc_relative */
    426 	 0,			/* bitpos */
    427 	 complain_overflow_signed, /* complain_on_overflow */
    428 	 _bfd_mips_elf_generic_reloc,	/* special_function */
    429 	 "R_MIPS_GOT_OFST",	/* name */
    430 	 TRUE,			/* partial_inplace */
    431 	 0x0000ffff,		/* src_mask */
    432 	 0x0000ffff,		/* dst_mask */
    433 	 FALSE),		/* pcrel_offset */
    434 
    435   /* High 16 bits of displacement in global offset table.  */
    436   HOWTO (R_MIPS_GOT_HI16,	/* type */
    437 	 0,			/* rightshift */
    438 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    439 	 16,			/* bitsize */
    440 	 FALSE,			/* pc_relative */
    441 	 0,			/* bitpos */
    442 	 complain_overflow_dont, /* complain_on_overflow */
    443 	 _bfd_mips_elf_generic_reloc,	/* special_function */
    444 	 "R_MIPS_GOT_HI16",	/* name */
    445 	 TRUE,			/* partial_inplace */
    446 	 0x0000ffff,		/* src_mask */
    447 	 0x0000ffff,		/* dst_mask */
    448 	 FALSE),		/* pcrel_offset */
    449 
    450   /* Low 16 bits of displacement in global offset table.  */
    451   HOWTO (R_MIPS_GOT_LO16,	/* type */
    452 	 0,			/* rightshift */
    453 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    454 	 16,			/* bitsize */
    455 	 FALSE,			/* pc_relative */
    456 	 0,			/* bitpos */
    457 	 complain_overflow_dont, /* complain_on_overflow */
    458 	 _bfd_mips_elf_generic_reloc,	/* special_function */
    459 	 "R_MIPS_GOT_LO16",	/* name */
    460 	 TRUE,			/* partial_inplace */
    461 	 0x0000ffff,		/* src_mask */
    462 	 0x0000ffff,		/* dst_mask */
    463 	 FALSE),		/* pcrel_offset */
    464 
    465   /* 64 bit subtraction.  */
    466   HOWTO (R_MIPS_SUB,		/* type */
    467 	 0,			/* rightshift */
    468 	 4,			/* size (0 = byte, 1 = short, 2 = long) */
    469 	 64,			/* bitsize */
    470 	 FALSE,			/* pc_relative */
    471 	 0,			/* bitpos */
    472 	 complain_overflow_dont, /* complain_on_overflow */
    473 	 _bfd_mips_elf_generic_reloc,	/* special_function */
    474 	 "R_MIPS_SUB",		/* name */
    475 	 TRUE,			/* partial_inplace */
    476 	 MINUS_ONE,		/* src_mask */
    477 	 MINUS_ONE,		/* dst_mask */
    478 	 FALSE),		/* pcrel_offset */
    479 
    480   /* Insert the addend as an instruction.  */
    481   /* FIXME: Not handled correctly.  */
    482   HOWTO (R_MIPS_INSERT_A,	/* type */
    483 	 0,			/* rightshift */
    484 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    485 	 32,			/* bitsize */
    486 	 FALSE,			/* pc_relative */
    487 	 0,			/* bitpos */
    488 	 complain_overflow_dont, /* complain_on_overflow */
    489 	 _bfd_mips_elf_generic_reloc,	/* special_function */
    490 	 "R_MIPS_INSERT_A",	/* name */
    491 	 TRUE,			/* partial_inplace */
    492 	 0xffffffff,		/* src_mask */
    493 	 0xffffffff,		/* dst_mask */
    494 	 FALSE),		/* pcrel_offset */
    495 
    496   /* Insert the addend as an instruction, and change all relocations
    497      to refer to the old instruction at the address.  */
    498   /* FIXME: Not handled correctly.  */
    499   HOWTO (R_MIPS_INSERT_B,	/* type */
    500 	 0,			/* rightshift */
    501 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    502 	 32,			/* bitsize */
    503 	 FALSE,			/* pc_relative */
    504 	 0,			/* bitpos */
    505 	 complain_overflow_dont, /* complain_on_overflow */
    506 	 _bfd_mips_elf_generic_reloc,	/* special_function */
    507 	 "R_MIPS_INSERT_B",	/* name */
    508 	 TRUE,			/* partial_inplace */
    509 	 0xffffffff,		/* src_mask */
    510 	 0xffffffff,		/* dst_mask */
    511 	 FALSE),		/* pcrel_offset */
    512 
    513   /* Delete a 32 bit instruction.  */
    514   /* FIXME: Not handled correctly.  */
    515   HOWTO (R_MIPS_DELETE,		/* type */
    516 	 0,			/* rightshift */
    517 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    518 	 32,			/* bitsize */
    519 	 FALSE,			/* pc_relative */
    520 	 0,			/* bitpos */
    521 	 complain_overflow_dont, /* complain_on_overflow */
    522 	 _bfd_mips_elf_generic_reloc,	/* special_function */
    523 	 "R_MIPS_DELETE",	/* name */
    524 	 TRUE,			/* partial_inplace */
    525 	 0xffffffff,		/* src_mask */
    526 	 0xffffffff,		/* dst_mask */
    527 	 FALSE),		/* pcrel_offset */
    528 
    529   /* The MIPS ELF64 ABI Draft wants us to support these for REL relocations.
    530      We don't, because
    531        a) It means building the addend from a R_MIPS_HIGHEST/R_MIPS_HIGHER/
    532 	  R_MIPS_HI16/R_MIPS_LO16 sequence with varying ordering, using
    533 	  fallable heuristics.
    534        b) No other NewABI toolchain actually emits such relocations.  */
    535   EMPTY_HOWTO (R_MIPS_HIGHER),
    536   EMPTY_HOWTO (R_MIPS_HIGHEST),
    537 
    538   /* High 16 bits of displacement in global offset table.  */
    539   HOWTO (R_MIPS_CALL_HI16,	/* type */
    540 	 0,			/* rightshift */
    541 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    542 	 16,			/* bitsize */
    543 	 FALSE,			/* pc_relative */
    544 	 0,			/* bitpos */
    545 	 complain_overflow_dont, /* complain_on_overflow */
    546 	 _bfd_mips_elf_generic_reloc,	/* special_function */
    547 	 "R_MIPS_CALL_HI16",	/* name */
    548 	 TRUE,			/* partial_inplace */
    549 	 0x0000ffff,		/* src_mask */
    550 	 0x0000ffff,		/* dst_mask */
    551 	 FALSE),		/* pcrel_offset */
    552 
    553   /* Low 16 bits of displacement in global offset table.  */
    554   HOWTO (R_MIPS_CALL_LO16,	/* type */
    555 	 0,			/* rightshift */
    556 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    557 	 16,			/* bitsize */
    558 	 FALSE,			/* pc_relative */
    559 	 0,			/* bitpos */
    560 	 complain_overflow_dont, /* complain_on_overflow */
    561 	 _bfd_mips_elf_generic_reloc,	/* special_function */
    562 	 "R_MIPS_CALL_LO16",	/* name */
    563 	 TRUE,			/* partial_inplace */
    564 	 0x0000ffff,		/* src_mask */
    565 	 0x0000ffff,		/* dst_mask */
    566 	 FALSE),		/* pcrel_offset */
    567 
    568   /* Section displacement, used by an associated event location section.  */
    569   HOWTO (R_MIPS_SCN_DISP,	/* type */
    570 	 0,			/* rightshift */
    571 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    572 	 32,			/* bitsize */
    573 	 FALSE,			/* pc_relative */
    574 	 0,			/* bitpos */
    575 	 complain_overflow_dont, /* complain_on_overflow */
    576 	 _bfd_mips_elf_generic_reloc,	/* special_function */
    577 	 "R_MIPS_SCN_DISP",	/* name */
    578 	 TRUE,			/* partial_inplace */
    579 	 0xffffffff,		/* src_mask */
    580 	 0xffffffff,		/* dst_mask */
    581 	 FALSE),		/* pcrel_offset */
    582 
    583   HOWTO (R_MIPS_REL16,		/* type */
    584 	 0,			/* rightshift */
    585 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
    586 	 16,			/* bitsize */
    587 	 FALSE,			/* pc_relative */
    588 	 0,			/* bitpos */
    589 	 complain_overflow_signed, /* complain_on_overflow */
    590 	 _bfd_mips_elf_generic_reloc,	/* special_function */
    591 	 "R_MIPS_REL16",	/* name */
    592 	 TRUE,			/* partial_inplace */
    593 	 0xffff,		/* src_mask */
    594 	 0xffff,		/* dst_mask */
    595 	 FALSE),		/* pcrel_offset */
    596 
    597   /* These two are obsolete.  */
    598   EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE),
    599   EMPTY_HOWTO (R_MIPS_PJUMP),
    600 
    601   /* Similiar to R_MIPS_REL32, but used for relocations in a GOT section.
    602      It must be used for multigot GOT's (and only there).  */
    603   HOWTO (R_MIPS_RELGOT,		/* type */
    604 	 0,			/* rightshift */
    605 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    606 	 32,			/* bitsize */
    607 	 FALSE,			/* pc_relative */
    608 	 0,			/* bitpos */
    609 	 complain_overflow_dont, /* complain_on_overflow */
    610 	 _bfd_mips_elf_generic_reloc,	/* special_function */
    611 	 "R_MIPS_RELGOT",	/* name */
    612 	 TRUE,			/* partial_inplace */
    613 	 0xffffffff,		/* src_mask */
    614 	 0xffffffff,		/* dst_mask */
    615 	 FALSE),		/* pcrel_offset */
    616 
    617   /* Protected jump conversion.  This is an optimization hint.  No
    618      relocation is required for correctness.  */
    619   HOWTO (R_MIPS_JALR,		/* type */
    620 	 0,			/* rightshift */
    621 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    622 	 32,			/* bitsize */
    623 	 FALSE,			/* pc_relative */
    624 	 0,			/* bitpos */
    625 	 complain_overflow_dont, /* complain_on_overflow */
    626 	 _bfd_mips_elf_generic_reloc,	/* special_function */
    627 	 "R_MIPS_JALR",		/* name */
    628 	 FALSE,			/* partial_inplace */
    629 	 0,			/* src_mask */
    630 	 0x00000000,		/* dst_mask */
    631 	 FALSE),		/* pcrel_offset */
    632 
    633   /* TLS relocations.  */
    634   EMPTY_HOWTO (R_MIPS_TLS_DTPMOD32),
    635   EMPTY_HOWTO (R_MIPS_TLS_DTPREL32),
    636 
    637   HOWTO (R_MIPS_TLS_DTPMOD64,	/* type */
    638 	 0,			/* rightshift */
    639 	 4,			/* size (0 = byte, 1 = short, 2 = long) */
    640 	 64,			/* bitsize */
    641 	 FALSE,			/* pc_relative */
    642 	 0,			/* bitpos */
    643 	 complain_overflow_dont, /* complain_on_overflow */
    644 	 _bfd_mips_elf_generic_reloc, /* special_function */
    645 	 "R_MIPS_TLS_DTPMOD64",	/* name */
    646 	 TRUE,			/* partial_inplace */
    647 	 MINUS_ONE,		/* src_mask */
    648 	 MINUS_ONE,		/* dst_mask */
    649 	 FALSE),		/* pcrel_offset */
    650 
    651   HOWTO (R_MIPS_TLS_DTPREL64,	/* type */
    652 	 0,			/* rightshift */
    653 	 4,			/* size (0 = byte, 1 = short, 2 = long) */
    654 	 64,			/* bitsize */
    655 	 FALSE,			/* pc_relative */
    656 	 0,			/* bitpos */
    657 	 complain_overflow_dont, /* complain_on_overflow */
    658 	 _bfd_mips_elf_generic_reloc, /* special_function */
    659 	 "R_MIPS_TLS_DTPREL64",	/* name */
    660 	 TRUE,			/* partial_inplace */
    661 	 MINUS_ONE,		/* src_mask */
    662 	 MINUS_ONE,		/* dst_mask */
    663 	 FALSE),		/* pcrel_offset */
    664 
    665   /* TLS general dynamic variable reference.  */
    666   HOWTO (R_MIPS_TLS_GD,		/* type */
    667 	 0,			/* rightshift */
    668 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    669 	 16,			/* bitsize */
    670 	 FALSE,			/* pc_relative */
    671 	 0,			/* bitpos */
    672 	 complain_overflow_signed, /* complain_on_overflow */
    673 	 _bfd_mips_elf_generic_reloc, /* special_function */
    674 	 "R_MIPS_TLS_GD",	/* name */
    675 	 TRUE,			/* partial_inplace */
    676 	 0x0000ffff,		/* src_mask */
    677 	 0x0000ffff,		/* dst_mask */
    678 	 FALSE),		/* pcrel_offset */
    679 
    680   /* TLS local dynamic variable reference.  */
    681   HOWTO (R_MIPS_TLS_LDM,	/* type */
    682 	 0,			/* rightshift */
    683 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    684 	 16,			/* bitsize */
    685 	 FALSE,			/* pc_relative */
    686 	 0,			/* bitpos */
    687 	 complain_overflow_signed, /* complain_on_overflow */
    688 	 _bfd_mips_elf_generic_reloc, /* special_function */
    689 	 "R_MIPS_TLS_LDM",	/* name */
    690 	 TRUE,			/* partial_inplace */
    691 	 0x0000ffff,		/* src_mask */
    692 	 0x0000ffff,		/* dst_mask */
    693 	 FALSE),		/* pcrel_offset */
    694 
    695   /* TLS local dynamic offset.  */
    696   HOWTO (R_MIPS_TLS_DTPREL_HI16,	/* type */
    697 	 0,			/* rightshift */
    698 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    699 	 16,			/* bitsize */
    700 	 FALSE,			/* pc_relative */
    701 	 0,			/* bitpos */
    702 	 complain_overflow_signed, /* complain_on_overflow */
    703 	 _bfd_mips_elf_generic_reloc, /* special_function */
    704 	 "R_MIPS_TLS_DTPREL_HI16",	/* name */
    705 	 TRUE,			/* partial_inplace */
    706 	 0x0000ffff,		/* src_mask */
    707 	 0x0000ffff,		/* dst_mask */
    708 	 FALSE),		/* pcrel_offset */
    709 
    710   /* TLS local dynamic offset.  */
    711   HOWTO (R_MIPS_TLS_DTPREL_LO16,	/* type */
    712 	 0,			/* rightshift */
    713 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    714 	 16,			/* bitsize */
    715 	 FALSE,			/* pc_relative */
    716 	 0,			/* bitpos */
    717 	 complain_overflow_signed, /* complain_on_overflow */
    718 	 _bfd_mips_elf_generic_reloc, /* special_function */
    719 	 "R_MIPS_TLS_DTPREL_LO16",	/* name */
    720 	 TRUE,			/* partial_inplace */
    721 	 0x0000ffff,		/* src_mask */
    722 	 0x0000ffff,		/* dst_mask */
    723 	 FALSE),		/* pcrel_offset */
    724 
    725   /* TLS thread pointer offset.  */
    726   HOWTO (R_MIPS_TLS_GOTTPREL,	/* type */
    727 	 0,			/* rightshift */
    728 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    729 	 16,			/* bitsize */
    730 	 FALSE,			/* pc_relative */
    731 	 0,			/* bitpos */
    732 	 complain_overflow_signed, /* complain_on_overflow */
    733 	 _bfd_mips_elf_generic_reloc, /* special_function */
    734 	 "R_MIPS_TLS_GOTTPREL",	/* name */
    735 	 TRUE,			/* partial_inplace */
    736 	 0x0000ffff,		/* src_mask */
    737 	 0x0000ffff,		/* dst_mask */
    738 	 FALSE),		/* pcrel_offset */
    739 
    740   /* TLS IE dynamic relocations.  */
    741   EMPTY_HOWTO (R_MIPS_TLS_TPREL32),
    742 
    743   HOWTO (R_MIPS_TLS_TPREL64,	/* type */
    744 	 0,			/* rightshift */
    745 	 4,			/* size (0 = byte, 1 = short, 2 = long) */
    746 	 64,			/* bitsize */
    747 	 FALSE,			/* pc_relative */
    748 	 0,			/* bitpos */
    749 	 complain_overflow_dont, /* complain_on_overflow */
    750 	 _bfd_mips_elf_generic_reloc, /* special_function */
    751 	 "R_MIPS_TLS_TPREL64",	/* name */
    752 	 TRUE,			/* partial_inplace */
    753 	 MINUS_ONE,		/* src_mask */
    754 	 MINUS_ONE,		/* dst_mask */
    755 	 FALSE),		/* pcrel_offset */
    756 
    757   /* TLS thread pointer offset.  */
    758   HOWTO (R_MIPS_TLS_TPREL_HI16,	/* type */
    759 	 0,			/* rightshift */
    760 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    761 	 16,			/* bitsize */
    762 	 FALSE,			/* pc_relative */
    763 	 0,			/* bitpos */
    764 	 complain_overflow_signed, /* complain_on_overflow */
    765 	 _bfd_mips_elf_generic_reloc, /* special_function */
    766 	 "R_MIPS_TLS_TPREL_HI16", /* name */
    767 	 TRUE,			/* partial_inplace */
    768 	 0x0000ffff,		/* src_mask */
    769 	 0x0000ffff,		/* dst_mask */
    770 	 FALSE),		/* pcrel_offset */
    771 
    772   /* TLS thread pointer offset.  */
    773   HOWTO (R_MIPS_TLS_TPREL_LO16,	/* type */
    774 	 0,			/* rightshift */
    775 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    776 	 16,			/* bitsize */
    777 	 FALSE,			/* pc_relative */
    778 	 0,			/* bitpos */
    779 	 complain_overflow_signed, /* complain_on_overflow */
    780 	 _bfd_mips_elf_generic_reloc, /* special_function */
    781 	 "R_MIPS_TLS_TPREL_LO16", /* name */
    782 	 TRUE,			/* partial_inplace */
    783 	 0x0000ffff,		/* src_mask */
    784 	 0x0000ffff,		/* dst_mask */
    785 	 FALSE),		/* pcrel_offset */
    786 
    787   /* 32 bit relocation with no addend.  */
    788   HOWTO (R_MIPS_GLOB_DAT,	/* type */
    789 	 0,			/* rightshift */
    790 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    791 	 32,			/* bitsize */
    792 	 FALSE,			/* pc_relative */
    793 	 0,			/* bitpos */
    794 	 complain_overflow_dont, /* complain_on_overflow */
    795 	 _bfd_mips_elf_generic_reloc, /* special_function */
    796 	 "R_MIPS_GLOB_DAT",	/* name */
    797 	 FALSE,			/* partial_inplace */
    798 	 0x0,			/* src_mask */
    799 	 0xffffffff,		/* dst_mask */
    800 	 FALSE),		/* pcrel_offset */
    801 
    802   EMPTY_HOWTO (52),
    803   EMPTY_HOWTO (53),
    804   EMPTY_HOWTO (54),
    805   EMPTY_HOWTO (55),
    806   EMPTY_HOWTO (56),
    807   EMPTY_HOWTO (57),
    808   EMPTY_HOWTO (58),
    809   EMPTY_HOWTO (59),
    810 
    811   HOWTO (R_MIPS_PC21_S2,	/* type */
    812 	 2,			/* rightshift */
    813 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    814 	 21,			/* bitsize */
    815 	 TRUE,			/* pc_relative */
    816 	 0,			/* bitpos */
    817 	 complain_overflow_signed, /* complain_on_overflow */
    818 	 _bfd_mips_elf_generic_reloc, /* special_function */
    819 	 "R_MIPS_PC21_S2",	/* name */
    820 	 TRUE,			/* partial_inplace */
    821 	 0x001fffff,		/* src_mask */
    822 	 0x001fffff,		/* dst_mask */
    823 	 TRUE),			/* pcrel_offset */
    824 
    825   HOWTO (R_MIPS_PC26_S2,	/* type */
    826 	 2,			/* rightshift */
    827 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    828 	 26,			/* bitsize */
    829 	 TRUE,			/* pc_relative */
    830 	 0,			/* bitpos */
    831 	 complain_overflow_signed, /* complain_on_overflow */
    832 	 _bfd_mips_elf_generic_reloc, /* special_function */
    833 	 "R_MIPS_PC26_S2",	/* name */
    834 	 TRUE,			/* partial_inplace */
    835 	 0x03ffffff,		/* src_mask */
    836 	 0x03ffffff,		/* dst_mask */
    837 	 TRUE),			/* pcrel_offset */
    838 
    839   HOWTO (R_MIPS_PC18_S3,	/* type */
    840 	 3,			/* rightshift */
    841 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    842 	 18,			/* bitsize */
    843 	 TRUE,			/* pc_relative */
    844 	 0,			/* bitpos */
    845 	 complain_overflow_signed, /* complain_on_overflow */
    846 	 _bfd_mips_elf_generic_reloc,   /* special_function */
    847 	 "R_MIPS_PC18_S3",	/* name */
    848 	 TRUE,			/* partial_inplace */
    849 	 0x0003ffff,		/* src_mask */
    850 	 0x0003ffff,		/* dst_mask */
    851 	 TRUE),			/* pcrel_offset */
    852 
    853   HOWTO (R_MIPS_PC19_S2,	/* type */
    854 	 2,			/* rightshift */
    855 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    856 	 19,			/* bitsize */
    857 	 TRUE,			/* pc_relative */
    858 	 0,			/* bitpos */
    859 	 complain_overflow_signed, /* complain_on_overflow */
    860 	 _bfd_mips_elf_generic_reloc,   /* special_function */
    861 	 "R_MIPS_PC19_S2",	/* name */
    862 	 TRUE,			/* partial_inplace */
    863 	 0x0007ffff,		/* src_mask */
    864 	 0x0007ffff,		/* dst_mask */
    865 	 TRUE),			/* pcrel_offset */
    866 
    867   HOWTO (R_MIPS_PCHI16,		/* type */
    868 	 16,			/* rightshift */
    869 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    870 	 16,			/* bitsize */
    871 	 TRUE,			/* pc_relative */
    872 	 0,			/* bitpos */
    873 	 complain_overflow_signed, /* complain_on_overflow */
    874 	 _bfd_mips_elf_generic_reloc,   /* special_function */
    875 	 "R_MIPS_PCHI16",	/* name */
    876 	 TRUE,			/* partial_inplace */
    877 	 0x0000ffff,		/* src_mask */
    878 	 0x0000ffff,		/* dst_mask */
    879 	 TRUE),			/* pcrel_offset */
    880 
    881   HOWTO (R_MIPS_PCLO16,		/* type */
    882 	 0,			/* rightshift */
    883 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    884 	 16,			/* bitsize */
    885 	 TRUE,			/* pc_relative */
    886 	 0,			/* bitpos */
    887 	 complain_overflow_dont, /* complain_on_overflow */
    888 	 _bfd_mips_elf_generic_reloc,   /* special_function */
    889 	 "R_MIPS_PCLO16",	/* name */
    890 	 TRUE,			/* partial_inplace */
    891 	 0x0000ffff,		/* src_mask */
    892 	 0x0000ffff,		/* dst_mask */
    893 	 TRUE),			/* pcrel_offset */
    894 
    895 };
    896 
    897 /* The relocation table used for SHT_RELA sections.  */
    898 
    899 static reloc_howto_type mips_elf64_howto_table_rela[] =
    900 {
    901   /* No relocation.  */
    902   HOWTO (R_MIPS_NONE,		/* type */
    903 	 0,			/* rightshift */
    904 	 3,			/* size (0 = byte, 1 = short, 2 = long) */
    905 	 0,			/* bitsize */
    906 	 FALSE,			/* pc_relative */
    907 	 0,			/* bitpos */
    908 	 complain_overflow_dont, /* complain_on_overflow */
    909 	 _bfd_mips_elf_generic_reloc,	/* special_function */
    910 	 "R_MIPS_NONE",		/* name */
    911 	 FALSE,			/* partial_inplace */
    912 	 0,			/* src_mask */
    913 	 0,			/* dst_mask */
    914 	 FALSE),		/* pcrel_offset */
    915 
    916   /* 16 bit relocation.  */
    917   HOWTO (R_MIPS_16,		/* type */
    918 	 0,			/* rightshift */
    919 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    920 	 16,			/* bitsize */
    921 	 FALSE,			/* pc_relative */
    922 	 0,			/* bitpos */
    923 	 complain_overflow_signed, /* complain_on_overflow */
    924 	 _bfd_mips_elf_generic_reloc,	/* special_function */
    925 	 "R_MIPS_16",		/* name */
    926 	 FALSE,			/* partial_inplace */
    927 	 0,			/* src_mask */
    928 	 0x0000ffff,		/* dst_mask */
    929 	 FALSE),		/* pcrel_offset */
    930 
    931   /* 32 bit relocation.  */
    932   HOWTO (R_MIPS_32,		/* type */
    933 	 0,			/* rightshift */
    934 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    935 	 32,			/* bitsize */
    936 	 FALSE,			/* pc_relative */
    937 	 0,			/* bitpos */
    938 	 complain_overflow_dont, /* complain_on_overflow */
    939 	 _bfd_mips_elf_generic_reloc,	/* special_function */
    940 	 "R_MIPS_32",		/* name */
    941 	 FALSE,			/* partial_inplace */
    942 	 0,			/* src_mask */
    943 	 0xffffffff,		/* dst_mask */
    944 	 FALSE),		/* pcrel_offset */
    945 
    946   /* 32 bit symbol relative relocation.  */
    947   HOWTO (R_MIPS_REL32,		/* type */
    948 	 0,			/* rightshift */
    949 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    950 	 32,			/* bitsize */
    951 	 FALSE,			/* pc_relative */
    952 	 0,			/* bitpos */
    953 	 complain_overflow_dont, /* complain_on_overflow */
    954 	 _bfd_mips_elf_generic_reloc,	/* special_function */
    955 	 "R_MIPS_REL32",	/* name */
    956 	 FALSE,			/* partial_inplace */
    957 	 0,			/* src_mask */
    958 	 0xffffffff,		/* dst_mask */
    959 	 FALSE),		/* pcrel_offset */
    960 
    961   /* 26 bit jump address.  */
    962   HOWTO (R_MIPS_26,		/* type */
    963 	 2,			/* rightshift */
    964 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    965 	 26,			/* bitsize */
    966 	 FALSE,			/* pc_relative */
    967 	 0,			/* bitpos */
    968 	 complain_overflow_dont, /* complain_on_overflow */
    969 				/* This needs complex overflow
    970 				   detection, because the upper 36
    971 				   bits must match the PC + 4.  */
    972 	 _bfd_mips_elf_generic_reloc,	/* special_function */
    973 	 "R_MIPS_26",		/* name */
    974 	 FALSE,			/* partial_inplace */
    975 	 0,			/* src_mask */
    976 	 0x03ffffff,		/* dst_mask */
    977 	 FALSE),		/* pcrel_offset */
    978 
    979   /* High 16 bits of symbol value.  */
    980   HOWTO (R_MIPS_HI16,		/* type */
    981 	 0,			/* rightshift */
    982 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    983 	 16,			/* bitsize */
    984 	 FALSE,			/* pc_relative */
    985 	 0,			/* bitpos */
    986 	 complain_overflow_dont, /* complain_on_overflow */
    987 	 _bfd_mips_elf_generic_reloc,	/* special_function */
    988 	 "R_MIPS_HI16",		/* name */
    989 	 FALSE,			/* partial_inplace */
    990 	 0,			/* src_mask */
    991 	 0x0000ffff,		/* dst_mask */
    992 	 FALSE),		/* pcrel_offset */
    993 
    994   /* Low 16 bits of symbol value.  */
    995   HOWTO (R_MIPS_LO16,		/* type */
    996 	 0,			/* rightshift */
    997 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    998 	 16,			/* bitsize */
    999 	 FALSE,			/* pc_relative */
   1000 	 0,			/* bitpos */
   1001 	 complain_overflow_dont, /* complain_on_overflow */
   1002 	 _bfd_mips_elf_generic_reloc,	/* special_function */
   1003 	 "R_MIPS_LO16",		/* name */
   1004 	 FALSE,			/* partial_inplace */
   1005 	 0,			/* src_mask */
   1006 	 0x0000ffff,		/* dst_mask */
   1007 	 FALSE),		/* pcrel_offset */
   1008 
   1009   /* GP relative reference.  */
   1010   HOWTO (R_MIPS_GPREL16,	/* type */
   1011 	 0,			/* rightshift */
   1012 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1013 	 16,			/* bitsize */
   1014 	 FALSE,			/* pc_relative */
   1015 	 0,			/* bitpos */
   1016 	 complain_overflow_signed, /* complain_on_overflow */
   1017 	 mips_elf64_gprel16_reloc, /* special_function */
   1018 	 "R_MIPS_GPREL16",	/* name */
   1019 	 FALSE,			/* partial_inplace */
   1020 	 0,			/* src_mask */
   1021 	 0x0000ffff,		/* dst_mask */
   1022 	 FALSE),		/* pcrel_offset */
   1023 
   1024   /* Reference to literal section.  */
   1025   HOWTO (R_MIPS_LITERAL,	/* type */
   1026 	 0,			/* rightshift */
   1027 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1028 	 16,			/* bitsize */
   1029 	 FALSE,			/* pc_relative */
   1030 	 0,			/* bitpos */
   1031 	 complain_overflow_signed, /* complain_on_overflow */
   1032 	 mips_elf64_literal_reloc, /* special_function */
   1033 	 "R_MIPS_LITERAL",	/* name */
   1034 	 FALSE,			/* partial_inplace */
   1035 	 0,			/* src_mask */
   1036 	 0x0000ffff,		/* dst_mask */
   1037 	 FALSE),		/* pcrel_offset */
   1038 
   1039   /* Reference to global offset table.  */
   1040   HOWTO (R_MIPS_GOT16,		/* type */
   1041 	 0,			/* rightshift */
   1042 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1043 	 16,			/* bitsize */
   1044 	 FALSE,			/* pc_relative */
   1045 	 0,			/* bitpos */
   1046 	 complain_overflow_signed, /* complain_on_overflow */
   1047 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1048 	 "R_MIPS_GOT16",	/* name */
   1049 	 FALSE,			/* partial_inplace */
   1050 	 0,			/* src_mask */
   1051 	 0x0000ffff,		/* dst_mask */
   1052 	 FALSE),		/* pcrel_offset */
   1053 
   1054   /* 16 bit PC relative reference.  Note that the ABI document has a typo
   1055      and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
   1056      We do the right thing here.  */
   1057   HOWTO (R_MIPS_PC16,		/* type */
   1058 	 2,			/* rightshift */
   1059 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1060 	 16,			/* bitsize */
   1061 	 TRUE,			/* pc_relative */
   1062 	 0,			/* bitpos */
   1063 	 complain_overflow_signed, /* complain_on_overflow */
   1064 	 _bfd_mips_elf_generic_reloc,	/* special_function */
   1065 	 "R_MIPS_PC16",		/* name */
   1066 	 FALSE,			/* partial_inplace */
   1067 	 0,			/* src_mask */
   1068 	 0x0000ffff,		/* dst_mask */
   1069 	 TRUE),			/* pcrel_offset */
   1070 
   1071   /* 16 bit call through global offset table.  */
   1072   HOWTO (R_MIPS_CALL16,		/* type */
   1073 	 0,			/* rightshift */
   1074 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1075 	 16,			/* bitsize */
   1076 	 FALSE,			/* pc_relative */
   1077 	 0,			/* bitpos */
   1078 	 complain_overflow_signed, /* complain_on_overflow */
   1079 	 _bfd_mips_elf_generic_reloc,	/* special_function */
   1080 	 "R_MIPS_CALL16",	/* name */
   1081 	 FALSE,			/* partial_inplace */
   1082 	 0,			/* src_mask */
   1083 	 0x0000ffff,		/* dst_mask */
   1084 	 FALSE),		/* pcrel_offset */
   1085 
   1086   /* 32 bit GP relative reference.  */
   1087   HOWTO (R_MIPS_GPREL32,	/* type */
   1088 	 0,			/* rightshift */
   1089 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1090 	 32,			/* bitsize */
   1091 	 FALSE,			/* pc_relative */
   1092 	 0,			/* bitpos */
   1093 	 complain_overflow_dont, /* complain_on_overflow */
   1094 	 mips_elf64_gprel32_reloc, /* special_function */
   1095 	 "R_MIPS_GPREL32",	/* name */
   1096 	 FALSE,			/* partial_inplace */
   1097 	 0,			/* src_mask */
   1098 	 0xffffffff,		/* dst_mask */
   1099 	 FALSE),		/* pcrel_offset */
   1100 
   1101   EMPTY_HOWTO (13),
   1102   EMPTY_HOWTO (14),
   1103   EMPTY_HOWTO (15),
   1104 
   1105   /* A 5 bit shift field.  */
   1106   HOWTO (R_MIPS_SHIFT5,		/* type */
   1107 	 0,			/* rightshift */
   1108 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1109 	 5,			/* bitsize */
   1110 	 FALSE,			/* pc_relative */
   1111 	 6,			/* bitpos */
   1112 	 complain_overflow_bitfield, /* complain_on_overflow */
   1113 	 _bfd_mips_elf_generic_reloc,	/* special_function */
   1114 	 "R_MIPS_SHIFT5",	/* name */
   1115 	 FALSE,			/* partial_inplace */
   1116 	 0,			/* src_mask */
   1117 	 0x000007c0,		/* dst_mask */
   1118 	 FALSE),		/* pcrel_offset */
   1119 
   1120   /* A 6 bit shift field.  */
   1121   HOWTO (R_MIPS_SHIFT6,		/* type */
   1122 	 0,			/* rightshift */
   1123 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1124 	 6,			/* bitsize */
   1125 	 FALSE,			/* pc_relative */
   1126 	 6,			/* bitpos */
   1127 	 complain_overflow_bitfield, /* complain_on_overflow */
   1128 	 mips_elf64_shift6_reloc, /* special_function */
   1129 	 "R_MIPS_SHIFT6",	/* name */
   1130 	 FALSE,			/* partial_inplace */
   1131 	 0,			/* src_mask */
   1132 	 0x000007c4,		/* dst_mask */
   1133 	 FALSE),		/* pcrel_offset */
   1134 
   1135   /* 64 bit relocation.  */
   1136   HOWTO (R_MIPS_64,		/* type */
   1137 	 0,			/* rightshift */
   1138 	 4,			/* size (0 = byte, 1 = short, 2 = long) */
   1139 	 64,			/* bitsize */
   1140 	 FALSE,			/* pc_relative */
   1141 	 0,			/* bitpos */
   1142 	 complain_overflow_dont, /* complain_on_overflow */
   1143 	 _bfd_mips_elf_generic_reloc,	/* special_function */
   1144 	 "R_MIPS_64",		/* name */
   1145 	 FALSE,			/* partial_inplace */
   1146 	 0,			/* src_mask */
   1147 	 MINUS_ONE,		/* dst_mask */
   1148 	 FALSE),		/* pcrel_offset */
   1149 
   1150   /* Displacement in the global offset table.  */
   1151   HOWTO (R_MIPS_GOT_DISP,	/* type */
   1152 	 0,			/* rightshift */
   1153 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1154 	 16,			/* bitsize */
   1155 	 FALSE,			/* pc_relative */
   1156 	 0,			/* bitpos */
   1157 	 complain_overflow_signed, /* complain_on_overflow */
   1158 	 _bfd_mips_elf_generic_reloc,	/* special_function */
   1159 	 "R_MIPS_GOT_DISP",	/* name */
   1160 	 FALSE,			/* partial_inplace */
   1161 	 0,			/* src_mask */
   1162 	 0x0000ffff,		/* dst_mask */
   1163 	 FALSE),		/* pcrel_offset */
   1164 
   1165   /* Displacement to page pointer in the global offset table.  */
   1166   HOWTO (R_MIPS_GOT_PAGE,	/* type */
   1167 	 0,			/* rightshift */
   1168 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1169 	 16,			/* bitsize */
   1170 	 FALSE,			/* pc_relative */
   1171 	 0,			/* bitpos */
   1172 	 complain_overflow_signed, /* complain_on_overflow */
   1173 	 _bfd_mips_elf_generic_reloc,	/* special_function */
   1174 	 "R_MIPS_GOT_PAGE",	/* name */
   1175 	 FALSE,			/* partial_inplace */
   1176 	 0,			/* src_mask */
   1177 	 0x0000ffff,		/* dst_mask */
   1178 	 FALSE),		/* pcrel_offset */
   1179 
   1180   /* Offset from page pointer in the global offset table.  */
   1181   HOWTO (R_MIPS_GOT_OFST,	/* type */
   1182 	 0,			/* rightshift */
   1183 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1184 	 16,			/* bitsize */
   1185 	 FALSE,			/* pc_relative */
   1186 	 0,			/* bitpos */
   1187 	 complain_overflow_signed, /* complain_on_overflow */
   1188 	 _bfd_mips_elf_generic_reloc,	/* special_function */
   1189 	 "R_MIPS_GOT_OFST",	/* name */
   1190 	 FALSE,			/* partial_inplace */
   1191 	 0,			/* src_mask */
   1192 	 0x0000ffff,		/* dst_mask */
   1193 	 FALSE),		/* pcrel_offset */
   1194 
   1195   /* High 16 bits of displacement in global offset table.  */
   1196   HOWTO (R_MIPS_GOT_HI16,	/* type */
   1197 	 0,			/* rightshift */
   1198 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1199 	 16,			/* bitsize */
   1200 	 FALSE,			/* pc_relative */
   1201 	 0,			/* bitpos */
   1202 	 complain_overflow_dont, /* complain_on_overflow */
   1203 	 _bfd_mips_elf_generic_reloc,	/* special_function */
   1204 	 "R_MIPS_GOT_HI16",	/* name */
   1205 	 FALSE,			/* partial_inplace */
   1206 	 0,			/* src_mask */
   1207 	 0x0000ffff,		/* dst_mask */
   1208 	 FALSE),		/* pcrel_offset */
   1209 
   1210   /* Low 16 bits of displacement in global offset table.  */
   1211   HOWTO (R_MIPS_GOT_LO16,	/* type */
   1212 	 0,			/* rightshift */
   1213 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1214 	 16,			/* bitsize */
   1215 	 FALSE,			/* pc_relative */
   1216 	 0,			/* bitpos */
   1217 	 complain_overflow_dont, /* complain_on_overflow */
   1218 	 _bfd_mips_elf_generic_reloc,	/* special_function */
   1219 	 "R_MIPS_GOT_LO16",	/* name */
   1220 	 FALSE,			/* partial_inplace */
   1221 	 0,			/* src_mask */
   1222 	 0x0000ffff,		/* dst_mask */
   1223 	 FALSE),		/* pcrel_offset */
   1224 
   1225   /* 64 bit subtraction.  */
   1226   HOWTO (R_MIPS_SUB,		/* type */
   1227 	 0,			/* rightshift */
   1228 	 4,			/* size (0 = byte, 1 = short, 2 = long) */
   1229 	 64,			/* bitsize */
   1230 	 FALSE,			/* pc_relative */
   1231 	 0,			/* bitpos */
   1232 	 complain_overflow_dont, /* complain_on_overflow */
   1233 	 _bfd_mips_elf_generic_reloc,	/* special_function */
   1234 	 "R_MIPS_SUB",		/* name */
   1235 	 FALSE,			/* partial_inplace */
   1236 	 0,			/* src_mask */
   1237 	 MINUS_ONE,		/* dst_mask */
   1238 	 FALSE),		/* pcrel_offset */
   1239 
   1240   /* Insert the addend as an instruction.  */
   1241   /* FIXME: Not handled correctly.  */
   1242   HOWTO (R_MIPS_INSERT_A,	/* type */
   1243 	 0,			/* rightshift */
   1244 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1245 	 32,			/* bitsize */
   1246 	 FALSE,			/* pc_relative */
   1247 	 0,			/* bitpos */
   1248 	 complain_overflow_dont, /* complain_on_overflow */
   1249 	 _bfd_mips_elf_generic_reloc,	/* special_function */
   1250 	 "R_MIPS_INSERT_A",	/* name */
   1251 	 FALSE,			/* partial_inplace */
   1252 	 0,			/* src_mask */
   1253 	 0xffffffff,		/* dst_mask */
   1254 	 FALSE),		/* pcrel_offset */
   1255 
   1256   /* Insert the addend as an instruction, and change all relocations
   1257      to refer to the old instruction at the address.  */
   1258   /* FIXME: Not handled correctly.  */
   1259   HOWTO (R_MIPS_INSERT_B,	/* type */
   1260 	 0,			/* rightshift */
   1261 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1262 	 32,			/* bitsize */
   1263 	 FALSE,			/* pc_relative */
   1264 	 0,			/* bitpos */
   1265 	 complain_overflow_dont, /* complain_on_overflow */
   1266 	 _bfd_mips_elf_generic_reloc,	/* special_function */
   1267 	 "R_MIPS_INSERT_B",	/* name */
   1268 	 FALSE,			/* partial_inplace */
   1269 	 0,			/* src_mask */
   1270 	 0xffffffff,		/* dst_mask */
   1271 	 FALSE),		/* pcrel_offset */
   1272 
   1273   /* Delete a 32 bit instruction.  */
   1274   /* FIXME: Not handled correctly.  */
   1275   HOWTO (R_MIPS_DELETE,		/* type */
   1276 	 0,			/* rightshift */
   1277 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1278 	 32,			/* bitsize */
   1279 	 FALSE,			/* pc_relative */
   1280 	 0,			/* bitpos */
   1281 	 complain_overflow_dont, /* complain_on_overflow */
   1282 	 _bfd_mips_elf_generic_reloc,	/* special_function */
   1283 	 "R_MIPS_DELETE",	/* name */
   1284 	 FALSE,			/* partial_inplace */
   1285 	 0,			/* src_mask */
   1286 	 0xffffffff,		/* dst_mask */
   1287 	 FALSE),		/* pcrel_offset */
   1288 
   1289   /* Get the higher value of a 64 bit addend.  */
   1290   HOWTO (R_MIPS_HIGHER,		/* type */
   1291 	 0,			/* rightshift */
   1292 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1293 	 16,			/* bitsize */
   1294 	 FALSE,			/* pc_relative */
   1295 	 0,			/* bitpos */
   1296 	 complain_overflow_dont, /* complain_on_overflow */
   1297 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1298 	 "R_MIPS_HIGHER",	/* name */
   1299 	 FALSE,			/* partial_inplace */
   1300 	 0,			/* src_mask */
   1301 	 0x0000ffff,		/* dst_mask */
   1302 	 FALSE),		/* pcrel_offset */
   1303 
   1304   /* Get the highest value of a 64 bit addend.  */
   1305   HOWTO (R_MIPS_HIGHEST,	/* type */
   1306 	 0,			/* rightshift */
   1307 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1308 	 16,			/* bitsize */
   1309 	 FALSE,			/* pc_relative */
   1310 	 0,			/* bitpos */
   1311 	 complain_overflow_dont, /* complain_on_overflow */
   1312 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1313 	 "R_MIPS_HIGHEST",	/* name */
   1314 	 FALSE,			/* partial_inplace */
   1315 	 0,			/* src_mask */
   1316 	 0x0000ffff,		/* dst_mask */
   1317 	 FALSE),		/* pcrel_offset */
   1318 
   1319   /* High 16 bits of displacement in global offset table.  */
   1320   HOWTO (R_MIPS_CALL_HI16,	/* type */
   1321 	 0,			/* rightshift */
   1322 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1323 	 16,			/* bitsize */
   1324 	 FALSE,			/* pc_relative */
   1325 	 0,			/* bitpos */
   1326 	 complain_overflow_dont, /* complain_on_overflow */
   1327 	 _bfd_mips_elf_generic_reloc,	/* special_function */
   1328 	 "R_MIPS_CALL_HI16",	/* name */
   1329 	 FALSE,			/* partial_inplace */
   1330 	 0,			/* src_mask */
   1331 	 0x0000ffff,		/* dst_mask */
   1332 	 FALSE),		/* pcrel_offset */
   1333 
   1334   /* Low 16 bits of displacement in global offset table.  */
   1335   HOWTO (R_MIPS_CALL_LO16,	/* type */
   1336 	 0,			/* rightshift */
   1337 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1338 	 16,			/* bitsize */
   1339 	 FALSE,			/* pc_relative */
   1340 	 0,			/* bitpos */
   1341 	 complain_overflow_dont, /* complain_on_overflow */
   1342 	 _bfd_mips_elf_generic_reloc,	/* special_function */
   1343 	 "R_MIPS_CALL_LO16",	/* name */
   1344 	 FALSE,			/* partial_inplace */
   1345 	 0,			/* src_mask */
   1346 	 0x0000ffff,		/* dst_mask */
   1347 	 FALSE),		/* pcrel_offset */
   1348 
   1349   /* Section displacement, used by an associated event location section.  */
   1350   HOWTO (R_MIPS_SCN_DISP,	/* type */
   1351 	 0,			/* rightshift */
   1352 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1353 	 32,			/* bitsize */
   1354 	 FALSE,			/* pc_relative */
   1355 	 0,			/* bitpos */
   1356 	 complain_overflow_dont, /* complain_on_overflow */
   1357 	 _bfd_mips_elf_generic_reloc,	/* special_function */
   1358 	 "R_MIPS_SCN_DISP",	/* name */
   1359 	 FALSE,			/* partial_inplace */
   1360 	 0,			/* src_mask */
   1361 	 0xffffffff,		/* dst_mask */
   1362 	 FALSE),		/* pcrel_offset */
   1363 
   1364   HOWTO (R_MIPS_REL16,		/* type */
   1365 	 0,			/* rightshift */
   1366 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
   1367 	 16,			/* bitsize */
   1368 	 FALSE,			/* pc_relative */
   1369 	 0,			/* bitpos */
   1370 	 complain_overflow_signed, /* complain_on_overflow */
   1371 	 _bfd_mips_elf_generic_reloc,	/* special_function */
   1372 	 "R_MIPS_REL16",	/* name */
   1373 	 FALSE,			/* partial_inplace */
   1374 	 0,			/* src_mask */
   1375 	 0xffff,		/* dst_mask */
   1376 	 FALSE),		/* pcrel_offset */
   1377 
   1378   /* These two are obsolete.  */
   1379   EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE),
   1380   EMPTY_HOWTO (R_MIPS_PJUMP),
   1381 
   1382   /* Similiar to R_MIPS_REL32, but used for relocations in a GOT section.
   1383      It must be used for multigot GOT's (and only there).  */
   1384   HOWTO (R_MIPS_RELGOT,		/* type */
   1385 	 0,			/* rightshift */
   1386 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1387 	 32,			/* bitsize */
   1388 	 FALSE,			/* pc_relative */
   1389 	 0,			/* bitpos */
   1390 	 complain_overflow_dont, /* complain_on_overflow */
   1391 	 _bfd_mips_elf_generic_reloc,	/* special_function */
   1392 	 "R_MIPS_RELGOT",	/* name */
   1393 	 FALSE,			/* partial_inplace */
   1394 	 0,			/* src_mask */
   1395 	 0xffffffff,		/* dst_mask */
   1396 	 FALSE),		/* pcrel_offset */
   1397 
   1398   /* Protected jump conversion.  This is an optimization hint.  No
   1399      relocation is required for correctness.  */
   1400   HOWTO (R_MIPS_JALR,		/* type */
   1401 	 0,			/* rightshift */
   1402 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1403 	 32,			/* bitsize */
   1404 	 FALSE,			/* pc_relative */
   1405 	 0,			/* bitpos */
   1406 	 complain_overflow_dont, /* complain_on_overflow */
   1407 	 _bfd_mips_elf_generic_reloc,	/* special_function */
   1408 	 "R_MIPS_JALR",		/* name */
   1409 	 FALSE,			/* partial_inplace */
   1410 	 0,			/* src_mask */
   1411 	 0x00000000,		/* dst_mask */
   1412 	 FALSE),		/* pcrel_offset */
   1413 
   1414   /* TLS relocations.  */
   1415   EMPTY_HOWTO (R_MIPS_TLS_DTPMOD32),
   1416   EMPTY_HOWTO (R_MIPS_TLS_DTPREL32),
   1417 
   1418   HOWTO (R_MIPS_TLS_DTPMOD64,	/* type */
   1419 	 0,			/* rightshift */
   1420 	 4,			/* size (0 = byte, 1 = short, 2 = long) */
   1421 	 64,			/* bitsize */
   1422 	 FALSE,			/* pc_relative */
   1423 	 0,			/* bitpos */
   1424 	 complain_overflow_dont, /* complain_on_overflow */
   1425 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1426 	 "R_MIPS_TLS_DTPMOD64", /* name */
   1427 	 FALSE,			/* partial_inplace */
   1428 	 0,			/* src_mask */
   1429 	 MINUS_ONE,		/* dst_mask */
   1430 	 FALSE),		/* pcrel_offset */
   1431 
   1432   HOWTO (R_MIPS_TLS_DTPREL64,	/* type */
   1433 	 0,			/* rightshift */
   1434 	 4,			/* size (0 = byte, 1 = short, 2 = long) */
   1435 	 64,			/* bitsize */
   1436 	 FALSE,			/* pc_relative */
   1437 	 0,			/* bitpos */
   1438 	 complain_overflow_dont, /* complain_on_overflow */
   1439 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1440 	 "R_MIPS_TLS_DTPREL64",	/* name */
   1441 	 FALSE,			/* partial_inplace */
   1442 	 0,			/* src_mask */
   1443 	 MINUS_ONE,		/* dst_mask */
   1444 	 FALSE),		/* pcrel_offset */
   1445 
   1446   /* TLS general dynamic variable reference.  */
   1447   HOWTO (R_MIPS_TLS_GD,		/* type */
   1448 	 0,			/* rightshift */
   1449 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1450 	 16,			/* bitsize */
   1451 	 FALSE,			/* pc_relative */
   1452 	 0,			/* bitpos */
   1453 	 complain_overflow_signed, /* complain_on_overflow */
   1454 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1455 	 "R_MIPS_TLS_GD",	/* name */
   1456 	 FALSE,			/* partial_inplace */
   1457 	 0,			/* src_mask */
   1458 	 0x0000ffff,		/* dst_mask */
   1459 	 FALSE),		/* pcrel_offset */
   1460 
   1461   /* TLS local dynamic variable reference.  */
   1462   HOWTO (R_MIPS_TLS_LDM,	/* type */
   1463 	 0,			/* rightshift */
   1464 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1465 	 16,			/* bitsize */
   1466 	 FALSE,			/* pc_relative */
   1467 	 0,			/* bitpos */
   1468 	 complain_overflow_signed, /* complain_on_overflow */
   1469 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1470 	 "R_MIPS_TLS_LDM",	/* name */
   1471 	 FALSE,			/* partial_inplace */
   1472 	 0,			/* src_mask */
   1473 	 0x0000ffff,		/* dst_mask */
   1474 	 FALSE),		/* pcrel_offset */
   1475 
   1476   /* TLS local dynamic offset.  */
   1477   HOWTO (R_MIPS_TLS_DTPREL_HI16,	/* type */
   1478 	 0,			/* rightshift */
   1479 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1480 	 16,			/* bitsize */
   1481 	 FALSE,			/* pc_relative */
   1482 	 0,			/* bitpos */
   1483 	 complain_overflow_signed, /* complain_on_overflow */
   1484 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1485 	 "R_MIPS_TLS_DTPREL_HI16",	/* name */
   1486 	 FALSE,			/* partial_inplace */
   1487 	 0,			/* src_mask */
   1488 	 0x0000ffff,		/* dst_mask */
   1489 	 FALSE),		/* pcrel_offset */
   1490 
   1491   /* TLS local dynamic offset.  */
   1492   HOWTO (R_MIPS_TLS_DTPREL_LO16,	/* type */
   1493 	 0,			/* rightshift */
   1494 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1495 	 16,			/* bitsize */
   1496 	 FALSE,			/* pc_relative */
   1497 	 0,			/* bitpos */
   1498 	 complain_overflow_signed, /* complain_on_overflow */
   1499 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1500 	 "R_MIPS_TLS_DTPREL_LO16",	/* name */
   1501 	 FALSE,			/* partial_inplace */
   1502 	 0,			/* src_mask */
   1503 	 0x0000ffff,		/* dst_mask */
   1504 	 FALSE),		/* pcrel_offset */
   1505 
   1506   /* TLS thread pointer offset.  */
   1507   HOWTO (R_MIPS_TLS_GOTTPREL,	/* type */
   1508 	 0,			/* rightshift */
   1509 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1510 	 16,			/* bitsize */
   1511 	 FALSE,			/* pc_relative */
   1512 	 0,			/* bitpos */
   1513 	 complain_overflow_signed, /* complain_on_overflow */
   1514 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1515 	 "R_MIPS_TLS_GOTTPREL",	/* name */
   1516 	 FALSE,			/* partial_inplace */
   1517 	 0,			/* src_mask */
   1518 	 0x0000ffff,		/* dst_mask */
   1519 	 FALSE),		/* pcrel_offset */
   1520 
   1521   /* TLS IE dynamic relocations.  */
   1522   EMPTY_HOWTO (R_MIPS_TLS_TPREL32),
   1523 
   1524   HOWTO (R_MIPS_TLS_TPREL64,	/* type */
   1525 	 0,			/* rightshift */
   1526 	 4,			/* size (0 = byte, 1 = short, 2 = long) */
   1527 	 64,			/* bitsize */
   1528 	 FALSE,			/* pc_relative */
   1529 	 0,			/* bitpos */
   1530 	 complain_overflow_dont, /* complain_on_overflow */
   1531 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1532 	 "R_MIPS_TLS_TPREL64",	/* name */
   1533 	 FALSE,			/* partial_inplace */
   1534 	 0,			/* src_mask */
   1535 	 MINUS_ONE,		/* dst_mask */
   1536 	 FALSE),		/* pcrel_offset */
   1537 
   1538   /* TLS thread pointer offset.  */
   1539   HOWTO (R_MIPS_TLS_TPREL_HI16,	/* type */
   1540 	 0,			/* rightshift */
   1541 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1542 	 16,			/* bitsize */
   1543 	 FALSE,			/* pc_relative */
   1544 	 0,			/* bitpos */
   1545 	 complain_overflow_signed, /* complain_on_overflow */
   1546 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1547 	 "R_MIPS_TLS_TPREL_HI16", /* name */
   1548 	 FALSE,			/* partial_inplace */
   1549 	 0,			/* src_mask */
   1550 	 0x0000ffff,		/* dst_mask */
   1551 	 FALSE),		/* pcrel_offset */
   1552 
   1553   /* TLS thread pointer offset.  */
   1554   HOWTO (R_MIPS_TLS_TPREL_LO16,	/* type */
   1555 	 0,			/* rightshift */
   1556 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1557 	 16,			/* bitsize */
   1558 	 FALSE,			/* pc_relative */
   1559 	 0,			/* bitpos */
   1560 	 complain_overflow_signed, /* complain_on_overflow */
   1561 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1562 	 "R_MIPS_TLS_TPREL_LO16", /* name */
   1563 	 FALSE,			/* partial_inplace */
   1564 	 0,			/* src_mask */
   1565 	 0x0000ffff,		/* dst_mask */
   1566 	 FALSE),		/* pcrel_offset */
   1567 
   1568   /* 32 bit relocation with no addend.  */
   1569   HOWTO (R_MIPS_GLOB_DAT,	/* type */
   1570 	 0,			/* rightshift */
   1571 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1572 	 32,			/* bitsize */
   1573 	 FALSE,			/* pc_relative */
   1574 	 0,			/* bitpos */
   1575 	 complain_overflow_dont, /* complain_on_overflow */
   1576 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1577 	 "R_MIPS_GLOB_DAT",	/* name */
   1578 	 FALSE,			/* partial_inplace */
   1579 	 0x0,			/* src_mask */
   1580 	 0xffffffff,		/* dst_mask */
   1581 	 FALSE),		/* pcrel_offset */
   1582 
   1583   EMPTY_HOWTO (52),
   1584   EMPTY_HOWTO (53),
   1585   EMPTY_HOWTO (54),
   1586   EMPTY_HOWTO (55),
   1587   EMPTY_HOWTO (56),
   1588   EMPTY_HOWTO (57),
   1589   EMPTY_HOWTO (58),
   1590   EMPTY_HOWTO (59),
   1591 
   1592   HOWTO (R_MIPS_PC21_S2,	/* type */
   1593 	 2,			/* rightshift */
   1594 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1595 	 21,			/* bitsize */
   1596 	 TRUE,			/* pc_relative */
   1597 	 0,			/* bitpos */
   1598 	 complain_overflow_signed, /* complain_on_overflow */
   1599 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1600 	 "R_MIPS_PC21_S2",	/* name */
   1601 	 FALSE,			/* partial_inplace */
   1602 	 0,			/* src_mask */
   1603 	 0x001fffff,		/* dst_mask */
   1604 	 TRUE),			/* pcrel_offset */
   1605 
   1606   HOWTO (R_MIPS_PC26_S2,	/* type */
   1607 	 2,			/* rightshift */
   1608 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1609 	 26,			/* bitsize */
   1610 	 TRUE,			/* pc_relative */
   1611 	 0,			/* bitpos */
   1612 	 complain_overflow_signed, /* complain_on_overflow */
   1613 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1614 	 "R_MIPS_PC26_S2",	/* name */
   1615 	 FALSE,			/* partial_inplace */
   1616 	 0,			/* src_mask */
   1617 	 0x03ffffff,		/* dst_mask */
   1618 	 TRUE),			/* pcrel_offset */
   1619 
   1620   HOWTO (R_MIPS_PC18_S3,	/* type */
   1621 	 3,			/* rightshift */
   1622 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1623 	 18,			/* bitsize */
   1624 	 TRUE,			/* pc_relative */
   1625 	 0,			/* bitpos */
   1626 	 complain_overflow_signed, /* complain_on_overflow */
   1627 	 _bfd_mips_elf_generic_reloc,   /* special_function */
   1628 	 "R_MIPS_PC18_S3",	/* name */
   1629 	 FALSE,			/* partial_inplace */
   1630 	 0,			/* src_mask */
   1631 	 0x0003ffff,		/* dst_mask */
   1632 	 TRUE),			/* pcrel_offset */
   1633 
   1634   HOWTO (R_MIPS_PC19_S2,	/* type */
   1635 	 2,			/* rightshift */
   1636 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1637 	 19,			/* bitsize */
   1638 	 TRUE,			/* pc_relative */
   1639 	 0,			/* bitpos */
   1640 	 complain_overflow_signed, /* complain_on_overflow */
   1641 	 _bfd_mips_elf_generic_reloc,   /* special_function */
   1642 	 "R_MIPS_PC19_S2",	/* name */
   1643 	 FALSE,			/* partial_inplace */
   1644 	 0,			/* src_mask */
   1645 	 0x0007ffff,		/* dst_mask */
   1646 	 TRUE),			/* pcrel_offset */
   1647 
   1648   HOWTO (R_MIPS_PCHI16,		/* type */
   1649 	 16,			/* rightshift */
   1650 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1651 	 16,			/* bitsize */
   1652 	 TRUE,			/* pc_relative */
   1653 	 0,			/* bitpos */
   1654 	 complain_overflow_signed, /* complain_on_overflow */
   1655 	 _bfd_mips_elf_generic_reloc,   /* special_function */
   1656 	 "R_MIPS_PCHI16",	/* name */
   1657 	 FALSE,			/* partial_inplace */
   1658 	 0,			/* src_mask */
   1659 	 0x0000ffff,		/* dst_mask */
   1660 	 TRUE),			/* pcrel_offset */
   1661 
   1662   HOWTO (R_MIPS_PCLO16,		/* type */
   1663 	 0,			/* rightshift */
   1664 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1665 	 16,			/* bitsize */
   1666 	 TRUE,			/* pc_relative */
   1667 	 0,			/* bitpos */
   1668 	 complain_overflow_dont, /* complain_on_overflow */
   1669 	 _bfd_mips_elf_generic_reloc,   /* special_function */
   1670 	 "R_MIPS_PCLO16",	/* name */
   1671 	 FALSE,			/* partial_inplace */
   1672 	 0,			/* src_mask */
   1673 	 0x0000ffff,		/* dst_mask */
   1674 	 TRUE),			/* pcrel_offset */
   1675 
   1676 };
   1677 
   1678 static reloc_howto_type mips16_elf64_howto_table_rel[] =
   1679 {
   1680   /* The reloc used for the mips16 jump instruction.  */
   1681   HOWTO (R_MIPS16_26,		/* type */
   1682 	 2,			/* rightshift */
   1683 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1684 	 26,			/* bitsize */
   1685 	 FALSE,			/* pc_relative */
   1686 	 0,			/* bitpos */
   1687 	 complain_overflow_dont, /* complain_on_overflow */
   1688 				/* This needs complex overflow
   1689 				   detection, because the upper four
   1690 				   bits must match the PC.  */
   1691 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1692 	 "R_MIPS16_26",		/* name */
   1693 	 TRUE,			/* partial_inplace */
   1694 	 0x3ffffff,		/* src_mask */
   1695 	 0x3ffffff,		/* dst_mask */
   1696 	 FALSE),		/* pcrel_offset */
   1697 
   1698   /* The reloc used for the mips16 gprel instruction.  */
   1699   HOWTO (R_MIPS16_GPREL,	/* type */
   1700 	 0,			/* rightshift */
   1701 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1702 	 16,			/* bitsize */
   1703 	 FALSE,			/* pc_relative */
   1704 	 0,			/* bitpos */
   1705 	 complain_overflow_signed, /* complain_on_overflow */
   1706 	 mips16_gprel_reloc,	/* special_function */
   1707 	 "R_MIPS16_GPREL",	/* name */
   1708 	 TRUE,			/* partial_inplace */
   1709 	 0x0000ffff,		/* src_mask */
   1710 	 0x0000ffff,		/* dst_mask */
   1711 	 FALSE),		/* pcrel_offset */
   1712 
   1713   /* A MIPS16 reference to the global offset table.  */
   1714   HOWTO (R_MIPS16_GOT16,	/* type */
   1715 	 0,			/* rightshift */
   1716 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1717 	 16,			/* bitsize */
   1718 	 FALSE,			/* pc_relative */
   1719 	 0,			/* bitpos */
   1720 	 complain_overflow_dont, /* complain_on_overflow */
   1721 	 _bfd_mips_elf_got16_reloc, /* special_function */
   1722 	 "R_MIPS16_GOT16",	/* name */
   1723 	 TRUE,			/* partial_inplace */
   1724 	 0x0000ffff,		/* src_mask */
   1725 	 0x0000ffff,		/* dst_mask */
   1726 	 FALSE),		/* pcrel_offset */
   1727 
   1728   /* A MIPS16 call through the global offset table.  */
   1729   HOWTO (R_MIPS16_CALL16,	/* type */
   1730 	 0,			/* rightshift */
   1731 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1732 	 16,			/* bitsize */
   1733 	 FALSE,			/* pc_relative */
   1734 	 0,			/* bitpos */
   1735 	 complain_overflow_dont, /* complain_on_overflow */
   1736 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1737 	 "R_MIPS16_CALL16",	/* name */
   1738 	 TRUE,			/* partial_inplace */
   1739 	 0x0000ffff,		/* src_mask */
   1740 	 0x0000ffff,		/* dst_mask */
   1741 	 FALSE),		/* pcrel_offset */
   1742 
   1743   /* MIPS16 high 16 bits of symbol value.  */
   1744   HOWTO (R_MIPS16_HI16,		/* type */
   1745 	 16,			/* rightshift */
   1746 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1747 	 16,			/* bitsize */
   1748 	 FALSE,			/* pc_relative */
   1749 	 0,			/* bitpos */
   1750 	 complain_overflow_dont, /* complain_on_overflow */
   1751 	 _bfd_mips_elf_hi16_reloc, /* special_function */
   1752 	 "R_MIPS16_HI16",	/* name */
   1753 	 TRUE,			/* partial_inplace */
   1754 	 0x0000ffff,		/* src_mask */
   1755 	 0x0000ffff,		/* dst_mask */
   1756 	 FALSE),		/* pcrel_offset */
   1757 
   1758   /* MIPS16 low 16 bits of symbol value.  */
   1759   HOWTO (R_MIPS16_LO16,		/* type */
   1760 	 0,			/* rightshift */
   1761 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1762 	 16,			/* bitsize */
   1763 	 FALSE,			/* pc_relative */
   1764 	 0,			/* bitpos */
   1765 	 complain_overflow_dont, /* complain_on_overflow */
   1766 	 _bfd_mips_elf_lo16_reloc, /* special_function */
   1767 	 "R_MIPS16_LO16",	/* name */
   1768 	 TRUE,			/* partial_inplace */
   1769 	 0x0000ffff,		/* src_mask */
   1770 	 0x0000ffff,		/* dst_mask */
   1771 	 FALSE),		/* pcrel_offset */
   1772 
   1773   /* MIPS16 TLS general dynamic variable reference.  */
   1774   HOWTO (R_MIPS16_TLS_GD,	/* type */
   1775 	 0,			/* rightshift */
   1776 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1777 	 16,			/* bitsize */
   1778 	 FALSE,			/* pc_relative */
   1779 	 0,			/* bitpos */
   1780 	 complain_overflow_signed, /* complain_on_overflow */
   1781 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1782 	 "R_MIPS16_TLS_GD",	/* name */
   1783 	 TRUE,			/* partial_inplace */
   1784 	 0x0000ffff,		/* src_mask */
   1785 	 0x0000ffff,		/* dst_mask */
   1786 	 FALSE),		/* pcrel_offset */
   1787 
   1788   /* MIPS16 TLS local dynamic variable reference.  */
   1789   HOWTO (R_MIPS16_TLS_LDM,	/* type */
   1790 	 0,			/* rightshift */
   1791 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1792 	 16,			/* bitsize */
   1793 	 FALSE,			/* pc_relative */
   1794 	 0,			/* bitpos */
   1795 	 complain_overflow_signed, /* complain_on_overflow */
   1796 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1797 	 "R_MIPS16_TLS_LDM",	/* name */
   1798 	 TRUE,			/* partial_inplace */
   1799 	 0x0000ffff,		/* src_mask */
   1800 	 0x0000ffff,		/* dst_mask */
   1801 	 FALSE),		/* pcrel_offset */
   1802 
   1803   /* MIPS16 TLS local dynamic offset.  */
   1804   HOWTO (R_MIPS16_TLS_DTPREL_HI16,	/* type */
   1805 	 0,			/* rightshift */
   1806 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1807 	 16,			/* bitsize */
   1808 	 FALSE,			/* pc_relative */
   1809 	 0,			/* bitpos */
   1810 	 complain_overflow_signed, /* complain_on_overflow */
   1811 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1812 	 "R_MIPS16_TLS_DTPREL_HI16",	/* name */
   1813 	 TRUE,			/* partial_inplace */
   1814 	 0x0000ffff,		/* src_mask */
   1815 	 0x0000ffff,		/* dst_mask */
   1816 	 FALSE),		/* pcrel_offset */
   1817 
   1818   /* MIPS16 TLS local dynamic offset.  */
   1819   HOWTO (R_MIPS16_TLS_DTPREL_LO16,	/* type */
   1820 	 0,			/* rightshift */
   1821 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1822 	 16,			/* bitsize */
   1823 	 FALSE,			/* pc_relative */
   1824 	 0,			/* bitpos */
   1825 	 complain_overflow_signed, /* complain_on_overflow */
   1826 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1827 	 "R_MIPS16_TLS_DTPREL_LO16",	/* name */
   1828 	 TRUE,			/* partial_inplace */
   1829 	 0x0000ffff,		/* src_mask */
   1830 	 0x0000ffff,		/* dst_mask */
   1831 	 FALSE),		/* pcrel_offset */
   1832 
   1833   /* MIPS16 TLS thread pointer offset.  */
   1834   HOWTO (R_MIPS16_TLS_GOTTPREL,	/* type */
   1835 	 0,			/* rightshift */
   1836 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1837 	 16,			/* bitsize */
   1838 	 FALSE,			/* pc_relative */
   1839 	 0,			/* bitpos */
   1840 	 complain_overflow_signed, /* complain_on_overflow */
   1841 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1842 	 "R_MIPS16_TLS_GOTTPREL",	/* name */
   1843 	 TRUE,			/* partial_inplace */
   1844 	 0x0000ffff,		/* src_mask */
   1845 	 0x0000ffff,		/* dst_mask */
   1846 	 FALSE),		/* pcrel_offset */
   1847 
   1848   /* MIPS16 TLS thread pointer offset.  */
   1849   HOWTO (R_MIPS16_TLS_TPREL_HI16,	/* type */
   1850 	 0,			/* rightshift */
   1851 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1852 	 16,			/* bitsize */
   1853 	 FALSE,			/* pc_relative */
   1854 	 0,			/* bitpos */
   1855 	 complain_overflow_signed, /* complain_on_overflow */
   1856 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1857 	 "R_MIPS16_TLS_TPREL_HI16", /* name */
   1858 	 TRUE,			/* partial_inplace */
   1859 	 0x0000ffff,		/* src_mask */
   1860 	 0x0000ffff,		/* dst_mask */
   1861 	 FALSE),		/* pcrel_offset */
   1862 
   1863   /* MIPS16 TLS thread pointer offset.  */
   1864   HOWTO (R_MIPS16_TLS_TPREL_LO16,	/* type */
   1865 	 0,			/* rightshift */
   1866 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1867 	 16,			/* bitsize */
   1868 	 FALSE,			/* pc_relative */
   1869 	 0,			/* bitpos */
   1870 	 complain_overflow_signed, /* complain_on_overflow */
   1871 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1872 	 "R_MIPS16_TLS_TPREL_LO16", /* name */
   1873 	 TRUE,			/* partial_inplace */
   1874 	 0x0000ffff,		/* src_mask */
   1875 	 0x0000ffff,		/* dst_mask */
   1876 	 FALSE),		/* pcrel_offset */
   1877 
   1878   /* MIPS16 16-bit PC-relative branch offset.  */
   1879   HOWTO (R_MIPS16_PC16_S1,	/* type */
   1880 	 1,			/* rightshift */
   1881 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1882 	 16,			/* bitsize */
   1883 	 TRUE,			/* pc_relative */
   1884 	 0,			/* bitpos */
   1885 	 complain_overflow_signed, /* complain_on_overflow */
   1886 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1887 	 "R_MIPS16_PC16_S1",	/* name */
   1888 	 TRUE,			/* partial_inplace */
   1889 	 0x0000ffff,		/* src_mask */
   1890 	 0x0000ffff,		/* dst_mask */
   1891 	 TRUE),			/* pcrel_offset */
   1892 };
   1893 
   1894 static reloc_howto_type mips16_elf64_howto_table_rela[] =
   1895 {
   1896   /* The reloc used for the mips16 jump instruction.  */
   1897   HOWTO (R_MIPS16_26,		/* type */
   1898 	 2,			/* rightshift */
   1899 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1900 	 26,			/* bitsize */
   1901 	 FALSE,			/* pc_relative */
   1902 	 0,			/* bitpos */
   1903 	 complain_overflow_dont, /* complain_on_overflow */
   1904 				/* This needs complex overflow
   1905 				   detection, because the upper four
   1906 				   bits must match the PC.  */
   1907 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1908 	 "R_MIPS16_26",		/* name */
   1909 	 FALSE,			/* partial_inplace */
   1910 	 0,			/* src_mask */
   1911 	 0x3ffffff,		/* dst_mask */
   1912 	 FALSE),		/* pcrel_offset */
   1913 
   1914   /* The reloc used for the mips16 gprel instruction.  */
   1915   HOWTO (R_MIPS16_GPREL,	/* type */
   1916 	 0,			/* rightshift */
   1917 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1918 	 16,			/* bitsize */
   1919 	 FALSE,			/* pc_relative */
   1920 	 0,			/* bitpos */
   1921 	 complain_overflow_signed, /* complain_on_overflow */
   1922 	 mips16_gprel_reloc,	/* special_function */
   1923 	 "R_MIPS16_GPREL",	/* name */
   1924 	 FALSE,			/* partial_inplace */
   1925 	 0,			/* src_mask */
   1926 	 0x0000ffff,		/* dst_mask */
   1927 	 FALSE),		/* pcrel_offset */
   1928 
   1929   /* A MIPS16 reference to the global offset table.  */
   1930   HOWTO (R_MIPS16_GOT16,	/* type */
   1931 	 0,			/* rightshift */
   1932 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1933 	 16,			/* bitsize */
   1934 	 FALSE,			/* pc_relative */
   1935 	 0,			/* bitpos */
   1936 	 complain_overflow_dont, /* complain_on_overflow */
   1937 	 _bfd_mips_elf_got16_reloc, /* special_function */
   1938 	 "R_MIPS16_GOT16",	/* name */
   1939 	 FALSE,			/* partial_inplace */
   1940 	 0,			/* src_mask */
   1941 	 0x0000ffff,		/* dst_mask */
   1942 	 FALSE),		/* pcrel_offset */
   1943 
   1944   /* A MIPS16 call through the global offset table.  */
   1945   HOWTO (R_MIPS16_CALL16,	/* type */
   1946 	 0,			/* rightshift */
   1947 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1948 	 16,			/* bitsize */
   1949 	 FALSE,			/* pc_relative */
   1950 	 0,			/* bitpos */
   1951 	 complain_overflow_dont, /* complain_on_overflow */
   1952 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1953 	 "R_MIPS16_CALL16",	/* name */
   1954 	 FALSE,			/* partial_inplace */
   1955 	 0,			/* src_mask */
   1956 	 0x0000ffff,		/* dst_mask */
   1957 	 FALSE),		/* pcrel_offset */
   1958 
   1959   /* MIPS16 high 16 bits of symbol value.  */
   1960   HOWTO (R_MIPS16_HI16,		/* type */
   1961 	 16,			/* rightshift */
   1962 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1963 	 16,			/* bitsize */
   1964 	 FALSE,			/* pc_relative */
   1965 	 0,			/* bitpos */
   1966 	 complain_overflow_dont, /* complain_on_overflow */
   1967 	 _bfd_mips_elf_hi16_reloc, /* special_function */
   1968 	 "R_MIPS16_HI16",	/* name */
   1969 	 FALSE,			/* partial_inplace */
   1970 	 0,			/* src_mask */
   1971 	 0x0000ffff,		/* dst_mask */
   1972 	 FALSE),		/* pcrel_offset */
   1973 
   1974   /* MIPS16 low 16 bits of symbol value.  */
   1975   HOWTO (R_MIPS16_LO16,		/* type */
   1976 	 0,			/* rightshift */
   1977 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1978 	 16,			/* bitsize */
   1979 	 FALSE,			/* pc_relative */
   1980 	 0,			/* bitpos */
   1981 	 complain_overflow_dont, /* complain_on_overflow */
   1982 	 _bfd_mips_elf_lo16_reloc, /* special_function */
   1983 	 "R_MIPS16_LO16",	/* name */
   1984 	 FALSE,			/* partial_inplace */
   1985 	 0,			/* src_mask */
   1986 	 0x0000ffff,		/* dst_mask */
   1987 	 FALSE),		/* pcrel_offset */
   1988 
   1989   /* MIPS16 TLS general dynamic variable reference.  */
   1990   HOWTO (R_MIPS16_TLS_GD,	/* type */
   1991 	 0,			/* rightshift */
   1992 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1993 	 16,			/* bitsize */
   1994 	 FALSE,			/* pc_relative */
   1995 	 0,			/* bitpos */
   1996 	 complain_overflow_signed, /* complain_on_overflow */
   1997 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1998 	 "R_MIPS16_TLS_GD",	/* name */
   1999 	 FALSE,			/* partial_inplace */
   2000 	 0,			/* src_mask */
   2001 	 0x0000ffff,		/* dst_mask */
   2002 	 FALSE),		/* pcrel_offset */
   2003 
   2004   /* MIPS16 TLS local dynamic variable reference.  */
   2005   HOWTO (R_MIPS16_TLS_LDM,	/* type */
   2006 	 0,			/* rightshift */
   2007 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2008 	 16,			/* bitsize */
   2009 	 FALSE,			/* pc_relative */
   2010 	 0,			/* bitpos */
   2011 	 complain_overflow_signed, /* complain_on_overflow */
   2012 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2013 	 "R_MIPS16_TLS_LDM",	/* name */
   2014 	 FALSE,			/* partial_inplace */
   2015 	 0,			/* src_mask */
   2016 	 0x0000ffff,		/* dst_mask */
   2017 	 FALSE),		/* pcrel_offset */
   2018 
   2019   /* MIPS16 TLS local dynamic offset.  */
   2020   HOWTO (R_MIPS16_TLS_DTPREL_HI16,	/* type */
   2021 	 0,			/* rightshift */
   2022 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2023 	 16,			/* bitsize */
   2024 	 FALSE,			/* pc_relative */
   2025 	 0,			/* bitpos */
   2026 	 complain_overflow_signed, /* complain_on_overflow */
   2027 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2028 	 "R_MIPS16_TLS_DTPREL_HI16",	/* name */
   2029 	 FALSE,			/* partial_inplace */
   2030 	 0,			/* src_mask */
   2031 	 0x0000ffff,		/* dst_mask */
   2032 	 FALSE),		/* pcrel_offset */
   2033 
   2034   /* MIPS16 TLS local dynamic offset.  */
   2035   HOWTO (R_MIPS16_TLS_DTPREL_LO16,	/* type */
   2036 	 0,			/* rightshift */
   2037 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2038 	 16,			/* bitsize */
   2039 	 FALSE,			/* pc_relative */
   2040 	 0,			/* bitpos */
   2041 	 complain_overflow_signed, /* complain_on_overflow */
   2042 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2043 	 "R_MIPS16_TLS_DTPREL_LO16",	/* name */
   2044 	 FALSE,			/* partial_inplace */
   2045 	 0,			/* src_mask */
   2046 	 0x0000ffff,		/* dst_mask */
   2047 	 FALSE),		/* pcrel_offset */
   2048 
   2049   /* MIPS16 TLS thread pointer offset.  */
   2050   HOWTO (R_MIPS16_TLS_GOTTPREL,	/* type */
   2051 	 0,			/* rightshift */
   2052 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2053 	 16,			/* bitsize */
   2054 	 FALSE,			/* pc_relative */
   2055 	 0,			/* bitpos */
   2056 	 complain_overflow_signed, /* complain_on_overflow */
   2057 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2058 	 "R_MIPS16_TLS_GOTTPREL",	/* name */
   2059 	 FALSE,			/* partial_inplace */
   2060 	 0,			/* src_mask */
   2061 	 0x0000ffff,		/* dst_mask */
   2062 	 FALSE),		/* pcrel_offset */
   2063 
   2064   /* MIPS16 TLS thread pointer offset.  */
   2065   HOWTO (R_MIPS16_TLS_TPREL_HI16,	/* type */
   2066 	 0,			/* rightshift */
   2067 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2068 	 16,			/* bitsize */
   2069 	 FALSE,			/* pc_relative */
   2070 	 0,			/* bitpos */
   2071 	 complain_overflow_signed, /* complain_on_overflow */
   2072 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2073 	 "R_MIPS16_TLS_TPREL_HI16", /* name */
   2074 	 FALSE,			/* partial_inplace */
   2075 	 0,			/* src_mask */
   2076 	 0x0000ffff,		/* dst_mask */
   2077 	 FALSE),		/* pcrel_offset */
   2078 
   2079   /* MIPS16 TLS thread pointer offset.  */
   2080   HOWTO (R_MIPS16_TLS_TPREL_LO16,	/* type */
   2081 	 0,			/* rightshift */
   2082 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2083 	 16,			/* bitsize */
   2084 	 FALSE,			/* pc_relative */
   2085 	 0,			/* bitpos */
   2086 	 complain_overflow_signed, /* complain_on_overflow */
   2087 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2088 	 "R_MIPS16_TLS_TPREL_LO16", /* name */
   2089 	 FALSE,			/* partial_inplace */
   2090 	 0,			/* src_mask */
   2091 	 0x0000ffff,		/* dst_mask */
   2092 	 FALSE),		/* pcrel_offset */
   2093 
   2094   /* MIPS16 16-bit PC-relative branch offset.  */
   2095   HOWTO (R_MIPS16_PC16_S1,	/* type */
   2096 	 1,			/* rightshift */
   2097 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2098 	 16,			/* bitsize */
   2099 	 TRUE,			/* pc_relative */
   2100 	 0,			/* bitpos */
   2101 	 complain_overflow_signed, /* complain_on_overflow */
   2102 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2103 	 "R_MIPS16_PC16_S1",	/* name */
   2104 	 FALSE,			/* partial_inplace */
   2105 	 0,			/* src_mask */
   2106 	 0x0000ffff,		/* dst_mask */
   2107 	 TRUE),			/* pcrel_offset */
   2108 };
   2109 
   2110 static reloc_howto_type micromips_elf64_howto_table_rel[] =
   2111 {
   2112   EMPTY_HOWTO (130),
   2113   EMPTY_HOWTO (131),
   2114   EMPTY_HOWTO (132),
   2115 
   2116   /* 26 bit jump address.  */
   2117   HOWTO (R_MICROMIPS_26_S1,	/* type */
   2118 	 1,			/* rightshift */
   2119 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2120 	 26,			/* bitsize */
   2121 	 FALSE,			/* pc_relative */
   2122 	 0,			/* bitpos */
   2123 	 complain_overflow_dont, /* complain_on_overflow */
   2124 				/* This needs complex overflow
   2125 				   detection, because the upper four
   2126 				   bits must match the PC.  */
   2127 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2128 	 "R_MICROMIPS_26_S1",	/* name */
   2129 	 TRUE,			/* partial_inplace */
   2130 	 0x3ffffff,		/* src_mask */
   2131 	 0x3ffffff,		/* dst_mask */
   2132 	 FALSE),		/* pcrel_offset */
   2133 
   2134   /* High 16 bits of symbol value.  */
   2135   HOWTO (R_MICROMIPS_HI16,	/* type */
   2136 	 16,			/* rightshift */
   2137 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2138 	 16,			/* bitsize */
   2139 	 FALSE,			/* pc_relative */
   2140 	 0,			/* bitpos */
   2141 	 complain_overflow_dont, /* complain_on_overflow */
   2142 	 _bfd_mips_elf_hi16_reloc, /* special_function */
   2143 	 "R_MICROMIPS_HI16",	/* name */
   2144 	 TRUE,			/* partial_inplace */
   2145 	 0x0000ffff,		/* src_mask */
   2146 	 0x0000ffff,		/* dst_mask */
   2147 	 FALSE),		/* pcrel_offset */
   2148 
   2149   /* Low 16 bits of symbol value.  */
   2150   HOWTO (R_MICROMIPS_LO16,	/* type */
   2151 	 0,			/* rightshift */
   2152 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2153 	 16,			/* bitsize */
   2154 	 FALSE,			/* pc_relative */
   2155 	 0,			/* bitpos */
   2156 	 complain_overflow_dont, /* complain_on_overflow */
   2157 	 _bfd_mips_elf_lo16_reloc, /* special_function */
   2158 	 "R_MICROMIPS_LO16",	/* name */
   2159 	 TRUE,			/* partial_inplace */
   2160 	 0x0000ffff,		/* src_mask */
   2161 	 0x0000ffff,		/* dst_mask */
   2162 	 FALSE),		/* pcrel_offset */
   2163 
   2164   /* GP relative reference.  */
   2165   HOWTO (R_MICROMIPS_GPREL16,	/* type */
   2166 	 0,			/* rightshift */
   2167 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2168 	 16,			/* bitsize */
   2169 	 FALSE,			/* pc_relative */
   2170 	 0,			/* bitpos */
   2171 	 complain_overflow_signed, /* complain_on_overflow */
   2172 	 _bfd_mips_elf32_gprel16_reloc, /* special_function */
   2173 	 "R_MICROMIPS_GPREL16",	/* name */
   2174 	 TRUE,			/* partial_inplace */
   2175 	 0x0000ffff,		/* src_mask */
   2176 	 0x0000ffff,		/* dst_mask */
   2177 	 FALSE),		/* pcrel_offset */
   2178 
   2179   /* Reference to literal section.  */
   2180   HOWTO (R_MICROMIPS_LITERAL,	/* type */
   2181 	 0,			/* rightshift */
   2182 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2183 	 16,			/* bitsize */
   2184 	 FALSE,			/* pc_relative */
   2185 	 0,			/* bitpos */
   2186 	 complain_overflow_signed, /* complain_on_overflow */
   2187 	 _bfd_mips_elf32_gprel16_reloc, /* special_function */
   2188 	 "R_MICROMIPS_LITERAL",	/* name */
   2189 	 TRUE,			/* partial_inplace */
   2190 	 0x0000ffff,		/* src_mask */
   2191 	 0x0000ffff,		/* dst_mask */
   2192 	 FALSE),		/* pcrel_offset */
   2193 
   2194   /* Reference to global offset table.  */
   2195   HOWTO (R_MICROMIPS_GOT16,	/* type */
   2196 	 0,			/* rightshift */
   2197 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2198 	 16,			/* bitsize */
   2199 	 FALSE,			/* pc_relative */
   2200 	 0,			/* bitpos */
   2201 	 complain_overflow_signed, /* complain_on_overflow */
   2202 	 _bfd_mips_elf_got16_reloc, /* special_function */
   2203 	 "R_MICROMIPS_GOT16",	/* name */
   2204 	 TRUE,			/* partial_inplace */
   2205 	 0x0000ffff,		/* src_mask */
   2206 	 0x0000ffff,		/* dst_mask */
   2207 	 FALSE),		/* pcrel_offset */
   2208 
   2209   /* This is for microMIPS branches.  */
   2210   HOWTO (R_MICROMIPS_PC7_S1,	/* type */
   2211 	 1,			/* rightshift */
   2212 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
   2213 	 7,			/* bitsize */
   2214 	 TRUE,			/* pc_relative */
   2215 	 0,			/* bitpos */
   2216 	 complain_overflow_signed, /* complain_on_overflow */
   2217 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2218 	 "R_MICROMIPS_PC7_S1",	/* name */
   2219 	 TRUE,			/* partial_inplace */
   2220 	 0x0000007f,		/* src_mask */
   2221 	 0x0000007f,		/* dst_mask */
   2222 	 TRUE),			/* pcrel_offset */
   2223 
   2224   HOWTO (R_MICROMIPS_PC10_S1,	/* type */
   2225 	 1,			/* rightshift */
   2226 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
   2227 	 10,			/* bitsize */
   2228 	 TRUE,			/* pc_relative */
   2229 	 0,			/* bitpos */
   2230 	 complain_overflow_signed, /* complain_on_overflow */
   2231 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2232 	 "R_MICROMIPS_PC10_S1",	/* name */
   2233 	 TRUE,			/* partial_inplace */
   2234 	 0x000003ff,		/* src_mask */
   2235 	 0x000003ff,		/* dst_mask */
   2236 	 TRUE),			/* pcrel_offset */
   2237 
   2238   HOWTO (R_MICROMIPS_PC16_S1,	/* type */
   2239 	 1,			/* rightshift */
   2240 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2241 	 16,			/* bitsize */
   2242 	 TRUE,			/* pc_relative */
   2243 	 0,			/* bitpos */
   2244 	 complain_overflow_signed, /* complain_on_overflow */
   2245 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2246 	 "R_MICROMIPS_PC16_S1",	/* name */
   2247 	 TRUE,			/* partial_inplace */
   2248 	 0x0000ffff,		/* src_mask */
   2249 	 0x0000ffff,		/* dst_mask */
   2250 	 TRUE),			/* pcrel_offset */
   2251 
   2252   /* 16 bit call through global offset table.  */
   2253   HOWTO (R_MICROMIPS_CALL16,	/* type */
   2254 	 0,			/* rightshift */
   2255 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2256 	 16,			/* bitsize */
   2257 	 FALSE,			/* pc_relative */
   2258 	 0,			/* bitpos */
   2259 	 complain_overflow_signed, /* complain_on_overflow */
   2260 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2261 	 "R_MICROMIPS_CALL16",	/* name */
   2262 	 TRUE,			/* partial_inplace */
   2263 	 0x0000ffff,		/* src_mask */
   2264 	 0x0000ffff,		/* dst_mask */
   2265 	 FALSE),		/* pcrel_offset */
   2266 
   2267   EMPTY_HOWTO (143),
   2268   EMPTY_HOWTO (144),
   2269 
   2270   /* Displacement in the global offset table.  */
   2271   HOWTO (R_MICROMIPS_GOT_DISP,	/* type */
   2272 	 0,			/* rightshift */
   2273 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2274 	 16,			/* bitsize */
   2275 	 FALSE,			/* pc_relative */
   2276 	 0,			/* bitpos */
   2277 	 complain_overflow_signed, /* complain_on_overflow */
   2278 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2279 	 "R_MICROMIPS_GOT_DISP",/* name */
   2280 	 TRUE,			/* partial_inplace */
   2281 	 0x0000ffff,		/* src_mask */
   2282 	 0x0000ffff,		/* dst_mask */
   2283 	 FALSE),		/* pcrel_offset */
   2284 
   2285   /* Displacement to page pointer in the global offset table.  */
   2286   HOWTO (R_MICROMIPS_GOT_PAGE,	/* type */
   2287 	 0,			/* rightshift */
   2288 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2289 	 16,			/* bitsize */
   2290 	 FALSE,			/* pc_relative */
   2291 	 0,			/* bitpos */
   2292 	 complain_overflow_signed, /* complain_on_overflow */
   2293 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2294 	 "R_MICROMIPS_GOT_PAGE",/* name */
   2295 	 TRUE,			/* partial_inplace */
   2296 	 0x0000ffff,		/* src_mask */
   2297 	 0x0000ffff,		/* dst_mask */
   2298 	 FALSE),		/* pcrel_offset */
   2299 
   2300   /* Offset from page pointer in the global offset table.  */
   2301   HOWTO (R_MICROMIPS_GOT_OFST,	/* type */
   2302 	 0,			/* rightshift */
   2303 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2304 	 16,			/* bitsize */
   2305 	 FALSE,			/* pc_relative */
   2306 	 0,			/* bitpos */
   2307 	 complain_overflow_signed, /* complain_on_overflow */
   2308 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2309 	 "R_MICROMIPS_GOT_OFST",/* name */
   2310 	 TRUE,			/* partial_inplace */
   2311 	 0x0000ffff,		/* src_mask */
   2312 	 0x0000ffff,		/* dst_mask */
   2313 	 FALSE),		/* pcrel_offset */
   2314 
   2315   /* High 16 bits of displacement in global offset table.  */
   2316   HOWTO (R_MICROMIPS_GOT_HI16,	/* type */
   2317 	 0,			/* rightshift */
   2318 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2319 	 16,			/* bitsize */
   2320 	 FALSE,			/* pc_relative */
   2321 	 0,			/* bitpos */
   2322 	 complain_overflow_dont, /* complain_on_overflow */
   2323 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2324 	 "R_MICROMIPS_GOT_HI16",/* name */
   2325 	 TRUE,			/* partial_inplace */
   2326 	 0x0000ffff,		/* src_mask */
   2327 	 0x0000ffff,		/* dst_mask */
   2328 	 FALSE),		/* pcrel_offset */
   2329 
   2330   /* Low 16 bits of displacement in global offset table.  */
   2331   HOWTO (R_MICROMIPS_GOT_LO16,	/* type */
   2332 	 0,			/* rightshift */
   2333 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2334 	 16,			/* bitsize */
   2335 	 FALSE,			/* pc_relative */
   2336 	 0,			/* bitpos */
   2337 	 complain_overflow_dont, /* complain_on_overflow */
   2338 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2339 	 "R_MICROMIPS_GOT_LO16",/* name */
   2340 	 TRUE,			/* partial_inplace */
   2341 	 0x0000ffff,		/* src_mask */
   2342 	 0x0000ffff,		/* dst_mask */
   2343 	 FALSE),		/* pcrel_offset */
   2344 
   2345   /* 64 bit subtraction.  Used in the N32 ABI.  */
   2346   HOWTO (R_MICROMIPS_SUB,	/* type */
   2347 	 0,			/* rightshift */
   2348 	 4,			/* size (0 = byte, 1 = short, 2 = long) */
   2349 	 64,			/* bitsize */
   2350 	 FALSE,			/* pc_relative */
   2351 	 0,			/* bitpos */
   2352 	 complain_overflow_dont, /* complain_on_overflow */
   2353 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2354 	 "R_MICROMIPS_SUB",	/* name */
   2355 	 TRUE,			/* partial_inplace */
   2356 	 MINUS_ONE,		/* src_mask */
   2357 	 MINUS_ONE,		/* dst_mask */
   2358 	 FALSE),		/* pcrel_offset */
   2359 
   2360   /* We don't support these for REL relocations, because it means building
   2361      the addend from a R_MICROMIPS_HIGHEST/R_MICROMIPS_HIGHER/
   2362      R_MICROMIPS_HI16/R_MICROMIPS_LO16 sequence with varying ordering,
   2363      using fallable heuristics.  */
   2364   EMPTY_HOWTO (R_MICROMIPS_HIGHER),
   2365   EMPTY_HOWTO (R_MICROMIPS_HIGHEST),
   2366 
   2367   /* High 16 bits of displacement in global offset table.  */
   2368   HOWTO (R_MICROMIPS_CALL_HI16,	/* type */
   2369 	 0,			/* rightshift */
   2370 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2371 	 16,			/* bitsize */
   2372 	 FALSE,			/* pc_relative */
   2373 	 0,			/* bitpos */
   2374 	 complain_overflow_dont, /* complain_on_overflow */
   2375 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2376 	 "R_MICROMIPS_CALL_HI16",/* name */
   2377 	 TRUE,			/* partial_inplace */
   2378 	 0x0000ffff,		/* src_mask */
   2379 	 0x0000ffff,		/* dst_mask */
   2380 	 FALSE),		/* pcrel_offset */
   2381 
   2382   /* Low 16 bits of displacement in global offset table.  */
   2383   HOWTO (R_MICROMIPS_CALL_LO16,	/* type */
   2384 	 0,			/* rightshift */
   2385 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2386 	 16,			/* bitsize */
   2387 	 FALSE,			/* pc_relative */
   2388 	 0,			/* bitpos */
   2389 	 complain_overflow_dont, /* complain_on_overflow */
   2390 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2391 	 "R_MICROMIPS_CALL_LO16",/* name */
   2392 	 TRUE,			/* partial_inplace */
   2393 	 0x0000ffff,		/* src_mask */
   2394 	 0x0000ffff,		/* dst_mask */
   2395 	 FALSE),		/* pcrel_offset */
   2396 
   2397   /* Section displacement.  */
   2398   HOWTO (R_MICROMIPS_SCN_DISP,  /* type */
   2399 	 0,			/* rightshift */
   2400 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2401 	 32,			/* bitsize */
   2402 	 FALSE,			/* pc_relative */
   2403 	 0,			/* bitpos */
   2404 	 complain_overflow_dont, /* complain_on_overflow */
   2405 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2406 	 "R_MICROMIPS_SCN_DISP", /* name */
   2407 	 TRUE,			/* partial_inplace */
   2408 	 0xffffffff,		/* src_mask */
   2409 	 0xffffffff,		/* dst_mask */
   2410 	 FALSE),		/* pcrel_offset */
   2411 
   2412   /* Protected jump conversion.  This is an optimization hint.  No
   2413      relocation is required for correctness.  */
   2414   HOWTO (R_MICROMIPS_JALR,	/* type */
   2415 	 0,			/* rightshift */
   2416 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2417 	 32,			/* bitsize */
   2418 	 FALSE,			/* pc_relative */
   2419 	 0,			/* bitpos */
   2420 	 complain_overflow_dont, /* complain_on_overflow */
   2421 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2422 	 "R_MICROMIPS_JALR",	/* name */
   2423 	 FALSE,			/* partial_inplace */
   2424 	 0,			/* src_mask */
   2425 	 0x00000000,		/* dst_mask */
   2426 	 FALSE),		/* pcrel_offset */
   2427 };
   2428 
   2429 static reloc_howto_type micromips_elf64_howto_table_rela[] =
   2430 {
   2431   EMPTY_HOWTO (130),
   2432   EMPTY_HOWTO (131),
   2433   EMPTY_HOWTO (132),
   2434 
   2435   /* 26 bit jump address.  */
   2436   HOWTO (R_MICROMIPS_26_S1,	/* type */
   2437 	 1,			/* rightshift */
   2438 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2439 	 26,			/* bitsize */
   2440 	 FALSE,			/* pc_relative */
   2441 	 0,			/* bitpos */
   2442 	 complain_overflow_dont, /* complain_on_overflow */
   2443 				/* This needs complex overflow
   2444 				   detection, because the upper four
   2445 				   bits must match the PC.  */
   2446 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2447 	 "R_MICROMIPS_26_S1",	/* name */
   2448 	 FALSE,			/* partial_inplace */
   2449 	 0,			/* src_mask */
   2450 	 0x3ffffff,		/* dst_mask */
   2451 	 FALSE),		/* pcrel_offset */
   2452 
   2453   /* High 16 bits of symbol value.  */
   2454   HOWTO (R_MICROMIPS_HI16,	/* type */
   2455 	 16,			/* rightshift */
   2456 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2457 	 16,			/* bitsize */
   2458 	 FALSE,			/* pc_relative */
   2459 	 0,			/* bitpos */
   2460 	 complain_overflow_dont, /* complain_on_overflow */
   2461 	 _bfd_mips_elf_hi16_reloc, /* special_function */
   2462 	 "R_MICROMIPS_HI16",	/* name */
   2463 	 FALSE,			/* partial_inplace */
   2464 	 0,			/* src_mask */
   2465 	 0x0000ffff,		/* dst_mask */
   2466 	 FALSE),		/* pcrel_offset */
   2467 
   2468   /* Low 16 bits of symbol value.  */
   2469   HOWTO (R_MICROMIPS_LO16,	/* type */
   2470 	 0,			/* rightshift */
   2471 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2472 	 16,			/* bitsize */
   2473 	 FALSE,			/* pc_relative */
   2474 	 0,			/* bitpos */
   2475 	 complain_overflow_dont, /* complain_on_overflow */
   2476 	 _bfd_mips_elf_lo16_reloc, /* special_function */
   2477 	 "R_MICROMIPS_LO16",	/* name */
   2478 	 FALSE,			/* partial_inplace */
   2479 	 0,			/* src_mask */
   2480 	 0x0000ffff,		/* dst_mask */
   2481 	 FALSE),		/* pcrel_offset */
   2482 
   2483   /* GP relative reference.  */
   2484   HOWTO (R_MICROMIPS_GPREL16,	/* type */
   2485 	 0,			/* rightshift */
   2486 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2487 	 16,			/* bitsize */
   2488 	 FALSE,			/* pc_relative */
   2489 	 0,			/* bitpos */
   2490 	 complain_overflow_signed, /* complain_on_overflow */
   2491 	 _bfd_mips_elf32_gprel16_reloc, /* special_function */
   2492 	 "R_MICROMIPS_GPREL16",	/* name */
   2493 	 FALSE,			/* partial_inplace */
   2494 	 0,			/* src_mask */
   2495 	 0x0000ffff,		/* dst_mask */
   2496 	 FALSE),		/* pcrel_offset */
   2497 
   2498   /* Reference to literal section.  */
   2499   HOWTO (R_MICROMIPS_LITERAL,	/* type */
   2500 	 0,			/* rightshift */
   2501 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2502 	 16,			/* bitsize */
   2503 	 FALSE,			/* pc_relative */
   2504 	 0,			/* bitpos */
   2505 	 complain_overflow_signed, /* complain_on_overflow */
   2506 	 _bfd_mips_elf32_gprel16_reloc, /* special_function */
   2507 	 "R_MICROMIPS_LITERAL",	/* name */
   2508 	 FALSE,			/* partial_inplace */
   2509 	 0,			/* src_mask */
   2510 	 0x0000ffff,		/* dst_mask */
   2511 	 FALSE),		/* pcrel_offset */
   2512 
   2513   /* Reference to global offset table.  */
   2514   HOWTO (R_MICROMIPS_GOT16,	/* type */
   2515 	 0,			/* rightshift */
   2516 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2517 	 16,			/* bitsize */
   2518 	 FALSE,			/* pc_relative */
   2519 	 0,			/* bitpos */
   2520 	 complain_overflow_signed, /* complain_on_overflow */
   2521 	 _bfd_mips_elf_got16_reloc, /* special_function */
   2522 	 "R_MICROMIPS_GOT16",	/* name */
   2523 	 FALSE,			/* partial_inplace */
   2524 	 0,			/* src_mask */
   2525 	 0x0000ffff,		/* dst_mask */
   2526 	 FALSE),		/* pcrel_offset */
   2527 
   2528   /* This is for microMIPS branches.  */
   2529   HOWTO (R_MICROMIPS_PC7_S1,	/* type */
   2530 	 1,			/* rightshift */
   2531 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
   2532 	 7,			/* bitsize */
   2533 	 TRUE,			/* pc_relative */
   2534 	 0,			/* bitpos */
   2535 	 complain_overflow_signed, /* complain_on_overflow */
   2536 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2537 	 "R_MICROMIPS_PC7_S1",	/* name */
   2538 	 FALSE,			/* partial_inplace */
   2539 	 0,			/* src_mask */
   2540 	 0x0000007f,		/* dst_mask */
   2541 	 TRUE),			/* pcrel_offset */
   2542 
   2543   HOWTO (R_MICROMIPS_PC10_S1,	/* type */
   2544 	 1,			/* rightshift */
   2545 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
   2546 	 10,			/* bitsize */
   2547 	 TRUE,			/* pc_relative */
   2548 	 0,			/* bitpos */
   2549 	 complain_overflow_signed, /* complain_on_overflow */
   2550 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2551 	 "R_MICROMIPS_PC10_S1",	/* name */
   2552 	 FALSE,			/* partial_inplace */
   2553 	 0,			/* src_mask */
   2554 	 0x000003ff,		/* dst_mask */
   2555 	 TRUE),			/* pcrel_offset */
   2556 
   2557   HOWTO (R_MICROMIPS_PC16_S1,	/* type */
   2558 	 1,			/* rightshift */
   2559 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2560 	 16,			/* bitsize */
   2561 	 TRUE,			/* pc_relative */
   2562 	 0,			/* bitpos */
   2563 	 complain_overflow_signed, /* complain_on_overflow */
   2564 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2565 	 "R_MICROMIPS_PC16_S1",	/* name */
   2566 	 FALSE,			/* partial_inplace */
   2567 	 0,			/* src_mask */
   2568 	 0x0000ffff,		/* dst_mask */
   2569 	 TRUE),			/* pcrel_offset */
   2570 
   2571   /* 16 bit call through global offset table.  */
   2572   HOWTO (R_MICROMIPS_CALL16,	/* type */
   2573 	 0,			/* rightshift */
   2574 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2575 	 16,			/* bitsize */
   2576 	 FALSE,			/* pc_relative */
   2577 	 0,			/* bitpos */
   2578 	 complain_overflow_signed, /* complain_on_overflow */
   2579 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2580 	 "R_MICROMIPS_CALL16",	/* name */
   2581 	 FALSE,			/* partial_inplace */
   2582 	 0,			/* src_mask */
   2583 	 0x0000ffff,		/* dst_mask */
   2584 	 FALSE),		/* pcrel_offset */
   2585 
   2586   EMPTY_HOWTO (143),
   2587   EMPTY_HOWTO (144),
   2588 
   2589   /* Displacement in the global offset table.  */
   2590   HOWTO (R_MICROMIPS_GOT_DISP,	/* type */
   2591 	 0,			/* rightshift */
   2592 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2593 	 16,			/* bitsize */
   2594 	 FALSE,			/* pc_relative */
   2595 	 0,			/* bitpos */
   2596 	 complain_overflow_signed, /* complain_on_overflow */
   2597 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2598 	 "R_MICROMIPS_GOT_DISP",/* name */
   2599 	 FALSE,			/* partial_inplace */
   2600 	 0,			/* src_mask */
   2601 	 0x0000ffff,		/* dst_mask */
   2602 	 FALSE),		/* pcrel_offset */
   2603 
   2604   /* Displacement to page pointer in the global offset table.  */
   2605   HOWTO (R_MICROMIPS_GOT_PAGE,	/* type */
   2606 	 0,			/* rightshift */
   2607 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2608 	 16,			/* bitsize */
   2609 	 FALSE,			/* pc_relative */
   2610 	 0,			/* bitpos */
   2611 	 complain_overflow_signed, /* complain_on_overflow */
   2612 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2613 	 "R_MICROMIPS_GOT_PAGE",/* name */
   2614 	 FALSE,			/* partial_inplace */
   2615 	 0,			/* src_mask */
   2616 	 0x0000ffff,		/* dst_mask */
   2617 	 FALSE),		/* pcrel_offset */
   2618 
   2619   /* Offset from page pointer in the global offset table.  */
   2620   HOWTO (R_MICROMIPS_GOT_OFST,	/* type */
   2621 	 0,			/* rightshift */
   2622 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2623 	 16,			/* bitsize */
   2624 	 FALSE,			/* pc_relative */
   2625 	 0,			/* bitpos */
   2626 	 complain_overflow_signed, /* complain_on_overflow */
   2627 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2628 	 "R_MICROMIPS_GOT_OFST",/* name */
   2629 	 FALSE,			/* partial_inplace */
   2630 	 0,			/* src_mask */
   2631 	 0x0000ffff,		/* dst_mask */
   2632 	 FALSE),		/* pcrel_offset */
   2633 
   2634   /* High 16 bits of displacement in global offset table.  */
   2635   HOWTO (R_MICROMIPS_GOT_HI16,	/* type */
   2636 	 0,			/* rightshift */
   2637 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2638 	 16,			/* bitsize */
   2639 	 FALSE,			/* pc_relative */
   2640 	 0,			/* bitpos */
   2641 	 complain_overflow_dont, /* complain_on_overflow */
   2642 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2643 	 "R_MICROMIPS_GOT_HI16",/* name */
   2644 	 FALSE,			/* partial_inplace */
   2645 	 0,			/* src_mask */
   2646 	 0x0000ffff,		/* dst_mask */
   2647 	 FALSE),		/* pcrel_offset */
   2648 
   2649   /* Low 16 bits of displacement in global offset table.  */
   2650   HOWTO (R_MICROMIPS_GOT_LO16,	/* type */
   2651 	 0,			/* rightshift */
   2652 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2653 	 16,			/* bitsize */
   2654 	 FALSE,			/* pc_relative */
   2655 	 0,			/* bitpos */
   2656 	 complain_overflow_dont, /* complain_on_overflow */
   2657 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2658 	 "R_MICROMIPS_GOT_LO16",/* name */
   2659 	 FALSE,			/* partial_inplace */
   2660 	 0,			/* src_mask */
   2661 	 0x0000ffff,		/* dst_mask */
   2662 	 FALSE),		/* pcrel_offset */
   2663 
   2664   /* 64 bit subtraction.  Used in the N32 ABI.  */
   2665   HOWTO (R_MICROMIPS_SUB,	/* type */
   2666 	 0,			/* rightshift */
   2667 	 4,			/* size (0 = byte, 1 = short, 2 = long) */
   2668 	 64,			/* bitsize */
   2669 	 FALSE,			/* pc_relative */
   2670 	 0,			/* bitpos */
   2671 	 complain_overflow_dont, /* complain_on_overflow */
   2672 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2673 	 "R_MICROMIPS_SUB",	/* name */
   2674 	 FALSE,			/* partial_inplace */
   2675 	 0,			/* src_mask */
   2676 	 MINUS_ONE,		/* dst_mask */
   2677 	 FALSE),		/* pcrel_offset */
   2678 
   2679   /* Get the higher value of a 64 bit addend.  */
   2680   HOWTO (R_MICROMIPS_HIGHER,	/* type */
   2681 	 0,			/* rightshift */
   2682 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2683 	 16,			/* bitsize */
   2684 	 FALSE,			/* pc_relative */
   2685 	 0,			/* bitpos */
   2686 	 complain_overflow_dont, /* complain_on_overflow */
   2687 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2688 	 "R_MICROMIPS_HIGHER",	/* name */
   2689 	 FALSE,			/* partial_inplace */
   2690 	 0,			/* src_mask */
   2691 	 0x0000ffff,		/* dst_mask */
   2692 	 FALSE),		/* pcrel_offset */
   2693 
   2694   /* Get the highest value of a 64 bit addend.  */
   2695   HOWTO (R_MICROMIPS_HIGHEST,	/* type */
   2696 	 0,			/* rightshift */
   2697 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2698 	 16,			/* bitsize */
   2699 	 FALSE,			/* pc_relative */
   2700 	 0,			/* bitpos */
   2701 	 complain_overflow_dont, /* complain_on_overflow */
   2702 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2703 	 "R_MICROMIPS_HIGHEST",	/* name */
   2704 	 FALSE,			/* partial_inplace */
   2705 	 0,			/* src_mask */
   2706 	 0x0000ffff,		/* dst_mask */
   2707 	 FALSE),		/* pcrel_offset */
   2708 
   2709   /* High 16 bits of displacement in global offset table.  */
   2710   HOWTO (R_MICROMIPS_CALL_HI16,	/* type */
   2711 	 0,			/* rightshift */
   2712 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2713 	 16,			/* bitsize */
   2714 	 FALSE,			/* pc_relative */
   2715 	 0,			/* bitpos */
   2716 	 complain_overflow_dont, /* complain_on_overflow */
   2717 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2718 	 "R_MICROMIPS_CALL_HI16",/* name */
   2719 	 FALSE,			/* partial_inplace */
   2720 	 0,			/* src_mask */
   2721 	 0x0000ffff,		/* dst_mask */
   2722 	 FALSE),		/* pcrel_offset */
   2723 
   2724   /* Low 16 bits of displacement in global offset table.  */
   2725   HOWTO (R_MICROMIPS_CALL_LO16,	/* type */
   2726 	 0,			/* rightshift */
   2727 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2728 	 16,			/* bitsize */
   2729 	 FALSE,			/* pc_relative */
   2730 	 0,			/* bitpos */
   2731 	 complain_overflow_dont, /* complain_on_overflow */
   2732 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2733 	 "R_MICROMIPS_CALL_LO16",/* name */
   2734 	 FALSE,			/* partial_inplace */
   2735 	 0,			/* src_mask */
   2736 	 0x0000ffff,		/* dst_mask */
   2737 	 FALSE),		/* pcrel_offset */
   2738 
   2739   /* Section displacement.  */
   2740   HOWTO (R_MICROMIPS_SCN_DISP,  /* type */
   2741 	 0,			/* rightshift */
   2742 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2743 	 32,			/* bitsize */
   2744 	 FALSE,			/* pc_relative */
   2745 	 0,			/* bitpos */
   2746 	 complain_overflow_dont, /* complain_on_overflow */
   2747 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2748 	 "R_MICROMIPS_SCN_DISP", /* name */
   2749 	 FALSE,			/* partial_inplace */
   2750 	 0,			/* src_mask */
   2751 	 0xffffffff,		/* dst_mask */
   2752 	 FALSE),		/* pcrel_offset */
   2753 
   2754   /* Protected jump conversion.  This is an optimization hint.  No
   2755      relocation is required for correctness.  */
   2756   HOWTO (R_MICROMIPS_JALR,	/* type */
   2757 	 0,			/* rightshift */
   2758 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2759 	 32,			/* bitsize */
   2760 	 FALSE,			/* pc_relative */
   2761 	 0,			/* bitpos */
   2762 	 complain_overflow_dont, /* complain_on_overflow */
   2763 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2764 	 "R_MICROMIPS_JALR",	/* name */
   2765 	 FALSE,			/* partial_inplace */
   2766 	 0,			/* src_mask */
   2767 	 0x00000000,		/* dst_mask */
   2768 	 FALSE),		/* pcrel_offset */
   2769 };
   2770 
   2771 /* GNU extension to record C++ vtable hierarchy */
   2772 static reloc_howto_type elf_mips_gnu_vtinherit_howto =
   2773   HOWTO (R_MIPS_GNU_VTINHERIT,	/* type */
   2774 	 0,			/* rightshift */
   2775 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2776 	 0,			/* bitsize */
   2777 	 FALSE,			/* pc_relative */
   2778 	 0,			/* bitpos */
   2779 	 complain_overflow_dont, /* complain_on_overflow */
   2780 	 NULL,			/* special_function */
   2781 	 "R_MIPS_GNU_VTINHERIT", /* name */
   2782 	 FALSE,			/* partial_inplace */
   2783 	 0,			/* src_mask */
   2784 	 0,			/* dst_mask */
   2785 	 FALSE);		/* pcrel_offset */
   2786 
   2787 /* GNU extension to record C++ vtable member usage */
   2788 static reloc_howto_type elf_mips_gnu_vtentry_howto =
   2789   HOWTO (R_MIPS_GNU_VTENTRY,	/* type */
   2790 	 0,			/* rightshift */
   2791 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2792 	 0,			/* bitsize */
   2793 	 FALSE,			/* pc_relative */
   2794 	 0,			/* bitpos */
   2795 	 complain_overflow_dont, /* complain_on_overflow */
   2796 	 _bfd_elf_rel_vtable_reloc_fn, /* special_function */
   2797 	 "R_MIPS_GNU_VTENTRY",	/* name */
   2798 	 FALSE,			/* partial_inplace */
   2799 	 0,			/* src_mask */
   2800 	 0,			/* dst_mask */
   2801 	 FALSE);		/* pcrel_offset */
   2802 
   2803 /* 16 bit offset for pc-relative branches.  */
   2805 static reloc_howto_type elf_mips_gnu_rel16_s2 =
   2806   HOWTO (R_MIPS_GNU_REL16_S2,	/* type */
   2807 	 2,			/* rightshift */
   2808 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2809 	 16,			/* bitsize */
   2810 	 TRUE,			/* pc_relative */
   2811 	 0,			/* bitpos */
   2812 	 complain_overflow_signed, /* complain_on_overflow */
   2813 	 _bfd_mips_elf_generic_reloc,	/* special_function */
   2814 	 "R_MIPS_GNU_REL16_S2",	/* name */
   2815 	 TRUE,			/* partial_inplace */
   2816 	 0x0000ffff,		/* src_mask */
   2817 	 0x0000ffff,		/* dst_mask */
   2818 	 TRUE);			/* pcrel_offset */
   2819 
   2820 /* 16 bit offset for pc-relative branches.  */
   2821 static reloc_howto_type elf_mips_gnu_rela16_s2 =
   2822   HOWTO (R_MIPS_GNU_REL16_S2,	/* type */
   2823 	 2,			/* rightshift */
   2824 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2825 	 16,			/* bitsize */
   2826 	 TRUE,			/* pc_relative */
   2827 	 0,			/* bitpos */
   2828 	 complain_overflow_signed, /* complain_on_overflow */
   2829 	 _bfd_mips_elf_generic_reloc,	/* special_function */
   2830 	 "R_MIPS_GNU_REL16_S2",	/* name */
   2831 	 FALSE,			/* partial_inplace */
   2832 	 0,			/* src_mask */
   2833 	 0x0000ffff,		/* dst_mask */
   2834 	 TRUE);			/* pcrel_offset */
   2835 
   2836 /* 32 bit pc-relative.  Used for compact EH tables.  */
   2837 static reloc_howto_type elf_mips_gnu_pcrel32 =
   2838   HOWTO (R_MIPS_PC32,		/* type */
   2839 	 0,			/* rightshift */
   2840 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2841 	 32,			/* bitsize */
   2842 	 TRUE,			/* pc_relative */
   2843 	 0,			/* bitpos */
   2844 	 complain_overflow_signed, /* complain_on_overflow */
   2845 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2846 	 "R_MIPS_PC32",		/* name */
   2847 	 TRUE,			/* partial_inplace */
   2848 	 0xffffffff,		/* src_mask */
   2849 	 0xffffffff,		/* dst_mask */
   2850 	 TRUE);			/* pcrel_offset */
   2851 
   2852 
   2853 /* Originally a VxWorks extension, but now used for other systems too.  */
   2855 static reloc_howto_type elf_mips_copy_howto =
   2856   HOWTO (R_MIPS_COPY,		/* type */
   2857 	 0,			/* rightshift */
   2858 	 0,			/* this one is variable size */
   2859 	 0,			/* bitsize */
   2860 	 FALSE,			/* pc_relative */
   2861 	 0,			/* bitpos */
   2862 	 complain_overflow_bitfield, /* complain_on_overflow */
   2863 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2864 	 "R_MIPS_COPY",		/* name */
   2865 	 FALSE,			/* partial_inplace */
   2866 	 0x0,			/* src_mask */
   2867 	 0x0,			/* dst_mask */
   2868 	 FALSE);		/* pcrel_offset */
   2869 
   2870 /* Originally a VxWorks extension, but now used for other systems too.  */
   2871 static reloc_howto_type elf_mips_jump_slot_howto =
   2872   HOWTO (R_MIPS_JUMP_SLOT,	/* type */
   2873 	 0,			/* rightshift */
   2874 	 4,			/* size (0 = byte, 1 = short, 2 = long) */
   2875 	 64,			/* bitsize */
   2876 	 FALSE,			/* pc_relative */
   2877 	 0,			/* bitpos */
   2878 	 complain_overflow_bitfield, /* complain_on_overflow */
   2879 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2880 	 "R_MIPS_JUMP_SLOT",	/* name */
   2881 	 FALSE,			/* partial_inplace */
   2882 	 0x0,			/* src_mask */
   2883 	 0x0,			/* dst_mask */
   2884 	 FALSE);		/* pcrel_offset */
   2885 
   2886 /* Used in EH tables.  */
   2887 static reloc_howto_type elf_mips_eh_howto =
   2888   HOWTO (R_MIPS_EH,		/* type */
   2889 	 0,			/* rightshift */
   2890 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2891 	 32,			/* bitsize */
   2892 	 FALSE,			/* pc_relative */
   2893 	 0,			/* bitpos */
   2894 	 complain_overflow_signed, /* complain_on_overflow */
   2895 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2896 	 "R_MIPS_EH",		/* name */
   2897 	 TRUE,			/* partial_inplace */
   2898 	 0xffffffff,		/* src_mask */
   2899 	 0xffffffff,		/* dst_mask */
   2900 	 FALSE);		/* pcrel_offset */
   2901 
   2902 
   2903 /* Swap in a MIPS 64-bit Rel reloc.  */
   2905 
   2906 static void
   2907 mips_elf64_swap_reloc_in (bfd *abfd, const Elf64_Mips_External_Rel *src,
   2908 			  Elf64_Mips_Internal_Rela *dst)
   2909 {
   2910   dst->r_offset = H_GET_64 (abfd, src->r_offset);
   2911   dst->r_sym = H_GET_32 (abfd, src->r_sym);
   2912   dst->r_ssym = H_GET_8 (abfd, src->r_ssym);
   2913   dst->r_type3 = H_GET_8 (abfd, src->r_type3);
   2914   dst->r_type2 = H_GET_8 (abfd, src->r_type2);
   2915   dst->r_type = H_GET_8 (abfd, src->r_type);
   2916   dst->r_addend = 0;
   2917 }
   2918 
   2919 /* Swap in a MIPS 64-bit Rela reloc.  */
   2920 
   2921 static void
   2922 mips_elf64_swap_reloca_in (bfd *abfd, const Elf64_Mips_External_Rela *src,
   2923 			   Elf64_Mips_Internal_Rela *dst)
   2924 {
   2925   dst->r_offset = H_GET_64 (abfd, src->r_offset);
   2926   dst->r_sym = H_GET_32 (abfd, src->r_sym);
   2927   dst->r_ssym = H_GET_8 (abfd, src->r_ssym);
   2928   dst->r_type3 = H_GET_8 (abfd, src->r_type3);
   2929   dst->r_type2 = H_GET_8 (abfd, src->r_type2);
   2930   dst->r_type = H_GET_8 (abfd, src->r_type);
   2931   dst->r_addend = H_GET_S64 (abfd, src->r_addend);
   2932 }
   2933 
   2934 /* Swap out a MIPS 64-bit Rel reloc.  */
   2935 
   2936 static void
   2937 mips_elf64_swap_reloc_out (bfd *abfd, const Elf64_Mips_Internal_Rela *src,
   2938 			   Elf64_Mips_External_Rel *dst)
   2939 {
   2940   H_PUT_64 (abfd, src->r_offset, dst->r_offset);
   2941   H_PUT_32 (abfd, src->r_sym, dst->r_sym);
   2942   H_PUT_8 (abfd, src->r_ssym, dst->r_ssym);
   2943   H_PUT_8 (abfd, src->r_type3, dst->r_type3);
   2944   H_PUT_8 (abfd, src->r_type2, dst->r_type2);
   2945   H_PUT_8 (abfd, src->r_type, dst->r_type);
   2946 }
   2947 
   2948 /* Swap out a MIPS 64-bit Rela reloc.  */
   2949 
   2950 static void
   2951 mips_elf64_swap_reloca_out (bfd *abfd, const Elf64_Mips_Internal_Rela *src,
   2952 			    Elf64_Mips_External_Rela *dst)
   2953 {
   2954   H_PUT_64 (abfd, src->r_offset, dst->r_offset);
   2955   H_PUT_32 (abfd, src->r_sym, dst->r_sym);
   2956   H_PUT_8 (abfd, src->r_ssym, dst->r_ssym);
   2957   H_PUT_8 (abfd, src->r_type3, dst->r_type3);
   2958   H_PUT_8 (abfd, src->r_type2, dst->r_type2);
   2959   H_PUT_8 (abfd, src->r_type, dst->r_type);
   2960   H_PUT_S64 (abfd, src->r_addend, dst->r_addend);
   2961 }
   2962 
   2963 /* Swap in a MIPS 64-bit Rel reloc.  */
   2964 
   2965 static void
   2966 mips_elf64_be_swap_reloc_in (bfd *abfd, const bfd_byte *src,
   2967 			     Elf_Internal_Rela *dst)
   2968 {
   2969   Elf64_Mips_Internal_Rela mirel;
   2970 
   2971   mips_elf64_swap_reloc_in (abfd,
   2972 			    (const Elf64_Mips_External_Rel *) src,
   2973 			    &mirel);
   2974 
   2975   dst[0].r_offset = mirel.r_offset;
   2976   dst[0].r_info = ELF64_R_INFO (mirel.r_sym, mirel.r_type);
   2977   dst[0].r_addend = 0;
   2978   dst[1].r_offset = mirel.r_offset;
   2979   dst[1].r_info = ELF64_R_INFO (mirel.r_ssym, mirel.r_type2);
   2980   dst[1].r_addend = 0;
   2981   dst[2].r_offset = mirel.r_offset;
   2982   dst[2].r_info = ELF64_R_INFO (STN_UNDEF, mirel.r_type3);
   2983   dst[2].r_addend = 0;
   2984 }
   2985 
   2986 /* Swap in a MIPS 64-bit Rela reloc.  */
   2987 
   2988 static void
   2989 mips_elf64_be_swap_reloca_in (bfd *abfd, const bfd_byte *src,
   2990 			      Elf_Internal_Rela *dst)
   2991 {
   2992   Elf64_Mips_Internal_Rela mirela;
   2993 
   2994   mips_elf64_swap_reloca_in (abfd,
   2995 			     (const Elf64_Mips_External_Rela *) src,
   2996 			     &mirela);
   2997 
   2998   dst[0].r_offset = mirela.r_offset;
   2999   dst[0].r_info = ELF64_R_INFO (mirela.r_sym, mirela.r_type);
   3000   dst[0].r_addend = mirela.r_addend;
   3001   dst[1].r_offset = mirela.r_offset;
   3002   dst[1].r_info = ELF64_R_INFO (mirela.r_ssym, mirela.r_type2);
   3003   dst[1].r_addend = 0;
   3004   dst[2].r_offset = mirela.r_offset;
   3005   dst[2].r_info = ELF64_R_INFO (STN_UNDEF, mirela.r_type3);
   3006   dst[2].r_addend = 0;
   3007 }
   3008 
   3009 /* Swap out a MIPS 64-bit Rel reloc.  */
   3010 
   3011 static void
   3012 mips_elf64_be_swap_reloc_out (bfd *abfd, const Elf_Internal_Rela *src,
   3013 			      bfd_byte *dst)
   3014 {
   3015   Elf64_Mips_Internal_Rela mirel;
   3016 
   3017   mirel.r_offset = src[0].r_offset;
   3018   BFD_ASSERT(src[0].r_offset == src[1].r_offset);
   3019   BFD_ASSERT(src[0].r_offset == src[2].r_offset);
   3020 
   3021   mirel.r_type = ELF64_MIPS_R_TYPE (src[0].r_info);
   3022   mirel.r_sym = ELF64_R_SYM (src[0].r_info);
   3023   mirel.r_type2 = ELF64_MIPS_R_TYPE (src[1].r_info);
   3024   mirel.r_ssym = ELF64_MIPS_R_SSYM (src[1].r_info);
   3025   mirel.r_type3 = ELF64_MIPS_R_TYPE (src[2].r_info);
   3026 
   3027   mips_elf64_swap_reloc_out (abfd, &mirel,
   3028 			     (Elf64_Mips_External_Rel *) dst);
   3029 }
   3030 
   3031 /* Swap out a MIPS 64-bit Rela reloc.  */
   3032 
   3033 static void
   3034 mips_elf64_be_swap_reloca_out (bfd *abfd, const Elf_Internal_Rela *src,
   3035 			       bfd_byte *dst)
   3036 {
   3037   Elf64_Mips_Internal_Rela mirela;
   3038 
   3039   mirela.r_offset = src[0].r_offset;
   3040   BFD_ASSERT(src[0].r_offset == src[1].r_offset);
   3041   BFD_ASSERT(src[0].r_offset == src[2].r_offset);
   3042 
   3043   mirela.r_type = ELF64_MIPS_R_TYPE (src[0].r_info);
   3044   mirela.r_sym = ELF64_R_SYM (src[0].r_info);
   3045   mirela.r_addend = src[0].r_addend;
   3046   BFD_ASSERT(src[1].r_addend == 0);
   3047   BFD_ASSERT(src[2].r_addend == 0);
   3048 
   3049   mirela.r_type2 = ELF64_MIPS_R_TYPE (src[1].r_info);
   3050   mirela.r_ssym = ELF64_MIPS_R_SSYM (src[1].r_info);
   3051   mirela.r_type3 = ELF64_MIPS_R_TYPE (src[2].r_info);
   3052 
   3053   mips_elf64_swap_reloca_out (abfd, &mirela,
   3054 			      (Elf64_Mips_External_Rela *) dst);
   3055 }
   3056 
   3057 /* Set the GP value for OUTPUT_BFD.  Returns FALSE if this is a
   3059    dangerous relocation.  */
   3060 
   3061 static bfd_boolean
   3062 mips_elf64_assign_gp (bfd *output_bfd, bfd_vma *pgp)
   3063 {
   3064   unsigned int count;
   3065   asymbol **sym;
   3066   unsigned int i;
   3067 
   3068   /* If we've already figured out what GP will be, just return it.  */
   3069   *pgp = _bfd_get_gp_value (output_bfd);
   3070   if (*pgp)
   3071     return TRUE;
   3072 
   3073   count = bfd_get_symcount (output_bfd);
   3074   sym = bfd_get_outsymbols (output_bfd);
   3075 
   3076   /* The linker script will have created a symbol named `_gp' with the
   3077      appropriate value.  */
   3078   if (sym == NULL)
   3079     i = count;
   3080   else
   3081     {
   3082       for (i = 0; i < count; i++, sym++)
   3083 	{
   3084 	  register const char *name;
   3085 
   3086 	  name = bfd_asymbol_name (*sym);
   3087 	  if (*name == '_' && strcmp (name, "_gp") == 0)
   3088 	    {
   3089 	      *pgp = bfd_asymbol_value (*sym);
   3090 	      _bfd_set_gp_value (output_bfd, *pgp);
   3091 	      break;
   3092 	    }
   3093 	}
   3094     }
   3095 
   3096   if (i >= count)
   3097     {
   3098       /* Only get the error once.  */
   3099       *pgp = 4;
   3100       _bfd_set_gp_value (output_bfd, *pgp);
   3101       return FALSE;
   3102     }
   3103 
   3104   return TRUE;
   3105 }
   3106 
   3107 /* We have to figure out the gp value, so that we can adjust the
   3108    symbol value correctly.  We look up the symbol _gp in the output
   3109    BFD.  If we can't find it, we're stuck.  We cache it in the ELF
   3110    target data.  We don't need to adjust the symbol value for an
   3111    external symbol if we are producing relocatable output.  */
   3112 
   3113 static bfd_reloc_status_type
   3114 mips_elf64_final_gp (bfd *output_bfd, asymbol *symbol, bfd_boolean relocatable,
   3115 		     char **error_message, bfd_vma *pgp)
   3116 {
   3117   if (bfd_is_und_section (symbol->section)
   3118       && ! relocatable)
   3119     {
   3120       *pgp = 0;
   3121       return bfd_reloc_undefined;
   3122     }
   3123 
   3124   *pgp = _bfd_get_gp_value (output_bfd);
   3125   if (*pgp == 0
   3126       && (! relocatable
   3127 	  || (symbol->flags & BSF_SECTION_SYM) != 0))
   3128     {
   3129       if (relocatable)
   3130 	{
   3131 	  /* Make up a value.  */
   3132 	  *pgp = symbol->section->output_section->vma /*+ 0x4000*/;
   3133 	  _bfd_set_gp_value (output_bfd, *pgp);
   3134 	}
   3135       else if (!mips_elf64_assign_gp (output_bfd, pgp))
   3136 	{
   3137 	  *error_message =
   3138 	    (char *) _("GP relative relocation when _gp not defined");
   3139 	  return bfd_reloc_dangerous;
   3140 	}
   3141     }
   3142 
   3143   return bfd_reloc_ok;
   3144 }
   3145 
   3146 /* Do a R_MIPS_GPREL16 relocation.  This is a 16 bit value which must
   3147    become the offset from the gp register.  */
   3148 
   3149 static bfd_reloc_status_type
   3150 mips_elf64_gprel16_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
   3151 			  void *data, asection *input_section, bfd *output_bfd,
   3152 			  char **error_message)
   3153 {
   3154   bfd_boolean relocatable;
   3155   bfd_reloc_status_type ret;
   3156   bfd_vma gp;
   3157 
   3158   /* If we're relocating, and this is an external symbol, we don't want
   3159      to change anything.  */
   3160   if (output_bfd != NULL
   3161       && (symbol->flags & BSF_SECTION_SYM) == 0
   3162       && (symbol->flags & BSF_LOCAL) != 0)
   3163     {
   3164       reloc_entry->address += input_section->output_offset;
   3165       return bfd_reloc_ok;
   3166     }
   3167 
   3168   if (output_bfd != NULL)
   3169     relocatable = TRUE;
   3170   else
   3171     {
   3172       relocatable = FALSE;
   3173       output_bfd = symbol->section->output_section->owner;
   3174     }
   3175 
   3176   ret = mips_elf64_final_gp (output_bfd, symbol, relocatable, error_message,
   3177 			     &gp);
   3178   if (ret != bfd_reloc_ok)
   3179     return ret;
   3180 
   3181   return _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
   3182 					input_section, relocatable,
   3183 					data, gp);
   3184 }
   3185 
   3186 /* Do a R_MIPS_LITERAL relocation.  */
   3187 
   3188 static bfd_reloc_status_type
   3189 mips_elf64_literal_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
   3190 			  void *data, asection *input_section, bfd *output_bfd,
   3191 			  char **error_message)
   3192 {
   3193   bfd_boolean relocatable;
   3194   bfd_reloc_status_type ret;
   3195   bfd_vma gp;
   3196 
   3197   /* R_MIPS_LITERAL relocations are defined for local symbols only.  */
   3198   if (output_bfd != NULL
   3199       && (symbol->flags & BSF_SECTION_SYM) == 0
   3200       && (symbol->flags & BSF_LOCAL) != 0)
   3201     {
   3202       *error_message = (char *)
   3203 	_("literal relocation occurs for an external symbol");
   3204       return bfd_reloc_outofrange;
   3205     }
   3206 
   3207   /* FIXME: The entries in the .lit8 and .lit4 sections should be merged.  */
   3208   if (output_bfd != NULL)
   3209     relocatable = TRUE;
   3210   else
   3211     {
   3212       relocatable = FALSE;
   3213       output_bfd = symbol->section->output_section->owner;
   3214     }
   3215 
   3216   ret = mips_elf64_final_gp (output_bfd, symbol, relocatable, error_message,
   3217 			     &gp);
   3218   if (ret != bfd_reloc_ok)
   3219     return ret;
   3220 
   3221   return _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
   3222 					input_section, relocatable,
   3223 					data, gp);
   3224 }
   3225 
   3226 /* Do a R_MIPS_GPREL32 relocation.  This is a 32 bit value which must
   3227    become the offset from the gp register.  */
   3228 
   3229 static bfd_reloc_status_type
   3230 mips_elf64_gprel32_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
   3231 			  void *data, asection *input_section, bfd *output_bfd,
   3232 			  char **error_message)
   3233 {
   3234   bfd_boolean relocatable;
   3235   bfd_reloc_status_type ret;
   3236   bfd_vma gp;
   3237   bfd_vma relocation;
   3238   bfd_vma val;
   3239 
   3240   /* R_MIPS_GPREL32 relocations are defined for local symbols only.  */
   3241   if (output_bfd != NULL
   3242       && (symbol->flags & BSF_SECTION_SYM) == 0
   3243       && (symbol->flags & BSF_LOCAL) != 0)
   3244     {
   3245       *error_message = (char *)
   3246 	_("32bits gp relative relocation occurs for an external symbol");
   3247       return bfd_reloc_outofrange;
   3248     }
   3249 
   3250   if (output_bfd != NULL)
   3251     relocatable = TRUE;
   3252   else
   3253     {
   3254       relocatable = FALSE;
   3255       output_bfd = symbol->section->output_section->owner;
   3256     }
   3257 
   3258   ret = mips_elf64_final_gp (output_bfd, symbol, relocatable,
   3259 			     error_message, &gp);
   3260   if (ret != bfd_reloc_ok)
   3261     return ret;
   3262 
   3263   if (bfd_is_com_section (symbol->section))
   3264     relocation = 0;
   3265   else
   3266     relocation = symbol->value;
   3267 
   3268   relocation += symbol->section->output_section->vma;
   3269   relocation += symbol->section->output_offset;
   3270 
   3271   if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
   3272     return bfd_reloc_outofrange;
   3273 
   3274   /* Set val to the offset into the section or symbol.  */
   3275   val = reloc_entry->addend;
   3276 
   3277   if (reloc_entry->howto->partial_inplace)
   3278     val += bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
   3279 
   3280   /* Adjust val for the final section location and GP value.  If we
   3281      are producing relocatable output, we don't want to do this for
   3282      an external symbol.  */
   3283   if (! relocatable
   3284       || (symbol->flags & BSF_SECTION_SYM) != 0)
   3285     val += relocation - gp;
   3286 
   3287   if (reloc_entry->howto->partial_inplace)
   3288     bfd_put_32 (abfd, val, (bfd_byte *) data + reloc_entry->address);
   3289   else
   3290     reloc_entry->addend = val;
   3291 
   3292   if (relocatable)
   3293     reloc_entry->address += input_section->output_offset;
   3294 
   3295   return bfd_reloc_ok;
   3296 }
   3297 
   3298 /* Do a R_MIPS_SHIFT6 relocation. The MSB of the shift is stored at bit 2,
   3299    the rest is at bits 6-10. The bitpos already got right by the howto.  */
   3300 
   3301 static bfd_reloc_status_type
   3302 mips_elf64_shift6_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
   3303 			 void *data, asection *input_section, bfd *output_bfd,
   3304 			 char **error_message)
   3305 {
   3306   if (reloc_entry->howto->partial_inplace)
   3307     {
   3308       reloc_entry->addend = ((reloc_entry->addend & 0x00007c0)
   3309 			     | (reloc_entry->addend & 0x00000800) >> 9);
   3310     }
   3311 
   3312   return _bfd_mips_elf_generic_reloc (abfd, reloc_entry, symbol, data,
   3313 				      input_section, output_bfd,
   3314 				      error_message);
   3315 }
   3316 
   3317 /* Handle a mips16 GP relative reloc.  */
   3318 
   3319 static bfd_reloc_status_type
   3320 mips16_gprel_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
   3321 		    void *data, asection *input_section, bfd *output_bfd,
   3322 		    char **error_message)
   3323 {
   3324   bfd_boolean relocatable;
   3325   bfd_reloc_status_type ret;
   3326   bfd_byte *location;
   3327   bfd_vma gp;
   3328 
   3329   /* If we're relocating, and this is an external symbol, we don't want
   3330      to change anything.  */
   3331   if (output_bfd != NULL
   3332       && (symbol->flags & BSF_SECTION_SYM) == 0
   3333       && (symbol->flags & BSF_LOCAL) != 0)
   3334     {
   3335       reloc_entry->address += input_section->output_offset;
   3336       return bfd_reloc_ok;
   3337     }
   3338 
   3339   if (output_bfd != NULL)
   3340     relocatable = TRUE;
   3341   else
   3342     {
   3343       relocatable = FALSE;
   3344       output_bfd = symbol->section->output_section->owner;
   3345     }
   3346 
   3347   ret = mips_elf64_final_gp (output_bfd, symbol, relocatable, error_message,
   3348 			     &gp);
   3349   if (ret != bfd_reloc_ok)
   3350     return ret;
   3351 
   3352   location = (bfd_byte *) data + reloc_entry->address;
   3353   _bfd_mips_elf_reloc_unshuffle (abfd, reloc_entry->howto->type, FALSE,
   3354 				 location);
   3355   ret = _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
   3356 				       input_section, relocatable,
   3357 				       data, gp);
   3358   _bfd_mips_elf_reloc_shuffle (abfd, reloc_entry->howto->type, !relocatable,
   3359 			       location);
   3360 
   3361   return ret;
   3362 }
   3363 
   3364 /* A mapping from BFD reloc types to MIPS ELF reloc types.  */
   3366 
   3367 struct elf_reloc_map {
   3368   bfd_reloc_code_real_type bfd_val;
   3369   enum elf_mips_reloc_type elf_val;
   3370 };
   3371 
   3372 static const struct elf_reloc_map mips_reloc_map[] =
   3373 {
   3374   { BFD_RELOC_NONE, R_MIPS_NONE },
   3375   { BFD_RELOC_16, R_MIPS_16 },
   3376   { BFD_RELOC_32, R_MIPS_32 },
   3377   /* There is no BFD reloc for R_MIPS_REL32.  */
   3378   { BFD_RELOC_64, R_MIPS_64 },
   3379   { BFD_RELOC_CTOR, R_MIPS_64 },
   3380   { BFD_RELOC_16_PCREL_S2, R_MIPS_PC16 },
   3381   { BFD_RELOC_HI16_S, R_MIPS_HI16 },
   3382   { BFD_RELOC_LO16, R_MIPS_LO16 },
   3383   { BFD_RELOC_GPREL16, R_MIPS_GPREL16 },
   3384   { BFD_RELOC_GPREL32, R_MIPS_GPREL32 },
   3385   { BFD_RELOC_MIPS_JMP, R_MIPS_26 },
   3386   { BFD_RELOC_MIPS_LITERAL, R_MIPS_LITERAL },
   3387   { BFD_RELOC_MIPS_GOT16, R_MIPS_GOT16 },
   3388   { BFD_RELOC_MIPS_CALL16, R_MIPS_CALL16 },
   3389   { BFD_RELOC_MIPS_SHIFT5, R_MIPS_SHIFT5 },
   3390   { BFD_RELOC_MIPS_SHIFT6, R_MIPS_SHIFT6 },
   3391   { BFD_RELOC_MIPS_GOT_DISP, R_MIPS_GOT_DISP },
   3392   { BFD_RELOC_MIPS_GOT_PAGE, R_MIPS_GOT_PAGE },
   3393   { BFD_RELOC_MIPS_GOT_OFST, R_MIPS_GOT_OFST },
   3394   { BFD_RELOC_MIPS_GOT_HI16, R_MIPS_GOT_HI16 },
   3395   { BFD_RELOC_MIPS_GOT_LO16, R_MIPS_GOT_LO16 },
   3396   { BFD_RELOC_MIPS_SUB, R_MIPS_SUB },
   3397   { BFD_RELOC_MIPS_INSERT_A, R_MIPS_INSERT_A },
   3398   { BFD_RELOC_MIPS_INSERT_B, R_MIPS_INSERT_B },
   3399   { BFD_RELOC_MIPS_DELETE, R_MIPS_DELETE },
   3400   { BFD_RELOC_MIPS_HIGHEST, R_MIPS_HIGHEST },
   3401   { BFD_RELOC_MIPS_HIGHER, R_MIPS_HIGHER },
   3402   { BFD_RELOC_MIPS_CALL_HI16, R_MIPS_CALL_HI16 },
   3403   { BFD_RELOC_MIPS_CALL_LO16, R_MIPS_CALL_LO16 },
   3404   { BFD_RELOC_MIPS_SCN_DISP, R_MIPS_SCN_DISP },
   3405   { BFD_RELOC_MIPS_REL16, R_MIPS_REL16 },
   3406   /* Use of R_MIPS_ADD_IMMEDIATE and R_MIPS_PJUMP is deprecated.  */
   3407   { BFD_RELOC_MIPS_RELGOT, R_MIPS_RELGOT },
   3408   { BFD_RELOC_MIPS_JALR, R_MIPS_JALR },
   3409   { BFD_RELOC_MIPS_TLS_DTPMOD32, R_MIPS_TLS_DTPMOD32 },
   3410   { BFD_RELOC_MIPS_TLS_DTPREL32, R_MIPS_TLS_DTPREL32 },
   3411   { BFD_RELOC_MIPS_TLS_DTPMOD64, R_MIPS_TLS_DTPMOD64 },
   3412   { BFD_RELOC_MIPS_TLS_DTPREL64, R_MIPS_TLS_DTPREL64 },
   3413   { BFD_RELOC_MIPS_TLS_GD, R_MIPS_TLS_GD },
   3414   { BFD_RELOC_MIPS_TLS_LDM, R_MIPS_TLS_LDM },
   3415   { BFD_RELOC_MIPS_TLS_DTPREL_HI16, R_MIPS_TLS_DTPREL_HI16 },
   3416   { BFD_RELOC_MIPS_TLS_DTPREL_LO16, R_MIPS_TLS_DTPREL_LO16 },
   3417   { BFD_RELOC_MIPS_TLS_GOTTPREL, R_MIPS_TLS_GOTTPREL },
   3418   { BFD_RELOC_MIPS_TLS_TPREL32, R_MIPS_TLS_TPREL32 },
   3419   { BFD_RELOC_MIPS_TLS_TPREL64, R_MIPS_TLS_TPREL64 },
   3420   { BFD_RELOC_MIPS_TLS_TPREL_HI16, R_MIPS_TLS_TPREL_HI16 },
   3421   { BFD_RELOC_MIPS_TLS_TPREL_LO16, R_MIPS_TLS_TPREL_LO16 },
   3422   { BFD_RELOC_MIPS_21_PCREL_S2, R_MIPS_PC21_S2 },
   3423   { BFD_RELOC_MIPS_26_PCREL_S2, R_MIPS_PC26_S2 },
   3424   { BFD_RELOC_MIPS_18_PCREL_S3, R_MIPS_PC18_S3 },
   3425   { BFD_RELOC_MIPS_19_PCREL_S2, R_MIPS_PC19_S2 },
   3426   { BFD_RELOC_HI16_S_PCREL, R_MIPS_PCHI16 },
   3427   { BFD_RELOC_LO16_PCREL, R_MIPS_PCLO16 }
   3428 };
   3429 
   3430 static const struct elf_reloc_map mips16_reloc_map[] =
   3431 {
   3432   { BFD_RELOC_MIPS16_JMP, R_MIPS16_26 - R_MIPS16_min },
   3433   { BFD_RELOC_MIPS16_GPREL, R_MIPS16_GPREL - R_MIPS16_min },
   3434   { BFD_RELOC_MIPS16_GOT16, R_MIPS16_GOT16 - R_MIPS16_min },
   3435   { BFD_RELOC_MIPS16_CALL16, R_MIPS16_CALL16 - R_MIPS16_min },
   3436   { BFD_RELOC_MIPS16_HI16_S, R_MIPS16_HI16 - R_MIPS16_min },
   3437   { BFD_RELOC_MIPS16_LO16, R_MIPS16_LO16 - R_MIPS16_min },
   3438   { BFD_RELOC_MIPS16_TLS_GD, R_MIPS16_TLS_GD - R_MIPS16_min },
   3439   { BFD_RELOC_MIPS16_TLS_LDM, R_MIPS16_TLS_LDM - R_MIPS16_min },
   3440   { BFD_RELOC_MIPS16_TLS_DTPREL_HI16,
   3441     R_MIPS16_TLS_DTPREL_HI16 - R_MIPS16_min },
   3442   { BFD_RELOC_MIPS16_TLS_DTPREL_LO16,
   3443     R_MIPS16_TLS_DTPREL_LO16 - R_MIPS16_min },
   3444   { BFD_RELOC_MIPS16_TLS_GOTTPREL, R_MIPS16_TLS_GOTTPREL - R_MIPS16_min },
   3445   { BFD_RELOC_MIPS16_TLS_TPREL_HI16, R_MIPS16_TLS_TPREL_HI16 - R_MIPS16_min },
   3446   { BFD_RELOC_MIPS16_TLS_TPREL_LO16, R_MIPS16_TLS_TPREL_LO16 - R_MIPS16_min },
   3447   { BFD_RELOC_MIPS16_16_PCREL_S1, R_MIPS16_PC16_S1 - R_MIPS16_min }
   3448 };
   3449 
   3450 static const struct elf_reloc_map micromips_reloc_map[] =
   3451 {
   3452   { BFD_RELOC_MICROMIPS_JMP, R_MICROMIPS_26_S1 - R_MICROMIPS_min },
   3453   { BFD_RELOC_MICROMIPS_HI16_S, R_MICROMIPS_HI16 - R_MICROMIPS_min },
   3454   { BFD_RELOC_MICROMIPS_LO16, R_MICROMIPS_LO16 - R_MICROMIPS_min },
   3455   { BFD_RELOC_MICROMIPS_GPREL16, R_MICROMIPS_GPREL16 - R_MICROMIPS_min },
   3456   { BFD_RELOC_MICROMIPS_LITERAL, R_MICROMIPS_LITERAL - R_MICROMIPS_min },
   3457   { BFD_RELOC_MICROMIPS_GOT16, R_MICROMIPS_GOT16 - R_MICROMIPS_min },
   3458   { BFD_RELOC_MICROMIPS_7_PCREL_S1, R_MICROMIPS_PC7_S1 - R_MICROMIPS_min },
   3459   { BFD_RELOC_MICROMIPS_10_PCREL_S1, R_MICROMIPS_PC10_S1 - R_MICROMIPS_min },
   3460   { BFD_RELOC_MICROMIPS_16_PCREL_S1, R_MICROMIPS_PC16_S1 - R_MICROMIPS_min },
   3461   { BFD_RELOC_MICROMIPS_CALL16, R_MICROMIPS_CALL16 - R_MICROMIPS_min },
   3462   { BFD_RELOC_MICROMIPS_GOT_DISP, R_MICROMIPS_GOT_DISP - R_MICROMIPS_min },
   3463   { BFD_RELOC_MICROMIPS_GOT_PAGE, R_MICROMIPS_GOT_PAGE - R_MICROMIPS_min },
   3464   { BFD_RELOC_MICROMIPS_GOT_OFST, R_MICROMIPS_GOT_OFST - R_MICROMIPS_min },
   3465   { BFD_RELOC_MICROMIPS_GOT_HI16, R_MICROMIPS_GOT_HI16 - R_MICROMIPS_min },
   3466   { BFD_RELOC_MICROMIPS_GOT_LO16, R_MICROMIPS_GOT_LO16 - R_MICROMIPS_min },
   3467   { BFD_RELOC_MICROMIPS_SUB, R_MICROMIPS_SUB - R_MICROMIPS_min },
   3468   { BFD_RELOC_MICROMIPS_HIGHER, R_MICROMIPS_HIGHER - R_MICROMIPS_min },
   3469   { BFD_RELOC_MICROMIPS_HIGHEST, R_MICROMIPS_HIGHEST - R_MICROMIPS_min },
   3470   { BFD_RELOC_MICROMIPS_CALL_HI16, R_MICROMIPS_CALL_HI16 - R_MICROMIPS_min },
   3471   { BFD_RELOC_MICROMIPS_CALL_LO16, R_MICROMIPS_CALL_LO16 - R_MICROMIPS_min },
   3472   { BFD_RELOC_MICROMIPS_SCN_DISP, R_MICROMIPS_SCN_DISP - R_MICROMIPS_min },
   3473   { BFD_RELOC_MICROMIPS_JALR, R_MICROMIPS_JALR - R_MICROMIPS_min },
   3474 };
   3475 /* Given a BFD reloc type, return a howto structure.  */
   3476 
   3477 static reloc_howto_type *
   3478 bfd_elf64_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
   3479 				 bfd_reloc_code_real_type code)
   3480 {
   3481   unsigned int i;
   3482   /* FIXME: We default to RELA here instead of choosing the right
   3483      relocation variant.  */
   3484   reloc_howto_type *howto_table = mips_elf64_howto_table_rela;
   3485   reloc_howto_type *howto16_table = mips16_elf64_howto_table_rela;
   3486   reloc_howto_type *howto_micromips_table = micromips_elf64_howto_table_rela;
   3487 
   3488   for (i = 0; i < sizeof (mips_reloc_map) / sizeof (struct elf_reloc_map);
   3489        i++)
   3490     {
   3491       if (mips_reloc_map[i].bfd_val == code)
   3492 	return &howto_table[(int) mips_reloc_map[i].elf_val];
   3493     }
   3494 
   3495   for (i = 0; i < sizeof (mips16_reloc_map) / sizeof (struct elf_reloc_map);
   3496        i++)
   3497     {
   3498       if (mips16_reloc_map[i].bfd_val == code)
   3499 	return &howto16_table[(int) mips16_reloc_map[i].elf_val];
   3500     }
   3501 
   3502   for (i = 0; i < sizeof (micromips_reloc_map) / sizeof (struct elf_reloc_map);
   3503        i++)
   3504     {
   3505       if (micromips_reloc_map[i].bfd_val == code)
   3506 	return &howto_micromips_table[(int) micromips_reloc_map[i].elf_val];
   3507     }
   3508 
   3509   switch (code)
   3510     {
   3511     case BFD_RELOC_VTABLE_INHERIT:
   3512       return &elf_mips_gnu_vtinherit_howto;
   3513     case BFD_RELOC_VTABLE_ENTRY:
   3514       return &elf_mips_gnu_vtentry_howto;
   3515     case BFD_RELOC_32_PCREL:
   3516       return &elf_mips_gnu_pcrel32;
   3517     case BFD_RELOC_MIPS_EH:
   3518       return &elf_mips_eh_howto;
   3519     case BFD_RELOC_MIPS_COPY:
   3520       return &elf_mips_copy_howto;
   3521     case BFD_RELOC_MIPS_JUMP_SLOT:
   3522       return &elf_mips_jump_slot_howto;
   3523     default:
   3524       bfd_set_error (bfd_error_bad_value);
   3525       return NULL;
   3526     }
   3527 }
   3528 
   3529 static reloc_howto_type *
   3530 bfd_elf64_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
   3531 				 const char *r_name)
   3532 {
   3533   unsigned int i;
   3534 
   3535   for (i = 0;
   3536        i < (sizeof (mips_elf64_howto_table_rela)
   3537 	    / sizeof (mips_elf64_howto_table_rela[0])); i++)
   3538     if (mips_elf64_howto_table_rela[i].name != NULL
   3539 	&& strcasecmp (mips_elf64_howto_table_rela[i].name, r_name) == 0)
   3540       return &mips_elf64_howto_table_rela[i];
   3541 
   3542   for (i = 0;
   3543        i < (sizeof (mips16_elf64_howto_table_rela)
   3544 	    / sizeof (mips16_elf64_howto_table_rela[0]));
   3545        i++)
   3546     if (mips16_elf64_howto_table_rela[i].name != NULL
   3547 	&& strcasecmp (mips16_elf64_howto_table_rela[i].name, r_name) == 0)
   3548       return &mips16_elf64_howto_table_rela[i];
   3549 
   3550   for (i = 0;
   3551        i < (sizeof (micromips_elf64_howto_table_rela)
   3552 	    / sizeof (micromips_elf64_howto_table_rela[0]));
   3553        i++)
   3554     if (micromips_elf64_howto_table_rela[i].name != NULL
   3555 	&& strcasecmp (micromips_elf64_howto_table_rela[i].name, r_name) == 0)
   3556       return &micromips_elf64_howto_table_rela[i];
   3557 
   3558   if (strcasecmp (elf_mips_gnu_vtinherit_howto.name, r_name) == 0)
   3559     return &elf_mips_gnu_vtinherit_howto;
   3560   if (strcasecmp (elf_mips_gnu_vtentry_howto.name, r_name) == 0)
   3561     return &elf_mips_gnu_vtentry_howto;
   3562   if (strcasecmp (elf_mips_gnu_rel16_s2.name, r_name) == 0)
   3563     return &elf_mips_gnu_rel16_s2;
   3564   if (strcasecmp (elf_mips_gnu_rela16_s2.name, r_name) == 0)
   3565     return &elf_mips_gnu_rela16_s2;
   3566   if (strcasecmp (elf_mips_gnu_pcrel32.name, r_name) == 0)
   3567     return &elf_mips_gnu_pcrel32;
   3568   if (strcasecmp (elf_mips_eh_howto.name, r_name) == 0)
   3569     return &elf_mips_eh_howto;
   3570   if (strcasecmp (elf_mips_copy_howto.name, r_name) == 0)
   3571     return &elf_mips_copy_howto;
   3572   if (strcasecmp (elf_mips_jump_slot_howto.name, r_name) == 0)
   3573     return &elf_mips_jump_slot_howto;
   3574 
   3575   return NULL;
   3576 }
   3577 
   3578 /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure.  */
   3579 
   3580 static reloc_howto_type *
   3581 mips_elf64_rtype_to_howto (bfd *abfd, unsigned int r_type, bfd_boolean rela_p)
   3582 {
   3583   reloc_howto_type *howto = NULL;
   3584 
   3585   switch (r_type)
   3586     {
   3587     case R_MIPS_GNU_VTINHERIT:
   3588       return &elf_mips_gnu_vtinherit_howto;
   3589     case R_MIPS_GNU_VTENTRY:
   3590       return &elf_mips_gnu_vtentry_howto;
   3591     case R_MIPS_GNU_REL16_S2:
   3592       if (rela_p)
   3593 	return &elf_mips_gnu_rela16_s2;
   3594       else
   3595 	return &elf_mips_gnu_rel16_s2;
   3596     case R_MIPS_PC32:
   3597       return &elf_mips_gnu_pcrel32;
   3598     case R_MIPS_EH:
   3599       return &elf_mips_eh_howto;
   3600     case R_MIPS_COPY:
   3601       return &elf_mips_copy_howto;
   3602     case R_MIPS_JUMP_SLOT:
   3603       return &elf_mips_jump_slot_howto;
   3604     default:
   3605       if (r_type >= R_MICROMIPS_min && r_type < R_MICROMIPS_max)
   3606 	{
   3607 	  if (rela_p)
   3608 	    howto
   3609 	      = &micromips_elf64_howto_table_rela[r_type - R_MICROMIPS_min];
   3610 	  else
   3611 	    howto
   3612 	      = &micromips_elf64_howto_table_rel[r_type - R_MICROMIPS_min];
   3613 	}
   3614       if (r_type >= R_MIPS16_min && r_type < R_MIPS16_max)
   3615 	{
   3616 	  if (rela_p)
   3617 	    howto = &mips16_elf64_howto_table_rela[r_type - R_MIPS16_min];
   3618 	  else
   3619 	    howto = &mips16_elf64_howto_table_rel[r_type - R_MIPS16_min];
   3620 	}
   3621       if (r_type < R_MIPS_max)
   3622 	{
   3623 	  if (rela_p)
   3624 	    howto = &mips_elf64_howto_table_rela[r_type];
   3625 	  else
   3626 	    howto = &mips_elf64_howto_table_rel[r_type];
   3627 	}
   3628       if (howto != NULL && howto->name != NULL)
   3629 	return howto;
   3630 
   3631       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
   3632 			  abfd, r_type);
   3633       bfd_set_error (bfd_error_bad_value);
   3634       return NULL;
   3635     }
   3636 }
   3637 
   3638 /* Prevent relocation handling by bfd for MIPS ELF64.  */
   3639 
   3640 static bfd_boolean
   3641 mips_elf64_info_to_howto_rela (bfd *abfd,
   3642 			       arelent *cache_ptr ATTRIBUTE_UNUSED,
   3643 			       Elf_Internal_Rela *dst)
   3644 {
   3645   unsigned int r_type = ELF32_R_TYPE (dst->r_info);
   3646   /* xgettext:c-format */
   3647   _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
   3648 		      abfd, r_type);
   3649   bfd_set_error (bfd_error_bad_value);
   3650   return FALSE;
   3651 }
   3652 
   3653 /* Since each entry in an SHT_REL or SHT_RELA section can represent up
   3654    to three relocs, we must tell the user to allocate more space.  */
   3655 
   3656 static long
   3657 mips_elf64_get_dynamic_reloc_upper_bound (bfd *abfd)
   3658 {
   3659   return _bfd_elf_get_dynamic_reloc_upper_bound (abfd) * 3;
   3660 }
   3661 
   3662 /* Read the relocations from one reloc section.  This is mostly copied
   3663    from elfcode.h, except for the changes to expand one external
   3664    relocation to 3 internal ones.  To reduce processing effort we
   3665    could discard those R_MIPS_NONE relocations that occupy the second
   3666    and the third entry of a triplet, as `mips_elf64_write_rel' and
   3667    `mips_elf64_write_rela' recreate them in output automagically,
   3668    however that would also remove them from `objdump -r' output,
   3669    breaking a long-established tradition and likely confusing people.  */
   3670 
   3671 static bfd_boolean
   3672 mips_elf64_slurp_one_reloc_table (bfd *abfd, asection *asect,
   3673 				  Elf_Internal_Shdr *rel_hdr,
   3674 				  bfd_size_type reloc_count,
   3675 				  arelent *relents, asymbol **symbols,
   3676 				  bfd_boolean dynamic)
   3677 {
   3678   void *allocated;
   3679   bfd_byte *native_relocs;
   3680   unsigned int symcount;
   3681   arelent *relent;
   3682   bfd_vma i;
   3683   int entsize;
   3684   bfd_boolean rela_p;
   3685 
   3686   allocated = bfd_malloc (rel_hdr->sh_size);
   3687   if (allocated == NULL)
   3688     return FALSE;
   3689 
   3690   if (bfd_seek (abfd, rel_hdr->sh_offset, SEEK_SET) != 0
   3691       || (bfd_bread (allocated, rel_hdr->sh_size, abfd)
   3692 	  != rel_hdr->sh_size))
   3693     goto error_return;
   3694 
   3695   native_relocs = allocated;
   3696 
   3697   entsize = rel_hdr->sh_entsize;
   3698   BFD_ASSERT (entsize == sizeof (Elf64_Mips_External_Rel)
   3699 	      || entsize == sizeof (Elf64_Mips_External_Rela));
   3700 
   3701   if (entsize == sizeof (Elf64_Mips_External_Rel))
   3702     rela_p = FALSE;
   3703   else
   3704     rela_p = TRUE;
   3705 
   3706   if (dynamic)
   3707     symcount = bfd_get_dynamic_symcount (abfd);
   3708   else
   3709     symcount = bfd_get_symcount (abfd);
   3710 
   3711   for (i = 0, relent = relents;
   3712        i < reloc_count;
   3713        i++, native_relocs += entsize)
   3714     {
   3715       Elf64_Mips_Internal_Rela rela;
   3716       bfd_boolean used_sym, used_ssym;
   3717       int ir;
   3718 
   3719       if (entsize == sizeof (Elf64_Mips_External_Rela))
   3720 	mips_elf64_swap_reloca_in (abfd,
   3721 				   (Elf64_Mips_External_Rela *) native_relocs,
   3722 				   &rela);
   3723       else
   3724 	mips_elf64_swap_reloc_in (abfd,
   3725 				  (Elf64_Mips_External_Rel *) native_relocs,
   3726 				  &rela);
   3727 
   3728       /* Each entry represents exactly three actual relocations.  */
   3729 
   3730       used_sym = FALSE;
   3731       used_ssym = FALSE;
   3732       for (ir = 0; ir < 3; ir++)
   3733 	{
   3734 	  enum elf_mips_reloc_type type;
   3735 
   3736 	  switch (ir)
   3737 	    {
   3738 	    default:
   3739 	      abort ();
   3740 	    case 0:
   3741 	      type = (enum elf_mips_reloc_type) rela.r_type;
   3742 	      break;
   3743 	    case 1:
   3744 	      type = (enum elf_mips_reloc_type) rela.r_type2;
   3745 	      break;
   3746 	    case 2:
   3747 	      type = (enum elf_mips_reloc_type) rela.r_type3;
   3748 	      break;
   3749 	    }
   3750 
   3751 	  /* Some types require symbols, whereas some do not.  */
   3752 	  switch (type)
   3753 	    {
   3754 	    case R_MIPS_NONE:
   3755 	    case R_MIPS_LITERAL:
   3756 	    case R_MIPS_INSERT_A:
   3757 	    case R_MIPS_INSERT_B:
   3758 	    case R_MIPS_DELETE:
   3759 	      relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
   3760 	      break;
   3761 
   3762 	    default:
   3763 	      if (! used_sym)
   3764 		{
   3765 		  if (rela.r_sym == STN_UNDEF)
   3766 		    relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
   3767 		  else if (rela.r_sym > symcount)
   3768 		    {
   3769 		      _bfd_error_handler
   3770 			/* xgettext:c-format */
   3771 			(_("%pB(%pA): relocation %" PRIu64
   3772 			   " has invalid symbol index %ld"),
   3773 			 abfd, asect, (uint64_t) i, rela.r_sym);
   3774 		      bfd_set_error (bfd_error_bad_value);
   3775 		      relent->sym_ptr_ptr
   3776 			= bfd_abs_section_ptr->symbol_ptr_ptr;
   3777 		    }
   3778 		  else
   3779 		    {
   3780 		      asymbol **ps, *s;
   3781 
   3782 		      ps = symbols + rela.r_sym - 1;
   3783 		      s = *ps;
   3784 		      if ((s->flags & BSF_SECTION_SYM) == 0)
   3785 			relent->sym_ptr_ptr = ps;
   3786 		      else
   3787 			relent->sym_ptr_ptr = s->section->symbol_ptr_ptr;
   3788 		    }
   3789 
   3790 		  used_sym = TRUE;
   3791 		}
   3792 	      else if (! used_ssym)
   3793 		{
   3794 		  switch (rela.r_ssym)
   3795 		    {
   3796 		    case RSS_UNDEF:
   3797 		      relent->sym_ptr_ptr =
   3798 			bfd_abs_section_ptr->symbol_ptr_ptr;
   3799 		      break;
   3800 
   3801 		    case RSS_GP:
   3802 		    case RSS_GP0:
   3803 		    case RSS_LOC:
   3804 		      /* FIXME: I think these need to be handled using
   3805 			 special howto structures.  */
   3806 		      BFD_ASSERT (0);
   3807 		      break;
   3808 
   3809 		    default:
   3810 		      BFD_ASSERT (0);
   3811 		      break;
   3812 		    }
   3813 
   3814 		  used_ssym = TRUE;
   3815 		}
   3816 	      else
   3817 		relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
   3818 
   3819 	      break;
   3820 	    }
   3821 
   3822 	  /* The address of an ELF reloc is section relative for an
   3823 	     object file, and absolute for an executable file or
   3824 	     shared library.  The address of a BFD reloc is always
   3825 	     section relative.  */
   3826 	  if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0 || dynamic)
   3827 	    relent->address = rela.r_offset;
   3828 	  else
   3829 	    relent->address = rela.r_offset - asect->vma;
   3830 
   3831 	  relent->addend = rela.r_addend;
   3832 
   3833 	  relent->howto = mips_elf64_rtype_to_howto (abfd, type, rela_p);
   3834 	  if (relent->howto == NULL)
   3835 	    goto error_return;
   3836 
   3837 	  ++relent;
   3838 	}
   3839     }
   3840 
   3841   if (allocated != NULL)
   3842     free (allocated);
   3843 
   3844   return TRUE;
   3845 
   3846  error_return:
   3847   if (allocated != NULL)
   3848     free (allocated);
   3849   return FALSE;
   3850 }
   3851 
   3852 /* Read the relocations.  On Irix 6, there can be two reloc sections
   3853    associated with a single data section.  This is copied from
   3854    elfcode.h as well, with changes as small as accounting for 3
   3855    internal relocs per external reloc.  */
   3856 
   3857 static bfd_boolean
   3858 mips_elf64_slurp_reloc_table (bfd *abfd, asection *asect,
   3859 			      asymbol **symbols, bfd_boolean dynamic)
   3860 {
   3861   struct bfd_elf_section_data * const d = elf_section_data (asect);
   3862   Elf_Internal_Shdr *rel_hdr;
   3863   Elf_Internal_Shdr *rel_hdr2;
   3864   bfd_size_type reloc_count;
   3865   bfd_size_type reloc_count2;
   3866   arelent *relents;
   3867   bfd_size_type amt;
   3868 
   3869   if (asect->relocation != NULL)
   3870     return TRUE;
   3871 
   3872   if (! dynamic)
   3873     {
   3874       if ((asect->flags & SEC_RELOC) == 0
   3875 	  || asect->reloc_count == 0)
   3876 	return TRUE;
   3877 
   3878       rel_hdr = d->rel.hdr;
   3879       reloc_count = rel_hdr ? NUM_SHDR_ENTRIES (rel_hdr) : 0;
   3880       rel_hdr2 = d->rela.hdr;
   3881       reloc_count2 = (rel_hdr2 ? NUM_SHDR_ENTRIES (rel_hdr2) : 0);
   3882 
   3883       BFD_ASSERT (asect->reloc_count == 3 * (reloc_count + reloc_count2));
   3884       BFD_ASSERT ((rel_hdr && asect->rel_filepos == rel_hdr->sh_offset)
   3885 		  || (rel_hdr2 && asect->rel_filepos == rel_hdr2->sh_offset));
   3886 
   3887     }
   3888   else
   3889     {
   3890       /* Note that ASECT->RELOC_COUNT tends not to be accurate in this
   3891 	 case because relocations against this section may use the
   3892 	 dynamic symbol table, and in that case bfd_section_from_shdr
   3893 	 in elf.c does not update the RELOC_COUNT.  */
   3894       if (asect->size == 0)
   3895 	return TRUE;
   3896 
   3897       rel_hdr = &d->this_hdr;
   3898       reloc_count = NUM_SHDR_ENTRIES (rel_hdr);
   3899       rel_hdr2 = NULL;
   3900       reloc_count2 = 0;
   3901     }
   3902 
   3903   /* Allocate space for 3 arelent structures for each Rel structure.  */
   3904   amt = (reloc_count + reloc_count2) * 3 * sizeof (arelent);
   3905   relents = bfd_alloc (abfd, amt);
   3906   if (relents == NULL)
   3907     return FALSE;
   3908 
   3909   if (rel_hdr != NULL
   3910       && ! mips_elf64_slurp_one_reloc_table (abfd, asect,
   3911 					     rel_hdr, reloc_count,
   3912 					     relents,
   3913 					     symbols, dynamic))
   3914     return FALSE;
   3915   if (rel_hdr2 != NULL
   3916       && ! mips_elf64_slurp_one_reloc_table (abfd, asect,
   3917 					     rel_hdr2, reloc_count2,
   3918 					     relents + reloc_count * 3,
   3919 					     symbols, dynamic))
   3920     return FALSE;
   3921 
   3922   asect->relocation = relents;
   3923   return TRUE;
   3924 }
   3925 
   3926 /* Write out the relocations.  */
   3927 
   3928 static void
   3929 mips_elf64_write_relocs (bfd *abfd, asection *sec, void *data)
   3930 {
   3931   bfd_boolean *failedp = data;
   3932   int count;
   3933   Elf_Internal_Shdr *rel_hdr;
   3934   unsigned int idx;
   3935 
   3936   /* If we have already failed, don't do anything.  */
   3937   if (*failedp)
   3938     return;
   3939 
   3940   if ((sec->flags & SEC_RELOC) == 0)
   3941     return;
   3942 
   3943   /* The linker backend writes the relocs out itself, and sets the
   3944      reloc_count field to zero to inhibit writing them here.  Also,
   3945      sometimes the SEC_RELOC flag gets set even when there aren't any
   3946      relocs.  */
   3947   if (sec->reloc_count == 0)
   3948     return;
   3949 
   3950   /* We can combine up to three relocs that refer to the same address
   3951      if the latter relocs have no associated symbol.  */
   3952   count = 0;
   3953   for (idx = 0; idx < sec->reloc_count; idx++)
   3954     {
   3955       bfd_vma addr;
   3956       unsigned int i;
   3957 
   3958       ++count;
   3959 
   3960       addr = sec->orelocation[idx]->address;
   3961       for (i = 0; i < 2; i++)
   3962 	{
   3963 	  arelent *r;
   3964 
   3965 	  if (idx + 1 >= sec->reloc_count)
   3966 	    break;
   3967 	  r = sec->orelocation[idx + 1];
   3968 	  if (r->address != addr
   3969 	      || ! bfd_is_abs_section ((*r->sym_ptr_ptr)->section)
   3970 	      || (*r->sym_ptr_ptr)->value != 0)
   3971 	    break;
   3972 
   3973 	  /* We can merge the reloc at IDX + 1 with the reloc at IDX.  */
   3974 
   3975 	  ++idx;
   3976 	}
   3977     }
   3978 
   3979   rel_hdr = _bfd_elf_single_rel_hdr (sec);
   3980 
   3981   /* Do the actual relocation.  */
   3982 
   3983   if (rel_hdr->sh_entsize == sizeof(Elf64_Mips_External_Rel))
   3984     mips_elf64_write_rel (abfd, sec, rel_hdr, &count, data);
   3985   else if (rel_hdr->sh_entsize == sizeof(Elf64_Mips_External_Rela))
   3986     mips_elf64_write_rela (abfd, sec, rel_hdr, &count, data);
   3987   else
   3988     BFD_ASSERT (0);
   3989 }
   3990 
   3991 static void
   3992 mips_elf64_write_rel (bfd *abfd, asection *sec,
   3993 		      Elf_Internal_Shdr *rel_hdr,
   3994 		      int *count, void *data)
   3995 {
   3996   bfd_boolean *failedp = data;
   3997   Elf64_Mips_External_Rel *ext_rel;
   3998   unsigned int idx;
   3999   asymbol *last_sym = 0;
   4000   int last_sym_idx = 0;
   4001 
   4002   rel_hdr->sh_size = rel_hdr->sh_entsize * *count;
   4003   rel_hdr->contents = bfd_alloc (abfd, rel_hdr->sh_size);
   4004   if (rel_hdr->contents == NULL)
   4005     {
   4006       *failedp = TRUE;
   4007       return;
   4008     }
   4009 
   4010   ext_rel = (Elf64_Mips_External_Rel *) rel_hdr->contents;
   4011   for (idx = 0; idx < sec->reloc_count; idx++, ext_rel++)
   4012     {
   4013       arelent *ptr;
   4014       Elf64_Mips_Internal_Rela int_rel;
   4015       asymbol *sym;
   4016       int n;
   4017       unsigned int i;
   4018 
   4019       ptr = sec->orelocation[idx];
   4020 
   4021       /* The address of an ELF reloc is section relative for an object
   4022 	 file, and absolute for an executable file or shared library.
   4023 	 The address of a BFD reloc is always section relative.  */
   4024       if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0)
   4025 	int_rel.r_offset = ptr->address;
   4026       else
   4027 	int_rel.r_offset = ptr->address + sec->vma;
   4028 
   4029       sym = *ptr->sym_ptr_ptr;
   4030       if (sym == last_sym)
   4031 	n = last_sym_idx;
   4032       else if (bfd_is_abs_section (sym->section) && sym->value == 0)
   4033 	n = STN_UNDEF;
   4034       else
   4035 	{
   4036 	  last_sym = sym;
   4037 	  n = _bfd_elf_symbol_from_bfd_symbol (abfd, &sym);
   4038 	  if (n < 0)
   4039 	    {
   4040 	      *failedp = TRUE;
   4041 	      return;
   4042 	    }
   4043 	  last_sym_idx = n;
   4044 	}
   4045 
   4046       int_rel.r_sym = n;
   4047       int_rel.r_ssym = RSS_UNDEF;
   4048 
   4049       if ((*ptr->sym_ptr_ptr)->the_bfd != NULL
   4050 	  && (*ptr->sym_ptr_ptr)->the_bfd->xvec != abfd->xvec
   4051 	  && ! _bfd_elf_validate_reloc (abfd, ptr))
   4052 	{
   4053 	  *failedp = TRUE;
   4054 	  return;
   4055 	}
   4056 
   4057       int_rel.r_type = ptr->howto->type;
   4058       int_rel.r_type2 = (int) R_MIPS_NONE;
   4059       int_rel.r_type3 = (int) R_MIPS_NONE;
   4060 
   4061       for (i = 0; i < 2; i++)
   4062 	{
   4063 	  arelent *r;
   4064 
   4065 	  if (idx + 1 >= sec->reloc_count)
   4066 	    break;
   4067 	  r = sec->orelocation[idx + 1];
   4068 	  if (r->address != ptr->address
   4069 	      || ! bfd_is_abs_section ((*r->sym_ptr_ptr)->section)
   4070 	      || (*r->sym_ptr_ptr)->value != 0)
   4071 	    break;
   4072 
   4073 	  /* We can merge the reloc at IDX + 1 with the reloc at IDX.  */
   4074 
   4075 	  if (i == 0)
   4076 	    int_rel.r_type2 = r->howto->type;
   4077 	  else
   4078 	    int_rel.r_type3 = r->howto->type;
   4079 
   4080 	  ++idx;
   4081 	}
   4082 
   4083       mips_elf64_swap_reloc_out (abfd, &int_rel, ext_rel);
   4084     }
   4085 
   4086   BFD_ASSERT (ext_rel - (Elf64_Mips_External_Rel *) rel_hdr->contents
   4087 	      == *count);
   4088 }
   4089 
   4090 static void
   4091 mips_elf64_write_rela (bfd *abfd, asection *sec,
   4092 		       Elf_Internal_Shdr *rela_hdr,
   4093 		       int *count, void *data)
   4094 {
   4095   bfd_boolean *failedp = data;
   4096   Elf64_Mips_External_Rela *ext_rela;
   4097   unsigned int idx;
   4098   asymbol *last_sym = 0;
   4099   int last_sym_idx = 0;
   4100 
   4101   rela_hdr->sh_size = rela_hdr->sh_entsize * *count;
   4102   rela_hdr->contents = bfd_alloc (abfd, rela_hdr->sh_size);
   4103   if (rela_hdr->contents == NULL)
   4104     {
   4105       *failedp = TRUE;
   4106       return;
   4107     }
   4108 
   4109   ext_rela = (Elf64_Mips_External_Rela *) rela_hdr->contents;
   4110   for (idx = 0; idx < sec->reloc_count; idx++, ext_rela++)
   4111     {
   4112       arelent *ptr;
   4113       Elf64_Mips_Internal_Rela int_rela;
   4114       asymbol *sym;
   4115       int n;
   4116       unsigned int i;
   4117 
   4118       ptr = sec->orelocation[idx];
   4119 
   4120       /* The address of an ELF reloc is section relative for an object
   4121 	 file, and absolute for an executable file or shared library.
   4122 	 The address of a BFD reloc is always section relative.  */
   4123       if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0)
   4124 	int_rela.r_offset = ptr->address;
   4125       else
   4126 	int_rela.r_offset = ptr->address + sec->vma;
   4127 
   4128       sym = *ptr->sym_ptr_ptr;
   4129       if (sym == last_sym)
   4130 	n = last_sym_idx;
   4131       else if (bfd_is_abs_section (sym->section) && sym->value == 0)
   4132 	n = STN_UNDEF;
   4133       else
   4134 	{
   4135 	  last_sym = sym;
   4136 	  n = _bfd_elf_symbol_from_bfd_symbol (abfd, &sym);
   4137 	  if (n < 0)
   4138 	    {
   4139 	      *failedp = TRUE;
   4140 	      return;
   4141 	    }
   4142 	  last_sym_idx = n;
   4143 	}
   4144 
   4145       int_rela.r_sym = n;
   4146       int_rela.r_addend = ptr->addend;
   4147       int_rela.r_ssym = RSS_UNDEF;
   4148 
   4149       if ((*ptr->sym_ptr_ptr)->the_bfd != NULL
   4150 	  && (*ptr->sym_ptr_ptr)->the_bfd->xvec != abfd->xvec
   4151 	  && ! _bfd_elf_validate_reloc (abfd, ptr))
   4152 	{
   4153 	  *failedp = TRUE;
   4154 	  return;
   4155 	}
   4156 
   4157       int_rela.r_type = ptr->howto->type;
   4158       int_rela.r_type2 = (int) R_MIPS_NONE;
   4159       int_rela.r_type3 = (int) R_MIPS_NONE;
   4160 
   4161       for (i = 0; i < 2; i++)
   4162 	{
   4163 	  arelent *r;
   4164 
   4165 	  if (idx + 1 >= sec->reloc_count)
   4166 	    break;
   4167 	  r = sec->orelocation[idx + 1];
   4168 	  if (r->address != ptr->address
   4169 	      || ! bfd_is_abs_section ((*r->sym_ptr_ptr)->section)
   4170 	      || (*r->sym_ptr_ptr)->value != 0)
   4171 	    break;
   4172 
   4173 	  /* We can merge the reloc at IDX + 1 with the reloc at IDX.  */
   4174 
   4175 	  if (i == 0)
   4176 	    int_rela.r_type2 = r->howto->type;
   4177 	  else
   4178 	    int_rela.r_type3 = r->howto->type;
   4179 
   4180 	  ++idx;
   4181 	}
   4182 
   4183       mips_elf64_swap_reloca_out (abfd, &int_rela, ext_rela);
   4184     }
   4185 
   4186   BFD_ASSERT (ext_rela - (Elf64_Mips_External_Rela *) rela_hdr->contents
   4187 	      == *count);
   4188 }
   4189 
   4190 /* Set the right machine number for a MIPS ELF file.  */
   4192 
   4193 static bfd_boolean
   4194 mips_elf64_object_p (bfd *abfd)
   4195 {
   4196   unsigned long mach;
   4197 
   4198   /* Irix 6 is broken.  Object file symbol tables are not always
   4199      sorted correctly such that local symbols precede global symbols,
   4200      and the sh_info field in the symbol table is not always right.  */
   4201   if (elf64_mips_irix_compat (abfd) != ict_none)
   4202     elf_bad_symtab (abfd) = TRUE;
   4203 
   4204   mach = _bfd_elf_mips_mach (elf_elfheader (abfd)->e_flags);
   4205   bfd_default_set_arch_mach (abfd, bfd_arch_mips, mach);
   4206   return TRUE;
   4207 }
   4208 
   4209 /* MIPS ELF local labels start with "$L".  */
   4211 static bfd_boolean
   4212 mips_elf64_is_local_label_name (bfd *abfd, const char *name)
   4213 {
   4214   if (name[0] == '$' && name[1] == 'L')
   4215     return TRUE;
   4216 
   4217   /* We accept the generic ELF local label syntax as well.  */
   4218   return _bfd_elf_is_local_label_name (abfd, name);
   4219 }
   4220 
   4221 /* Depending on the target vector we generate some version of Irix
   4223    executables or "normal" MIPS ELF ABI executables.  */
   4224 static irix_compat_t
   4225 elf64_mips_irix_compat (bfd *abfd)
   4226 {
   4227   if ((abfd->xvec == &mips_elf64_be_vec)
   4228       || (abfd->xvec == &mips_elf64_le_vec))
   4229     return ict_irix6;
   4230   else
   4231     return ict_none;
   4232 }
   4233 
   4234 /* Support for core dump NOTE sections.  */
   4236 static bfd_boolean
   4237 elf64_mips_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
   4238 {
   4239   int offset;
   4240   unsigned int size;
   4241 
   4242   switch (note->descsz)
   4243     {
   4244       default:
   4245 	return FALSE;
   4246 
   4247       case 480:		/* Linux/MIPS - N64 kernel */
   4248 	/* pr_cursig */
   4249 	elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
   4250 
   4251 	/* pr_pid */
   4252 	elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 32);
   4253 
   4254 	/* pr_reg */
   4255 	offset = 112;
   4256 	size = 360;
   4257 
   4258 	break;
   4259     }
   4260 
   4261   /* Make a ".reg/999" section.  */
   4262   return _bfd_elfcore_make_pseudosection (abfd, ".reg",
   4263 					  size, note->descpos + offset);
   4264 }
   4265 
   4266 static bfd_boolean
   4267 elf64_mips_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
   4268 {
   4269   switch (note->descsz)
   4270     {
   4271       default:
   4272 	return FALSE;
   4273 
   4274       case 136:		/* Linux/MIPS - N64 kernel elf_prpsinfo */
   4275 	elf_tdata (abfd)->core->pid
   4276 	 = bfd_get_32 (abfd, note->descdata + 24);
   4277 	elf_tdata (abfd)->core->program
   4278 	 = _bfd_elfcore_strndup (abfd, note->descdata + 40, 16);
   4279 	elf_tdata (abfd)->core->command
   4280 	 = _bfd_elfcore_strndup (abfd, note->descdata + 56, 80);
   4281     }
   4282 
   4283   /* Note that for some reason, a spurious space is tacked
   4284      onto the end of the args in some (at least one anyway)
   4285      implementations, so strip it off if it exists.  */
   4286 
   4287   {
   4288     char *command = elf_tdata (abfd)->core->command;
   4289     int n = strlen (command);
   4290 
   4291     if (0 < n && command[n - 1] == ' ')
   4292       command[n - 1] = '\0';
   4293   }
   4294 
   4295   return TRUE;
   4296 }
   4297 
   4298 /* Write Linux core PRSTATUS note into core file.  */
   4299 
   4300 static char *
   4301 elf64_mips_write_core_note (bfd *abfd, char *buf, int *bufsiz, int note_type,
   4302 			     ...)
   4303 {
   4304   switch (note_type)
   4305     {
   4306     default:
   4307       return NULL;
   4308 
   4309     case NT_PRPSINFO:
   4310       BFD_FAIL ();
   4311       return NULL;
   4312 
   4313     case NT_PRSTATUS:
   4314       {
   4315 	char data[480];
   4316 	va_list ap;
   4317 	long pid;
   4318 	int cursig;
   4319 	const void *greg;
   4320 
   4321 	va_start (ap, note_type);
   4322 	memset (data, 0, 112);
   4323 	pid = va_arg (ap, long);
   4324 	bfd_put_32 (abfd, pid, data + 32);
   4325 	cursig = va_arg (ap, int);
   4326 	bfd_put_16 (abfd, cursig, data + 12);
   4327 	greg = va_arg (ap, const void *);
   4328 	memcpy (data + 112, greg, 360);
   4329 	memset (data + 472, 0, 8);
   4330 	va_end (ap);
   4331 	return elfcore_write_note (abfd, buf, bufsiz,
   4332 				   "CORE", note_type, data, sizeof (data));
   4333       }
   4334     }
   4335 }
   4336 
   4337 /* ECOFF swapping routines.  These are used when dealing with the
   4339    .mdebug section, which is in the ECOFF debugging format.  */
   4340 static const struct ecoff_debug_swap mips_elf64_ecoff_debug_swap =
   4341 {
   4342   /* Symbol table magic number.  */
   4343   magicSym2,
   4344   /* Alignment of debugging information.  E.g., 4.  */
   4345   8,
   4346   /* Sizes of external symbolic information.  */
   4347   sizeof (struct hdr_ext),
   4348   sizeof (struct dnr_ext),
   4349   sizeof (struct pdr_ext),
   4350   sizeof (struct sym_ext),
   4351   sizeof (struct opt_ext),
   4352   sizeof (struct fdr_ext),
   4353   sizeof (struct rfd_ext),
   4354   sizeof (struct ext_ext),
   4355   /* Functions to swap in external symbolic data.  */
   4356   ecoff_swap_hdr_in,
   4357   ecoff_swap_dnr_in,
   4358   ecoff_swap_pdr_in,
   4359   ecoff_swap_sym_in,
   4360   ecoff_swap_opt_in,
   4361   ecoff_swap_fdr_in,
   4362   ecoff_swap_rfd_in,
   4363   ecoff_swap_ext_in,
   4364   _bfd_ecoff_swap_tir_in,
   4365   _bfd_ecoff_swap_rndx_in,
   4366   /* Functions to swap out external symbolic data.  */
   4367   ecoff_swap_hdr_out,
   4368   ecoff_swap_dnr_out,
   4369   ecoff_swap_pdr_out,
   4370   ecoff_swap_sym_out,
   4371   ecoff_swap_opt_out,
   4372   ecoff_swap_fdr_out,
   4373   ecoff_swap_rfd_out,
   4374   ecoff_swap_ext_out,
   4375   _bfd_ecoff_swap_tir_out,
   4376   _bfd_ecoff_swap_rndx_out,
   4377   /* Function to read in symbolic data.  */
   4378   _bfd_mips_elf_read_ecoff_info
   4379 };
   4380 
   4381 /* Relocations in the 64 bit MIPS ELF ABI are more complex than in
   4383    standard ELF.  This structure is used to redirect the relocation
   4384    handling routines.  */
   4385 
   4386 const struct elf_size_info mips_elf64_size_info =
   4387 {
   4388   sizeof (Elf64_External_Ehdr),
   4389   sizeof (Elf64_External_Phdr),
   4390   sizeof (Elf64_External_Shdr),
   4391   sizeof (Elf64_Mips_External_Rel),
   4392   sizeof (Elf64_Mips_External_Rela),
   4393   sizeof (Elf64_External_Sym),
   4394   sizeof (Elf64_External_Dyn),
   4395   sizeof (Elf_External_Note),
   4396   4,		/* hash-table entry size */
   4397   3,		/* internal relocations per external relocations */
   4398   64,		/* arch_size */
   4399   3,		/* log_file_align */
   4400   ELFCLASS64,
   4401   EV_CURRENT,
   4402   bfd_elf64_write_out_phdrs,
   4403   bfd_elf64_write_shdrs_and_ehdr,
   4404   bfd_elf64_checksum_contents,
   4405   mips_elf64_write_relocs,
   4406   bfd_elf64_swap_symbol_in,
   4407   bfd_elf64_swap_symbol_out,
   4408   mips_elf64_slurp_reloc_table,
   4409   bfd_elf64_slurp_symbol_table,
   4410   bfd_elf64_swap_dyn_in,
   4411   bfd_elf64_swap_dyn_out,
   4412   mips_elf64_be_swap_reloc_in,
   4413   mips_elf64_be_swap_reloc_out,
   4414   mips_elf64_be_swap_reloca_in,
   4415   mips_elf64_be_swap_reloca_out
   4416 };
   4417 
   4418 #define ELF_ARCH			bfd_arch_mips
   4419 #define ELF_TARGET_ID			MIPS_ELF_DATA
   4420 #define ELF_MACHINE_CODE		EM_MIPS
   4421 
   4422 #define elf_backend_collect		TRUE
   4423 #define elf_backend_type_change_ok	TRUE
   4424 #define elf_backend_can_gc_sections	TRUE
   4425 #define elf_backend_gc_mark_extra_sections \
   4426 					_bfd_mips_elf_gc_mark_extra_sections
   4427 #define elf_info_to_howto		mips_elf64_info_to_howto_rela
   4428 #define elf_info_to_howto_rel		mips_elf64_info_to_howto_rela
   4429 #define elf_backend_object_p		mips_elf64_object_p
   4430 #define elf_backend_symbol_processing	_bfd_mips_elf_symbol_processing
   4431 #define elf_backend_section_processing	_bfd_mips_elf_section_processing
   4432 #define elf_backend_section_from_shdr	_bfd_mips_elf_section_from_shdr
   4433 #define elf_backend_fake_sections	_bfd_mips_elf_fake_sections
   4434 #define elf_backend_section_from_bfd_section \
   4435 				_bfd_mips_elf_section_from_bfd_section
   4436 #define elf_backend_add_symbol_hook	_bfd_mips_elf_add_symbol_hook
   4437 #define elf_backend_link_output_symbol_hook \
   4438 				_bfd_mips_elf_link_output_symbol_hook
   4439 #define elf_backend_create_dynamic_sections \
   4440 				_bfd_mips_elf_create_dynamic_sections
   4441 #define elf_backend_check_relocs	_bfd_mips_elf_check_relocs
   4442 #define elf_backend_merge_symbol_attribute \
   4443 				_bfd_mips_elf_merge_symbol_attribute
   4444 #define elf_backend_get_target_dtag	_bfd_mips_elf_get_target_dtag
   4445 #define elf_backend_adjust_dynamic_symbol \
   4446 				_bfd_mips_elf_adjust_dynamic_symbol
   4447 #define elf_backend_always_size_sections \
   4448 				_bfd_mips_elf_always_size_sections
   4449 #define elf_backend_size_dynamic_sections \
   4450 				_bfd_mips_elf_size_dynamic_sections
   4451 #define elf_backend_init_index_section	_bfd_elf_init_1_index_section
   4452 #define elf_backend_relocate_section    _bfd_mips_elf_relocate_section
   4453 #define elf_backend_finish_dynamic_symbol \
   4454 				_bfd_mips_elf_finish_dynamic_symbol
   4455 #define elf_backend_finish_dynamic_sections \
   4456 				_bfd_mips_elf_finish_dynamic_sections
   4457 #define elf_backend_final_write_processing \
   4458 				_bfd_mips_elf_final_write_processing
   4459 #define elf_backend_additional_program_headers \
   4460 				_bfd_mips_elf_additional_program_headers
   4461 #define elf_backend_modify_segment_map	_bfd_mips_elf_modify_segment_map
   4462 #define elf_backend_gc_mark_hook	_bfd_mips_elf_gc_mark_hook
   4463 #define elf_backend_copy_indirect_symbol \
   4464 					_bfd_mips_elf_copy_indirect_symbol
   4465 #define elf_backend_ignore_discarded_relocs \
   4466 					_bfd_mips_elf_ignore_discarded_relocs
   4467 #define elf_backend_mips_irix_compat	elf64_mips_irix_compat
   4468 #define elf_backend_mips_rtype_to_howto	mips_elf64_rtype_to_howto
   4469 #define elf_backend_ecoff_debug_swap	&mips_elf64_ecoff_debug_swap
   4470 #define elf_backend_size_info		mips_elf64_size_info
   4471 
   4472 #define elf_backend_grok_prstatus	elf64_mips_grok_prstatus
   4473 #define elf_backend_grok_psinfo		elf64_mips_grok_psinfo
   4474 
   4475 #define elf_backend_got_header_size	(8 * MIPS_RESERVED_GOTNO)
   4476 #define elf_backend_want_dynrelro	1
   4477 
   4478 /* MIPS ELF64 can use a mixture of REL and RELA, but some Relocations
   4479    work better/work only in RELA, so we default to this.  */
   4480 #define elf_backend_may_use_rel_p	1
   4481 #define elf_backend_may_use_rela_p	1
   4482 #define elf_backend_default_use_rela_p	1
   4483 #define elf_backend_rela_plts_and_copies_p 0
   4484 #define elf_backend_plt_readonly	1
   4485 #define elf_backend_plt_sym_val		_bfd_mips_elf_plt_sym_val
   4486 
   4487 #define elf_backend_sign_extend_vma	TRUE
   4488 
   4489 #define elf_backend_write_section	_bfd_mips_elf_write_section
   4490 #define elf_backend_sort_relocs_p	_bfd_mips_elf_sort_relocs_p
   4491 
   4492 #define bfd_elf64_bfd_is_local_label_name \
   4493 					mips_elf64_is_local_label_name
   4494 #define bfd_elf64_bfd_is_target_special_symbol \
   4495 					_bfd_mips_elf_is_target_special_symbol
   4496 #define bfd_elf64_find_nearest_line	_bfd_mips_elf_find_nearest_line
   4497 #define bfd_elf64_find_inliner_info	_bfd_mips_elf_find_inliner_info
   4498 #define bfd_elf64_new_section_hook	_bfd_mips_elf_new_section_hook
   4499 #define bfd_elf64_set_section_contents	_bfd_mips_elf_set_section_contents
   4500 #define bfd_elf64_bfd_get_relocated_section_contents \
   4501 				_bfd_elf_mips_get_relocated_section_contents
   4502 #define bfd_elf64_bfd_link_hash_table_create \
   4503 				_bfd_mips_elf_link_hash_table_create
   4504 #define bfd_elf64_bfd_final_link	_bfd_mips_elf_final_link
   4505 #define bfd_elf64_bfd_merge_private_bfd_data \
   4506 				_bfd_mips_elf_merge_private_bfd_data
   4507 #define bfd_elf64_bfd_set_private_flags	_bfd_mips_elf_set_private_flags
   4508 #define bfd_elf64_bfd_print_private_bfd_data \
   4509 				_bfd_mips_elf_print_private_bfd_data
   4510 
   4511 #define bfd_elf64_get_dynamic_reloc_upper_bound mips_elf64_get_dynamic_reloc_upper_bound
   4512 #define bfd_elf64_mkobject		_bfd_mips_elf_mkobject
   4513 
   4514 /* The SGI style (n)64 NewABI.  */
   4515 #define TARGET_LITTLE_SYM		mips_elf64_le_vec
   4516 #define TARGET_LITTLE_NAME		"elf64-littlemips"
   4517 #define TARGET_BIG_SYM			mips_elf64_be_vec
   4518 #define TARGET_BIG_NAME			"elf64-bigmips"
   4519 
   4520 #define ELF_MAXPAGESIZE			0x10000
   4521 #define ELF_COMMONPAGESIZE		0x1000
   4522 
   4523 #include "elf64-target.h"
   4524 
   4525 /* The SYSV-style 'traditional' (n)64 NewABI.  */
   4526 #undef TARGET_LITTLE_SYM
   4527 #undef TARGET_LITTLE_NAME
   4528 #undef TARGET_BIG_SYM
   4529 #undef TARGET_BIG_NAME
   4530 
   4531 #undef ELF_MAXPAGESIZE
   4532 #undef ELF_COMMONPAGESIZE
   4533 
   4534 #define TARGET_LITTLE_SYM		mips_elf64_trad_le_vec
   4535 #define TARGET_LITTLE_NAME		"elf64-tradlittlemips"
   4536 #define TARGET_BIG_SYM			mips_elf64_trad_be_vec
   4537 #define TARGET_BIG_NAME			"elf64-tradbigmips"
   4538 
   4539 #define ELF_MAXPAGESIZE			0x10000
   4540 #define ELF_COMMONPAGESIZE		0x1000
   4541 #define elf64_bed			elf64_tradbed
   4542 
   4543 #undef elf_backend_write_core_note
   4544 #define elf_backend_write_core_note	elf64_mips_write_core_note
   4545 
   4546 /* Include the target file again for this target.  */
   4547 #include "elf64-target.h"
   4548 
   4549 
   4550 /* FreeBSD support.  */
   4551 
   4552 #undef TARGET_LITTLE_SYM
   4553 #undef TARGET_LITTLE_NAME
   4554 #undef TARGET_BIG_SYM
   4555 #undef TARGET_BIG_NAME
   4556 
   4557 #define	TARGET_LITTLE_SYM		mips_elf64_tradfbsd_le_vec
   4558 #define	TARGET_LITTLE_NAME		"elf64-tradlittlemips-freebsd"
   4559 #define	TARGET_BIG_SYM			mips_elf64_tradfbsd_be_vec
   4560 #define	TARGET_BIG_NAME			"elf64-tradbigmips-freebsd"
   4561 
   4562 #undef	ELF_OSABI
   4563 #define	ELF_OSABI			ELFOSABI_FREEBSD
   4564 
   4565 #undef	elf64_bed
   4566 #define elf64_bed				elf64_fbsd_tradbed
   4567 
   4568 #undef elf64_mips_write_core_note
   4569 
   4570 #include "elf64-target.h"
   4571