Home | History | Annotate | Line # | Download | only in bfd
elfn32-mips.c revision 1.1.1.1
      1 /* MIPS-specific support for 32-bit ELF
      2    Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
      3    2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
      4 
      5    Most of the information added by Ian Lance Taylor, Cygnus Support,
      6    <ian (at) cygnus.com>.
      7    N32/64 ABI support added by Mark Mitchell, CodeSourcery, LLC.
      8    <mark (at) codesourcery.com>
      9    Traditional MIPS targets support added by Koundinya.K, Dansk Data
     10    Elektronik & Operations Research Group. <kk (at) ddeorg.soft.net>
     11 
     12    This file is part of BFD, the Binary File Descriptor library.
     13 
     14    This program is free software; you can redistribute it and/or modify
     15    it under the terms of the GNU General Public License as published by
     16    the Free Software Foundation; either version 3 of the License, or
     17    (at your option) any later version.
     18 
     19    This program is distributed in the hope that it will be useful,
     20    but WITHOUT ANY WARRANTY; without even the implied warranty of
     21    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     22    GNU General Public License for more details.
     23 
     24    You should have received a copy of the GNU General Public License
     25    along with this program; if not, write to the Free Software
     26    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
     27    MA 02110-1301, USA.  */
     28 
     29 
     30 /* This file handles MIPS ELF targets.  SGI Irix 5 uses a slightly
     31    different MIPS ELF from other targets.  This matters when linking.
     32    This file supports both, switching at runtime.  */
     33 
     34 #include "sysdep.h"
     35 #include "bfd.h"
     36 #include "libbfd.h"
     37 #include "bfdlink.h"
     38 #include "genlink.h"
     39 #include "elf-bfd.h"
     40 #include "elfxx-mips.h"
     41 #include "elf/mips.h"
     42 
     43 /* Get the ECOFF swapping routines.  */
     44 #include "coff/sym.h"
     45 #include "coff/symconst.h"
     46 #include "coff/internal.h"
     47 #include "coff/ecoff.h"
     48 #include "coff/mips.h"
     49 #define ECOFF_SIGNED_32
     50 #include "ecoffswap.h"
     51 
     52 static bfd_boolean mips_elf_assign_gp
     53   (bfd *, bfd_vma *);
     54 static bfd_reloc_status_type mips_elf_final_gp
     55   (bfd *, asymbol *, bfd_boolean, char **, bfd_vma *);
     56 static bfd_reloc_status_type mips_elf_gprel16_reloc
     57   (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
     58 static bfd_reloc_status_type mips_elf_literal_reloc
     59   (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
     60 static bfd_reloc_status_type mips_elf_gprel32_reloc
     61   (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
     62 static bfd_reloc_status_type gprel32_with_gp
     63   (bfd *, asymbol *, arelent *, asection *, bfd_boolean, void *, bfd_vma);
     64 static bfd_reloc_status_type mips_elf_shift6_reloc
     65   (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
     66 static bfd_reloc_status_type mips16_gprel_reloc
     67   (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
     68 static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
     69   (bfd *, bfd_reloc_code_real_type);
     70 static reloc_howto_type *mips_elf_n32_rtype_to_howto
     71   (unsigned int, bfd_boolean);
     72 static void mips_info_to_howto_rel
     73   (bfd *, arelent *, Elf_Internal_Rela *);
     74 static void mips_info_to_howto_rela
     75   (bfd *, arelent *, Elf_Internal_Rela *);
     76 static bfd_boolean mips_elf_sym_is_global
     77   (bfd *, asymbol *);
     78 static bfd_boolean mips_elf_n32_object_p
     79   (bfd *);
     80 static bfd_boolean elf32_mips_grok_prstatus
     81   (bfd *, Elf_Internal_Note *);
     82 static bfd_boolean elf32_mips_grok_psinfo
     83   (bfd *, Elf_Internal_Note *);
     84 static bfd_boolean mips_elf_n32_is_local_label_name
     85   (bfd *, const char *);
     86 static irix_compat_t elf_n32_mips_irix_compat
     87   (bfd *);
     88 
     89 extern const bfd_target bfd_elf32_nbigmips_vec;
     90 extern const bfd_target bfd_elf32_nlittlemips_vec;
     91 
     92 /* Nonzero if ABFD is using the N32 ABI.  */
     93 #define ABI_N32_P(abfd) \
     94   ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI2) != 0)
     95 
     96 /* Whether we are trying to be compatible with IRIX at all.  */
     97 #define SGI_COMPAT(abfd) \
     98   (elf_n32_mips_irix_compat (abfd) != ict_none)
     99 
    100 /* The number of local .got entries we reserve.  */
    101 #define MIPS_RESERVED_GOTNO (2)
    102 
    103 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
    104    from smaller values.  Start with zero, widen, *then* decrement.  */
    105 #define MINUS_ONE	(((bfd_vma)0) - 1)
    106 
    107 /* The relocation table used for SHT_REL sections.  */
    108 
    109 static reloc_howto_type elf_mips_howto_table_rel[] =
    110 {
    111   /* No relocation.  */
    112   HOWTO (R_MIPS_NONE,		/* type */
    113 	 0,			/* rightshift */
    114 	 0,			/* size (0 = byte, 1 = short, 2 = long) */
    115 	 0,			/* bitsize */
    116 	 FALSE,			/* pc_relative */
    117 	 0,			/* bitpos */
    118 	 complain_overflow_dont, /* complain_on_overflow */
    119 	 _bfd_mips_elf_generic_reloc, /* special_function */
    120 	 "R_MIPS_NONE",		/* name */
    121 	 FALSE,			/* partial_inplace */
    122 	 0,			/* src_mask */
    123 	 0,			/* dst_mask */
    124 	 FALSE),		/* pcrel_offset */
    125 
    126   /* 16 bit relocation.  */
    127   HOWTO (R_MIPS_16,		/* type */
    128 	 0,			/* rightshift */
    129 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    130 	 16,			/* bitsize */
    131 	 FALSE,			/* pc_relative */
    132 	 0,			/* bitpos */
    133 	 complain_overflow_signed, /* complain_on_overflow */
    134 	 _bfd_mips_elf_generic_reloc, /* special_function */
    135 	 "R_MIPS_16",		/* name */
    136 	 TRUE,			/* partial_inplace */
    137 	 0x0000ffff,		/* src_mask */
    138 	 0x0000ffff,		/* dst_mask */
    139 	 FALSE),		/* pcrel_offset */
    140 
    141   /* 32 bit relocation.  */
    142   HOWTO (R_MIPS_32,		/* type */
    143 	 0,			/* rightshift */
    144 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    145 	 32,			/* bitsize */
    146 	 FALSE,			/* pc_relative */
    147 	 0,			/* bitpos */
    148 	 complain_overflow_dont, /* complain_on_overflow */
    149 	 _bfd_mips_elf_generic_reloc, /* special_function */
    150 	 "R_MIPS_32",		/* name */
    151 	 TRUE,			/* partial_inplace */
    152 	 0xffffffff,		/* src_mask */
    153 	 0xffffffff,		/* dst_mask */
    154 	 FALSE),		/* pcrel_offset */
    155 
    156   /* 32 bit symbol relative relocation.  */
    157   HOWTO (R_MIPS_REL32,		/* type */
    158 	 0,			/* rightshift */
    159 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    160 	 32,			/* bitsize */
    161 	 FALSE,			/* pc_relative */
    162 	 0,			/* bitpos */
    163 	 complain_overflow_dont, /* complain_on_overflow */
    164 	 _bfd_mips_elf_generic_reloc, /* special_function */
    165 	 "R_MIPS_REL32",	/* name */
    166 	 TRUE,			/* partial_inplace */
    167 	 0xffffffff,		/* src_mask */
    168 	 0xffffffff,		/* dst_mask */
    169 	 FALSE),		/* pcrel_offset */
    170 
    171   /* 26 bit jump address.  */
    172   HOWTO (R_MIPS_26,		/* type */
    173 	 2,			/* rightshift */
    174 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    175 	 26,			/* bitsize */
    176 	 FALSE,			/* pc_relative */
    177 	 0,			/* bitpos */
    178 	 complain_overflow_dont, /* complain_on_overflow */
    179 	 			/* This needs complex overflow
    180 				   detection, because the upper four
    181 				   bits must match the PC + 4.  */
    182 	 _bfd_mips_elf_generic_reloc, /* special_function */
    183 	 "R_MIPS_26",		/* name */
    184 	 TRUE,			/* partial_inplace */
    185 	 0x03ffffff,		/* src_mask */
    186 	 0x03ffffff,		/* dst_mask */
    187 	 FALSE),		/* pcrel_offset */
    188 
    189   /* R_MIPS_HI16 and R_MIPS_LO16 are unsupported for NewABI REL.
    190      However, the native IRIX6 tools use them, so we try our best. */
    191 
    192   /* High 16 bits of symbol value.  */
    193   HOWTO (R_MIPS_HI16,		/* type */
    194 	 16,			/* rightshift */
    195 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    196 	 16,			/* bitsize */
    197 	 FALSE,			/* pc_relative */
    198 	 0,			/* bitpos */
    199 	 complain_overflow_dont, /* complain_on_overflow */
    200 	 _bfd_mips_elf_hi16_reloc, /* special_function */
    201 	 "R_MIPS_HI16",		/* name */
    202 	 TRUE,			/* partial_inplace */
    203 	 0x0000ffff,		/* src_mask */
    204 	 0x0000ffff,		/* dst_mask */
    205 	 FALSE),		/* pcrel_offset */
    206 
    207   /* Low 16 bits of symbol value.  */
    208   HOWTO (R_MIPS_LO16,		/* type */
    209 	 0,			/* rightshift */
    210 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    211 	 16,			/* bitsize */
    212 	 FALSE,			/* pc_relative */
    213 	 0,			/* bitpos */
    214 	 complain_overflow_dont, /* complain_on_overflow */
    215 	 _bfd_mips_elf_lo16_reloc, /* special_function */
    216 	 "R_MIPS_LO16",		/* name */
    217 	 TRUE,			/* partial_inplace */
    218 	 0x0000ffff,		/* src_mask */
    219 	 0x0000ffff,		/* dst_mask */
    220 	 FALSE),		/* pcrel_offset */
    221 
    222   /* GP relative reference.  */
    223   HOWTO (R_MIPS_GPREL16,	/* type */
    224 	 0,			/* rightshift */
    225 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    226 	 16,			/* bitsize */
    227 	 FALSE,			/* pc_relative */
    228 	 0,			/* bitpos */
    229 	 complain_overflow_signed, /* complain_on_overflow */
    230 	 mips_elf_gprel16_reloc, /* special_function */
    231 	 "R_MIPS_GPREL16",	/* name */
    232 	 TRUE,			/* partial_inplace */
    233 	 0x0000ffff,		/* src_mask */
    234 	 0x0000ffff,		/* dst_mask */
    235 	 FALSE),		/* pcrel_offset */
    236 
    237   /* Reference to literal section.  */
    238   HOWTO (R_MIPS_LITERAL,	/* type */
    239 	 0,			/* rightshift */
    240 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    241 	 16,			/* bitsize */
    242 	 FALSE,			/* pc_relative */
    243 	 0,			/* bitpos */
    244 	 complain_overflow_signed, /* complain_on_overflow */
    245 	 mips_elf_literal_reloc, /* special_function */
    246 	 "R_MIPS_LITERAL",	/* name */
    247 	 TRUE,			/* partial_inplace */
    248 	 0x0000ffff,		/* src_mask */
    249 	 0x0000ffff,		/* dst_mask */
    250 	 FALSE),		/* pcrel_offset */
    251 
    252   /* Reference to global offset table.  */
    253   HOWTO (R_MIPS_GOT16,		/* type */
    254 	 0,			/* rightshift */
    255 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    256 	 16,			/* bitsize */
    257 	 FALSE,			/* pc_relative */
    258 	 0,			/* bitpos */
    259 	 complain_overflow_signed, /* complain_on_overflow */
    260 	 _bfd_mips_elf_got16_reloc, /* special_function */
    261 	 "R_MIPS_GOT16",	/* name */
    262 	 TRUE,			/* partial_inplace */
    263 	 0x0000ffff,		/* src_mask */
    264 	 0x0000ffff,		/* dst_mask */
    265 	 FALSE),		/* pcrel_offset */
    266 
    267   /* 16 bit PC relative reference.  Note that the ABI document has a typo
    268      and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
    269      We do the right thing here.  */
    270   HOWTO (R_MIPS_PC16,		/* type */
    271 	 2,			/* rightshift */
    272 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    273 	 16,			/* bitsize */
    274 	 TRUE,			/* pc_relative */
    275 	 0,			/* bitpos */
    276 	 complain_overflow_signed, /* complain_on_overflow */
    277 	 _bfd_mips_elf_generic_reloc, /* special_function */
    278 	 "R_MIPS_PC16",		/* name */
    279 	 TRUE,			/* partial_inplace */
    280 	 0x0000ffff,		/* src_mask */
    281 	 0x0000ffff,		/* dst_mask */
    282 	 TRUE),			/* pcrel_offset */
    283 
    284   /* 16 bit call through global offset table.  */
    285   HOWTO (R_MIPS_CALL16,		/* type */
    286 	 0,			/* rightshift */
    287 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    288 	 16,			/* bitsize */
    289 	 FALSE,			/* pc_relative */
    290 	 0,			/* bitpos */
    291 	 complain_overflow_signed, /* complain_on_overflow */
    292 	 _bfd_mips_elf_generic_reloc, /* special_function */
    293 	 "R_MIPS_CALL16",	/* name */
    294 	 TRUE,			/* partial_inplace */
    295 	 0x0000ffff,		/* src_mask */
    296 	 0x0000ffff,		/* dst_mask */
    297 	 FALSE),		/* pcrel_offset */
    298 
    299   /* 32 bit GP relative reference.  */
    300   HOWTO (R_MIPS_GPREL32,	/* type */
    301 	 0,			/* rightshift */
    302 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    303 	 32,			/* bitsize */
    304 	 FALSE,			/* pc_relative */
    305 	 0,			/* bitpos */
    306 	 complain_overflow_dont, /* complain_on_overflow */
    307 	 mips_elf_gprel32_reloc, /* special_function */
    308 	 "R_MIPS_GPREL32",	/* name */
    309 	 TRUE,			/* partial_inplace */
    310 	 0xffffffff,		/* src_mask */
    311 	 0xffffffff,		/* dst_mask */
    312 	 FALSE),		/* pcrel_offset */
    313 
    314   /* The remaining relocs are defined on Irix 5, although they are
    315      not defined by the ABI.  */
    316   EMPTY_HOWTO (13),
    317   EMPTY_HOWTO (14),
    318   EMPTY_HOWTO (15),
    319 
    320   /* A 5 bit shift field.  */
    321   HOWTO (R_MIPS_SHIFT5,		/* type */
    322 	 0,			/* rightshift */
    323 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    324 	 5,			/* bitsize */
    325 	 FALSE,			/* pc_relative */
    326 	 6,			/* bitpos */
    327 	 complain_overflow_bitfield, /* complain_on_overflow */
    328 	 _bfd_mips_elf_generic_reloc, /* special_function */
    329 	 "R_MIPS_SHIFT5",	/* name */
    330 	 TRUE,			/* partial_inplace */
    331 	 0x000007c0,		/* src_mask */
    332 	 0x000007c0,		/* dst_mask */
    333 	 FALSE),		/* pcrel_offset */
    334 
    335   /* A 6 bit shift field.  */
    336   HOWTO (R_MIPS_SHIFT6,		/* type */
    337 	 0,			/* rightshift */
    338 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    339 	 6,			/* bitsize */
    340 	 FALSE,			/* pc_relative */
    341 	 6,			/* bitpos */
    342 	 complain_overflow_bitfield, /* complain_on_overflow */
    343 	 mips_elf_shift6_reloc,	/* special_function */
    344 	 "R_MIPS_SHIFT6",	/* name */
    345 	 TRUE,			/* partial_inplace */
    346 	 0x000007c4,		/* src_mask */
    347 	 0x000007c4,		/* dst_mask */
    348 	 FALSE),		/* pcrel_offset */
    349 
    350   /* A 64 bit relocation.  */
    351   HOWTO (R_MIPS_64,		/* type */
    352 	 0,			/* rightshift */
    353 	 4,			/* size (0 = byte, 1 = short, 2 = long) */
    354 	 64,			/* bitsize */
    355 	 FALSE,			/* pc_relative */
    356 	 0,			/* bitpos */
    357 	 complain_overflow_dont, /* complain_on_overflow */
    358 	 _bfd_mips_elf_generic_reloc, /* special_function */
    359 	 "R_MIPS_64",		/* name */
    360 	 TRUE,			/* partial_inplace */
    361 	 MINUS_ONE,		/* src_mask */
    362 	 MINUS_ONE,		/* dst_mask */
    363 	 FALSE),		/* pcrel_offset */
    364 
    365   /* Displacement in the global offset table.  */
    366   HOWTO (R_MIPS_GOT_DISP,	/* type */
    367 	 0,			/* rightshift */
    368 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    369 	 16,			/* bitsize */
    370 	 FALSE,			/* pc_relative */
    371 	 0,			/* bitpos */
    372 	 complain_overflow_signed, /* complain_on_overflow */
    373 	 _bfd_mips_elf_generic_reloc, /* special_function */
    374 	 "R_MIPS_GOT_DISP",	/* name */
    375 	 TRUE,			/* partial_inplace */
    376 	 0x0000ffff,		/* src_mask */
    377 	 0x0000ffff,		/* dst_mask */
    378 	 FALSE),		/* pcrel_offset */
    379 
    380   /* Displacement to page pointer in the global offset table.  */
    381   HOWTO (R_MIPS_GOT_PAGE,	/* type */
    382 	 0,			/* rightshift */
    383 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    384 	 16,			/* bitsize */
    385 	 FALSE,			/* pc_relative */
    386 	 0,			/* bitpos */
    387 	 complain_overflow_signed, /* complain_on_overflow */
    388 	 _bfd_mips_elf_generic_reloc, /* special_function */
    389 	 "R_MIPS_GOT_PAGE",	/* name */
    390 	 TRUE,			/* partial_inplace */
    391 	 0x0000ffff,		/* src_mask */
    392 	 0x0000ffff,		/* dst_mask */
    393 	 FALSE),		/* pcrel_offset */
    394 
    395   /* Offset from page pointer in the global offset table.  */
    396   HOWTO (R_MIPS_GOT_OFST,	/* type */
    397 	 0,			/* rightshift */
    398 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    399 	 16,			/* bitsize */
    400 	 FALSE,			/* pc_relative */
    401 	 0,			/* bitpos */
    402 	 complain_overflow_signed, /* complain_on_overflow */
    403 	 _bfd_mips_elf_generic_reloc, /* special_function */
    404 	 "R_MIPS_GOT_OFST",	/* name */
    405 	 TRUE,			/* partial_inplace */
    406 	 0x0000ffff,		/* src_mask */
    407 	 0x0000ffff,		/* dst_mask */
    408 	 FALSE),		/* pcrel_offset */
    409 
    410   /* High 16 bits of displacement in global offset table.  */
    411   HOWTO (R_MIPS_GOT_HI16,	/* type */
    412 	 0,			/* rightshift */
    413 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    414 	 16,			/* bitsize */
    415 	 FALSE,			/* pc_relative */
    416 	 0,			/* bitpos */
    417 	 complain_overflow_dont, /* complain_on_overflow */
    418 	 _bfd_mips_elf_generic_reloc, /* special_function */
    419 	 "R_MIPS_GOT_HI16",	/* name */
    420 	 TRUE,			/* partial_inplace */
    421 	 0x0000ffff,		/* src_mask */
    422 	 0x0000ffff,		/* dst_mask */
    423 	 FALSE),		/* pcrel_offset */
    424 
    425   /* Low 16 bits of displacement in global offset table.  */
    426   HOWTO (R_MIPS_GOT_LO16,	/* type */
    427 	 0,			/* rightshift */
    428 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    429 	 16,			/* bitsize */
    430 	 FALSE,			/* pc_relative */
    431 	 0,			/* bitpos */
    432 	 complain_overflow_dont, /* complain_on_overflow */
    433 	 _bfd_mips_elf_generic_reloc, /* special_function */
    434 	 "R_MIPS_GOT_LO16",	/* name */
    435 	 TRUE,			/* partial_inplace */
    436 	 0x0000ffff,		/* src_mask */
    437 	 0x0000ffff,		/* dst_mask */
    438 	 FALSE),		/* pcrel_offset */
    439 
    440   /* 64 bit subtraction.  */
    441   HOWTO (R_MIPS_SUB,		/* type */
    442 	 0,			/* rightshift */
    443 	 4,			/* size (0 = byte, 1 = short, 2 = long) */
    444 	 64,			/* bitsize */
    445 	 FALSE,			/* pc_relative */
    446 	 0,			/* bitpos */
    447 	 complain_overflow_dont, /* complain_on_overflow */
    448 	 _bfd_mips_elf_generic_reloc, /* special_function */
    449 	 "R_MIPS_SUB",		/* name */
    450 	 TRUE,			/* partial_inplace */
    451 	 MINUS_ONE,		/* src_mask */
    452 	 MINUS_ONE,		/* dst_mask */
    453 	 FALSE),		/* pcrel_offset */
    454 
    455   /* Insert the addend as an instruction.  */
    456   /* FIXME: Not handled correctly.  */
    457   HOWTO (R_MIPS_INSERT_A,	/* type */
    458 	 0,			/* rightshift */
    459 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    460 	 32,			/* bitsize */
    461 	 FALSE,			/* pc_relative */
    462 	 0,			/* bitpos */
    463 	 complain_overflow_dont, /* complain_on_overflow */
    464 	 _bfd_mips_elf_generic_reloc, /* special_function */
    465 	 "R_MIPS_INSERT_A",	/* name */
    466 	 TRUE,			/* partial_inplace */
    467 	 0xffffffff,		/* src_mask */
    468 	 0xffffffff,		/* dst_mask */
    469 	 FALSE),		/* pcrel_offset */
    470 
    471   /* Insert the addend as an instruction, and change all relocations
    472      to refer to the old instruction at the address.  */
    473   /* FIXME: Not handled correctly.  */
    474   HOWTO (R_MIPS_INSERT_B,	/* type */
    475 	 0,			/* rightshift */
    476 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    477 	 32,			/* bitsize */
    478 	 FALSE,			/* pc_relative */
    479 	 0,			/* bitpos */
    480 	 complain_overflow_dont, /* complain_on_overflow */
    481 	 _bfd_mips_elf_generic_reloc, /* special_function */
    482 	 "R_MIPS_INSERT_B",	/* name */
    483 	 TRUE,			/* partial_inplace */
    484 	 0xffffffff,		/* src_mask */
    485 	 0xffffffff,		/* dst_mask */
    486 	 FALSE),		/* pcrel_offset */
    487 
    488   /* Delete a 32 bit instruction.  */
    489   /* FIXME: Not handled correctly.  */
    490   HOWTO (R_MIPS_DELETE,		/* type */
    491 	 0,			/* rightshift */
    492 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    493 	 32,			/* bitsize */
    494 	 FALSE,			/* pc_relative */
    495 	 0,			/* bitpos */
    496 	 complain_overflow_dont, /* complain_on_overflow */
    497 	 _bfd_mips_elf_generic_reloc, /* special_function */
    498 	 "R_MIPS_DELETE",	/* name */
    499 	 TRUE,			/* partial_inplace */
    500 	 0xffffffff,		/* src_mask */
    501 	 0xffffffff,		/* dst_mask */
    502 	 FALSE),		/* pcrel_offset */
    503 
    504   /* The MIPS ELF64 ABI Draft wants us to support these for REL relocations.
    505      We don't, because
    506        a) It means building the addend from a R_MIPS_HIGHEST/R_MIPS_HIGHER/
    507 	  R_MIPS_HI16/R_MIPS_LO16 sequence with varying ordering, using
    508 	  fallable heuristics.
    509        b) No other NewABI toolchain actually emits such relocations.  */
    510   EMPTY_HOWTO (R_MIPS_HIGHER),
    511   EMPTY_HOWTO (R_MIPS_HIGHEST),
    512 
    513   /* High 16 bits of displacement in global offset table.  */
    514   HOWTO (R_MIPS_CALL_HI16,	/* type */
    515 	 0,			/* rightshift */
    516 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    517 	 16,			/* bitsize */
    518 	 FALSE,			/* pc_relative */
    519 	 0,			/* bitpos */
    520 	 complain_overflow_dont, /* complain_on_overflow */
    521 	 _bfd_mips_elf_generic_reloc, /* special_function */
    522 	 "R_MIPS_CALL_HI16",	/* name */
    523 	 TRUE,			/* partial_inplace */
    524 	 0x0000ffff,		/* src_mask */
    525 	 0x0000ffff,		/* dst_mask */
    526 	 FALSE),		/* pcrel_offset */
    527 
    528   /* Low 16 bits of displacement in global offset table.  */
    529   HOWTO (R_MIPS_CALL_LO16,	/* type */
    530 	 0,			/* rightshift */
    531 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    532 	 16,			/* bitsize */
    533 	 FALSE,			/* pc_relative */
    534 	 0,			/* bitpos */
    535 	 complain_overflow_dont, /* complain_on_overflow */
    536 	 _bfd_mips_elf_generic_reloc, /* special_function */
    537 	 "R_MIPS_CALL_LO16",	/* name */
    538 	 TRUE,			/* partial_inplace */
    539 	 0x0000ffff,		/* src_mask */
    540 	 0x0000ffff,		/* dst_mask */
    541 	 FALSE),		/* pcrel_offset */
    542 
    543   /* Section displacement.  */
    544   HOWTO (R_MIPS_SCN_DISP,       /* type */
    545 	 0,			/* rightshift */
    546 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    547 	 32,			/* bitsize */
    548 	 FALSE,			/* pc_relative */
    549 	 0,			/* bitpos */
    550 	 complain_overflow_dont, /* complain_on_overflow */
    551 	 _bfd_mips_elf_generic_reloc, /* special_function */
    552 	 "R_MIPS_SCN_DISP",     /* name */
    553 	 TRUE,			/* partial_inplace */
    554 	 0xffffffff,		/* src_mask */
    555 	 0xffffffff,		/* dst_mask */
    556 	 FALSE),		/* pcrel_offset */
    557 
    558   HOWTO (R_MIPS_REL16,		/* type */
    559 	 0,			/* rightshift */
    560 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
    561 	 16,			/* bitsize */
    562 	 FALSE,			/* pc_relative */
    563 	 0,			/* bitpos */
    564 	 complain_overflow_signed, /* complain_on_overflow */
    565 	 _bfd_mips_elf_generic_reloc, /* special_function */
    566 	 "R_MIPS_REL16",	/* name */
    567 	 TRUE,			/* partial_inplace */
    568 	 0xffff,		/* src_mask */
    569 	 0xffff,		/* dst_mask */
    570 	 FALSE),		/* pcrel_offset */
    571 
    572   /* These two are obsolete.  */
    573   EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE),
    574   EMPTY_HOWTO (R_MIPS_PJUMP),
    575 
    576   /* Similiar to R_MIPS_REL32, but used for relocations in a GOT section.
    577      It must be used for multigot GOT's (and only there).  */
    578   HOWTO (R_MIPS_RELGOT,		/* type */
    579 	 0,			/* rightshift */
    580 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    581 	 32,			/* bitsize */
    582 	 FALSE,			/* pc_relative */
    583 	 0,			/* bitpos */
    584 	 complain_overflow_dont, /* complain_on_overflow */
    585 	 _bfd_mips_elf_generic_reloc, /* special_function */
    586 	 "R_MIPS_RELGOT",	/* name */
    587 	 TRUE,			/* partial_inplace */
    588 	 0xffffffff,		/* src_mask */
    589 	 0xffffffff,		/* dst_mask */
    590 	 FALSE),		/* pcrel_offset */
    591 
    592   /* Protected jump conversion.  This is an optimization hint.  No
    593      relocation is required for correctness.  */
    594   HOWTO (R_MIPS_JALR,	        /* type */
    595 	 0,			/* rightshift */
    596 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    597 	 32,			/* bitsize */
    598 	 FALSE,			/* pc_relative */
    599 	 0,			/* bitpos */
    600 	 complain_overflow_dont, /* complain_on_overflow */
    601 	 _bfd_mips_elf_generic_reloc, /* special_function */
    602 	 "R_MIPS_JALR",	        /* name */
    603 	 FALSE,			/* partial_inplace */
    604 	 0x00000000,		/* src_mask */
    605 	 0x00000000,		/* dst_mask */
    606 	 FALSE),		/* pcrel_offset */
    607 
    608   /* TLS GD/LD dynamic relocations.  */
    609   HOWTO (R_MIPS_TLS_DTPMOD32,	/* type */
    610 	 0,			/* rightshift */
    611 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    612 	 32,			/* bitsize */
    613 	 FALSE,			/* pc_relative */
    614 	 0,			/* bitpos */
    615 	 complain_overflow_dont, /* complain_on_overflow */
    616 	 _bfd_mips_elf_generic_reloc, /* special_function */
    617 	 "R_MIPS_TLS_DTPMOD32",	/* name */
    618 	 TRUE,			/* partial_inplace */
    619 	 0xffffffff,		/* src_mask */
    620 	 0xffffffff,		/* dst_mask */
    621 	 FALSE),		/* pcrel_offset */
    622 
    623   HOWTO (R_MIPS_TLS_DTPREL32,	/* type */
    624 	 0,			/* rightshift */
    625 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    626 	 32,			/* bitsize */
    627 	 FALSE,			/* pc_relative */
    628 	 0,			/* bitpos */
    629 	 complain_overflow_dont, /* complain_on_overflow */
    630 	 _bfd_mips_elf_generic_reloc, /* special_function */
    631 	 "R_MIPS_TLS_DTPREL32",	/* name */
    632 	 TRUE,			/* partial_inplace */
    633 	 0xffffffff,		/* src_mask */
    634 	 0xffffffff,		/* dst_mask */
    635 	 FALSE),		/* pcrel_offset */
    636 
    637   EMPTY_HOWTO (R_MIPS_TLS_DTPMOD64),
    638   EMPTY_HOWTO (R_MIPS_TLS_DTPREL64),
    639 
    640   /* TLS general dynamic variable reference.  */
    641   HOWTO (R_MIPS_TLS_GD,		/* type */
    642 	 0,			/* rightshift */
    643 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    644 	 16,			/* bitsize */
    645 	 FALSE,			/* pc_relative */
    646 	 0,			/* bitpos */
    647 	 complain_overflow_signed, /* complain_on_overflow */
    648 	 _bfd_mips_elf_generic_reloc, /* special_function */
    649 	 "R_MIPS_TLS_GD",	/* name */
    650 	 TRUE,			/* partial_inplace */
    651 	 0x0000ffff,		/* src_mask */
    652 	 0x0000ffff,		/* dst_mask */
    653 	 FALSE),		/* pcrel_offset */
    654 
    655   /* TLS local dynamic variable reference.  */
    656   HOWTO (R_MIPS_TLS_LDM,	/* type */
    657 	 0,			/* rightshift */
    658 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    659 	 16,			/* bitsize */
    660 	 FALSE,			/* pc_relative */
    661 	 0,			/* bitpos */
    662 	 complain_overflow_signed, /* complain_on_overflow */
    663 	 _bfd_mips_elf_generic_reloc, /* special_function */
    664 	 "R_MIPS_TLS_LDM",	/* name */
    665 	 TRUE,			/* partial_inplace */
    666 	 0x0000ffff,		/* src_mask */
    667 	 0x0000ffff,		/* dst_mask */
    668 	 FALSE),		/* pcrel_offset */
    669 
    670   /* TLS local dynamic offset.  */
    671   HOWTO (R_MIPS_TLS_DTPREL_HI16,	/* type */
    672 	 0,			/* rightshift */
    673 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    674 	 16,			/* bitsize */
    675 	 FALSE,			/* pc_relative */
    676 	 0,			/* bitpos */
    677 	 complain_overflow_signed, /* complain_on_overflow */
    678 	 _bfd_mips_elf_generic_reloc, /* special_function */
    679 	 "R_MIPS_TLS_DTPREL_HI16",	/* name */
    680 	 TRUE,			/* partial_inplace */
    681 	 0x0000ffff,		/* src_mask */
    682 	 0x0000ffff,		/* dst_mask */
    683 	 FALSE),		/* pcrel_offset */
    684 
    685   /* TLS local dynamic offset.  */
    686   HOWTO (R_MIPS_TLS_DTPREL_LO16,	/* type */
    687 	 0,			/* rightshift */
    688 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    689 	 16,			/* bitsize */
    690 	 FALSE,			/* pc_relative */
    691 	 0,			/* bitpos */
    692 	 complain_overflow_signed, /* complain_on_overflow */
    693 	 _bfd_mips_elf_generic_reloc, /* special_function */
    694 	 "R_MIPS_TLS_DTPREL_LO16",	/* name */
    695 	 TRUE,			/* partial_inplace */
    696 	 0x0000ffff,		/* src_mask */
    697 	 0x0000ffff,		/* dst_mask */
    698 	 FALSE),		/* pcrel_offset */
    699 
    700   /* TLS thread pointer offset.  */
    701   HOWTO (R_MIPS_TLS_GOTTPREL,	/* type */
    702 	 0,			/* rightshift */
    703 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    704 	 16,			/* bitsize */
    705 	 FALSE,			/* pc_relative */
    706 	 0,			/* bitpos */
    707 	 complain_overflow_signed, /* complain_on_overflow */
    708 	 _bfd_mips_elf_generic_reloc, /* special_function */
    709 	 "R_MIPS_TLS_GOTTPREL",	/* name */
    710 	 TRUE,			/* partial_inplace */
    711 	 0x0000ffff,		/* src_mask */
    712 	 0x0000ffff,		/* dst_mask */
    713 	 FALSE),		/* pcrel_offset */
    714 
    715   /* TLS IE dynamic relocations.  */
    716   HOWTO (R_MIPS_TLS_TPREL32,	/* type */
    717 	 0,			/* rightshift */
    718 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    719 	 32,			/* bitsize */
    720 	 FALSE,			/* pc_relative */
    721 	 0,			/* bitpos */
    722 	 complain_overflow_dont, /* complain_on_overflow */
    723 	 _bfd_mips_elf_generic_reloc, /* special_function */
    724 	 "R_MIPS_TLS_TPREL32",	/* name */
    725 	 TRUE,			/* partial_inplace */
    726 	 0xffffffff,		/* src_mask */
    727 	 0xffffffff,		/* dst_mask */
    728 	 FALSE),		/* pcrel_offset */
    729 
    730   EMPTY_HOWTO (R_MIPS_TLS_TPREL64),
    731 
    732   /* TLS thread pointer offset.  */
    733   HOWTO (R_MIPS_TLS_TPREL_HI16,	/* type */
    734 	 0,			/* rightshift */
    735 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    736 	 16,			/* bitsize */
    737 	 FALSE,			/* pc_relative */
    738 	 0,			/* bitpos */
    739 	 complain_overflow_signed, /* complain_on_overflow */
    740 	 _bfd_mips_elf_generic_reloc, /* special_function */
    741 	 "R_MIPS_TLS_TPREL_HI16", /* name */
    742 	 TRUE,			/* partial_inplace */
    743 	 0x0000ffff,		/* src_mask */
    744 	 0x0000ffff,		/* dst_mask */
    745 	 FALSE),		/* pcrel_offset */
    746 
    747   /* TLS thread pointer offset.  */
    748   HOWTO (R_MIPS_TLS_TPREL_LO16,	/* type */
    749 	 0,			/* rightshift */
    750 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    751 	 16,			/* bitsize */
    752 	 FALSE,			/* pc_relative */
    753 	 0,			/* bitpos */
    754 	 complain_overflow_signed, /* complain_on_overflow */
    755 	 _bfd_mips_elf_generic_reloc, /* special_function */
    756 	 "R_MIPS_TLS_TPREL_LO16", /* name */
    757 	 TRUE,			/* partial_inplace */
    758 	 0x0000ffff,		/* src_mask */
    759 	 0x0000ffff,		/* dst_mask */
    760 	 FALSE),		/* pcrel_offset */
    761 
    762   /* 32 bit relocation with no addend.  */
    763   HOWTO (R_MIPS_GLOB_DAT,	/* type */
    764 	 0,			/* rightshift */
    765 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    766 	 32,			/* bitsize */
    767 	 FALSE,			/* pc_relative */
    768 	 0,			/* bitpos */
    769 	 complain_overflow_dont, /* complain_on_overflow */
    770 	 _bfd_mips_elf_generic_reloc, /* special_function */
    771 	 "R_MIPS_GLOB_DAT",	/* name */
    772 	 FALSE,			/* partial_inplace */
    773 	 0x0,			/* src_mask */
    774 	 0xffffffff,		/* dst_mask */
    775 	 FALSE),		/* pcrel_offset */
    776 };
    777 
    778 /* The relocation table used for SHT_RELA sections.  */
    779 
    780 static reloc_howto_type elf_mips_howto_table_rela[] =
    781 {
    782   /* No relocation.  */
    783   HOWTO (R_MIPS_NONE,		/* type */
    784 	 0,			/* rightshift */
    785 	 0,			/* size (0 = byte, 1 = short, 2 = long) */
    786 	 0,			/* bitsize */
    787 	 FALSE,			/* pc_relative */
    788 	 0,			/* bitpos */
    789 	 complain_overflow_dont, /* complain_on_overflow */
    790 	 _bfd_mips_elf_generic_reloc, /* special_function */
    791 	 "R_MIPS_NONE",		/* name */
    792 	 FALSE,			/* partial_inplace */
    793 	 0,			/* src_mask */
    794 	 0,			/* dst_mask */
    795 	 FALSE),		/* pcrel_offset */
    796 
    797   /* 16 bit relocation.  */
    798   HOWTO (R_MIPS_16,		/* type */
    799 	 0,			/* rightshift */
    800 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    801 	 16,			/* bitsize */
    802 	 FALSE,			/* pc_relative */
    803 	 0,			/* bitpos */
    804 	 complain_overflow_signed, /* complain_on_overflow */
    805 	 _bfd_mips_elf_generic_reloc, /* special_function */
    806 	 "R_MIPS_16",		/* name */
    807 	 FALSE,			/* partial_inplace */
    808 	 0,			/* src_mask */
    809 	 0x0000,		/* dst_mask */
    810 	 FALSE),		/* pcrel_offset */
    811 
    812   /* 32 bit relocation.  */
    813   HOWTO (R_MIPS_32,		/* type */
    814 	 0,			/* rightshift */
    815 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    816 	 32,			/* bitsize */
    817 	 FALSE,			/* pc_relative */
    818 	 0,			/* bitpos */
    819 	 complain_overflow_dont, /* complain_on_overflow */
    820 	 _bfd_mips_elf_generic_reloc, /* special_function */
    821 	 "R_MIPS_32",		/* name */
    822 	 FALSE,			/* partial_inplace */
    823 	 0,			/* src_mask */
    824 	 0xffffffff,		/* dst_mask */
    825 	 FALSE),		/* pcrel_offset */
    826 
    827   /* 32 bit symbol relative relocation.  */
    828   HOWTO (R_MIPS_REL32,		/* type */
    829 	 0,			/* rightshift */
    830 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    831 	 32,			/* bitsize */
    832 	 FALSE,			/* pc_relative */
    833 	 0,			/* bitpos */
    834 	 complain_overflow_dont, /* complain_on_overflow */
    835 	 _bfd_mips_elf_generic_reloc, /* special_function */
    836 	 "R_MIPS_REL32",	/* name */
    837 	 FALSE,			/* partial_inplace */
    838 	 0,			/* src_mask */
    839 	 0xffffffff,		/* dst_mask */
    840 	 FALSE),		/* pcrel_offset */
    841 
    842   /* 26 bit jump address.  */
    843   HOWTO (R_MIPS_26,		/* type */
    844 	 2,			/* rightshift */
    845 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    846 	 26,			/* bitsize */
    847 	 FALSE,			/* pc_relative */
    848 	 0,			/* bitpos */
    849 	 complain_overflow_dont, /* complain_on_overflow */
    850 				/* This needs complex overflow
    851 				   detection, because the upper 36
    852 				   bits must match the PC + 4.  */
    853 	 _bfd_mips_elf_generic_reloc, /* special_function */
    854 	 "R_MIPS_26",		/* name */
    855 	 FALSE,			/* partial_inplace */
    856 	 0,			/* src_mask */
    857 	 0x03ffffff,		/* dst_mask */
    858 	 FALSE),		/* pcrel_offset */
    859 
    860   /* High 16 bits of symbol value.  */
    861   HOWTO (R_MIPS_HI16,		/* type */
    862 	 0,			/* rightshift */
    863 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    864 	 16,			/* bitsize */
    865 	 FALSE,			/* pc_relative */
    866 	 0,			/* bitpos */
    867 	 complain_overflow_dont, /* complain_on_overflow */
    868 	 _bfd_mips_elf_generic_reloc, /* special_function */
    869 	 "R_MIPS_HI16",		/* name */
    870 	 FALSE,			/* partial_inplace */
    871 	 0,			/* src_mask */
    872 	 0x0000ffff,		/* dst_mask */
    873 	 FALSE),		/* pcrel_offset */
    874 
    875   /* Low 16 bits of symbol value.  */
    876   HOWTO (R_MIPS_LO16,		/* type */
    877 	 0,			/* rightshift */
    878 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    879 	 16,			/* bitsize */
    880 	 FALSE,			/* pc_relative */
    881 	 0,			/* bitpos */
    882 	 complain_overflow_dont, /* complain_on_overflow */
    883 	 _bfd_mips_elf_generic_reloc, /* special_function */
    884 	 "R_MIPS_LO16",		/* name */
    885 	 FALSE,			/* partial_inplace */
    886 	 0,			/* src_mask */
    887 	 0x0000ffff,		/* dst_mask */
    888 	 FALSE),		/* pcrel_offset */
    889 
    890   /* GP relative reference.  */
    891   HOWTO (R_MIPS_GPREL16,	/* type */
    892 	 0,			/* rightshift */
    893 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    894 	 16,			/* bitsize */
    895 	 FALSE,			/* pc_relative */
    896 	 0,			/* bitpos */
    897 	 complain_overflow_signed, /* complain_on_overflow */
    898 	 mips_elf_gprel16_reloc, /* special_function */
    899 	 "R_MIPS_GPREL16",	/* name */
    900 	 FALSE,			/* partial_inplace */
    901 	 0,			/* src_mask */
    902 	 0x0000ffff,		/* dst_mask */
    903 	 FALSE),		/* pcrel_offset */
    904 
    905   /* Reference to literal section.  */
    906   HOWTO (R_MIPS_LITERAL,	/* type */
    907 	 0,			/* rightshift */
    908 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    909 	 16,			/* bitsize */
    910 	 FALSE,			/* pc_relative */
    911 	 0,			/* bitpos */
    912 	 complain_overflow_signed, /* complain_on_overflow */
    913 	 mips_elf_literal_reloc, /* special_function */
    914 	 "R_MIPS_LITERAL",	/* name */
    915 	 FALSE,			/* partial_inplace */
    916 	 0,			/* src_mask */
    917 	 0x0000ffff,		/* dst_mask */
    918 	 FALSE),		/* pcrel_offset */
    919 
    920   /* Reference to global offset table.  */
    921   HOWTO (R_MIPS_GOT16,		/* type */
    922 	 0,			/* rightshift */
    923 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    924 	 16,			/* bitsize */
    925 	 FALSE,			/* pc_relative */
    926 	 0,			/* bitpos */
    927 	 complain_overflow_signed, /* complain_on_overflow */
    928 	 _bfd_mips_elf_generic_reloc, /* special_function */
    929 	 "R_MIPS_GOT16",	/* name */
    930 	 FALSE,			/* partial_inplace */
    931 	 0,			/* src_mask */
    932 	 0x0000ffff,		/* dst_mask */
    933 	 FALSE),		/* pcrel_offset */
    934 
    935   /* 16 bit PC relative reference.  Note that the ABI document has a typo
    936      and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
    937      We do the right thing here.  */
    938   HOWTO (R_MIPS_PC16,		/* type */
    939 	 2,			/* rightshift */
    940 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    941 	 16,			/* bitsize */
    942 	 TRUE,			/* pc_relative */
    943 	 0,			/* bitpos */
    944 	 complain_overflow_signed, /* complain_on_overflow */
    945 	 _bfd_mips_elf_generic_reloc, /* special_function */
    946 	 "R_MIPS_PC16",		/* name */
    947 	 FALSE,			/* partial_inplace */
    948 	 0,			/* src_mask */
    949 	 0x0000ffff,		/* dst_mask */
    950 	 TRUE),			/* pcrel_offset */
    951 
    952   /* 16 bit call through global offset table.  */
    953   HOWTO (R_MIPS_CALL16,		/* type */
    954 	 0,			/* rightshift */
    955 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    956 	 16,			/* bitsize */
    957 	 FALSE,			/* pc_relative */
    958 	 0,			/* bitpos */
    959 	 complain_overflow_signed, /* complain_on_overflow */
    960 	 _bfd_mips_elf_generic_reloc, /* special_function */
    961 	 "R_MIPS_CALL16",	/* name */
    962 	 FALSE,			/* partial_inplace */
    963 	 0,			/* src_mask */
    964 	 0x0000ffff,		/* dst_mask */
    965 	 FALSE),		/* pcrel_offset */
    966 
    967   /* 32 bit GP relative reference.  */
    968   HOWTO (R_MIPS_GPREL32,	/* type */
    969 	 0,			/* rightshift */
    970 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    971 	 32,			/* bitsize */
    972 	 FALSE,			/* pc_relative */
    973 	 0,			/* bitpos */
    974 	 complain_overflow_dont, /* complain_on_overflow */
    975 	 mips_elf_gprel32_reloc, /* special_function */
    976 	 "R_MIPS_GPREL32",	/* name */
    977 	 FALSE,			/* partial_inplace */
    978 	 0,			/* src_mask */
    979 	 0xffffffff,		/* dst_mask */
    980 	 FALSE),		/* pcrel_offset */
    981 
    982   EMPTY_HOWTO (13),
    983   EMPTY_HOWTO (14),
    984   EMPTY_HOWTO (15),
    985 
    986   /* A 5 bit shift field.  */
    987   HOWTO (R_MIPS_SHIFT5,		/* type */
    988 	 0,			/* rightshift */
    989 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
    990 	 5,			/* bitsize */
    991 	 FALSE,			/* pc_relative */
    992 	 6,			/* bitpos */
    993 	 complain_overflow_bitfield, /* complain_on_overflow */
    994 	 _bfd_mips_elf_generic_reloc, /* special_function */
    995 	 "R_MIPS_SHIFT5",	/* name */
    996 	 FALSE,			/* partial_inplace */
    997 	 0,			/* src_mask */
    998 	 0x000007c0,		/* dst_mask */
    999 	 FALSE),		/* pcrel_offset */
   1000 
   1001   /* A 6 bit shift field.  */
   1002   HOWTO (R_MIPS_SHIFT6,		/* type */
   1003 	 0,			/* rightshift */
   1004 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1005 	 6,			/* bitsize */
   1006 	 FALSE,			/* pc_relative */
   1007 	 6,			/* bitpos */
   1008 	 complain_overflow_bitfield, /* complain_on_overflow */
   1009 	 mips_elf_shift6_reloc,	/* special_function */
   1010 	 "R_MIPS_SHIFT6",	/* name */
   1011 	 FALSE,			/* partial_inplace */
   1012 	 0,			/* src_mask */
   1013 	 0x000007c4,		/* dst_mask */
   1014 	 FALSE),		/* pcrel_offset */
   1015 
   1016   /* 64 bit relocation.  */
   1017   HOWTO (R_MIPS_64,		/* type */
   1018 	 0,			/* rightshift */
   1019 	 4,			/* size (0 = byte, 1 = short, 2 = long) */
   1020 	 64,			/* bitsize */
   1021 	 FALSE,			/* pc_relative */
   1022 	 0,			/* bitpos */
   1023 	 complain_overflow_dont, /* complain_on_overflow */
   1024 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1025 	 "R_MIPS_64",		/* name */
   1026 	 FALSE,			/* partial_inplace */
   1027 	 0,			/* src_mask */
   1028 	 MINUS_ONE,		/* dst_mask */
   1029 	 FALSE),		/* pcrel_offset */
   1030 
   1031   /* Displacement in the global offset table.  */
   1032   HOWTO (R_MIPS_GOT_DISP,	/* type */
   1033 	 0,			/* rightshift */
   1034 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1035 	 16,			/* bitsize */
   1036 	 FALSE,			/* pc_relative */
   1037 	 0,			/* bitpos */
   1038 	 complain_overflow_signed, /* complain_on_overflow */
   1039 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1040 	 "R_MIPS_GOT_DISP",	/* name */
   1041 	 FALSE,			/* partial_inplace */
   1042 	 0,			/* src_mask */
   1043 	 0x0000ffff,		/* dst_mask */
   1044 	 FALSE),		/* pcrel_offset */
   1045 
   1046   /* Displacement to page pointer in the global offset table.  */
   1047   HOWTO (R_MIPS_GOT_PAGE,	/* type */
   1048 	 0,			/* rightshift */
   1049 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1050 	 16,			/* bitsize */
   1051 	 FALSE,			/* pc_relative */
   1052 	 0,			/* bitpos */
   1053 	 complain_overflow_signed, /* complain_on_overflow */
   1054 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1055 	 "R_MIPS_GOT_PAGE",	/* name */
   1056 	 FALSE,			/* partial_inplace */
   1057 	 0,			/* src_mask */
   1058 	 0x0000ffff,		/* dst_mask */
   1059 	 FALSE),		/* pcrel_offset */
   1060 
   1061   /* Offset from page pointer in the global offset table.  */
   1062   HOWTO (R_MIPS_GOT_OFST,	/* type */
   1063 	 0,			/* rightshift */
   1064 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1065 	 16,			/* bitsize */
   1066 	 FALSE,			/* pc_relative */
   1067 	 0,			/* bitpos */
   1068 	 complain_overflow_signed, /* complain_on_overflow */
   1069 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1070 	 "R_MIPS_GOT_OFST",	/* name */
   1071 	 FALSE,			/* partial_inplace */
   1072 	 0,			/* src_mask */
   1073 	 0x0000ffff,		/* dst_mask */
   1074 	 FALSE),		/* pcrel_offset */
   1075 
   1076   /* High 16 bits of displacement in global offset table.  */
   1077   HOWTO (R_MIPS_GOT_HI16,	/* type */
   1078 	 0,			/* rightshift */
   1079 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1080 	 16,			/* bitsize */
   1081 	 FALSE,			/* pc_relative */
   1082 	 0,			/* bitpos */
   1083 	 complain_overflow_dont, /* complain_on_overflow */
   1084 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1085 	 "R_MIPS_GOT_HI16",	/* name */
   1086 	 FALSE,			/* partial_inplace */
   1087 	 0,			/* src_mask */
   1088 	 0x0000ffff,		/* dst_mask */
   1089 	 FALSE),		/* pcrel_offset */
   1090 
   1091   /* Low 16 bits of displacement in global offset table.  */
   1092   HOWTO (R_MIPS_GOT_LO16,	/* type */
   1093 	 0,			/* rightshift */
   1094 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1095 	 16,			/* bitsize */
   1096 	 FALSE,			/* pc_relative */
   1097 	 0,			/* bitpos */
   1098 	 complain_overflow_dont, /* complain_on_overflow */
   1099 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1100 	 "R_MIPS_GOT_LO16",	/* name */
   1101 	 FALSE,			/* partial_inplace */
   1102 	 0,			/* src_mask */
   1103 	 0x0000ffff,		/* dst_mask */
   1104 	 FALSE),		/* pcrel_offset */
   1105 
   1106   /* 64 bit subtraction.  */
   1107   HOWTO (R_MIPS_SUB,		/* type */
   1108 	 0,			/* rightshift */
   1109 	 4,			/* size (0 = byte, 1 = short, 2 = long) */
   1110 	 64,			/* bitsize */
   1111 	 FALSE,			/* pc_relative */
   1112 	 0,			/* bitpos */
   1113 	 complain_overflow_dont, /* complain_on_overflow */
   1114 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1115 	 "R_MIPS_SUB",		/* name */
   1116 	 FALSE,			/* partial_inplace */
   1117 	 0,			/* src_mask */
   1118 	 MINUS_ONE,		/* dst_mask */
   1119 	 FALSE),		/* pcrel_offset */
   1120 
   1121   /* Insert the addend as an instruction.  */
   1122   /* FIXME: Not handled correctly.  */
   1123   HOWTO (R_MIPS_INSERT_A,	/* type */
   1124 	 0,			/* rightshift */
   1125 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1126 	 32,			/* bitsize */
   1127 	 FALSE,			/* pc_relative */
   1128 	 0,			/* bitpos */
   1129 	 complain_overflow_dont, /* complain_on_overflow */
   1130 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1131 	 "R_MIPS_INSERT_A",	/* name */
   1132 	 FALSE,			/* partial_inplace */
   1133 	 0,			/* src_mask */
   1134 	 0xffffffff,		/* dst_mask */
   1135 	 FALSE),		/* pcrel_offset */
   1136 
   1137   /* Insert the addend as an instruction, and change all relocations
   1138      to refer to the old instruction at the address.  */
   1139   /* FIXME: Not handled correctly.  */
   1140   HOWTO (R_MIPS_INSERT_B,	/* type */
   1141 	 0,			/* rightshift */
   1142 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1143 	 32,			/* bitsize */
   1144 	 FALSE,			/* pc_relative */
   1145 	 0,			/* bitpos */
   1146 	 complain_overflow_dont, /* complain_on_overflow */
   1147 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1148 	 "R_MIPS_INSERT_B",	/* name */
   1149 	 FALSE,			/* partial_inplace */
   1150 	 0,			/* src_mask */
   1151 	 0xffffffff,		/* dst_mask */
   1152 	 FALSE),		/* pcrel_offset */
   1153 
   1154   /* Delete a 32 bit instruction.  */
   1155   /* FIXME: Not handled correctly.  */
   1156   HOWTO (R_MIPS_DELETE,		/* type */
   1157 	 0,			/* rightshift */
   1158 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1159 	 32,			/* bitsize */
   1160 	 FALSE,			/* pc_relative */
   1161 	 0,			/* bitpos */
   1162 	 complain_overflow_dont, /* complain_on_overflow */
   1163 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1164 	 "R_MIPS_DELETE",	/* name */
   1165 	 FALSE,			/* partial_inplace */
   1166 	 0,			/* src_mask */
   1167 	 0xffffffff,		/* dst_mask */
   1168 	 FALSE),		/* pcrel_offset */
   1169 
   1170   /* Get the higher value of a 64 bit addend.  */
   1171   HOWTO (R_MIPS_HIGHER,		/* type */
   1172 	 0,			/* rightshift */
   1173 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1174 	 16,			/* bitsize */
   1175 	 FALSE,			/* pc_relative */
   1176 	 0,			/* bitpos */
   1177 	 complain_overflow_dont, /* complain_on_overflow */
   1178 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1179 	 "R_MIPS_HIGHER",	/* name */
   1180 	 FALSE,			/* partial_inplace */
   1181 	 0,			/* src_mask */
   1182 	 0x0000ffff,		/* dst_mask */
   1183 	 FALSE),		/* pcrel_offset */
   1184 
   1185   /* Get the highest value of a 64 bit addend.  */
   1186   HOWTO (R_MIPS_HIGHEST,	/* type */
   1187 	 0,			/* rightshift */
   1188 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1189 	 16,			/* bitsize */
   1190 	 FALSE,			/* pc_relative */
   1191 	 0,			/* bitpos */
   1192 	 complain_overflow_dont, /* complain_on_overflow */
   1193 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1194 	 "R_MIPS_HIGHEST",	/* name */
   1195 	 FALSE,			/* partial_inplace */
   1196 	 0,			/* src_mask */
   1197 	 0x0000ffff,		/* dst_mask */
   1198 	 FALSE),		/* pcrel_offset */
   1199 
   1200   /* High 16 bits of displacement in global offset table.  */
   1201   HOWTO (R_MIPS_CALL_HI16,	/* type */
   1202 	 0,			/* rightshift */
   1203 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1204 	 16,			/* bitsize */
   1205 	 FALSE,			/* pc_relative */
   1206 	 0,			/* bitpos */
   1207 	 complain_overflow_dont, /* complain_on_overflow */
   1208 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1209 	 "R_MIPS_CALL_HI16",	/* name */
   1210 	 FALSE,			/* partial_inplace */
   1211 	 0,			/* src_mask */
   1212 	 0x0000ffff,		/* dst_mask */
   1213 	 FALSE),		/* pcrel_offset */
   1214 
   1215   /* Low 16 bits of displacement in global offset table.  */
   1216   HOWTO (R_MIPS_CALL_LO16,	/* type */
   1217 	 0,			/* rightshift */
   1218 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1219 	 16,			/* bitsize */
   1220 	 FALSE,			/* pc_relative */
   1221 	 0,			/* bitpos */
   1222 	 complain_overflow_dont, /* complain_on_overflow */
   1223 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1224 	 "R_MIPS_CALL_LO16",	/* name */
   1225 	 FALSE,			/* partial_inplace */
   1226 	 0,			/* src_mask */
   1227 	 0x0000ffff,		/* dst_mask */
   1228 	 FALSE),		/* pcrel_offset */
   1229 
   1230   /* Section displacement, used by an associated event location section.  */
   1231   HOWTO (R_MIPS_SCN_DISP,	/* type */
   1232 	 0,			/* rightshift */
   1233 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1234 	 32,			/* bitsize */
   1235 	 FALSE,			/* pc_relative */
   1236 	 0,			/* bitpos */
   1237 	 complain_overflow_dont, /* complain_on_overflow */
   1238 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1239 	 "R_MIPS_SCN_DISP",	/* name */
   1240 	 FALSE,			/* partial_inplace */
   1241 	 0,			/* src_mask */
   1242 	 0xffffffff,		/* dst_mask */
   1243 	 FALSE),		/* pcrel_offset */
   1244 
   1245   /* 16 bit relocation.  */
   1246   HOWTO (R_MIPS_REL16,		/* type */
   1247 	 0,			/* rightshift */
   1248 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
   1249 	 16,			/* bitsize */
   1250 	 FALSE,			/* pc_relative */
   1251 	 0,			/* bitpos */
   1252 	 complain_overflow_signed, /* complain_on_overflow */
   1253 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1254 	 "R_MIPS_REL16",	/* name */
   1255 	 FALSE,			/* partial_inplace */
   1256 	 0,			/* src_mask */
   1257 	 0xffff,		/* dst_mask */
   1258 	 FALSE),		/* pcrel_offset */
   1259 
   1260   /* These two are obsolete.  */
   1261   EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE),
   1262   EMPTY_HOWTO (R_MIPS_PJUMP),
   1263 
   1264   /* Similiar to R_MIPS_REL32, but used for relocations in a GOT section.
   1265      It must be used for multigot GOT's (and only there).  */
   1266   HOWTO (R_MIPS_RELGOT,		/* type */
   1267 	 0,			/* rightshift */
   1268 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1269 	 32,			/* bitsize */
   1270 	 FALSE,			/* pc_relative */
   1271 	 0,			/* bitpos */
   1272 	 complain_overflow_dont, /* complain_on_overflow */
   1273 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1274 	 "R_MIPS_RELGOT",	/* name */
   1275 	 FALSE,			/* partial_inplace */
   1276 	 0,			/* src_mask */
   1277 	 0xffffffff,		/* dst_mask */
   1278 	 FALSE),		/* pcrel_offset */
   1279 
   1280   /* Protected jump conversion.  This is an optimization hint.  No
   1281      relocation is required for correctness.  */
   1282   HOWTO (R_MIPS_JALR,	        /* type */
   1283 	 0,			/* rightshift */
   1284 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1285 	 32,			/* bitsize */
   1286 	 FALSE,			/* pc_relative */
   1287 	 0,			/* bitpos */
   1288 	 complain_overflow_dont, /* complain_on_overflow */
   1289 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1290 	 "R_MIPS_JALR",	        /* name */
   1291 	 FALSE,			/* partial_inplace */
   1292 	 0,			/* src_mask */
   1293 	 0,			/* dst_mask */
   1294 	 FALSE),		/* pcrel_offset */
   1295 
   1296   /* TLS GD/LD dynamic relocations.  */
   1297   HOWTO (R_MIPS_TLS_DTPMOD32,	/* type */
   1298 	 0,			/* rightshift */
   1299 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1300 	 32,			/* bitsize */
   1301 	 FALSE,			/* pc_relative */
   1302 	 0,			/* bitpos */
   1303 	 complain_overflow_dont, /* complain_on_overflow */
   1304 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1305 	 "R_MIPS_TLS_DTPMOD32",	/* name */
   1306 	 FALSE,			/* partial_inplace */
   1307 	 0,			/* src_mask */
   1308 	 0xffffffff,		/* dst_mask */
   1309 	 FALSE),		/* pcrel_offset */
   1310 
   1311   HOWTO (R_MIPS_TLS_DTPREL32,	/* type */
   1312 	 0,			/* rightshift */
   1313 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1314 	 32,			/* bitsize */
   1315 	 FALSE,			/* pc_relative */
   1316 	 0,			/* bitpos */
   1317 	 complain_overflow_dont, /* complain_on_overflow */
   1318 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1319 	 "R_MIPS_TLS_DTPREL32",	/* name */
   1320 	 FALSE,			/* partial_inplace */
   1321 	 0,			/* src_mask */
   1322 	 0xffffffff,		/* dst_mask */
   1323 	 FALSE),		/* pcrel_offset */
   1324 
   1325   EMPTY_HOWTO (R_MIPS_TLS_DTPMOD64),
   1326   EMPTY_HOWTO (R_MIPS_TLS_DTPREL64),
   1327 
   1328   /* TLS general dynamic variable reference.  */
   1329   HOWTO (R_MIPS_TLS_GD,		/* type */
   1330 	 0,			/* rightshift */
   1331 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1332 	 16,			/* bitsize */
   1333 	 FALSE,			/* pc_relative */
   1334 	 0,			/* bitpos */
   1335 	 complain_overflow_signed, /* complain_on_overflow */
   1336 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1337 	 "R_MIPS_TLS_GD",	/* name */
   1338 	 FALSE,			/* partial_inplace */
   1339 	 0,			/* src_mask */
   1340 	 0x0000ffff,		/* dst_mask */
   1341 	 FALSE),		/* pcrel_offset */
   1342 
   1343   /* TLS local dynamic variable reference.  */
   1344   HOWTO (R_MIPS_TLS_LDM,	/* type */
   1345 	 0,			/* rightshift */
   1346 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1347 	 16,			/* bitsize */
   1348 	 FALSE,			/* pc_relative */
   1349 	 0,			/* bitpos */
   1350 	 complain_overflow_signed, /* complain_on_overflow */
   1351 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1352 	 "R_MIPS_TLS_LDM",	/* name */
   1353 	 FALSE,			/* partial_inplace */
   1354 	 0,			/* src_mask */
   1355 	 0x0000ffff,		/* dst_mask */
   1356 	 FALSE),		/* pcrel_offset */
   1357 
   1358   /* TLS local dynamic offset.  */
   1359   HOWTO (R_MIPS_TLS_DTPREL_HI16,	/* type */
   1360 	 0,			/* rightshift */
   1361 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1362 	 16,			/* bitsize */
   1363 	 FALSE,			/* pc_relative */
   1364 	 0,			/* bitpos */
   1365 	 complain_overflow_signed, /* complain_on_overflow */
   1366 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1367 	 "R_MIPS_TLS_DTPREL_HI16",	/* name */
   1368 	 FALSE,			/* partial_inplace */
   1369 	 0,			/* src_mask */
   1370 	 0x0000ffff,		/* dst_mask */
   1371 	 FALSE),		/* pcrel_offset */
   1372 
   1373   /* TLS local dynamic offset.  */
   1374   HOWTO (R_MIPS_TLS_DTPREL_LO16,	/* type */
   1375 	 0,			/* rightshift */
   1376 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1377 	 16,			/* bitsize */
   1378 	 FALSE,			/* pc_relative */
   1379 	 0,			/* bitpos */
   1380 	 complain_overflow_signed, /* complain_on_overflow */
   1381 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1382 	 "R_MIPS_TLS_DTPREL_LO16",	/* name */
   1383 	 FALSE,			/* partial_inplace */
   1384 	 0,			/* src_mask */
   1385 	 0x0000ffff,		/* dst_mask */
   1386 	 FALSE),		/* pcrel_offset */
   1387 
   1388   /* TLS thread pointer offset.  */
   1389   HOWTO (R_MIPS_TLS_GOTTPREL,	/* type */
   1390 	 0,			/* rightshift */
   1391 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1392 	 16,			/* bitsize */
   1393 	 FALSE,			/* pc_relative */
   1394 	 0,			/* bitpos */
   1395 	 complain_overflow_signed, /* complain_on_overflow */
   1396 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1397 	 "R_MIPS_TLS_GOTTPREL",	/* name */
   1398 	 FALSE,			/* partial_inplace */
   1399 	 0,			/* src_mask */
   1400 	 0x0000ffff,		/* dst_mask */
   1401 	 FALSE),		/* pcrel_offset */
   1402 
   1403   /* TLS IE dynamic relocations.  */
   1404   HOWTO (R_MIPS_TLS_TPREL32,	/* type */
   1405 	 0,			/* rightshift */
   1406 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1407 	 32,			/* bitsize */
   1408 	 FALSE,			/* pc_relative */
   1409 	 0,			/* bitpos */
   1410 	 complain_overflow_dont, /* complain_on_overflow */
   1411 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1412 	 "R_MIPS_TLS_TPREL32",	/* name */
   1413 	 FALSE,			/* partial_inplace */
   1414 	 0,			/* src_mask */
   1415 	 0xffffffff,		/* dst_mask */
   1416 	 FALSE),		/* pcrel_offset */
   1417 
   1418   EMPTY_HOWTO (R_MIPS_TLS_TPREL64),
   1419 
   1420   /* TLS thread pointer offset.  */
   1421   HOWTO (R_MIPS_TLS_TPREL_HI16,	/* type */
   1422 	 0,			/* rightshift */
   1423 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1424 	 16,			/* bitsize */
   1425 	 FALSE,			/* pc_relative */
   1426 	 0,			/* bitpos */
   1427 	 complain_overflow_signed, /* complain_on_overflow */
   1428 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1429 	 "R_MIPS_TLS_TPREL_HI16", /* name */
   1430 	 FALSE,			/* partial_inplace */
   1431 	 0,			/* src_mask */
   1432 	 0x0000ffff,		/* dst_mask */
   1433 	 FALSE),		/* pcrel_offset */
   1434 
   1435   /* TLS thread pointer offset.  */
   1436   HOWTO (R_MIPS_TLS_TPREL_LO16,	/* type */
   1437 	 0,			/* rightshift */
   1438 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1439 	 16,			/* bitsize */
   1440 	 FALSE,			/* pc_relative */
   1441 	 0,			/* bitpos */
   1442 	 complain_overflow_signed, /* complain_on_overflow */
   1443 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1444 	 "R_MIPS_TLS_TPREL_LO16", /* name */
   1445 	 FALSE,			/* partial_inplace */
   1446 	 0,			/* src_mask */
   1447 	 0x0000ffff,		/* dst_mask */
   1448 	 FALSE),		/* pcrel_offset */
   1449 
   1450   /* 32 bit relocation with no addend.  */
   1451   HOWTO (R_MIPS_GLOB_DAT,	/* type */
   1452 	 0,			/* rightshift */
   1453 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1454 	 32,			/* bitsize */
   1455 	 FALSE,			/* pc_relative */
   1456 	 0,			/* bitpos */
   1457 	 complain_overflow_dont, /* complain_on_overflow */
   1458 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1459 	 "R_MIPS_GLOB_DAT",	/* name */
   1460 	 FALSE,			/* partial_inplace */
   1461 	 0x0,			/* src_mask */
   1462 	 0xffffffff,		/* dst_mask */
   1463 	 FALSE),		/* pcrel_offset */
   1464 };
   1465 
   1466 static reloc_howto_type elf_mips16_howto_table_rel[] =
   1467 {
   1468   /* The reloc used for the mips16 jump instruction.  */
   1469   HOWTO (R_MIPS16_26,		/* type */
   1470 	 2,			/* rightshift */
   1471 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1472 	 26,			/* bitsize */
   1473 	 FALSE,			/* pc_relative */
   1474 	 0,			/* bitpos */
   1475 	 complain_overflow_dont, /* complain_on_overflow */
   1476 	 			/* This needs complex overflow
   1477 				   detection, because the upper four
   1478 				   bits must match the PC.  */
   1479 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1480 	 "R_MIPS16_26",		/* name */
   1481 	 TRUE,			/* partial_inplace */
   1482 	 0x3ffffff,		/* src_mask */
   1483 	 0x3ffffff,		/* dst_mask */
   1484 	 FALSE),		/* pcrel_offset */
   1485 
   1486   /* The reloc used for the mips16 gprel instruction.  */
   1487   HOWTO (R_MIPS16_GPREL,	/* type */
   1488 	 0,			/* rightshift */
   1489 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1490 	 16,			/* bitsize */
   1491 	 FALSE,			/* pc_relative */
   1492 	 0,			/* bitpos */
   1493 	 complain_overflow_signed, /* complain_on_overflow */
   1494 	 mips16_gprel_reloc,	/* special_function */
   1495 	 "R_MIPS16_GPREL",	/* name */
   1496 	 TRUE,			/* partial_inplace */
   1497 	 0x0000ffff,		/* src_mask */
   1498 	 0x0000ffff,	        /* dst_mask */
   1499 	 FALSE),		/* pcrel_offset */
   1500 
   1501   /* A MIPS16 reference to the global offset table.  */
   1502   HOWTO (R_MIPS16_GOT16,	/* type */
   1503 	 0,			/* rightshift */
   1504 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1505 	 16,			/* bitsize */
   1506 	 FALSE,			/* pc_relative */
   1507 	 0,			/* bitpos */
   1508 	 complain_overflow_dont, /* complain_on_overflow */
   1509 	 _bfd_mips_elf_got16_reloc, /* special_function */
   1510 	 "R_MIPS16_GOT16",	/* name */
   1511 	 TRUE,			/* partial_inplace */
   1512 	 0x0000ffff,		/* src_mask */
   1513 	 0x0000ffff,	        /* dst_mask */
   1514 	 FALSE),		/* pcrel_offset */
   1515 
   1516   /* A MIPS16 call through the global offset table.  */
   1517   HOWTO (R_MIPS16_CALL16,	/* type */
   1518 	 0,			/* rightshift */
   1519 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1520 	 16,			/* bitsize */
   1521 	 FALSE,			/* pc_relative */
   1522 	 0,			/* bitpos */
   1523 	 complain_overflow_dont, /* complain_on_overflow */
   1524 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1525 	 "R_MIPS16_CALL16",	/* name */
   1526 	 TRUE,			/* partial_inplace */
   1527 	 0x0000ffff,		/* src_mask */
   1528 	 0x0000ffff,	        /* dst_mask */
   1529 	 FALSE),		/* pcrel_offset */
   1530 
   1531   /* MIPS16 high 16 bits of symbol value.  */
   1532   HOWTO (R_MIPS16_HI16,		/* type */
   1533 	 16,			/* rightshift */
   1534 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1535 	 16,			/* bitsize */
   1536 	 FALSE,			/* pc_relative */
   1537 	 0,			/* bitpos */
   1538 	 complain_overflow_dont, /* complain_on_overflow */
   1539 	 _bfd_mips_elf_hi16_reloc, /* special_function */
   1540 	 "R_MIPS16_HI16",	/* name */
   1541 	 TRUE,			/* partial_inplace */
   1542 	 0x0000ffff,		/* src_mask */
   1543 	 0x0000ffff,		/* dst_mask */
   1544 	 FALSE),		/* pcrel_offset */
   1545 
   1546   /* MIPS16 low 16 bits of symbol value.  */
   1547   HOWTO (R_MIPS16_LO16,		/* type */
   1548 	 0,			/* rightshift */
   1549 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1550 	 16,			/* bitsize */
   1551 	 FALSE,			/* pc_relative */
   1552 	 0,			/* bitpos */
   1553 	 complain_overflow_dont, /* complain_on_overflow */
   1554 	 _bfd_mips_elf_lo16_reloc, /* special_function */
   1555 	 "R_MIPS16_LO16",	/* name */
   1556 	 TRUE,			/* partial_inplace */
   1557 	 0x0000ffff,		/* src_mask */
   1558 	 0x0000ffff,		/* dst_mask */
   1559 	 FALSE),		/* pcrel_offset */
   1560 
   1561   /* MIPS16 TLS general dynamic variable reference.  */
   1562   HOWTO (R_MIPS16_TLS_GD,	/* type */
   1563 	 0,			/* rightshift */
   1564 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1565 	 16,			/* bitsize */
   1566 	 FALSE,			/* pc_relative */
   1567 	 0,			/* bitpos */
   1568 	 complain_overflow_signed, /* complain_on_overflow */
   1569 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1570 	 "R_MIPS16_TLS_GD",	/* name */
   1571 	 TRUE,			/* partial_inplace */
   1572 	 0x0000ffff,		/* src_mask */
   1573 	 0x0000ffff,		/* dst_mask */
   1574 	 FALSE),		/* pcrel_offset */
   1575 
   1576   /* MIPS16 TLS local dynamic variable reference.  */
   1577   HOWTO (R_MIPS16_TLS_LDM,	/* type */
   1578 	 0,			/* rightshift */
   1579 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1580 	 16,			/* bitsize */
   1581 	 FALSE,			/* pc_relative */
   1582 	 0,			/* bitpos */
   1583 	 complain_overflow_signed, /* complain_on_overflow */
   1584 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1585 	 "R_MIPS16_TLS_LDM",	/* name */
   1586 	 TRUE,			/* partial_inplace */
   1587 	 0x0000ffff,		/* src_mask */
   1588 	 0x0000ffff,		/* dst_mask */
   1589 	 FALSE),		/* pcrel_offset */
   1590 
   1591   /* MIPS16 TLS local dynamic offset.  */
   1592   HOWTO (R_MIPS16_TLS_DTPREL_HI16,	/* type */
   1593 	 0,			/* rightshift */
   1594 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1595 	 16,			/* bitsize */
   1596 	 FALSE,			/* pc_relative */
   1597 	 0,			/* bitpos */
   1598 	 complain_overflow_signed, /* complain_on_overflow */
   1599 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1600 	 "R_MIPS16_TLS_DTPREL_HI16",	/* name */
   1601 	 TRUE,			/* partial_inplace */
   1602 	 0x0000ffff,		/* src_mask */
   1603 	 0x0000ffff,		/* dst_mask */
   1604 	 FALSE),		/* pcrel_offset */
   1605 
   1606   /* MIPS16 TLS local dynamic offset.  */
   1607   HOWTO (R_MIPS16_TLS_DTPREL_LO16,	/* type */
   1608 	 0,			/* rightshift */
   1609 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1610 	 16,			/* bitsize */
   1611 	 FALSE,			/* pc_relative */
   1612 	 0,			/* bitpos */
   1613 	 complain_overflow_signed, /* complain_on_overflow */
   1614 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1615 	 "R_MIPS16_TLS_DTPREL_LO16",	/* name */
   1616 	 TRUE,			/* partial_inplace */
   1617 	 0x0000ffff,		/* src_mask */
   1618 	 0x0000ffff,		/* dst_mask */
   1619 	 FALSE),		/* pcrel_offset */
   1620 
   1621   /* MIPS16 TLS thread pointer offset.  */
   1622   HOWTO (R_MIPS16_TLS_GOTTPREL,	/* type */
   1623 	 0,			/* rightshift */
   1624 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1625 	 16,			/* bitsize */
   1626 	 FALSE,			/* pc_relative */
   1627 	 0,			/* bitpos */
   1628 	 complain_overflow_signed, /* complain_on_overflow */
   1629 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1630 	 "R_MIPS16_TLS_GOTTPREL",	/* name */
   1631 	 TRUE,			/* partial_inplace */
   1632 	 0x0000ffff,		/* src_mask */
   1633 	 0x0000ffff,		/* dst_mask */
   1634 	 FALSE),		/* pcrel_offset */
   1635 
   1636   /* MIPS16 TLS thread pointer offset.  */
   1637   HOWTO (R_MIPS16_TLS_TPREL_HI16,	/* type */
   1638 	 0,			/* rightshift */
   1639 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1640 	 16,			/* bitsize */
   1641 	 FALSE,			/* pc_relative */
   1642 	 0,			/* bitpos */
   1643 	 complain_overflow_signed, /* complain_on_overflow */
   1644 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1645 	 "R_MIPS16_TLS_TPREL_HI16", /* name */
   1646 	 TRUE,			/* partial_inplace */
   1647 	 0x0000ffff,		/* src_mask */
   1648 	 0x0000ffff,		/* dst_mask */
   1649 	 FALSE),		/* pcrel_offset */
   1650 
   1651   /* MIPS16 TLS thread pointer offset.  */
   1652   HOWTO (R_MIPS16_TLS_TPREL_LO16,	/* type */
   1653 	 0,			/* rightshift */
   1654 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1655 	 16,			/* bitsize */
   1656 	 FALSE,			/* pc_relative */
   1657 	 0,			/* bitpos */
   1658 	 complain_overflow_signed, /* complain_on_overflow */
   1659 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1660 	 "R_MIPS16_TLS_TPREL_LO16", /* name */
   1661 	 TRUE,			/* partial_inplace */
   1662 	 0x0000ffff,		/* src_mask */
   1663 	 0x0000ffff,		/* dst_mask */
   1664 	 FALSE),		/* pcrel_offset */
   1665 };
   1666 
   1667 static reloc_howto_type elf_mips16_howto_table_rela[] =
   1668 {
   1669   /* The reloc used for the mips16 jump instruction.  */
   1670   HOWTO (R_MIPS16_26,		/* type */
   1671 	 2,			/* rightshift */
   1672 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1673 	 26,			/* bitsize */
   1674 	 FALSE,			/* pc_relative */
   1675 	 0,			/* bitpos */
   1676 	 complain_overflow_dont, /* complain_on_overflow */
   1677 	 			/* This needs complex overflow
   1678 				   detection, because the upper four
   1679 				   bits must match the PC.  */
   1680 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1681 	 "R_MIPS16_26",		/* name */
   1682 	 FALSE,			/* partial_inplace */
   1683 	 0,			/* src_mask */
   1684 	 0x3ffffff,		/* dst_mask */
   1685 	 FALSE),		/* pcrel_offset */
   1686 
   1687   /* The reloc used for the mips16 gprel instruction.  */
   1688   HOWTO (R_MIPS16_GPREL,	/* type */
   1689 	 0,			/* rightshift */
   1690 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1691 	 16,			/* bitsize */
   1692 	 FALSE,			/* pc_relative */
   1693 	 0,			/* bitpos */
   1694 	 complain_overflow_signed, /* complain_on_overflow */
   1695 	 mips16_gprel_reloc,	/* special_function */
   1696 	 "R_MIPS16_GPREL",	/* name */
   1697 	 FALSE,			/* partial_inplace */
   1698 	 0,			/* src_mask */
   1699 	 0x0000ffff,	        /* dst_mask */
   1700 	 FALSE),		/* pcrel_offset */
   1701 
   1702   /* A MIPS16 reference to the global offset table.  */
   1703   HOWTO (R_MIPS16_GOT16,	/* type */
   1704 	 0,			/* rightshift */
   1705 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1706 	 16,			/* bitsize */
   1707 	 FALSE,			/* pc_relative */
   1708 	 0,			/* bitpos */
   1709 	 complain_overflow_dont, /* complain_on_overflow */
   1710 	 _bfd_mips_elf_got16_reloc, /* special_function */
   1711 	 "R_MIPS16_GOT16",	/* name */
   1712 	 FALSE,			/* partial_inplace */
   1713 	 0,			/* src_mask */
   1714 	 0x0000ffff,	        /* dst_mask */
   1715 	 FALSE),		/* pcrel_offset */
   1716 
   1717   /* A MIPS16 call through the global offset table.  */
   1718   HOWTO (R_MIPS16_CALL16,	/* type */
   1719 	 0,			/* rightshift */
   1720 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1721 	 16,			/* bitsize */
   1722 	 FALSE,			/* pc_relative */
   1723 	 0,			/* bitpos */
   1724 	 complain_overflow_dont, /* complain_on_overflow */
   1725 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1726 	 "R_MIPS16_CALL16",	/* name */
   1727 	 FALSE,			/* partial_inplace */
   1728 	 0,			/* src_mask */
   1729 	 0x0000ffff,	        /* dst_mask */
   1730 	 FALSE),		/* pcrel_offset */
   1731 
   1732   /* MIPS16 high 16 bits of symbol value.  */
   1733   HOWTO (R_MIPS16_HI16,		/* type */
   1734 	 16,			/* rightshift */
   1735 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1736 	 16,			/* bitsize */
   1737 	 FALSE,			/* pc_relative */
   1738 	 0,			/* bitpos */
   1739 	 complain_overflow_dont, /* complain_on_overflow */
   1740 	 _bfd_mips_elf_hi16_reloc, /* special_function */
   1741 	 "R_MIPS16_HI16",	/* name */
   1742 	 FALSE,			/* partial_inplace */
   1743 	 0,			/* src_mask */
   1744 	 0x0000ffff,		/* dst_mask */
   1745 	 FALSE),		/* pcrel_offset */
   1746 
   1747   /* MIPS16 low 16 bits of symbol value.  */
   1748   HOWTO (R_MIPS16_LO16,		/* type */
   1749 	 0,			/* rightshift */
   1750 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1751 	 16,			/* bitsize */
   1752 	 FALSE,			/* pc_relative */
   1753 	 0,			/* bitpos */
   1754 	 complain_overflow_dont, /* complain_on_overflow */
   1755 	 _bfd_mips_elf_lo16_reloc, /* special_function */
   1756 	 "R_MIPS16_LO16",	/* name */
   1757 	 FALSE,			/* partial_inplace */
   1758 	 0,			/* src_mask */
   1759 	 0x0000ffff,		/* dst_mask */
   1760 	 FALSE),		/* pcrel_offset */
   1761 
   1762   /* MIPS16 TLS general dynamic variable reference.  */
   1763   HOWTO (R_MIPS16_TLS_GD,	/* type */
   1764 	 0,			/* rightshift */
   1765 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1766 	 16,			/* bitsize */
   1767 	 FALSE,			/* pc_relative */
   1768 	 0,			/* bitpos */
   1769 	 complain_overflow_signed, /* complain_on_overflow */
   1770 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1771 	 "R_MIPS16_TLS_GD",	/* name */
   1772 	 FALSE,			/* partial_inplace */
   1773 	 0,			/* src_mask */
   1774 	 0x0000ffff,		/* dst_mask */
   1775 	 FALSE),		/* pcrel_offset */
   1776 
   1777   /* MIPS16 TLS local dynamic variable reference.  */
   1778   HOWTO (R_MIPS16_TLS_LDM,	/* type */
   1779 	 0,			/* rightshift */
   1780 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1781 	 16,			/* bitsize */
   1782 	 FALSE,			/* pc_relative */
   1783 	 0,			/* bitpos */
   1784 	 complain_overflow_signed, /* complain_on_overflow */
   1785 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1786 	 "R_MIPS16_TLS_LDM",	/* name */
   1787 	 FALSE,			/* partial_inplace */
   1788 	 0,			/* src_mask */
   1789 	 0x0000ffff,		/* dst_mask */
   1790 	 FALSE),		/* pcrel_offset */
   1791 
   1792   /* MIPS16 TLS local dynamic offset.  */
   1793   HOWTO (R_MIPS16_TLS_DTPREL_HI16,	/* type */
   1794 	 0,			/* rightshift */
   1795 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1796 	 16,			/* bitsize */
   1797 	 FALSE,			/* pc_relative */
   1798 	 0,			/* bitpos */
   1799 	 complain_overflow_signed, /* complain_on_overflow */
   1800 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1801 	 "R_MIPS16_TLS_DTPREL_HI16",	/* name */
   1802 	 FALSE,			/* partial_inplace */
   1803 	 0,			/* src_mask */
   1804 	 0x0000ffff,		/* dst_mask */
   1805 	 FALSE),		/* pcrel_offset */
   1806 
   1807   /* MIPS16 TLS local dynamic offset.  */
   1808   HOWTO (R_MIPS16_TLS_DTPREL_LO16,	/* type */
   1809 	 0,			/* rightshift */
   1810 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1811 	 16,			/* bitsize */
   1812 	 FALSE,			/* pc_relative */
   1813 	 0,			/* bitpos */
   1814 	 complain_overflow_signed, /* complain_on_overflow */
   1815 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1816 	 "R_MIPS16_TLS_DTPREL_LO16",	/* name */
   1817 	 FALSE,			/* partial_inplace */
   1818 	 0,			/* src_mask */
   1819 	 0x0000ffff,		/* dst_mask */
   1820 	 FALSE),		/* pcrel_offset */
   1821 
   1822   /* MIPS16 TLS thread pointer offset.  */
   1823   HOWTO (R_MIPS16_TLS_GOTTPREL,	/* type */
   1824 	 0,			/* rightshift */
   1825 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1826 	 16,			/* bitsize */
   1827 	 FALSE,			/* pc_relative */
   1828 	 0,			/* bitpos */
   1829 	 complain_overflow_signed, /* complain_on_overflow */
   1830 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1831 	 "R_MIPS16_TLS_GOTTPREL",	/* name */
   1832 	 FALSE,			/* partial_inplace */
   1833 	 0,			/* src_mask */
   1834 	 0x0000ffff,		/* dst_mask */
   1835 	 FALSE),		/* pcrel_offset */
   1836 
   1837   /* MIPS16 TLS thread pointer offset.  */
   1838   HOWTO (R_MIPS16_TLS_TPREL_HI16,	/* type */
   1839 	 0,			/* rightshift */
   1840 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1841 	 16,			/* bitsize */
   1842 	 FALSE,			/* pc_relative */
   1843 	 0,			/* bitpos */
   1844 	 complain_overflow_signed, /* complain_on_overflow */
   1845 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1846 	 "R_MIPS16_TLS_TPREL_HI16", /* name */
   1847 	 FALSE,			/* partial_inplace */
   1848 	 0,			/* src_mask */
   1849 	 0x0000ffff,		/* dst_mask */
   1850 	 FALSE),		/* pcrel_offset */
   1851 
   1852   /* MIPS16 TLS thread pointer offset.  */
   1853   HOWTO (R_MIPS16_TLS_TPREL_LO16,	/* type */
   1854 	 0,			/* rightshift */
   1855 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1856 	 16,			/* bitsize */
   1857 	 FALSE,			/* pc_relative */
   1858 	 0,			/* bitpos */
   1859 	 complain_overflow_signed, /* complain_on_overflow */
   1860 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1861 	 "R_MIPS16_TLS_TPREL_LO16", /* name */
   1862 	 FALSE,			/* partial_inplace */
   1863 	 0,			/* src_mask */
   1864 	 0x0000ffff,		/* dst_mask */
   1865 	 FALSE),		/* pcrel_offset */
   1866 };
   1867 
   1868 static reloc_howto_type elf_micromips_howto_table_rel[] =
   1869 {
   1870   EMPTY_HOWTO (130),
   1871   EMPTY_HOWTO (131),
   1872   EMPTY_HOWTO (132),
   1873 
   1874   /* 26 bit jump address.  */
   1875   HOWTO (R_MICROMIPS_26_S1,	/* type */
   1876 	 1,			/* rightshift */
   1877 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1878 	 26,			/* bitsize */
   1879 	 FALSE,			/* pc_relative */
   1880 	 0,			/* bitpos */
   1881 	 complain_overflow_dont, /* complain_on_overflow */
   1882 	 			/* This needs complex overflow
   1883 				   detection, because the upper four
   1884 				   bits must match the PC.  */
   1885 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1886 	 "R_MICROMIPS_26_S1",	/* name */
   1887 	 TRUE,			/* partial_inplace */
   1888 	 0x3ffffff,		/* src_mask */
   1889 	 0x3ffffff,		/* dst_mask */
   1890 	 FALSE),		/* pcrel_offset */
   1891 
   1892   /* High 16 bits of symbol value.  */
   1893   HOWTO (R_MICROMIPS_HI16,	/* type */
   1894 	 16,			/* rightshift */
   1895 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1896 	 16,			/* bitsize */
   1897 	 FALSE,			/* pc_relative */
   1898 	 0,			/* bitpos */
   1899 	 complain_overflow_dont, /* complain_on_overflow */
   1900 	 _bfd_mips_elf_hi16_reloc, /* special_function */
   1901 	 "R_MICROMIPS_HI16",	/* name */
   1902 	 TRUE,			/* partial_inplace */
   1903 	 0x0000ffff,		/* src_mask */
   1904 	 0x0000ffff,		/* dst_mask */
   1905 	 FALSE),		/* pcrel_offset */
   1906 
   1907   /* Low 16 bits of symbol value.  */
   1908   HOWTO (R_MICROMIPS_LO16,	/* type */
   1909 	 0,			/* rightshift */
   1910 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1911 	 16,			/* bitsize */
   1912 	 FALSE,			/* pc_relative */
   1913 	 0,			/* bitpos */
   1914 	 complain_overflow_dont, /* complain_on_overflow */
   1915 	 _bfd_mips_elf_lo16_reloc, /* special_function */
   1916 	 "R_MICROMIPS_LO16",	/* name */
   1917 	 TRUE,			/* partial_inplace */
   1918 	 0x0000ffff,		/* src_mask */
   1919 	 0x0000ffff,		/* dst_mask */
   1920 	 FALSE),		/* pcrel_offset */
   1921 
   1922   /* GP relative reference.  */
   1923   HOWTO (R_MICROMIPS_GPREL16,	/* type */
   1924 	 0,			/* rightshift */
   1925 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1926 	 16,			/* bitsize */
   1927 	 FALSE,			/* pc_relative */
   1928 	 0,			/* bitpos */
   1929 	 complain_overflow_signed, /* complain_on_overflow */
   1930 	 _bfd_mips_elf32_gprel16_reloc, /* special_function */
   1931 	 "R_MICROMIPS_GPREL16",	/* name */
   1932 	 TRUE,			/* partial_inplace */
   1933 	 0x0000ffff,		/* src_mask */
   1934 	 0x0000ffff,		/* dst_mask */
   1935 	 FALSE),		/* pcrel_offset */
   1936 
   1937   /* Reference to literal section.  */
   1938   HOWTO (R_MICROMIPS_LITERAL,	/* type */
   1939 	 0,			/* rightshift */
   1940 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1941 	 16,			/* bitsize */
   1942 	 FALSE,			/* pc_relative */
   1943 	 0,			/* bitpos */
   1944 	 complain_overflow_signed, /* complain_on_overflow */
   1945 	 _bfd_mips_elf32_gprel16_reloc, /* special_function */
   1946 	 "R_MICROMIPS_LITERAL",	/* name */
   1947 	 TRUE,			/* partial_inplace */
   1948 	 0x0000ffff,		/* src_mask */
   1949 	 0x0000ffff,		/* dst_mask */
   1950 	 FALSE),		/* pcrel_offset */
   1951 
   1952   /* Reference to global offset table.  */
   1953   HOWTO (R_MICROMIPS_GOT16,	/* type */
   1954 	 0,			/* rightshift */
   1955 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1956 	 16,			/* bitsize */
   1957 	 FALSE,			/* pc_relative */
   1958 	 0,			/* bitpos */
   1959 	 complain_overflow_signed, /* complain_on_overflow */
   1960 	 _bfd_mips_elf_got16_reloc, /* special_function */
   1961 	 "R_MICROMIPS_GOT16",	/* name */
   1962 	 TRUE,			/* partial_inplace */
   1963 	 0x0000ffff,		/* src_mask */
   1964 	 0x0000ffff,		/* dst_mask */
   1965 	 FALSE),		/* pcrel_offset */
   1966 
   1967   /* This is for microMIPS branches.  */
   1968   HOWTO (R_MICROMIPS_PC7_S1,	/* type */
   1969 	 1,			/* rightshift */
   1970 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
   1971 	 7,			/* bitsize */
   1972 	 TRUE,			/* pc_relative */
   1973 	 0,			/* bitpos */
   1974 	 complain_overflow_signed, /* complain_on_overflow */
   1975 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1976 	 "R_MICROMIPS_PC7_S1",	/* name */
   1977 	 TRUE,			/* partial_inplace */
   1978 	 0x0000007f,		/* src_mask */
   1979 	 0x0000007f,		/* dst_mask */
   1980 	 TRUE),			/* pcrel_offset */
   1981 
   1982   HOWTO (R_MICROMIPS_PC10_S1,	/* type */
   1983 	 1,			/* rightshift */
   1984 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
   1985 	 10,			/* bitsize */
   1986 	 TRUE,			/* pc_relative */
   1987 	 0,			/* bitpos */
   1988 	 complain_overflow_signed, /* complain_on_overflow */
   1989 	 _bfd_mips_elf_generic_reloc, /* special_function */
   1990 	 "R_MICROMIPS_PC10_S1",	/* name */
   1991 	 TRUE,			/* partial_inplace */
   1992 	 0x000003ff,		/* src_mask */
   1993 	 0x000003ff,		/* dst_mask */
   1994 	 TRUE),			/* pcrel_offset */
   1995 
   1996   HOWTO (R_MICROMIPS_PC16_S1,	/* type */
   1997 	 1,			/* rightshift */
   1998 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   1999 	 16,			/* bitsize */
   2000 	 TRUE,			/* pc_relative */
   2001 	 0,			/* bitpos */
   2002 	 complain_overflow_signed, /* complain_on_overflow */
   2003 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2004 	 "R_MICROMIPS_PC16_S1",	/* name */
   2005 	 TRUE,			/* partial_inplace */
   2006 	 0x0000ffff,		/* src_mask */
   2007 	 0x0000ffff,		/* dst_mask */
   2008 	 TRUE),			/* pcrel_offset */
   2009 
   2010   /* 16 bit call through global offset table.  */
   2011   HOWTO (R_MICROMIPS_CALL16,	/* type */
   2012 	 0,			/* rightshift */
   2013 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2014 	 16,			/* bitsize */
   2015 	 FALSE,			/* pc_relative */
   2016 	 0,			/* bitpos */
   2017 	 complain_overflow_signed, /* complain_on_overflow */
   2018 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2019 	 "R_MICROMIPS_CALL16",	/* name */
   2020 	 TRUE,			/* partial_inplace */
   2021 	 0x0000ffff,		/* src_mask */
   2022 	 0x0000ffff,		/* dst_mask */
   2023 	 FALSE),		/* pcrel_offset */
   2024 
   2025   EMPTY_HOWTO (143),
   2026   EMPTY_HOWTO (144),
   2027 
   2028   /* Displacement in the global offset table.  */
   2029   HOWTO (R_MICROMIPS_GOT_DISP,	/* type */
   2030 	 0,			/* rightshift */
   2031 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2032 	 16,			/* bitsize */
   2033 	 FALSE,			/* pc_relative */
   2034 	 0,			/* bitpos */
   2035 	 complain_overflow_signed, /* complain_on_overflow */
   2036 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2037 	 "R_MICROMIPS_GOT_DISP",/* name */
   2038 	 TRUE,			/* partial_inplace */
   2039 	 0x0000ffff,		/* src_mask */
   2040 	 0x0000ffff,		/* dst_mask */
   2041 	 FALSE),		/* pcrel_offset */
   2042 
   2043   /* Displacement to page pointer in the global offset table.  */
   2044   HOWTO (R_MICROMIPS_GOT_PAGE,	/* type */
   2045 	 0,			/* rightshift */
   2046 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2047 	 16,			/* bitsize */
   2048 	 FALSE,			/* pc_relative */
   2049 	 0,			/* bitpos */
   2050 	 complain_overflow_signed, /* complain_on_overflow */
   2051 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2052 	 "R_MICROMIPS_GOT_PAGE",/* name */
   2053 	 TRUE,			/* partial_inplace */
   2054 	 0x0000ffff,		/* src_mask */
   2055 	 0x0000ffff,		/* dst_mask */
   2056 	 FALSE),		/* pcrel_offset */
   2057 
   2058   /* Offset from page pointer in the global offset table.  */
   2059   HOWTO (R_MICROMIPS_GOT_OFST,	/* type */
   2060 	 0,			/* rightshift */
   2061 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2062 	 16,			/* bitsize */
   2063 	 FALSE,			/* pc_relative */
   2064 	 0,			/* bitpos */
   2065 	 complain_overflow_signed, /* complain_on_overflow */
   2066 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2067 	 "R_MICROMIPS_GOT_OFST",/* name */
   2068 	 TRUE,			/* partial_inplace */
   2069 	 0x0000ffff,		/* src_mask */
   2070 	 0x0000ffff,		/* dst_mask */
   2071 	 FALSE),		/* pcrel_offset */
   2072 
   2073   /* High 16 bits of displacement in global offset table.  */
   2074   HOWTO (R_MICROMIPS_GOT_HI16,	/* type */
   2075 	 0,			/* rightshift */
   2076 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2077 	 16,			/* bitsize */
   2078 	 FALSE,			/* pc_relative */
   2079 	 0,			/* bitpos */
   2080 	 complain_overflow_dont, /* complain_on_overflow */
   2081 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2082 	 "R_MICROMIPS_GOT_HI16",/* name */
   2083 	 TRUE,			/* partial_inplace */
   2084 	 0x0000ffff,		/* src_mask */
   2085 	 0x0000ffff,		/* dst_mask */
   2086 	 FALSE),		/* pcrel_offset */
   2087 
   2088   /* Low 16 bits of displacement in global offset table.  */
   2089   HOWTO (R_MICROMIPS_GOT_LO16,	/* type */
   2090 	 0,			/* rightshift */
   2091 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2092 	 16,			/* bitsize */
   2093 	 FALSE,			/* pc_relative */
   2094 	 0,			/* bitpos */
   2095 	 complain_overflow_dont, /* complain_on_overflow */
   2096 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2097 	 "R_MICROMIPS_GOT_LO16",/* name */
   2098 	 TRUE,			/* partial_inplace */
   2099 	 0x0000ffff,		/* src_mask */
   2100 	 0x0000ffff,		/* dst_mask */
   2101 	 FALSE),		/* pcrel_offset */
   2102 
   2103   /* 64 bit subtraction.  Used in the N32 ABI.  */
   2104   HOWTO (R_MICROMIPS_SUB,	/* type */
   2105 	 0,			/* rightshift */
   2106 	 4,			/* size (0 = byte, 1 = short, 2 = long) */
   2107 	 64,			/* bitsize */
   2108 	 FALSE,			/* pc_relative */
   2109 	 0,			/* bitpos */
   2110 	 complain_overflow_dont, /* complain_on_overflow */
   2111 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2112 	 "R_MICROMIPS_SUB",	/* name */
   2113 	 TRUE,			/* partial_inplace */
   2114 	 MINUS_ONE,		/* src_mask */
   2115 	 MINUS_ONE,		/* dst_mask */
   2116 	 FALSE),		/* pcrel_offset */
   2117 
   2118   /* We don't support these for REL relocations, because it means building
   2119      the addend from a R_MICROMIPS_HIGHEST/R_MICROMIPS_HIGHER/
   2120      R_MICROMIPS_HI16/R_MICROMIPS_LO16 sequence with varying ordering,
   2121      using fallable heuristics.  */
   2122   EMPTY_HOWTO (R_MICROMIPS_HIGHER),
   2123   EMPTY_HOWTO (R_MICROMIPS_HIGHEST),
   2124 
   2125   /* High 16 bits of displacement in global offset table.  */
   2126   HOWTO (R_MICROMIPS_CALL_HI16,	/* type */
   2127 	 0,			/* rightshift */
   2128 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2129 	 16,			/* bitsize */
   2130 	 FALSE,			/* pc_relative */
   2131 	 0,			/* bitpos */
   2132 	 complain_overflow_dont, /* complain_on_overflow */
   2133 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2134 	 "R_MICROMIPS_CALL_HI16",/* name */
   2135 	 TRUE,			/* partial_inplace */
   2136 	 0x0000ffff,		/* src_mask */
   2137 	 0x0000ffff,		/* dst_mask */
   2138 	 FALSE),		/* pcrel_offset */
   2139 
   2140   /* Low 16 bits of displacement in global offset table.  */
   2141   HOWTO (R_MICROMIPS_CALL_LO16,	/* type */
   2142 	 0,			/* rightshift */
   2143 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2144 	 16,			/* bitsize */
   2145 	 FALSE,			/* pc_relative */
   2146 	 0,			/* bitpos */
   2147 	 complain_overflow_dont, /* complain_on_overflow */
   2148 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2149 	 "R_MICROMIPS_CALL_LO16",/* name */
   2150 	 TRUE,			/* partial_inplace */
   2151 	 0x0000ffff,		/* src_mask */
   2152 	 0x0000ffff,		/* dst_mask */
   2153 	 FALSE),		/* pcrel_offset */
   2154 };
   2155 
   2156 static reloc_howto_type elf_micromips_howto_table_rela[] =
   2157 {
   2158   EMPTY_HOWTO (130),
   2159   EMPTY_HOWTO (131),
   2160   EMPTY_HOWTO (132),
   2161 
   2162   /* 26 bit jump address.  */
   2163   HOWTO (R_MICROMIPS_26_S1,	/* type */
   2164 	 1,			/* rightshift */
   2165 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2166 	 26,			/* bitsize */
   2167 	 FALSE,			/* pc_relative */
   2168 	 0,			/* bitpos */
   2169 	 complain_overflow_dont, /* complain_on_overflow */
   2170 	 			/* This needs complex overflow
   2171 				   detection, because the upper four
   2172 				   bits must match the PC.  */
   2173 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2174 	 "R_MICROMIPS_26_S1",	/* name */
   2175 	 FALSE,			/* partial_inplace */
   2176 	 0,			/* src_mask */
   2177 	 0x3ffffff,		/* dst_mask */
   2178 	 FALSE),		/* pcrel_offset */
   2179 
   2180   /* High 16 bits of symbol value.  */
   2181   HOWTO (R_MICROMIPS_HI16,	/* type */
   2182 	 16,			/* rightshift */
   2183 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2184 	 16,			/* bitsize */
   2185 	 FALSE,			/* pc_relative */
   2186 	 0,			/* bitpos */
   2187 	 complain_overflow_dont, /* complain_on_overflow */
   2188 	 _bfd_mips_elf_hi16_reloc, /* special_function */
   2189 	 "R_MICROMIPS_HI16",	/* name */
   2190 	 FALSE,			/* partial_inplace */
   2191 	 0,			/* src_mask */
   2192 	 0x0000ffff,		/* dst_mask */
   2193 	 FALSE),		/* pcrel_offset */
   2194 
   2195   /* Low 16 bits of symbol value.  */
   2196   HOWTO (R_MICROMIPS_LO16,	/* type */
   2197 	 0,			/* rightshift */
   2198 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2199 	 16,			/* bitsize */
   2200 	 FALSE,			/* pc_relative */
   2201 	 0,			/* bitpos */
   2202 	 complain_overflow_dont, /* complain_on_overflow */
   2203 	 _bfd_mips_elf_lo16_reloc, /* special_function */
   2204 	 "R_MICROMIPS_LO16",	/* name */
   2205 	 FALSE,			/* partial_inplace */
   2206 	 0,			/* src_mask */
   2207 	 0x0000ffff,		/* dst_mask */
   2208 	 FALSE),		/* pcrel_offset */
   2209 
   2210   /* GP relative reference.  */
   2211   HOWTO (R_MICROMIPS_GPREL16,	/* type */
   2212 	 0,			/* rightshift */
   2213 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2214 	 16,			/* bitsize */
   2215 	 FALSE,			/* pc_relative */
   2216 	 0,			/* bitpos */
   2217 	 complain_overflow_signed, /* complain_on_overflow */
   2218 	 _bfd_mips_elf32_gprel16_reloc, /* special_function */
   2219 	 "R_MICROMIPS_GPREL16",	/* name */
   2220 	 FALSE,			/* partial_inplace */
   2221 	 0,			/* src_mask */
   2222 	 0x0000ffff,		/* dst_mask */
   2223 	 FALSE),		/* pcrel_offset */
   2224 
   2225   /* Reference to literal section.  */
   2226   HOWTO (R_MICROMIPS_LITERAL,	/* type */
   2227 	 0,			/* rightshift */
   2228 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2229 	 16,			/* bitsize */
   2230 	 FALSE,			/* pc_relative */
   2231 	 0,			/* bitpos */
   2232 	 complain_overflow_signed, /* complain_on_overflow */
   2233 	 _bfd_mips_elf32_gprel16_reloc, /* special_function */
   2234 	 "R_MICROMIPS_LITERAL",	/* name */
   2235 	 FALSE,			/* partial_inplace */
   2236 	 0,			/* src_mask */
   2237 	 0x0000ffff,		/* dst_mask */
   2238 	 FALSE),		/* pcrel_offset */
   2239 
   2240   /* Reference to global offset table.  */
   2241   HOWTO (R_MICROMIPS_GOT16,	/* type */
   2242 	 0,			/* rightshift */
   2243 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2244 	 16,			/* bitsize */
   2245 	 FALSE,			/* pc_relative */
   2246 	 0,			/* bitpos */
   2247 	 complain_overflow_signed, /* complain_on_overflow */
   2248 	 _bfd_mips_elf_got16_reloc, /* special_function */
   2249 	 "R_MICROMIPS_GOT16",	/* name */
   2250 	 FALSE,			/* partial_inplace */
   2251 	 0,			/* src_mask */
   2252 	 0x0000ffff,		/* dst_mask */
   2253 	 FALSE),		/* pcrel_offset */
   2254 
   2255   /* This is for microMIPS branches.  */
   2256   HOWTO (R_MICROMIPS_PC7_S1,	/* type */
   2257 	 1,			/* rightshift */
   2258 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
   2259 	 7,			/* bitsize */
   2260 	 TRUE,			/* pc_relative */
   2261 	 0,			/* bitpos */
   2262 	 complain_overflow_signed, /* complain_on_overflow */
   2263 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2264 	 "R_MICROMIPS_PC7_S1",	/* name */
   2265 	 FALSE,			/* partial_inplace */
   2266 	 0,			/* src_mask */
   2267 	 0x0000007f,		/* dst_mask */
   2268 	 TRUE),			/* pcrel_offset */
   2269 
   2270   HOWTO (R_MICROMIPS_PC10_S1,	/* type */
   2271 	 1,			/* rightshift */
   2272 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
   2273 	 10,			/* bitsize */
   2274 	 TRUE,			/* pc_relative */
   2275 	 0,			/* bitpos */
   2276 	 complain_overflow_signed, /* complain_on_overflow */
   2277 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2278 	 "R_MICROMIPS_PC10_S1",	/* name */
   2279 	 FALSE,			/* partial_inplace */
   2280 	 0,			/* src_mask */
   2281 	 0x000003ff,		/* dst_mask */
   2282 	 TRUE),			/* pcrel_offset */
   2283 
   2284   HOWTO (R_MICROMIPS_PC16_S1,	/* type */
   2285 	 1,			/* rightshift */
   2286 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2287 	 16,			/* bitsize */
   2288 	 TRUE,			/* pc_relative */
   2289 	 0,			/* bitpos */
   2290 	 complain_overflow_signed, /* complain_on_overflow */
   2291 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2292 	 "R_MICROMIPS_PC16_S1",	/* name */
   2293 	 FALSE,			/* partial_inplace */
   2294 	 0,			/* src_mask */
   2295 	 0x0000ffff,		/* dst_mask */
   2296 	 TRUE),			/* pcrel_offset */
   2297 
   2298   /* 16 bit call through global offset table.  */
   2299   HOWTO (R_MICROMIPS_CALL16,	/* type */
   2300 	 0,			/* rightshift */
   2301 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2302 	 16,			/* bitsize */
   2303 	 FALSE,			/* pc_relative */
   2304 	 0,			/* bitpos */
   2305 	 complain_overflow_signed, /* complain_on_overflow */
   2306 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2307 	 "R_MICROMIPS_CALL16",	/* name */
   2308 	 FALSE,			/* partial_inplace */
   2309 	 0,			/* src_mask */
   2310 	 0x0000ffff,		/* dst_mask */
   2311 	 FALSE),		/* pcrel_offset */
   2312 
   2313   EMPTY_HOWTO (143),
   2314   EMPTY_HOWTO (144),
   2315 
   2316   /* Displacement in the global offset table.  */
   2317   HOWTO (R_MICROMIPS_GOT_DISP,	/* type */
   2318 	 0,			/* rightshift */
   2319 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2320 	 16,			/* bitsize */
   2321 	 FALSE,			/* pc_relative */
   2322 	 0,			/* bitpos */
   2323 	 complain_overflow_signed, /* complain_on_overflow */
   2324 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2325 	 "R_MICROMIPS_GOT_DISP",/* name */
   2326 	 FALSE,			/* partial_inplace */
   2327 	 0,			/* src_mask */
   2328 	 0x0000ffff,		/* dst_mask */
   2329 	 FALSE),		/* pcrel_offset */
   2330 
   2331   /* Displacement to page pointer in the global offset table.  */
   2332   HOWTO (R_MICROMIPS_GOT_PAGE,	/* type */
   2333 	 0,			/* rightshift */
   2334 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2335 	 16,			/* bitsize */
   2336 	 FALSE,			/* pc_relative */
   2337 	 0,			/* bitpos */
   2338 	 complain_overflow_signed, /* complain_on_overflow */
   2339 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2340 	 "R_MICROMIPS_GOT_PAGE",/* name */
   2341 	 FALSE,			/* partial_inplace */
   2342 	 0,			/* src_mask */
   2343 	 0x0000ffff,		/* dst_mask */
   2344 	 FALSE),		/* pcrel_offset */
   2345 
   2346   /* Offset from page pointer in the global offset table.  */
   2347   HOWTO (R_MICROMIPS_GOT_OFST,	/* type */
   2348 	 0,			/* rightshift */
   2349 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2350 	 16,			/* bitsize */
   2351 	 FALSE,			/* pc_relative */
   2352 	 0,			/* bitpos */
   2353 	 complain_overflow_signed, /* complain_on_overflow */
   2354 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2355 	 "R_MICROMIPS_GOT_OFST",/* name */
   2356 	 FALSE,			/* partial_inplace */
   2357 	 0,			/* src_mask */
   2358 	 0x0000ffff,		/* dst_mask */
   2359 	 FALSE),		/* pcrel_offset */
   2360 
   2361   /* High 16 bits of displacement in global offset table.  */
   2362   HOWTO (R_MICROMIPS_GOT_HI16,	/* type */
   2363 	 0,			/* rightshift */
   2364 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2365 	 16,			/* bitsize */
   2366 	 FALSE,			/* pc_relative */
   2367 	 0,			/* bitpos */
   2368 	 complain_overflow_dont, /* complain_on_overflow */
   2369 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2370 	 "R_MICROMIPS_GOT_HI16",/* name */
   2371 	 FALSE,			/* partial_inplace */
   2372 	 0,			/* src_mask */
   2373 	 0x0000ffff,		/* dst_mask */
   2374 	 FALSE),		/* pcrel_offset */
   2375 
   2376   /* Low 16 bits of displacement in global offset table.  */
   2377   HOWTO (R_MICROMIPS_GOT_LO16,	/* type */
   2378 	 0,			/* rightshift */
   2379 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2380 	 16,			/* bitsize */
   2381 	 FALSE,			/* pc_relative */
   2382 	 0,			/* bitpos */
   2383 	 complain_overflow_dont, /* complain_on_overflow */
   2384 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2385 	 "R_MICROMIPS_GOT_LO16",/* name */
   2386 	 FALSE,			/* partial_inplace */
   2387 	 0,			/* src_mask */
   2388 	 0x0000ffff,		/* dst_mask */
   2389 	 FALSE),		/* pcrel_offset */
   2390 
   2391   /* 64 bit subtraction.  Used in the N32 ABI.  */
   2392   HOWTO (R_MICROMIPS_SUB,	/* type */
   2393 	 0,			/* rightshift */
   2394 	 4,			/* size (0 = byte, 1 = short, 2 = long) */
   2395 	 64,			/* bitsize */
   2396 	 FALSE,			/* pc_relative */
   2397 	 0,			/* bitpos */
   2398 	 complain_overflow_dont, /* complain_on_overflow */
   2399 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2400 	 "R_MICROMIPS_SUB",	/* name */
   2401 	 FALSE,			/* partial_inplace */
   2402 	 0,			/* src_mask */
   2403 	 MINUS_ONE,		/* dst_mask */
   2404 	 FALSE),		/* pcrel_offset */
   2405 
   2406   /* Get the higher value of a 64 bit addend.  */
   2407   HOWTO (R_MICROMIPS_HIGHER,	/* type */
   2408 	 0,			/* rightshift */
   2409 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2410 	 16,			/* bitsize */
   2411 	 FALSE,			/* pc_relative */
   2412 	 0,			/* bitpos */
   2413 	 complain_overflow_dont, /* complain_on_overflow */
   2414 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2415 	 "R_MICROMIPS_HIGHER",	/* name */
   2416 	 FALSE,			/* partial_inplace */
   2417 	 0,			/* src_mask */
   2418 	 0x0000ffff,		/* dst_mask */
   2419 	 FALSE),		/* pcrel_offset */
   2420 
   2421   /* Get the highest value of a 64 bit addend.  */
   2422   HOWTO (R_MICROMIPS_HIGHEST,	/* type */
   2423 	 0,			/* rightshift */
   2424 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2425 	 16,			/* bitsize */
   2426 	 FALSE,			/* pc_relative */
   2427 	 0,			/* bitpos */
   2428 	 complain_overflow_dont, /* complain_on_overflow */
   2429 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2430 	 "R_MICROMIPS_HIGHEST",	/* name */
   2431 	 FALSE,			/* partial_inplace */
   2432 	 0,			/* src_mask */
   2433 	 0x0000ffff,		/* dst_mask */
   2434 	 FALSE),		/* pcrel_offset */
   2435 
   2436   /* High 16 bits of displacement in global offset table.  */
   2437   HOWTO (R_MICROMIPS_CALL_HI16,	/* type */
   2438 	 0,			/* rightshift */
   2439 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2440 	 16,			/* bitsize */
   2441 	 FALSE,			/* pc_relative */
   2442 	 0,			/* bitpos */
   2443 	 complain_overflow_dont, /* complain_on_overflow */
   2444 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2445 	 "R_MICROMIPS_CALL_HI16",/* name */
   2446 	 FALSE,			/* partial_inplace */
   2447 	 0,			/* src_mask */
   2448 	 0x0000ffff,		/* dst_mask */
   2449 	 FALSE),		/* pcrel_offset */
   2450 
   2451   /* Low 16 bits of displacement in global offset table.  */
   2452   HOWTO (R_MICROMIPS_CALL_LO16,	/* type */
   2453 	 0,			/* rightshift */
   2454 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2455 	 16,			/* bitsize */
   2456 	 FALSE,			/* pc_relative */
   2457 	 0,			/* bitpos */
   2458 	 complain_overflow_dont, /* complain_on_overflow */
   2459 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2460 	 "R_MICROMIPS_CALL_LO16",/* name */
   2461 	 FALSE,			/* partial_inplace */
   2462 	 0,			/* src_mask */
   2463 	 0x0000ffff,		/* dst_mask */
   2464 	 FALSE),		/* pcrel_offset */
   2465 };
   2466 
   2467 /* GNU extension to record C++ vtable hierarchy */
   2468 static reloc_howto_type elf_mips_gnu_vtinherit_howto =
   2469   HOWTO (R_MIPS_GNU_VTINHERIT,	/* type */
   2470 	 0,			/* rightshift */
   2471 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2472 	 0,			/* bitsize */
   2473 	 FALSE,			/* pc_relative */
   2474 	 0,			/* bitpos */
   2475 	 complain_overflow_dont, /* complain_on_overflow */
   2476 	 NULL,			/* special_function */
   2477 	 "R_MIPS_GNU_VTINHERIT", /* name */
   2478 	 FALSE,			/* partial_inplace */
   2479 	 0,			/* src_mask */
   2480 	 0,			/* dst_mask */
   2481 	 FALSE);		/* pcrel_offset */
   2482 
   2483 /* GNU extension to record C++ vtable member usage */
   2484 static reloc_howto_type elf_mips_gnu_vtentry_howto =
   2485   HOWTO (R_MIPS_GNU_VTENTRY,	/* type */
   2486 	 0,			/* rightshift */
   2487 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2488 	 0,			/* bitsize */
   2489 	 FALSE,			/* pc_relative */
   2490 	 0,			/* bitpos */
   2491 	 complain_overflow_dont, /* complain_on_overflow */
   2492 	 _bfd_elf_rel_vtable_reloc_fn, /* special_function */
   2493 	 "R_MIPS_GNU_VTENTRY",	/* name */
   2494 	 FALSE,			/* partial_inplace */
   2495 	 0,			/* src_mask */
   2496 	 0,			/* dst_mask */
   2497 	 FALSE);		/* pcrel_offset */
   2498 
   2499 /* 16 bit offset for pc-relative branches.  */
   2501 static reloc_howto_type elf_mips_gnu_rel16_s2 =
   2502   HOWTO (R_MIPS_GNU_REL16_S2,	/* type */
   2503 	 2,			/* rightshift */
   2504 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2505 	 16,			/* bitsize */
   2506 	 TRUE,			/* pc_relative */
   2507 	 0,			/* bitpos */
   2508 	 complain_overflow_signed, /* complain_on_overflow */
   2509 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2510 	 "R_MIPS_GNU_REL16_S2",	/* name */
   2511 	 TRUE,			/* partial_inplace */
   2512 	 0x0000ffff,		/* src_mask */
   2513 	 0x0000ffff,		/* dst_mask */
   2514 	 TRUE);			/* pcrel_offset */
   2515 
   2516 /* 16 bit offset for pc-relative branches.  */
   2517 static reloc_howto_type elf_mips_gnu_rela16_s2 =
   2518   HOWTO (R_MIPS_GNU_REL16_S2,	/* type */
   2519 	 2,			/* rightshift */
   2520 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2521 	 16,			/* bitsize */
   2522 	 TRUE,			/* pc_relative */
   2523 	 0,			/* bitpos */
   2524 	 complain_overflow_signed, /* complain_on_overflow */
   2525 	 _bfd_mips_elf_generic_reloc, /* special_function */
   2526 	 "R_MIPS_GNU_REL16_S2",	/* name */
   2527 	 FALSE,			/* partial_inplace */
   2528 	 0,			/* src_mask */
   2529 	 0x0000ffff,		/* dst_mask */
   2530 	 TRUE);			/* pcrel_offset */
   2531 
   2532 /* Originally a VxWorks extension, but now used for other systems too.  */
   2534 static reloc_howto_type elf_mips_copy_howto =
   2535   HOWTO (R_MIPS_COPY,		/* type */
   2536 	 0,			/* rightshift */
   2537 	 0,			/* this one is variable size */
   2538 	 0,			/* bitsize */
   2539 	 FALSE,			/* pc_relative */
   2540 	 0,			/* bitpos */
   2541 	 complain_overflow_bitfield, /* complain_on_overflow */
   2542 	 bfd_elf_generic_reloc,	/* special_function */
   2543 	 "R_MIPS_COPY",		/* name */
   2544 	 FALSE,			/* partial_inplace */
   2545 	 0x0,         		/* src_mask */
   2546 	 0x0,		        /* dst_mask */
   2547 	 FALSE);		/* pcrel_offset */
   2548 
   2549 /* Originally a VxWorks extension, but now used for other systems too.  */
   2550 static reloc_howto_type elf_mips_jump_slot_howto =
   2551   HOWTO (R_MIPS_JUMP_SLOT,	/* type */
   2552 	 0,			/* rightshift */
   2553 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
   2554 	 32,			/* bitsize */
   2555 	 FALSE,			/* pc_relative */
   2556 	 0,			/* bitpos */
   2557 	 complain_overflow_bitfield, /* complain_on_overflow */
   2558 	 bfd_elf_generic_reloc,	/* special_function */
   2559 	 "R_MIPS_JUMP_SLOT",	/* name */
   2560 	 FALSE,			/* partial_inplace */
   2561 	 0x0,         		/* src_mask */
   2562 	 0x0,		        /* dst_mask */
   2563 	 FALSE);		/* pcrel_offset */
   2564 
   2565 /* Set the GP value for OUTPUT_BFD.  Returns FALSE if this is a
   2567    dangerous relocation.  */
   2568 
   2569 static bfd_boolean
   2570 mips_elf_assign_gp (bfd *output_bfd, bfd_vma *pgp)
   2571 {
   2572   unsigned int count;
   2573   asymbol **sym;
   2574   unsigned int i;
   2575 
   2576   /* If we've already figured out what GP will be, just return it.  */
   2577   *pgp = _bfd_get_gp_value (output_bfd);
   2578   if (*pgp)
   2579     return TRUE;
   2580 
   2581   count = bfd_get_symcount (output_bfd);
   2582   sym = bfd_get_outsymbols (output_bfd);
   2583 
   2584   /* The linker script will have created a symbol named `_gp' with the
   2585      appropriate value.  */
   2586   if (sym == NULL)
   2587     i = count;
   2588   else
   2589     {
   2590       for (i = 0; i < count; i++, sym++)
   2591 	{
   2592 	  register const char *name;
   2593 
   2594 	  name = bfd_asymbol_name (*sym);
   2595 	  if (*name == '_' && strcmp (name, "_gp") == 0)
   2596 	    {
   2597 	      *pgp = bfd_asymbol_value (*sym);
   2598 	      _bfd_set_gp_value (output_bfd, *pgp);
   2599 	      break;
   2600 	    }
   2601 	}
   2602     }
   2603 
   2604   if (i >= count)
   2605     {
   2606       /* Only get the error once.  */
   2607       *pgp = 4;
   2608       _bfd_set_gp_value (output_bfd, *pgp);
   2609       return FALSE;
   2610     }
   2611 
   2612   return TRUE;
   2613 }
   2614 
   2615 /* We have to figure out the gp value, so that we can adjust the
   2616    symbol value correctly.  We look up the symbol _gp in the output
   2617    BFD.  If we can't find it, we're stuck.  We cache it in the ELF
   2618    target data.  We don't need to adjust the symbol value for an
   2619    external symbol if we are producing relocatable output.  */
   2620 
   2621 static bfd_reloc_status_type
   2622 mips_elf_final_gp (bfd *output_bfd, asymbol *symbol, bfd_boolean relocatable,
   2623 		   char **error_message, bfd_vma *pgp)
   2624 {
   2625   if (bfd_is_und_section (symbol->section)
   2626       && ! relocatable)
   2627     {
   2628       *pgp = 0;
   2629       return bfd_reloc_undefined;
   2630     }
   2631 
   2632   *pgp = _bfd_get_gp_value (output_bfd);
   2633   if (*pgp == 0
   2634       && (! relocatable
   2635 	  || (symbol->flags & BSF_SECTION_SYM) != 0))
   2636     {
   2637       if (relocatable)
   2638 	{
   2639 	  /* Make up a value.  */
   2640 	  *pgp = symbol->section->output_section->vma /*+ 0x4000*/;
   2641 	  _bfd_set_gp_value (output_bfd, *pgp);
   2642 	}
   2643       else if (!mips_elf_assign_gp (output_bfd, pgp))
   2644 	{
   2645 	  *error_message =
   2646 	    (char *) _("GP relative relocation when _gp not defined");
   2647 	  return bfd_reloc_dangerous;
   2648 	}
   2649     }
   2650 
   2651   return bfd_reloc_ok;
   2652 }
   2653 
   2654 /* Do a R_MIPS_GPREL16 relocation.  This is a 16 bit value which must
   2655    become the offset from the gp register.  */
   2656 
   2657 static bfd_reloc_status_type
   2658 mips_elf_gprel16_reloc (bfd *abfd ATTRIBUTE_UNUSED, arelent *reloc_entry,
   2659 			asymbol *symbol, void *data ATTRIBUTE_UNUSED,
   2660 			asection *input_section, bfd *output_bfd,
   2661 			char **error_message ATTRIBUTE_UNUSED)
   2662 {
   2663   bfd_boolean relocatable;
   2664   bfd_reloc_status_type ret;
   2665   bfd_vma gp;
   2666 
   2667   if (output_bfd != NULL)
   2668     relocatable = TRUE;
   2669   else
   2670     {
   2671       relocatable = FALSE;
   2672       output_bfd = symbol->section->output_section->owner;
   2673     }
   2674 
   2675   ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
   2676 			   &gp);
   2677   if (ret != bfd_reloc_ok)
   2678     return ret;
   2679 
   2680   return _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
   2681 					input_section, relocatable,
   2682 					data, gp);
   2683 }
   2684 
   2685 /* Do a R_MIPS_LITERAL relocation.  */
   2686 
   2687 static bfd_reloc_status_type
   2688 mips_elf_literal_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
   2689 			void *data, asection *input_section, bfd *output_bfd,
   2690 			char **error_message)
   2691 {
   2692   bfd_boolean relocatable;
   2693   bfd_reloc_status_type ret;
   2694   bfd_vma gp;
   2695 
   2696   /* R_MIPS_LITERAL relocations are defined for local symbols only.  */
   2697   if (output_bfd != NULL
   2698       && (symbol->flags & BSF_SECTION_SYM) == 0
   2699       && (symbol->flags & BSF_LOCAL) != 0)
   2700     {
   2701       *error_message = (char *)
   2702 	_("literal relocation occurs for an external symbol");
   2703       return bfd_reloc_outofrange;
   2704     }
   2705 
   2706   /* FIXME: The entries in the .lit8 and .lit4 sections should be merged.  */
   2707   if (output_bfd != NULL)
   2708     relocatable = TRUE;
   2709   else
   2710     {
   2711       relocatable = FALSE;
   2712       output_bfd = symbol->section->output_section->owner;
   2713     }
   2714 
   2715   ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
   2716 			   &gp);
   2717   if (ret != bfd_reloc_ok)
   2718     return ret;
   2719 
   2720   return _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
   2721 					input_section, relocatable,
   2722 					data, gp);
   2723 }
   2724 
   2725 /* Do a R_MIPS_GPREL32 relocation.  This is a 32 bit value which must
   2726    become the offset from the gp register.  */
   2727 
   2728 static bfd_reloc_status_type
   2729 mips_elf_gprel32_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
   2730 			void *data, asection *input_section, bfd *output_bfd,
   2731 			char **error_message)
   2732 {
   2733   bfd_boolean relocatable;
   2734   bfd_reloc_status_type ret;
   2735   bfd_vma gp;
   2736 
   2737   /* R_MIPS_GPREL32 relocations are defined for local symbols only.  */
   2738   if (output_bfd != NULL
   2739       && (symbol->flags & BSF_SECTION_SYM) == 0
   2740       && (symbol->flags & BSF_LOCAL) != 0)
   2741     {
   2742       *error_message = (char *)
   2743 	_("32bits gp relative relocation occurs for an external symbol");
   2744       return bfd_reloc_outofrange;
   2745     }
   2746 
   2747   if (output_bfd != NULL)
   2748     {
   2749       relocatable = TRUE;
   2750       gp = _bfd_get_gp_value (output_bfd);
   2751     }
   2752   else
   2753     {
   2754       relocatable = FALSE;
   2755       output_bfd = symbol->section->output_section->owner;
   2756 
   2757       ret = mips_elf_final_gp (output_bfd, symbol, relocatable,
   2758 			       error_message, &gp);
   2759       if (ret != bfd_reloc_ok)
   2760 	return ret;
   2761     }
   2762 
   2763   return gprel32_with_gp (abfd, symbol, reloc_entry, input_section,
   2764 			  relocatable, data, gp);
   2765 }
   2766 
   2767 static bfd_reloc_status_type
   2768 gprel32_with_gp (bfd *abfd, asymbol *symbol, arelent *reloc_entry,
   2769 		 asection *input_section, bfd_boolean relocatable,
   2770 		 void *data, bfd_vma gp)
   2771 {
   2772   bfd_vma relocation;
   2773   unsigned long val;
   2774 
   2775   if (bfd_is_com_section (symbol->section))
   2776     relocation = 0;
   2777   else
   2778     relocation = symbol->value;
   2779 
   2780   relocation += symbol->section->output_section->vma;
   2781   relocation += symbol->section->output_offset;
   2782 
   2783   if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
   2784     return bfd_reloc_outofrange;
   2785 
   2786   if (reloc_entry->howto->src_mask == 0)
   2787     val = 0;
   2788   else
   2789     val = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
   2790 
   2791   /* Set val to the offset into the section or symbol.  */
   2792   val += reloc_entry->addend;
   2793 
   2794   /* Adjust val for the final section location and GP value.  If we
   2795      are producing relocatable output, we don't want to do this for
   2796      an external symbol.  */
   2797   if (! relocatable
   2798       || (symbol->flags & BSF_SECTION_SYM) != 0)
   2799     val += relocation - gp;
   2800 
   2801   bfd_put_32 (abfd, val, (bfd_byte *) data + reloc_entry->address);
   2802 
   2803   if (relocatable)
   2804     reloc_entry->address += input_section->output_offset;
   2805 
   2806   return bfd_reloc_ok;
   2807 }
   2808 
   2809 /* Do a R_MIPS_SHIFT6 relocation. The MSB of the shift is stored at bit 2,
   2810    the rest is at bits 6-10. The bitpos already got right by the howto.  */
   2811 
   2812 static bfd_reloc_status_type
   2813 mips_elf_shift6_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
   2814 		       void *data, asection *input_section, bfd *output_bfd,
   2815 		       char **error_message)
   2816 {
   2817   if (reloc_entry->howto->partial_inplace)
   2818     {
   2819       reloc_entry->addend = ((reloc_entry->addend & 0x00007c0)
   2820 			     | (reloc_entry->addend & 0x00000800) >> 9);
   2821     }
   2822 
   2823   return _bfd_mips_elf_generic_reloc (abfd, reloc_entry, symbol, data,
   2824 				      input_section, output_bfd,
   2825 				      error_message);
   2826 }
   2827 
   2828 /* Handle a mips16 GP relative reloc.  */
   2830 
   2831 static bfd_reloc_status_type
   2832 mips16_gprel_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
   2833 		    void *data, asection *input_section, bfd *output_bfd,
   2834 		    char **error_message)
   2835 {
   2836   bfd_boolean relocatable;
   2837   bfd_reloc_status_type ret;
   2838   bfd_byte *location;
   2839   bfd_vma gp;
   2840 
   2841   /* If we're relocating, and this is an external symbol, we don't want
   2842      to change anything.  */
   2843   if (output_bfd != NULL
   2844       && (symbol->flags & BSF_SECTION_SYM) == 0
   2845       && (symbol->flags & BSF_LOCAL) != 0)
   2846     {
   2847       reloc_entry->address += input_section->output_offset;
   2848       return bfd_reloc_ok;
   2849     }
   2850 
   2851   if (output_bfd != NULL)
   2852     relocatable = TRUE;
   2853   else
   2854     {
   2855       relocatable = FALSE;
   2856       output_bfd = symbol->section->output_section->owner;
   2857     }
   2858 
   2859   ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
   2860 			   &gp);
   2861   if (ret != bfd_reloc_ok)
   2862     return ret;
   2863 
   2864   location = (bfd_byte *) data + reloc_entry->address;
   2865   _bfd_mips_elf_reloc_unshuffle (abfd, reloc_entry->howto->type, FALSE,
   2866 				 location);
   2867   ret = _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
   2868 				       input_section, relocatable,
   2869 				       data, gp);
   2870   _bfd_mips_elf_reloc_shuffle (abfd, reloc_entry->howto->type, !relocatable,
   2871 			       location);
   2872 
   2873   return ret;
   2874 }
   2875 
   2876 /* A mapping from BFD reloc types to MIPS ELF reloc types.  */
   2878 
   2879 struct elf_reloc_map {
   2880   bfd_reloc_code_real_type bfd_val;
   2881   enum elf_mips_reloc_type elf_val;
   2882 };
   2883 
   2884 static const struct elf_reloc_map mips_reloc_map[] =
   2885 {
   2886   { BFD_RELOC_NONE, R_MIPS_NONE },
   2887   { BFD_RELOC_16, R_MIPS_16 },
   2888   { BFD_RELOC_32, R_MIPS_32 },
   2889   /* There is no BFD reloc for R_MIPS_REL32.  */
   2890   { BFD_RELOC_CTOR, R_MIPS_32 },
   2891   { BFD_RELOC_64, R_MIPS_64 },
   2892   { BFD_RELOC_16_PCREL_S2, R_MIPS_PC16 },
   2893   { BFD_RELOC_HI16_S, R_MIPS_HI16 },
   2894   { BFD_RELOC_LO16, R_MIPS_LO16 },
   2895   { BFD_RELOC_GPREL16, R_MIPS_GPREL16 },
   2896   { BFD_RELOC_GPREL32, R_MIPS_GPREL32 },
   2897   { BFD_RELOC_MIPS_JMP, R_MIPS_26 },
   2898   { BFD_RELOC_MIPS_LITERAL, R_MIPS_LITERAL },
   2899   { BFD_RELOC_MIPS_GOT16, R_MIPS_GOT16 },
   2900   { BFD_RELOC_MIPS_CALL16, R_MIPS_CALL16 },
   2901   { BFD_RELOC_MIPS_SHIFT5, R_MIPS_SHIFT5 },
   2902   { BFD_RELOC_MIPS_SHIFT6, R_MIPS_SHIFT6 },
   2903   { BFD_RELOC_MIPS_GOT_DISP, R_MIPS_GOT_DISP },
   2904   { BFD_RELOC_MIPS_GOT_PAGE, R_MIPS_GOT_PAGE },
   2905   { BFD_RELOC_MIPS_GOT_OFST, R_MIPS_GOT_OFST },
   2906   { BFD_RELOC_MIPS_GOT_HI16, R_MIPS_GOT_HI16 },
   2907   { BFD_RELOC_MIPS_GOT_LO16, R_MIPS_GOT_LO16 },
   2908   { BFD_RELOC_MIPS_SUB, R_MIPS_SUB },
   2909   { BFD_RELOC_MIPS_INSERT_A, R_MIPS_INSERT_A },
   2910   { BFD_RELOC_MIPS_INSERT_B, R_MIPS_INSERT_B },
   2911   { BFD_RELOC_MIPS_DELETE, R_MIPS_DELETE },
   2912   { BFD_RELOC_MIPS_HIGHEST, R_MIPS_HIGHEST },
   2913   { BFD_RELOC_MIPS_HIGHER, R_MIPS_HIGHER },
   2914   { BFD_RELOC_MIPS_CALL_HI16, R_MIPS_CALL_HI16 },
   2915   { BFD_RELOC_MIPS_CALL_LO16, R_MIPS_CALL_LO16 },
   2916   { BFD_RELOC_MIPS_SCN_DISP, R_MIPS_SCN_DISP },
   2917   { BFD_RELOC_MIPS_REL16, R_MIPS_REL16 },
   2918   /* Use of R_MIPS_ADD_IMMEDIATE and R_MIPS_PJUMP is deprecated.  */
   2919   { BFD_RELOC_MIPS_RELGOT, R_MIPS_RELGOT },
   2920   { BFD_RELOC_MIPS_JALR, R_MIPS_JALR },
   2921   { BFD_RELOC_MIPS_TLS_DTPMOD32, R_MIPS_TLS_DTPMOD32 },
   2922   { BFD_RELOC_MIPS_TLS_DTPREL32, R_MIPS_TLS_DTPREL32 },
   2923   { BFD_RELOC_MIPS_TLS_DTPMOD64, R_MIPS_TLS_DTPMOD64 },
   2924   { BFD_RELOC_MIPS_TLS_DTPREL64, R_MIPS_TLS_DTPREL64 },
   2925   { BFD_RELOC_MIPS_TLS_GD, R_MIPS_TLS_GD },
   2926   { BFD_RELOC_MIPS_TLS_LDM, R_MIPS_TLS_LDM },
   2927   { BFD_RELOC_MIPS_TLS_DTPREL_HI16, R_MIPS_TLS_DTPREL_HI16 },
   2928   { BFD_RELOC_MIPS_TLS_DTPREL_LO16, R_MIPS_TLS_DTPREL_LO16 },
   2929   { BFD_RELOC_MIPS_TLS_GOTTPREL, R_MIPS_TLS_GOTTPREL },
   2930   { BFD_RELOC_MIPS_TLS_TPREL32, R_MIPS_TLS_TPREL32 },
   2931   { BFD_RELOC_MIPS_TLS_TPREL64, R_MIPS_TLS_TPREL64 },
   2932   { BFD_RELOC_MIPS_TLS_TPREL_HI16, R_MIPS_TLS_TPREL_HI16 },
   2933   { BFD_RELOC_MIPS_TLS_TPREL_LO16, R_MIPS_TLS_TPREL_LO16 }
   2934 };
   2935 
   2936 static const struct elf_reloc_map mips16_reloc_map[] =
   2937 {
   2938   { BFD_RELOC_MIPS16_JMP, R_MIPS16_26 - R_MIPS16_min },
   2939   { BFD_RELOC_MIPS16_GPREL, R_MIPS16_GPREL - R_MIPS16_min },
   2940   { BFD_RELOC_MIPS16_GOT16, R_MIPS16_GOT16 - R_MIPS16_min },
   2941   { BFD_RELOC_MIPS16_CALL16, R_MIPS16_CALL16 - R_MIPS16_min },
   2942   { BFD_RELOC_MIPS16_HI16_S, R_MIPS16_HI16 - R_MIPS16_min },
   2943   { BFD_RELOC_MIPS16_LO16, R_MIPS16_LO16 - R_MIPS16_min },
   2944   { BFD_RELOC_MIPS16_TLS_GD, R_MIPS16_TLS_GD - R_MIPS16_min },
   2945   { BFD_RELOC_MIPS16_TLS_LDM, R_MIPS16_TLS_LDM - R_MIPS16_min },
   2946   { BFD_RELOC_MIPS16_TLS_DTPREL_HI16,
   2947     R_MIPS16_TLS_DTPREL_HI16 - R_MIPS16_min },
   2948   { BFD_RELOC_MIPS16_TLS_DTPREL_LO16,
   2949     R_MIPS16_TLS_DTPREL_LO16 - R_MIPS16_min },
   2950   { BFD_RELOC_MIPS16_TLS_GOTTPREL, R_MIPS16_TLS_GOTTPREL - R_MIPS16_min },
   2951   { BFD_RELOC_MIPS16_TLS_TPREL_HI16, R_MIPS16_TLS_TPREL_HI16 - R_MIPS16_min },
   2952   { BFD_RELOC_MIPS16_TLS_TPREL_LO16, R_MIPS16_TLS_TPREL_LO16 - R_MIPS16_min }
   2953 };
   2954 
   2955 static const struct elf_reloc_map micromips_reloc_map[] =
   2956 {
   2957   { BFD_RELOC_MICROMIPS_JMP, R_MICROMIPS_26_S1 - R_MICROMIPS_min },
   2958   { BFD_RELOC_MICROMIPS_HI16_S, R_MICROMIPS_HI16 - R_MICROMIPS_min },
   2959   { BFD_RELOC_MICROMIPS_LO16, R_MICROMIPS_LO16 - R_MICROMIPS_min },
   2960   { BFD_RELOC_MICROMIPS_GPREL16, R_MICROMIPS_GPREL16 - R_MICROMIPS_min },
   2961   { BFD_RELOC_MICROMIPS_LITERAL, R_MICROMIPS_LITERAL - R_MICROMIPS_min },
   2962   { BFD_RELOC_MICROMIPS_GOT16, R_MICROMIPS_GOT16 - R_MICROMIPS_min },
   2963   { BFD_RELOC_MICROMIPS_7_PCREL_S1, R_MICROMIPS_PC7_S1 - R_MICROMIPS_min },
   2964   { BFD_RELOC_MICROMIPS_10_PCREL_S1, R_MICROMIPS_PC10_S1 - R_MICROMIPS_min },
   2965   { BFD_RELOC_MICROMIPS_16_PCREL_S1, R_MICROMIPS_PC16_S1 - R_MICROMIPS_min },
   2966   { BFD_RELOC_MICROMIPS_CALL16, R_MICROMIPS_CALL16 - R_MICROMIPS_min },
   2967   { BFD_RELOC_MICROMIPS_GOT_DISP, R_MICROMIPS_GOT_DISP - R_MICROMIPS_min },
   2968   { BFD_RELOC_MICROMIPS_GOT_PAGE, R_MICROMIPS_GOT_PAGE - R_MICROMIPS_min },
   2969   { BFD_RELOC_MICROMIPS_GOT_OFST, R_MICROMIPS_GOT_OFST - R_MICROMIPS_min },
   2970   { BFD_RELOC_MICROMIPS_GOT_HI16, R_MICROMIPS_GOT_HI16 - R_MICROMIPS_min },
   2971   { BFD_RELOC_MICROMIPS_GOT_LO16, R_MICROMIPS_GOT_LO16 - R_MICROMIPS_min },
   2972   { BFD_RELOC_MICROMIPS_SUB, R_MICROMIPS_SUB - R_MICROMIPS_min },
   2973   { BFD_RELOC_MICROMIPS_HIGHER, R_MICROMIPS_HIGHER - R_MICROMIPS_min },
   2974   { BFD_RELOC_MICROMIPS_HIGHEST, R_MICROMIPS_HIGHEST - R_MICROMIPS_min },
   2975   { BFD_RELOC_MICROMIPS_CALL_HI16, R_MICROMIPS_CALL_HI16 - R_MICROMIPS_min },
   2976   { BFD_RELOC_MICROMIPS_CALL_LO16, R_MICROMIPS_CALL_LO16 - R_MICROMIPS_min },
   2977 };
   2978 
   2979 /* Given a BFD reloc type, return a howto structure.  */
   2980 
   2981 static reloc_howto_type *
   2982 bfd_elf32_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
   2983 				 bfd_reloc_code_real_type code)
   2984 {
   2985   unsigned int i;
   2986   /* FIXME: We default to RELA here instead of choosing the right
   2987      relocation variant.  */
   2988   reloc_howto_type *howto_table = elf_mips_howto_table_rela;
   2989   reloc_howto_type *howto16_table = elf_mips16_howto_table_rela;
   2990   reloc_howto_type *howto_micromips_table = elf_micromips_howto_table_rela;
   2991 
   2992   for (i = 0; i < sizeof (mips_reloc_map) / sizeof (struct elf_reloc_map);
   2993        i++)
   2994     {
   2995       if (mips_reloc_map[i].bfd_val == code)
   2996 	return &howto_table[(int) mips_reloc_map[i].elf_val];
   2997     }
   2998 
   2999   for (i = 0; i < sizeof (mips16_reloc_map) / sizeof (struct elf_reloc_map);
   3000        i++)
   3001     {
   3002       if (mips16_reloc_map[i].bfd_val == code)
   3003 	return &howto16_table[(int) mips16_reloc_map[i].elf_val];
   3004     }
   3005 
   3006   for (i = 0; i < sizeof (micromips_reloc_map) / sizeof (struct elf_reloc_map);
   3007        i++)
   3008     {
   3009       if (micromips_reloc_map[i].bfd_val == code)
   3010 	return &howto_micromips_table[(int) micromips_reloc_map[i].elf_val];
   3011     }
   3012 
   3013   switch (code)
   3014     {
   3015     case BFD_RELOC_VTABLE_INHERIT:
   3016       return &elf_mips_gnu_vtinherit_howto;
   3017     case BFD_RELOC_VTABLE_ENTRY:
   3018       return &elf_mips_gnu_vtentry_howto;
   3019     case BFD_RELOC_MIPS_COPY:
   3020       return &elf_mips_copy_howto;
   3021     case BFD_RELOC_MIPS_JUMP_SLOT:
   3022       return &elf_mips_jump_slot_howto;
   3023     default:
   3024       bfd_set_error (bfd_error_bad_value);
   3025       return NULL;
   3026     }
   3027 }
   3028 
   3029 static reloc_howto_type *
   3030 bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
   3031 				 const char *r_name)
   3032 {
   3033   unsigned int i;
   3034 
   3035   for (i = 0;
   3036        i < (sizeof (elf_mips_howto_table_rela)
   3037 	    / sizeof (elf_mips_howto_table_rela[0]));
   3038        i++)
   3039     if (elf_mips_howto_table_rela[i].name != NULL
   3040 	&& strcasecmp (elf_mips_howto_table_rela[i].name, r_name) == 0)
   3041       return &elf_mips_howto_table_rela[i];
   3042 
   3043   for (i = 0;
   3044        i < (sizeof (elf_mips16_howto_table_rela)
   3045 	    / sizeof (elf_mips16_howto_table_rela[0]));
   3046        i++)
   3047     if (elf_mips16_howto_table_rela[i].name != NULL
   3048 	&& strcasecmp (elf_mips16_howto_table_rela[i].name, r_name) == 0)
   3049       return &elf_mips16_howto_table_rela[i];
   3050 
   3051   for (i = 0;
   3052        i < (sizeof (elf_micromips_howto_table_rela)
   3053 	    / sizeof (elf_micromips_howto_table_rela[0]));
   3054        i++)
   3055     if (elf_micromips_howto_table_rela[i].name != NULL
   3056 	&& strcasecmp (elf_micromips_howto_table_rela[i].name, r_name) == 0)
   3057       return &elf_micromips_howto_table_rela[i];
   3058 
   3059   if (strcasecmp (elf_mips_gnu_vtinherit_howto.name, r_name) == 0)
   3060     return &elf_mips_gnu_vtinherit_howto;
   3061   if (strcasecmp (elf_mips_gnu_vtentry_howto.name, r_name) == 0)
   3062     return &elf_mips_gnu_vtentry_howto;
   3063   if (strcasecmp (elf_mips_gnu_rel16_s2.name, r_name) == 0)
   3064     return &elf_mips_gnu_rel16_s2;
   3065   if (strcasecmp (elf_mips_gnu_rela16_s2.name, r_name) == 0)
   3066     return &elf_mips_gnu_rela16_s2;
   3067   if (strcasecmp (elf_mips_copy_howto.name, r_name) == 0)
   3068     return &elf_mips_copy_howto;
   3069   if (strcasecmp (elf_mips_jump_slot_howto.name, r_name) == 0)
   3070     return &elf_mips_jump_slot_howto;
   3071 
   3072   return NULL;
   3073 }
   3074 
   3075 /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure.  */
   3076 
   3077 static reloc_howto_type *
   3078 mips_elf_n32_rtype_to_howto (unsigned int r_type, bfd_boolean rela_p)
   3079 {
   3080   switch (r_type)
   3081     {
   3082     case R_MIPS_GNU_VTINHERIT:
   3083       return &elf_mips_gnu_vtinherit_howto;
   3084     case R_MIPS_GNU_VTENTRY:
   3085       return &elf_mips_gnu_vtentry_howto;
   3086     case R_MIPS_GNU_REL16_S2:
   3087       if (rela_p)
   3088 	return &elf_mips_gnu_rela16_s2;
   3089       else
   3090 	return &elf_mips_gnu_rel16_s2;
   3091     case R_MIPS_COPY:
   3092       return &elf_mips_copy_howto;
   3093     case R_MIPS_JUMP_SLOT:
   3094       return &elf_mips_jump_slot_howto;
   3095     default:
   3096       if (r_type >= R_MICROMIPS_min && r_type < R_MICROMIPS_max)
   3097 	{
   3098 	  if (rela_p)
   3099 	    return &elf_micromips_howto_table_rela[r_type - R_MICROMIPS_min];
   3100 	  else
   3101 	    return &elf_micromips_howto_table_rel[r_type - R_MICROMIPS_min];
   3102 	}
   3103       if (r_type >= R_MIPS16_min && r_type < R_MIPS16_max)
   3104 	{
   3105 	  if (rela_p)
   3106 	    return &elf_mips16_howto_table_rela[r_type - R_MIPS16_min];
   3107 	  else
   3108 	    return &elf_mips16_howto_table_rel[r_type - R_MIPS16_min];
   3109 	}
   3110       BFD_ASSERT (r_type < (unsigned int) R_MIPS_max);
   3111       if (rela_p)
   3112 	return &elf_mips_howto_table_rela[r_type];
   3113       else
   3114 	return &elf_mips_howto_table_rel[r_type];
   3115       break;
   3116     }
   3117 }
   3118 
   3119 /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure.  */
   3120 
   3121 static void
   3122 mips_info_to_howto_rel (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)
   3123 {
   3124   unsigned int r_type;
   3125 
   3126   r_type = ELF32_R_TYPE (dst->r_info);
   3127   cache_ptr->howto = mips_elf_n32_rtype_to_howto (r_type, FALSE);
   3128 
   3129   /* The addend for a GPREL16 or LITERAL relocation comes from the GP
   3130      value for the object file.  We get the addend now, rather than
   3131      when we do the relocation, because the symbol manipulations done
   3132      by the linker may cause us to lose track of the input BFD.  */
   3133   if (((*cache_ptr->sym_ptr_ptr)->flags & BSF_SECTION_SYM) != 0
   3134       && (gprel16_reloc_p (r_type) || r_type == (unsigned int) R_MIPS_LITERAL))
   3135     cache_ptr->addend = elf_gp (abfd);
   3136 }
   3137 
   3138 /* Given a MIPS Elf_Internal_Rela, fill in an arelent structure.  */
   3139 
   3140 static void
   3141 mips_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED,
   3142 			 arelent *cache_ptr, Elf_Internal_Rela *dst)
   3143 {
   3144   unsigned int r_type;
   3145 
   3146   r_type = ELF32_R_TYPE (dst->r_info);
   3147   cache_ptr->howto = mips_elf_n32_rtype_to_howto (r_type, TRUE);
   3148   cache_ptr->addend = dst->r_addend;
   3149 }
   3150 
   3151 /* Determine whether a symbol is global for the purposes of splitting
   3153    the symbol table into global symbols and local symbols.  At least
   3154    on Irix 5, this split must be between section symbols and all other
   3155    symbols.  On most ELF targets the split is between static symbols
   3156    and externally visible symbols.  */
   3157 
   3158 static bfd_boolean
   3159 mips_elf_sym_is_global (bfd *abfd ATTRIBUTE_UNUSED, asymbol *sym)
   3160 {
   3161   if (SGI_COMPAT (abfd))
   3162     return (sym->flags & BSF_SECTION_SYM) == 0;
   3163   else
   3164     return ((sym->flags & (BSF_GLOBAL | BSF_WEAK | BSF_GNU_UNIQUE)) != 0
   3165 	    || bfd_is_und_section (bfd_get_section (sym))
   3166 	    || bfd_is_com_section (bfd_get_section (sym)));
   3167 }
   3168 
   3169 /* Set the right machine number for a MIPS ELF file.  */
   3171 
   3172 static bfd_boolean
   3173 mips_elf_n32_object_p (bfd *abfd)
   3174 {
   3175   unsigned long mach;
   3176 
   3177   /* Irix 5 and 6 are broken.  Object file symbol tables are not always
   3178      sorted correctly such that local symbols precede global symbols,
   3179      and the sh_info field in the symbol table is not always right.  */
   3180   if (SGI_COMPAT (abfd))
   3181     elf_bad_symtab (abfd) = TRUE;
   3182 
   3183   mach = _bfd_elf_mips_mach (elf_elfheader (abfd)->e_flags);
   3184   bfd_default_set_arch_mach (abfd, bfd_arch_mips, mach);
   3185 
   3186   if (! ABI_N32_P(abfd))
   3187     return FALSE;
   3188 
   3189   return TRUE;
   3190 }
   3191 
   3192 /* Support for core dump NOTE sections.  */
   3194 static bfd_boolean
   3195 elf32_mips_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
   3196 {
   3197   int offset;
   3198   unsigned int size;
   3199 
   3200   switch (note->descsz)
   3201     {
   3202       default:
   3203 	return FALSE;
   3204 
   3205       case 440:		/* Linux/MIPS N32 */
   3206 	/* pr_cursig */
   3207 	elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
   3208 
   3209 	/* pr_pid */
   3210 	elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 24);
   3211 
   3212 	/* pr_reg */
   3213 	offset = 72;
   3214 	size = 360;
   3215 
   3216 	break;
   3217     }
   3218 
   3219   /* Make a ".reg/999" section.  */
   3220   return _bfd_elfcore_make_pseudosection (abfd, ".reg", size,
   3221 					  note->descpos + offset);
   3222 }
   3223 
   3224 static bfd_boolean
   3225 elf32_mips_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
   3226 {
   3227   switch (note->descsz)
   3228     {
   3229       default:
   3230 	return FALSE;
   3231 
   3232       case 128:		/* Linux/MIPS elf_prpsinfo */
   3233 	elf_tdata (abfd)->core_program
   3234 	 = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
   3235 	elf_tdata (abfd)->core_command
   3236 	 = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80);
   3237     }
   3238 
   3239   /* Note that for some reason, a spurious space is tacked
   3240      onto the end of the args in some (at least one anyway)
   3241      implementations, so strip it off if it exists.  */
   3242 
   3243   {
   3244     char *command = elf_tdata (abfd)->core_command;
   3245     int n = strlen (command);
   3246 
   3247     if (0 < n && command[n - 1] == ' ')
   3248       command[n - 1] = '\0';
   3249   }
   3250 
   3251   return TRUE;
   3252 }
   3253 
   3254 /* MIPS ELF local labels start with "$L".  */
   3256 static bfd_boolean
   3257 mips_elf_n32_is_local_label_name (bfd *abfd, const char *name)
   3258 {
   3259   if (name[0] == '$' && name[1] == 'L')
   3260     return TRUE;
   3261 
   3262   /* We accept the generic ELF local label syntax as well.  */
   3263   return _bfd_elf_is_local_label_name (abfd, name);
   3264 }
   3265 
   3266 /* Depending on the target vector we generate some version of Irix
   3268    executables or "normal" MIPS ELF ABI executables.  */
   3269 static irix_compat_t
   3270 elf_n32_mips_irix_compat (bfd *abfd)
   3271 {
   3272   if ((abfd->xvec == &bfd_elf32_nbigmips_vec)
   3273       || (abfd->xvec == &bfd_elf32_nlittlemips_vec))
   3274     return ict_irix6;
   3275   else
   3276     return ict_none;
   3277 }
   3278 
   3279 /* ECOFF swapping routines.  These are used when dealing with the
   3281    .mdebug section, which is in the ECOFF debugging format.  */
   3282 static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
   3283   /* Symbol table magic number.  */
   3284   magicSym,
   3285   /* Alignment of debugging information.  E.g., 4.  */
   3286   4,
   3287   /* Sizes of external symbolic information.  */
   3288   sizeof (struct hdr_ext),
   3289   sizeof (struct dnr_ext),
   3290   sizeof (struct pdr_ext),
   3291   sizeof (struct sym_ext),
   3292   sizeof (struct opt_ext),
   3293   sizeof (struct fdr_ext),
   3294   sizeof (struct rfd_ext),
   3295   sizeof (struct ext_ext),
   3296   /* Functions to swap in external symbolic data.  */
   3297   ecoff_swap_hdr_in,
   3298   ecoff_swap_dnr_in,
   3299   ecoff_swap_pdr_in,
   3300   ecoff_swap_sym_in,
   3301   ecoff_swap_opt_in,
   3302   ecoff_swap_fdr_in,
   3303   ecoff_swap_rfd_in,
   3304   ecoff_swap_ext_in,
   3305   _bfd_ecoff_swap_tir_in,
   3306   _bfd_ecoff_swap_rndx_in,
   3307   /* Functions to swap out external symbolic data.  */
   3308   ecoff_swap_hdr_out,
   3309   ecoff_swap_dnr_out,
   3310   ecoff_swap_pdr_out,
   3311   ecoff_swap_sym_out,
   3312   ecoff_swap_opt_out,
   3313   ecoff_swap_fdr_out,
   3314   ecoff_swap_rfd_out,
   3315   ecoff_swap_ext_out,
   3316   _bfd_ecoff_swap_tir_out,
   3317   _bfd_ecoff_swap_rndx_out,
   3318   /* Function to read in symbolic data.  */
   3319   _bfd_mips_elf_read_ecoff_info
   3320 };
   3321 
   3322 #define ELF_ARCH			bfd_arch_mips
   3324 #define ELF_TARGET_ID			MIPS_ELF_DATA
   3325 #define ELF_MACHINE_CODE		EM_MIPS
   3326 
   3327 #define elf_backend_collect		TRUE
   3328 #define elf_backend_type_change_ok	TRUE
   3329 #define elf_backend_can_gc_sections	TRUE
   3330 #define elf_info_to_howto		mips_info_to_howto_rela
   3331 #define elf_info_to_howto_rel		mips_info_to_howto_rel
   3332 #define elf_backend_sym_is_global	mips_elf_sym_is_global
   3333 #define elf_backend_object_p		mips_elf_n32_object_p
   3334 #define elf_backend_symbol_processing	_bfd_mips_elf_symbol_processing
   3335 #define elf_backend_section_processing	_bfd_mips_elf_section_processing
   3336 #define elf_backend_section_from_shdr	_bfd_mips_elf_section_from_shdr
   3337 #define elf_backend_fake_sections	_bfd_mips_elf_fake_sections
   3338 #define elf_backend_section_from_bfd_section \
   3339 					_bfd_mips_elf_section_from_bfd_section
   3340 #define elf_backend_add_symbol_hook	_bfd_mips_elf_add_symbol_hook
   3341 #define elf_backend_link_output_symbol_hook \
   3342 					_bfd_mips_elf_link_output_symbol_hook
   3343 #define elf_backend_create_dynamic_sections \
   3344 					_bfd_mips_elf_create_dynamic_sections
   3345 #define elf_backend_check_relocs	_bfd_mips_elf_check_relocs
   3346 #define elf_backend_merge_symbol_attribute \
   3347 					_bfd_mips_elf_merge_symbol_attribute
   3348 #define elf_backend_get_target_dtag	_bfd_mips_elf_get_target_dtag
   3349 #define elf_backend_adjust_dynamic_symbol \
   3350 					_bfd_mips_elf_adjust_dynamic_symbol
   3351 #define elf_backend_always_size_sections \
   3352 					_bfd_mips_elf_always_size_sections
   3353 #define elf_backend_size_dynamic_sections \
   3354 					_bfd_mips_elf_size_dynamic_sections
   3355 #define elf_backend_init_index_section	_bfd_elf_init_1_index_section
   3356 #define elf_backend_relocate_section	_bfd_mips_elf_relocate_section
   3357 #define elf_backend_finish_dynamic_symbol \
   3358 					_bfd_mips_elf_finish_dynamic_symbol
   3359 #define elf_backend_finish_dynamic_sections \
   3360 					_bfd_mips_elf_finish_dynamic_sections
   3361 #define elf_backend_final_write_processing \
   3362 					_bfd_mips_elf_final_write_processing
   3363 #define elf_backend_additional_program_headers \
   3364 					_bfd_mips_elf_additional_program_headers
   3365 #define elf_backend_modify_segment_map	_bfd_mips_elf_modify_segment_map
   3366 #define elf_backend_gc_mark_hook	_bfd_mips_elf_gc_mark_hook
   3367 #define elf_backend_gc_sweep_hook	_bfd_mips_elf_gc_sweep_hook
   3368 #define elf_backend_copy_indirect_symbol \
   3369 					_bfd_mips_elf_copy_indirect_symbol
   3370 #define elf_backend_grok_prstatus	elf32_mips_grok_prstatus
   3371 #define elf_backend_grok_psinfo		elf32_mips_grok_psinfo
   3372 #define elf_backend_ecoff_debug_swap	&mips_elf32_ecoff_debug_swap
   3373 
   3374 #define elf_backend_got_header_size	(4 * MIPS_RESERVED_GOTNO)
   3375 
   3376 /* MIPS n32 ELF can use a mixture of REL and RELA, but some Relocations
   3377    work better/work only in RELA, so we default to this.  */
   3378 #define elf_backend_may_use_rel_p	1
   3379 #define elf_backend_may_use_rela_p	1
   3380 #define elf_backend_default_use_rela_p	1
   3381 #define elf_backend_rela_plts_and_copies_p 0
   3382 #define elf_backend_sign_extend_vma	TRUE
   3383 #define elf_backend_plt_readonly	1
   3384 #define elf_backend_plt_sym_val		_bfd_mips_elf_plt_sym_val
   3385 
   3386 #define elf_backend_discard_info	_bfd_mips_elf_discard_info
   3387 #define elf_backend_ignore_discarded_relocs \
   3388 					_bfd_mips_elf_ignore_discarded_relocs
   3389 #define elf_backend_write_section	_bfd_mips_elf_write_section
   3390 #define elf_backend_mips_irix_compat	elf_n32_mips_irix_compat
   3391 #define elf_backend_mips_rtype_to_howto	mips_elf_n32_rtype_to_howto
   3392 
   3393 #define bfd_elf32_bfd_is_local_label_name \
   3394 					mips_elf_n32_is_local_label_name
   3395 #define bfd_elf32_bfd_is_target_special_symbol \
   3396 					_bfd_mips_elf_is_target_special_symbol
   3397 #define bfd_elf32_find_nearest_line	_bfd_mips_elf_find_nearest_line
   3398 #define bfd_elf32_find_inliner_info	_bfd_mips_elf_find_inliner_info
   3399 #define bfd_elf32_new_section_hook	_bfd_mips_elf_new_section_hook
   3400 #define bfd_elf32_set_section_contents	_bfd_mips_elf_set_section_contents
   3401 #define bfd_elf32_bfd_get_relocated_section_contents \
   3402 				_bfd_elf_mips_get_relocated_section_contents
   3403 #define bfd_elf32_bfd_link_hash_table_create \
   3404 					_bfd_mips_elf_link_hash_table_create
   3405 #define bfd_elf32_bfd_final_link	_bfd_mips_elf_final_link
   3406 #define bfd_elf32_bfd_merge_private_bfd_data \
   3407 					_bfd_mips_elf_merge_private_bfd_data
   3408 #define bfd_elf32_bfd_set_private_flags	_bfd_mips_elf_set_private_flags
   3409 #define bfd_elf32_bfd_print_private_bfd_data \
   3410 					_bfd_mips_elf_print_private_bfd_data
   3411 #define bfd_elf32_bfd_relax_section     _bfd_mips_relax_section
   3412 
   3413 /* Support for SGI-ish mips targets using n32 ABI.  */
   3414 
   3415 #define TARGET_LITTLE_SYM               bfd_elf32_nlittlemips_vec
   3416 #define TARGET_LITTLE_NAME              "elf32-nlittlemips"
   3417 #define TARGET_BIG_SYM                  bfd_elf32_nbigmips_vec
   3418 #define TARGET_BIG_NAME                 "elf32-nbigmips"
   3419 
   3420 #define ELF_MAXPAGESIZE			0x10000
   3421 #define ELF_COMMONPAGESIZE		0x1000
   3422 
   3423 #include "elf32-target.h"
   3424 
   3425 /* Support for traditional mips targets using n32 ABI.  */
   3426 #undef TARGET_LITTLE_SYM
   3427 #undef TARGET_LITTLE_NAME
   3428 #undef TARGET_BIG_SYM
   3429 #undef TARGET_BIG_NAME
   3430 
   3431 #undef ELF_MAXPAGESIZE
   3432 #undef ELF_COMMONPAGESIZE
   3433 
   3434 #define TARGET_LITTLE_SYM               bfd_elf32_ntradlittlemips_vec
   3435 #define TARGET_LITTLE_NAME              "elf32-ntradlittlemips"
   3436 #define TARGET_BIG_SYM                  bfd_elf32_ntradbigmips_vec
   3437 #define TARGET_BIG_NAME                 "elf32-ntradbigmips"
   3438 
   3439 #define ELF_MAXPAGESIZE			0x10000
   3440 #define ELF_COMMONPAGESIZE		0x1000
   3441 #define elf32_bed			elf32_tradbed
   3442 
   3443 /* Include the target file again for this target.  */
   3444 #include "elf32-target.h"
   3445 
   3446 
   3447 /* FreeBSD support.  */
   3448 
   3449 #undef TARGET_LITTLE_SYM
   3450 #undef TARGET_LITTLE_NAME
   3451 #undef TARGET_BIG_SYM
   3452 #undef TARGET_BIG_NAME
   3453 
   3454 #define	TARGET_LITTLE_SYM		bfd_elf32_ntradlittlemips_freebsd_vec
   3455 #define	TARGET_LITTLE_NAME		"elf32-ntradlittlemips-freebsd"
   3456 #define	TARGET_BIG_SYM			bfd_elf32_ntradbigmips_freebsd_vec
   3457 #define	TARGET_BIG_NAME			"elf32-ntradbigmips-freebsd"
   3458 
   3459 #undef	ELF_OSABI
   3460 #define	ELF_OSABI			ELFOSABI_FREEBSD
   3461 
   3462 /* The kernel recognizes executables as valid only if they carry a
   3463    "FreeBSD" label in the ELF header.  So we put this label on all
   3464    executables and (for simplicity) also all other object files.  */
   3465 
   3466 static void
   3467 elf_fbsd_post_process_headers (bfd *abfd, struct bfd_link_info *info)
   3468 {
   3469   _bfd_elf_set_osabi (abfd, info);
   3470 }
   3471 
   3472 #undef	elf_backend_post_process_headers
   3473 #define	elf_backend_post_process_headers	elf_fbsd_post_process_headers
   3474 #undef	elf32_bed
   3475 #define elf32_bed				elf32_fbsd_tradbed
   3476 
   3477 #include "elf32-target.h"
   3478