xref: /netbsd-src/external/gpl3/binutils/dist/bfd/elfn32-mips.c (revision a5847cc334d9a7029f6352b847e9e8d71a0f9e0c)
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@cygnus.com>.
7    N32/64 ABI support added by Mark Mitchell, CodeSourcery, LLC.
8    <mark@codesourcery.com>
9    Traditional MIPS targets support added by Koundinya.K, Dansk Data
10    Elektronik & Operations Research Group. <kk@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 	 0xffffffff,		/* 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 	 0xffffffff,		/* 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 	 0x0000ffff,		/* 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 	 0x0000ffff,		/* 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 	 0x0000ffff,		/* 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 	 0x0000ffff,		/* 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 	 0x0000ffff,		/* 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 	 0xffffffff,		/* 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 	 0x0000ffff,		/* 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 	 0x0000ffff,		/* 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 
1562 static reloc_howto_type elf_mips16_howto_table_rela[] =
1563 {
1564   /* The reloc used for the mips16 jump instruction.  */
1565   HOWTO (R_MIPS16_26,		/* type */
1566 	 2,			/* rightshift */
1567 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
1568 	 26,			/* bitsize */
1569 	 FALSE,			/* pc_relative */
1570 	 0,			/* bitpos */
1571 	 complain_overflow_dont, /* complain_on_overflow */
1572 	 			/* This needs complex overflow
1573 				   detection, because the upper four
1574 				   bits must match the PC.  */
1575 	 _bfd_mips_elf_generic_reloc, /* special_function */
1576 	 "R_MIPS16_26",		/* name */
1577 	 FALSE,			/* partial_inplace */
1578 	 0x3ffffff,		/* src_mask */
1579 	 0x3ffffff,		/* dst_mask */
1580 	 FALSE),		/* pcrel_offset */
1581 
1582   /* The reloc used for the mips16 gprel instruction.  */
1583   HOWTO (R_MIPS16_GPREL,	/* type */
1584 	 0,			/* rightshift */
1585 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
1586 	 16,			/* bitsize */
1587 	 FALSE,			/* pc_relative */
1588 	 0,			/* bitpos */
1589 	 complain_overflow_signed, /* complain_on_overflow */
1590 	 mips16_gprel_reloc,	/* special_function */
1591 	 "R_MIPS16_GPREL",	/* name */
1592 	 FALSE,			/* partial_inplace */
1593 	 0x0000ffff,		/* src_mask */
1594 	 0x0000ffff,	        /* dst_mask */
1595 	 FALSE),		/* pcrel_offset */
1596 
1597   /* A MIPS16 reference to the global offset table.  */
1598   HOWTO (R_MIPS16_GOT16,	/* type */
1599 	 0,			/* rightshift */
1600 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
1601 	 16,			/* bitsize */
1602 	 FALSE,			/* pc_relative */
1603 	 0,			/* bitpos */
1604 	 complain_overflow_dont, /* complain_on_overflow */
1605 	 _bfd_mips_elf_got16_reloc, /* special_function */
1606 	 "R_MIPS16_GOT16",	/* name */
1607 	 FALSE,			/* partial_inplace */
1608 	 0x0000ffff,		/* src_mask */
1609 	 0x0000ffff,	        /* dst_mask */
1610 	 FALSE),		/* pcrel_offset */
1611 
1612   /* A MIPS16 call through the global offset table.  */
1613   HOWTO (R_MIPS16_CALL16,	/* type */
1614 	 0,			/* rightshift */
1615 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
1616 	 16,			/* bitsize */
1617 	 FALSE,			/* pc_relative */
1618 	 0,			/* bitpos */
1619 	 complain_overflow_dont, /* complain_on_overflow */
1620 	 _bfd_mips_elf_generic_reloc, /* special_function */
1621 	 "R_MIPS16_CALL16",	/* name */
1622 	 FALSE,			/* partial_inplace */
1623 	 0x0000ffff,		/* src_mask */
1624 	 0x0000ffff,	        /* dst_mask */
1625 	 FALSE),		/* pcrel_offset */
1626 
1627   /* MIPS16 high 16 bits of symbol value.  */
1628   HOWTO (R_MIPS16_HI16,		/* type */
1629 	 16,			/* rightshift */
1630 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
1631 	 16,			/* bitsize */
1632 	 FALSE,			/* pc_relative */
1633 	 0,			/* bitpos */
1634 	 complain_overflow_dont, /* complain_on_overflow */
1635 	 _bfd_mips_elf_hi16_reloc, /* special_function */
1636 	 "R_MIPS16_HI16",	/* name */
1637 	 FALSE,			/* partial_inplace */
1638 	 0x0000ffff,		/* src_mask */
1639 	 0x0000ffff,		/* dst_mask */
1640 	 FALSE),		/* pcrel_offset */
1641 
1642   /* MIPS16 low 16 bits of symbol value.  */
1643   HOWTO (R_MIPS16_LO16,		/* type */
1644 	 0,			/* rightshift */
1645 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
1646 	 16,			/* bitsize */
1647 	 FALSE,			/* pc_relative */
1648 	 0,			/* bitpos */
1649 	 complain_overflow_dont, /* complain_on_overflow */
1650 	 _bfd_mips_elf_lo16_reloc, /* special_function */
1651 	 "R_MIPS16_LO16",	/* name */
1652 	 FALSE,			/* partial_inplace */
1653 	 0x0000ffff,		/* src_mask */
1654 	 0x0000ffff,		/* dst_mask */
1655 	 FALSE),		/* pcrel_offset */
1656 };
1657 
1658 /* GNU extension to record C++ vtable hierarchy */
1659 static reloc_howto_type elf_mips_gnu_vtinherit_howto =
1660   HOWTO (R_MIPS_GNU_VTINHERIT,	/* type */
1661 	 0,			/* rightshift */
1662 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
1663 	 0,			/* bitsize */
1664 	 FALSE,			/* pc_relative */
1665 	 0,			/* bitpos */
1666 	 complain_overflow_dont, /* complain_on_overflow */
1667 	 NULL,			/* special_function */
1668 	 "R_MIPS_GNU_VTINHERIT", /* name */
1669 	 FALSE,			/* partial_inplace */
1670 	 0,			/* src_mask */
1671 	 0,			/* dst_mask */
1672 	 FALSE);		/* pcrel_offset */
1673 
1674 /* GNU extension to record C++ vtable member usage */
1675 static reloc_howto_type elf_mips_gnu_vtentry_howto =
1676   HOWTO (R_MIPS_GNU_VTENTRY,	/* type */
1677 	 0,			/* rightshift */
1678 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
1679 	 0,			/* bitsize */
1680 	 FALSE,			/* pc_relative */
1681 	 0,			/* bitpos */
1682 	 complain_overflow_dont, /* complain_on_overflow */
1683 	 _bfd_elf_rel_vtable_reloc_fn, /* special_function */
1684 	 "R_MIPS_GNU_VTENTRY",	/* name */
1685 	 FALSE,			/* partial_inplace */
1686 	 0,			/* src_mask */
1687 	 0,			/* dst_mask */
1688 	 FALSE);		/* pcrel_offset */
1689 
1690 /* 16 bit offset for pc-relative branches.  */
1691 static reloc_howto_type elf_mips_gnu_rel16_s2 =
1692   HOWTO (R_MIPS_GNU_REL16_S2,	/* type */
1693 	 2,			/* rightshift */
1694 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
1695 	 16,			/* bitsize */
1696 	 TRUE,			/* pc_relative */
1697 	 0,			/* bitpos */
1698 	 complain_overflow_signed, /* complain_on_overflow */
1699 	 _bfd_mips_elf_generic_reloc, /* special_function */
1700 	 "R_MIPS_GNU_REL16_S2",	/* name */
1701 	 TRUE,			/* partial_inplace */
1702 	 0x0000ffff,		/* src_mask */
1703 	 0x0000ffff,		/* dst_mask */
1704 	 TRUE);			/* pcrel_offset */
1705 
1706 /* 16 bit offset for pc-relative branches.  */
1707 static reloc_howto_type elf_mips_gnu_rela16_s2 =
1708   HOWTO (R_MIPS_GNU_REL16_S2,	/* type */
1709 	 2,			/* rightshift */
1710 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
1711 	 16,			/* bitsize */
1712 	 TRUE,			/* pc_relative */
1713 	 0,			/* bitpos */
1714 	 complain_overflow_signed, /* complain_on_overflow */
1715 	 _bfd_mips_elf_generic_reloc, /* special_function */
1716 	 "R_MIPS_GNU_REL16_S2",	/* name */
1717 	 FALSE,			/* partial_inplace */
1718 	 0,			/* src_mask */
1719 	 0x0000ffff,		/* dst_mask */
1720 	 TRUE);			/* pcrel_offset */
1721 
1722 /* Originally a VxWorks extension, but now used for other systems too.  */
1723 static reloc_howto_type elf_mips_copy_howto =
1724   HOWTO (R_MIPS_COPY,		/* type */
1725 	 0,			/* rightshift */
1726 	 0,			/* this one is variable size */
1727 	 0,			/* bitsize */
1728 	 FALSE,			/* pc_relative */
1729 	 0,			/* bitpos */
1730 	 complain_overflow_bitfield, /* complain_on_overflow */
1731 	 bfd_elf_generic_reloc,	/* special_function */
1732 	 "R_MIPS_COPY",		/* name */
1733 	 FALSE,			/* partial_inplace */
1734 	 0x0,         		/* src_mask */
1735 	 0x0,		        /* dst_mask */
1736 	 FALSE);		/* pcrel_offset */
1737 
1738 /* Originally a VxWorks extension, but now used for other systems too.  */
1739 static reloc_howto_type elf_mips_jump_slot_howto =
1740   HOWTO (R_MIPS_JUMP_SLOT,	/* type */
1741 	 0,			/* rightshift */
1742 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
1743 	 32,			/* bitsize */
1744 	 FALSE,			/* pc_relative */
1745 	 0,			/* bitpos */
1746 	 complain_overflow_bitfield, /* complain_on_overflow */
1747 	 bfd_elf_generic_reloc,	/* special_function */
1748 	 "R_MIPS_JUMP_SLOT",	/* name */
1749 	 FALSE,			/* partial_inplace */
1750 	 0x0,         		/* src_mask */
1751 	 0x0,		        /* dst_mask */
1752 	 FALSE);		/* pcrel_offset */
1753 
1754 /* Set the GP value for OUTPUT_BFD.  Returns FALSE if this is a
1755    dangerous relocation.  */
1756 
1757 static bfd_boolean
1758 mips_elf_assign_gp (bfd *output_bfd, bfd_vma *pgp)
1759 {
1760   unsigned int count;
1761   asymbol **sym;
1762   unsigned int i;
1763 
1764   /* If we've already figured out what GP will be, just return it.  */
1765   *pgp = _bfd_get_gp_value (output_bfd);
1766   if (*pgp)
1767     return TRUE;
1768 
1769   count = bfd_get_symcount (output_bfd);
1770   sym = bfd_get_outsymbols (output_bfd);
1771 
1772   /* The linker script will have created a symbol named `_gp' with the
1773      appropriate value.  */
1774   if (sym == NULL)
1775     i = count;
1776   else
1777     {
1778       for (i = 0; i < count; i++, sym++)
1779 	{
1780 	  register const char *name;
1781 
1782 	  name = bfd_asymbol_name (*sym);
1783 	  if (*name == '_' && strcmp (name, "_gp") == 0)
1784 	    {
1785 	      *pgp = bfd_asymbol_value (*sym);
1786 	      _bfd_set_gp_value (output_bfd, *pgp);
1787 	      break;
1788 	    }
1789 	}
1790     }
1791 
1792   if (i >= count)
1793     {
1794       /* Only get the error once.  */
1795       *pgp = 4;
1796       _bfd_set_gp_value (output_bfd, *pgp);
1797       return FALSE;
1798     }
1799 
1800   return TRUE;
1801 }
1802 
1803 /* We have to figure out the gp value, so that we can adjust the
1804    symbol value correctly.  We look up the symbol _gp in the output
1805    BFD.  If we can't find it, we're stuck.  We cache it in the ELF
1806    target data.  We don't need to adjust the symbol value for an
1807    external symbol if we are producing relocatable output.  */
1808 
1809 static bfd_reloc_status_type
1810 mips_elf_final_gp (bfd *output_bfd, asymbol *symbol, bfd_boolean relocatable,
1811 		   char **error_message, bfd_vma *pgp)
1812 {
1813   if (bfd_is_und_section (symbol->section)
1814       && ! relocatable)
1815     {
1816       *pgp = 0;
1817       return bfd_reloc_undefined;
1818     }
1819 
1820   *pgp = _bfd_get_gp_value (output_bfd);
1821   if (*pgp == 0
1822       && (! relocatable
1823 	  || (symbol->flags & BSF_SECTION_SYM) != 0))
1824     {
1825       if (relocatable)
1826 	{
1827 	  /* Make up a value.  */
1828 	  *pgp = symbol->section->output_section->vma /*+ 0x4000*/;
1829 	  _bfd_set_gp_value (output_bfd, *pgp);
1830 	}
1831       else if (!mips_elf_assign_gp (output_bfd, pgp))
1832 	{
1833 	  *error_message =
1834 	    (char *) _("GP relative relocation when _gp not defined");
1835 	  return bfd_reloc_dangerous;
1836 	}
1837     }
1838 
1839   return bfd_reloc_ok;
1840 }
1841 
1842 /* Do a R_MIPS_GPREL16 relocation.  This is a 16 bit value which must
1843    become the offset from the gp register.  */
1844 
1845 static bfd_reloc_status_type
1846 mips_elf_gprel16_reloc (bfd *abfd ATTRIBUTE_UNUSED, arelent *reloc_entry,
1847 			asymbol *symbol, void *data ATTRIBUTE_UNUSED,
1848 			asection *input_section, bfd *output_bfd,
1849 			char **error_message ATTRIBUTE_UNUSED)
1850 {
1851   bfd_boolean relocatable;
1852   bfd_reloc_status_type ret;
1853   bfd_vma gp;
1854 
1855   if (output_bfd != NULL)
1856     relocatable = TRUE;
1857   else
1858     {
1859       relocatable = FALSE;
1860       output_bfd = symbol->section->output_section->owner;
1861     }
1862 
1863   ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
1864 			   &gp);
1865   if (ret != bfd_reloc_ok)
1866     return ret;
1867 
1868   return _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
1869 					input_section, relocatable,
1870 					data, gp);
1871 }
1872 
1873 /* Do a R_MIPS_LITERAL relocation.  */
1874 
1875 static bfd_reloc_status_type
1876 mips_elf_literal_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
1877 			void *data, asection *input_section, bfd *output_bfd,
1878 			char **error_message)
1879 {
1880   bfd_boolean relocatable;
1881   bfd_reloc_status_type ret;
1882   bfd_vma gp;
1883 
1884   /* R_MIPS_LITERAL relocations are defined for local symbols only.  */
1885   if (output_bfd != NULL
1886       && (symbol->flags & BSF_SECTION_SYM) == 0
1887       && (symbol->flags & BSF_LOCAL) != 0)
1888     {
1889       *error_message = (char *)
1890 	_("literal relocation occurs for an external symbol");
1891       return bfd_reloc_outofrange;
1892     }
1893 
1894   /* FIXME: The entries in the .lit8 and .lit4 sections should be merged.  */
1895   if (output_bfd != NULL)
1896     relocatable = TRUE;
1897   else
1898     {
1899       relocatable = FALSE;
1900       output_bfd = symbol->section->output_section->owner;
1901     }
1902 
1903   ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
1904 			   &gp);
1905   if (ret != bfd_reloc_ok)
1906     return ret;
1907 
1908   return _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
1909 					input_section, relocatable,
1910 					data, gp);
1911 }
1912 
1913 /* Do a R_MIPS_GPREL32 relocation.  This is a 32 bit value which must
1914    become the offset from the gp register.  */
1915 
1916 static bfd_reloc_status_type
1917 mips_elf_gprel32_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
1918 			void *data, asection *input_section, bfd *output_bfd,
1919 			char **error_message)
1920 {
1921   bfd_boolean relocatable;
1922   bfd_reloc_status_type ret;
1923   bfd_vma gp;
1924 
1925   /* R_MIPS_GPREL32 relocations are defined for local symbols only.  */
1926   if (output_bfd != NULL
1927       && (symbol->flags & BSF_SECTION_SYM) == 0
1928       && (symbol->flags & BSF_LOCAL) != 0)
1929     {
1930       *error_message = (char *)
1931 	_("32bits gp relative relocation occurs for an external symbol");
1932       return bfd_reloc_outofrange;
1933     }
1934 
1935   if (output_bfd != NULL)
1936     {
1937       relocatable = TRUE;
1938       gp = _bfd_get_gp_value (output_bfd);
1939     }
1940   else
1941     {
1942       relocatable = FALSE;
1943       output_bfd = symbol->section->output_section->owner;
1944 
1945       ret = mips_elf_final_gp (output_bfd, symbol, relocatable,
1946 			       error_message, &gp);
1947       if (ret != bfd_reloc_ok)
1948 	return ret;
1949     }
1950 
1951   return gprel32_with_gp (abfd, symbol, reloc_entry, input_section,
1952 			  relocatable, data, gp);
1953 }
1954 
1955 static bfd_reloc_status_type
1956 gprel32_with_gp (bfd *abfd, asymbol *symbol, arelent *reloc_entry,
1957 		 asection *input_section, bfd_boolean relocatable,
1958 		 void *data, bfd_vma gp)
1959 {
1960   bfd_vma relocation;
1961   unsigned long val;
1962 
1963   if (bfd_is_com_section (symbol->section))
1964     relocation = 0;
1965   else
1966     relocation = symbol->value;
1967 
1968   relocation += symbol->section->output_section->vma;
1969   relocation += symbol->section->output_offset;
1970 
1971   if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
1972     return bfd_reloc_outofrange;
1973 
1974   if (reloc_entry->howto->src_mask == 0)
1975     val = 0;
1976   else
1977     val = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
1978 
1979   /* Set val to the offset into the section or symbol.  */
1980   val += reloc_entry->addend;
1981 
1982   /* Adjust val for the final section location and GP value.  If we
1983      are producing relocatable output, we don't want to do this for
1984      an external symbol.  */
1985   if (! relocatable
1986       || (symbol->flags & BSF_SECTION_SYM) != 0)
1987     val += relocation - gp;
1988 
1989   bfd_put_32 (abfd, val, (bfd_byte *) data + reloc_entry->address);
1990 
1991   if (relocatable)
1992     reloc_entry->address += input_section->output_offset;
1993 
1994   return bfd_reloc_ok;
1995 }
1996 
1997 /* Do a R_MIPS_SHIFT6 relocation. The MSB of the shift is stored at bit 2,
1998    the rest is at bits 6-10. The bitpos already got right by the howto.  */
1999 
2000 static bfd_reloc_status_type
2001 mips_elf_shift6_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
2002 		       void *data, asection *input_section, bfd *output_bfd,
2003 		       char **error_message)
2004 {
2005   if (reloc_entry->howto->partial_inplace)
2006     {
2007       reloc_entry->addend = ((reloc_entry->addend & 0x00007c0)
2008 			     | (reloc_entry->addend & 0x00000800) >> 9);
2009     }
2010 
2011   return _bfd_mips_elf_generic_reloc (abfd, reloc_entry, symbol, data,
2012 				      input_section, output_bfd,
2013 				      error_message);
2014 }
2015 
2016 /* Handle a mips16 GP relative reloc.  */
2017 
2018 static bfd_reloc_status_type
2019 mips16_gprel_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
2020 		    void *data, asection *input_section, bfd *output_bfd,
2021 		    char **error_message)
2022 {
2023   bfd_boolean relocatable;
2024   bfd_reloc_status_type ret;
2025   bfd_byte *location;
2026   bfd_vma gp;
2027 
2028   /* If we're relocating, and this is an external symbol, we don't want
2029      to change anything.  */
2030   if (output_bfd != NULL
2031       && (symbol->flags & BSF_SECTION_SYM) == 0
2032       && (symbol->flags & BSF_LOCAL) != 0)
2033     {
2034       reloc_entry->address += input_section->output_offset;
2035       return bfd_reloc_ok;
2036     }
2037 
2038   if (output_bfd != NULL)
2039     relocatable = TRUE;
2040   else
2041     {
2042       relocatable = FALSE;
2043       output_bfd = symbol->section->output_section->owner;
2044     }
2045 
2046   ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
2047 			   &gp);
2048   if (ret != bfd_reloc_ok)
2049     return ret;
2050 
2051   location = (bfd_byte *) data + reloc_entry->address;
2052   _bfd_mips16_elf_reloc_unshuffle (abfd, reloc_entry->howto->type, FALSE,
2053 				   location);
2054   ret = _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
2055 				       input_section, relocatable,
2056 				       data, gp);
2057   _bfd_mips16_elf_reloc_shuffle (abfd, reloc_entry->howto->type, !relocatable,
2058 				 location);
2059 
2060   return ret;
2061 }
2062 
2063 /* A mapping from BFD reloc types to MIPS ELF reloc types.  */
2064 
2065 struct elf_reloc_map {
2066   bfd_reloc_code_real_type bfd_val;
2067   enum elf_mips_reloc_type elf_val;
2068 };
2069 
2070 static const struct elf_reloc_map mips_reloc_map[] =
2071 {
2072   { BFD_RELOC_NONE, R_MIPS_NONE },
2073   { BFD_RELOC_16, R_MIPS_16 },
2074   { BFD_RELOC_32, R_MIPS_32 },
2075   /* There is no BFD reloc for R_MIPS_REL32.  */
2076   { BFD_RELOC_CTOR, R_MIPS_32 },
2077   { BFD_RELOC_64, R_MIPS_64 },
2078   { BFD_RELOC_16_PCREL_S2, R_MIPS_PC16 },
2079   { BFD_RELOC_HI16_S, R_MIPS_HI16 },
2080   { BFD_RELOC_LO16, R_MIPS_LO16 },
2081   { BFD_RELOC_GPREL16, R_MIPS_GPREL16 },
2082   { BFD_RELOC_GPREL32, R_MIPS_GPREL32 },
2083   { BFD_RELOC_MIPS_JMP, R_MIPS_26 },
2084   { BFD_RELOC_MIPS_LITERAL, R_MIPS_LITERAL },
2085   { BFD_RELOC_MIPS_GOT16, R_MIPS_GOT16 },
2086   { BFD_RELOC_MIPS_CALL16, R_MIPS_CALL16 },
2087   { BFD_RELOC_MIPS_SHIFT5, R_MIPS_SHIFT5 },
2088   { BFD_RELOC_MIPS_SHIFT6, R_MIPS_SHIFT6 },
2089   { BFD_RELOC_MIPS_GOT_DISP, R_MIPS_GOT_DISP },
2090   { BFD_RELOC_MIPS_GOT_PAGE, R_MIPS_GOT_PAGE },
2091   { BFD_RELOC_MIPS_GOT_OFST, R_MIPS_GOT_OFST },
2092   { BFD_RELOC_MIPS_GOT_HI16, R_MIPS_GOT_HI16 },
2093   { BFD_RELOC_MIPS_GOT_LO16, R_MIPS_GOT_LO16 },
2094   { BFD_RELOC_MIPS_SUB, R_MIPS_SUB },
2095   { BFD_RELOC_MIPS_INSERT_A, R_MIPS_INSERT_A },
2096   { BFD_RELOC_MIPS_INSERT_B, R_MIPS_INSERT_B },
2097   { BFD_RELOC_MIPS_DELETE, R_MIPS_DELETE },
2098   { BFD_RELOC_MIPS_HIGHEST, R_MIPS_HIGHEST },
2099   { BFD_RELOC_MIPS_HIGHER, R_MIPS_HIGHER },
2100   { BFD_RELOC_MIPS_CALL_HI16, R_MIPS_CALL_HI16 },
2101   { BFD_RELOC_MIPS_CALL_LO16, R_MIPS_CALL_LO16 },
2102   { BFD_RELOC_MIPS_SCN_DISP, R_MIPS_SCN_DISP },
2103   { BFD_RELOC_MIPS_REL16, R_MIPS_REL16 },
2104   /* Use of R_MIPS_ADD_IMMEDIATE and R_MIPS_PJUMP is deprecated.  */
2105   { BFD_RELOC_MIPS_RELGOT, R_MIPS_RELGOT },
2106   { BFD_RELOC_MIPS_JALR, R_MIPS_JALR },
2107   { BFD_RELOC_MIPS_TLS_DTPMOD32, R_MIPS_TLS_DTPMOD32 },
2108   { BFD_RELOC_MIPS_TLS_DTPREL32, R_MIPS_TLS_DTPREL32 },
2109   { BFD_RELOC_MIPS_TLS_DTPMOD64, R_MIPS_TLS_DTPMOD64 },
2110   { BFD_RELOC_MIPS_TLS_DTPREL64, R_MIPS_TLS_DTPREL64 },
2111   { BFD_RELOC_MIPS_TLS_GD, R_MIPS_TLS_GD },
2112   { BFD_RELOC_MIPS_TLS_LDM, R_MIPS_TLS_LDM },
2113   { BFD_RELOC_MIPS_TLS_DTPREL_HI16, R_MIPS_TLS_DTPREL_HI16 },
2114   { BFD_RELOC_MIPS_TLS_DTPREL_LO16, R_MIPS_TLS_DTPREL_LO16 },
2115   { BFD_RELOC_MIPS_TLS_GOTTPREL, R_MIPS_TLS_GOTTPREL },
2116   { BFD_RELOC_MIPS_TLS_TPREL32, R_MIPS_TLS_TPREL32 },
2117   { BFD_RELOC_MIPS_TLS_TPREL64, R_MIPS_TLS_TPREL64 },
2118   { BFD_RELOC_MIPS_TLS_TPREL_HI16, R_MIPS_TLS_TPREL_HI16 },
2119   { BFD_RELOC_MIPS_TLS_TPREL_LO16, R_MIPS_TLS_TPREL_LO16 }
2120 };
2121 
2122 static const struct elf_reloc_map mips16_reloc_map[] =
2123 {
2124   { BFD_RELOC_MIPS16_JMP, R_MIPS16_26 - R_MIPS16_min },
2125   { BFD_RELOC_MIPS16_GPREL, R_MIPS16_GPREL - R_MIPS16_min },
2126   { BFD_RELOC_MIPS16_GOT16, R_MIPS16_GOT16 - R_MIPS16_min },
2127   { BFD_RELOC_MIPS16_CALL16, R_MIPS16_CALL16 - R_MIPS16_min },
2128   { BFD_RELOC_MIPS16_HI16_S, R_MIPS16_HI16 - R_MIPS16_min },
2129   { BFD_RELOC_MIPS16_LO16, R_MIPS16_LO16 - R_MIPS16_min },
2130 };
2131 
2132 /* Given a BFD reloc type, return a howto structure.  */
2133 
2134 static reloc_howto_type *
2135 bfd_elf32_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
2136 				 bfd_reloc_code_real_type code)
2137 {
2138   unsigned int i;
2139   /* FIXME: We default to RELA here instead of choosing the right
2140      relocation variant.  */
2141   reloc_howto_type *howto_table = elf_mips_howto_table_rela;
2142   reloc_howto_type *howto16_table = elf_mips16_howto_table_rela;
2143 
2144   for (i = 0; i < sizeof (mips_reloc_map) / sizeof (struct elf_reloc_map);
2145        i++)
2146     {
2147       if (mips_reloc_map[i].bfd_val == code)
2148 	return &howto_table[(int) mips_reloc_map[i].elf_val];
2149     }
2150 
2151   for (i = 0; i < sizeof (mips16_reloc_map) / sizeof (struct elf_reloc_map);
2152        i++)
2153     {
2154       if (mips16_reloc_map[i].bfd_val == code)
2155 	return &howto16_table[(int) mips16_reloc_map[i].elf_val];
2156     }
2157 
2158   switch (code)
2159     {
2160     case BFD_RELOC_VTABLE_INHERIT:
2161       return &elf_mips_gnu_vtinherit_howto;
2162     case BFD_RELOC_VTABLE_ENTRY:
2163       return &elf_mips_gnu_vtentry_howto;
2164     case BFD_RELOC_MIPS_COPY:
2165       return &elf_mips_copy_howto;
2166     case BFD_RELOC_MIPS_JUMP_SLOT:
2167       return &elf_mips_jump_slot_howto;
2168     default:
2169       bfd_set_error (bfd_error_bad_value);
2170       return NULL;
2171     }
2172 }
2173 
2174 static reloc_howto_type *
2175 bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
2176 				 const char *r_name)
2177 {
2178   unsigned int i;
2179 
2180   for (i = 0;
2181        i < (sizeof (elf_mips_howto_table_rela)
2182 	    / sizeof (elf_mips_howto_table_rela[0]));
2183        i++)
2184     if (elf_mips_howto_table_rela[i].name != NULL
2185 	&& strcasecmp (elf_mips_howto_table_rela[i].name, r_name) == 0)
2186       return &elf_mips_howto_table_rela[i];
2187 
2188   for (i = 0;
2189        i < (sizeof (elf_mips16_howto_table_rela)
2190 	    / sizeof (elf_mips16_howto_table_rela[0]));
2191        i++)
2192     if (elf_mips16_howto_table_rela[i].name != NULL
2193 	&& strcasecmp (elf_mips16_howto_table_rela[i].name, r_name) == 0)
2194       return &elf_mips16_howto_table_rela[i];
2195 
2196   if (strcasecmp (elf_mips_gnu_vtinherit_howto.name, r_name) == 0)
2197     return &elf_mips_gnu_vtinherit_howto;
2198   if (strcasecmp (elf_mips_gnu_vtentry_howto.name, r_name) == 0)
2199     return &elf_mips_gnu_vtentry_howto;
2200   if (strcasecmp (elf_mips_gnu_rel16_s2.name, r_name) == 0)
2201     return &elf_mips_gnu_rel16_s2;
2202   if (strcasecmp (elf_mips_gnu_rela16_s2.name, r_name) == 0)
2203     return &elf_mips_gnu_rela16_s2;
2204   if (strcasecmp (elf_mips_copy_howto.name, r_name) == 0)
2205     return &elf_mips_copy_howto;
2206   if (strcasecmp (elf_mips_jump_slot_howto.name, r_name) == 0)
2207     return &elf_mips_jump_slot_howto;
2208 
2209   return NULL;
2210 }
2211 
2212 /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure.  */
2213 
2214 static reloc_howto_type *
2215 mips_elf_n32_rtype_to_howto (unsigned int r_type, bfd_boolean rela_p)
2216 {
2217   switch (r_type)
2218     {
2219     case R_MIPS_GNU_VTINHERIT:
2220       return &elf_mips_gnu_vtinherit_howto;
2221     case R_MIPS_GNU_VTENTRY:
2222       return &elf_mips_gnu_vtentry_howto;
2223     case R_MIPS_GNU_REL16_S2:
2224       if (rela_p)
2225 	return &elf_mips_gnu_rela16_s2;
2226       else
2227 	return &elf_mips_gnu_rel16_s2;
2228     case R_MIPS_COPY:
2229       return &elf_mips_copy_howto;
2230     case R_MIPS_JUMP_SLOT:
2231       return &elf_mips_jump_slot_howto;
2232     default:
2233       if (r_type >= R_MIPS16_min && r_type < R_MIPS16_max)
2234 	{
2235 	  if (rela_p)
2236 	    return &elf_mips16_howto_table_rela[r_type - R_MIPS16_min];
2237 	  else
2238 	    return &elf_mips16_howto_table_rel[r_type - R_MIPS16_min];
2239 	}
2240       BFD_ASSERT (r_type < (unsigned int) R_MIPS_max);
2241       if (rela_p)
2242 	return &elf_mips_howto_table_rela[r_type];
2243       else
2244 	return &elf_mips_howto_table_rel[r_type];
2245       break;
2246     }
2247 }
2248 
2249 /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure.  */
2250 
2251 static void
2252 mips_info_to_howto_rel (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)
2253 {
2254   unsigned int r_type;
2255 
2256   r_type = ELF32_R_TYPE (dst->r_info);
2257   cache_ptr->howto = mips_elf_n32_rtype_to_howto (r_type, FALSE);
2258 
2259   /* The addend for a GPREL16 or LITERAL relocation comes from the GP
2260      value for the object file.  We get the addend now, rather than
2261      when we do the relocation, because the symbol manipulations done
2262      by the linker may cause us to lose track of the input BFD.  */
2263   if (((*cache_ptr->sym_ptr_ptr)->flags & BSF_SECTION_SYM) != 0
2264       && (gprel16_reloc_p (r_type) || r_type == (unsigned int) R_MIPS_LITERAL))
2265     cache_ptr->addend = elf_gp (abfd);
2266 }
2267 
2268 /* Given a MIPS Elf_Internal_Rela, fill in an arelent structure.  */
2269 
2270 static void
2271 mips_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED,
2272 			 arelent *cache_ptr, Elf_Internal_Rela *dst)
2273 {
2274   unsigned int r_type;
2275 
2276   r_type = ELF32_R_TYPE (dst->r_info);
2277   cache_ptr->howto = mips_elf_n32_rtype_to_howto (r_type, TRUE);
2278   cache_ptr->addend = dst->r_addend;
2279 }
2280 
2281 /* Determine whether a symbol is global for the purposes of splitting
2282    the symbol table into global symbols and local symbols.  At least
2283    on Irix 5, this split must be between section symbols and all other
2284    symbols.  On most ELF targets the split is between static symbols
2285    and externally visible symbols.  */
2286 
2287 static bfd_boolean
2288 mips_elf_sym_is_global (bfd *abfd ATTRIBUTE_UNUSED, asymbol *sym)
2289 {
2290   if (SGI_COMPAT (abfd))
2291     return (sym->flags & BSF_SECTION_SYM) == 0;
2292   else
2293     return ((sym->flags & (BSF_GLOBAL | BSF_WEAK | BSF_GNU_UNIQUE)) != 0
2294 	    || bfd_is_und_section (bfd_get_section (sym))
2295 	    || bfd_is_com_section (bfd_get_section (sym)));
2296 }
2297 
2298 /* Set the right machine number for a MIPS ELF file.  */
2299 
2300 static bfd_boolean
2301 mips_elf_n32_object_p (bfd *abfd)
2302 {
2303   unsigned long mach;
2304 
2305   /* Irix 5 and 6 are broken.  Object file symbol tables are not always
2306      sorted correctly such that local symbols precede global symbols,
2307      and the sh_info field in the symbol table is not always right.  */
2308   if (SGI_COMPAT (abfd))
2309     elf_bad_symtab (abfd) = TRUE;
2310 
2311   mach = _bfd_elf_mips_mach (elf_elfheader (abfd)->e_flags);
2312   bfd_default_set_arch_mach (abfd, bfd_arch_mips, mach);
2313 
2314   if (! ABI_N32_P(abfd))
2315     return FALSE;
2316 
2317   return TRUE;
2318 }
2319 
2320 /* Support for core dump NOTE sections.  */
2321 static bfd_boolean
2322 elf32_mips_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
2323 {
2324   int offset;
2325   unsigned int size;
2326 
2327   switch (note->descsz)
2328     {
2329       default:
2330 	return FALSE;
2331 
2332       case 440:		/* Linux/MIPS N32 */
2333 	/* pr_cursig */
2334 	elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
2335 
2336 	/* pr_pid */
2337 	elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 24);
2338 
2339 	/* pr_reg */
2340 	offset = 72;
2341 	size = 360;
2342 
2343 	break;
2344     }
2345 
2346   /* Make a ".reg/999" section.  */
2347   return _bfd_elfcore_make_pseudosection (abfd, ".reg", size,
2348 					  note->descpos + offset);
2349 }
2350 
2351 static bfd_boolean
2352 elf32_mips_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
2353 {
2354   switch (note->descsz)
2355     {
2356       default:
2357 	return FALSE;
2358 
2359       case 128:		/* Linux/MIPS elf_prpsinfo */
2360 	elf_tdata (abfd)->core_program
2361 	 = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
2362 	elf_tdata (abfd)->core_command
2363 	 = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80);
2364     }
2365 
2366   /* Note that for some reason, a spurious space is tacked
2367      onto the end of the args in some (at least one anyway)
2368      implementations, so strip it off if it exists.  */
2369 
2370   {
2371     char *command = elf_tdata (abfd)->core_command;
2372     int n = strlen (command);
2373 
2374     if (0 < n && command[n - 1] == ' ')
2375       command[n - 1] = '\0';
2376   }
2377 
2378   return TRUE;
2379 }
2380 
2381 /* MIPS ELF local labels start with "$L".  */
2382 static bfd_boolean
2383 mips_elf_n32_is_local_label_name (bfd *abfd, const char *name)
2384 {
2385   if (name[0] == '$' && name[1] == 'L')
2386     return TRUE;
2387 
2388   /* We accept the generic ELF local label syntax as well.  */
2389   return _bfd_elf_is_local_label_name (abfd, name);
2390 }
2391 
2392 /* Depending on the target vector we generate some version of Irix
2393    executables or "normal" MIPS ELF ABI executables.  */
2394 static irix_compat_t
2395 elf_n32_mips_irix_compat (bfd *abfd)
2396 {
2397   if ((abfd->xvec == &bfd_elf32_nbigmips_vec)
2398       || (abfd->xvec == &bfd_elf32_nlittlemips_vec))
2399     return ict_irix6;
2400   else
2401     return ict_none;
2402 }
2403 
2404 /* ECOFF swapping routines.  These are used when dealing with the
2405    .mdebug section, which is in the ECOFF debugging format.  */
2406 static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
2407   /* Symbol table magic number.  */
2408   magicSym,
2409   /* Alignment of debugging information.  E.g., 4.  */
2410   4,
2411   /* Sizes of external symbolic information.  */
2412   sizeof (struct hdr_ext),
2413   sizeof (struct dnr_ext),
2414   sizeof (struct pdr_ext),
2415   sizeof (struct sym_ext),
2416   sizeof (struct opt_ext),
2417   sizeof (struct fdr_ext),
2418   sizeof (struct rfd_ext),
2419   sizeof (struct ext_ext),
2420   /* Functions to swap in external symbolic data.  */
2421   ecoff_swap_hdr_in,
2422   ecoff_swap_dnr_in,
2423   ecoff_swap_pdr_in,
2424   ecoff_swap_sym_in,
2425   ecoff_swap_opt_in,
2426   ecoff_swap_fdr_in,
2427   ecoff_swap_rfd_in,
2428   ecoff_swap_ext_in,
2429   _bfd_ecoff_swap_tir_in,
2430   _bfd_ecoff_swap_rndx_in,
2431   /* Functions to swap out external symbolic data.  */
2432   ecoff_swap_hdr_out,
2433   ecoff_swap_dnr_out,
2434   ecoff_swap_pdr_out,
2435   ecoff_swap_sym_out,
2436   ecoff_swap_opt_out,
2437   ecoff_swap_fdr_out,
2438   ecoff_swap_rfd_out,
2439   ecoff_swap_ext_out,
2440   _bfd_ecoff_swap_tir_out,
2441   _bfd_ecoff_swap_rndx_out,
2442   /* Function to read in symbolic data.  */
2443   _bfd_mips_elf_read_ecoff_info
2444 };
2445 
2446 #define ELF_ARCH			bfd_arch_mips
2447 #define ELF_TARGET_ID			MIPS_ELF_DATA
2448 #define ELF_MACHINE_CODE		EM_MIPS
2449 
2450 #define elf_backend_collect		TRUE
2451 #define elf_backend_type_change_ok	TRUE
2452 #define elf_backend_can_gc_sections	TRUE
2453 #define elf_info_to_howto		mips_info_to_howto_rela
2454 #define elf_info_to_howto_rel		mips_info_to_howto_rel
2455 #define elf_backend_sym_is_global	mips_elf_sym_is_global
2456 #define elf_backend_object_p		mips_elf_n32_object_p
2457 #define elf_backend_symbol_processing	_bfd_mips_elf_symbol_processing
2458 #define elf_backend_section_processing	_bfd_mips_elf_section_processing
2459 #define elf_backend_section_from_shdr	_bfd_mips_elf_section_from_shdr
2460 #define elf_backend_fake_sections	_bfd_mips_elf_fake_sections
2461 #define elf_backend_section_from_bfd_section \
2462 					_bfd_mips_elf_section_from_bfd_section
2463 #define elf_backend_add_symbol_hook	_bfd_mips_elf_add_symbol_hook
2464 #define elf_backend_link_output_symbol_hook \
2465 					_bfd_mips_elf_link_output_symbol_hook
2466 #define elf_backend_create_dynamic_sections \
2467 					_bfd_mips_elf_create_dynamic_sections
2468 #define elf_backend_check_relocs	_bfd_mips_elf_check_relocs
2469 #define elf_backend_merge_symbol_attribute \
2470 					_bfd_mips_elf_merge_symbol_attribute
2471 #define elf_backend_get_target_dtag	_bfd_mips_elf_get_target_dtag
2472 #define elf_backend_adjust_dynamic_symbol \
2473 					_bfd_mips_elf_adjust_dynamic_symbol
2474 #define elf_backend_always_size_sections \
2475 					_bfd_mips_elf_always_size_sections
2476 #define elf_backend_size_dynamic_sections \
2477 					_bfd_mips_elf_size_dynamic_sections
2478 #define elf_backend_init_index_section	_bfd_elf_init_1_index_section
2479 #define elf_backend_relocate_section	_bfd_mips_elf_relocate_section
2480 #define elf_backend_finish_dynamic_symbol \
2481 					_bfd_mips_elf_finish_dynamic_symbol
2482 #define elf_backend_finish_dynamic_sections \
2483 					_bfd_mips_elf_finish_dynamic_sections
2484 #define elf_backend_final_write_processing \
2485 					_bfd_mips_elf_final_write_processing
2486 #define elf_backend_additional_program_headers \
2487 					_bfd_mips_elf_additional_program_headers
2488 #define elf_backend_modify_segment_map	_bfd_mips_elf_modify_segment_map
2489 #define elf_backend_gc_mark_hook	_bfd_mips_elf_gc_mark_hook
2490 #define elf_backend_gc_sweep_hook	_bfd_mips_elf_gc_sweep_hook
2491 #define elf_backend_copy_indirect_symbol \
2492 					_bfd_mips_elf_copy_indirect_symbol
2493 #define elf_backend_grok_prstatus	elf32_mips_grok_prstatus
2494 #define elf_backend_grok_psinfo		elf32_mips_grok_psinfo
2495 #define elf_backend_ecoff_debug_swap	&mips_elf32_ecoff_debug_swap
2496 
2497 #define elf_backend_got_header_size	(4 * MIPS_RESERVED_GOTNO)
2498 
2499 /* MIPS n32 ELF can use a mixture of REL and RELA, but some Relocations
2500    work better/work only in RELA, so we default to this.  */
2501 #define elf_backend_may_use_rel_p	1
2502 #define elf_backend_may_use_rela_p	1
2503 #define elf_backend_default_use_rela_p	1
2504 #define elf_backend_rela_plts_and_copies_p 0
2505 #define elf_backend_sign_extend_vma	TRUE
2506 #define elf_backend_plt_readonly	1
2507 #define elf_backend_plt_sym_val		_bfd_mips_elf_plt_sym_val
2508 
2509 #define elf_backend_discard_info	_bfd_mips_elf_discard_info
2510 #define elf_backend_ignore_discarded_relocs \
2511 					_bfd_mips_elf_ignore_discarded_relocs
2512 #define elf_backend_write_section	_bfd_mips_elf_write_section
2513 #define elf_backend_mips_irix_compat	elf_n32_mips_irix_compat
2514 #define elf_backend_mips_rtype_to_howto	mips_elf_n32_rtype_to_howto
2515 #define bfd_elf32_bfd_is_local_label_name \
2516 				mips_elf_n32_is_local_label_name
2517 #define bfd_elf32_find_nearest_line	_bfd_mips_elf_find_nearest_line
2518 #define bfd_elf32_find_inliner_info	_bfd_mips_elf_find_inliner_info
2519 #define bfd_elf32_new_section_hook	_bfd_mips_elf_new_section_hook
2520 #define bfd_elf32_set_section_contents	_bfd_mips_elf_set_section_contents
2521 #define bfd_elf32_bfd_get_relocated_section_contents \
2522 				_bfd_elf_mips_get_relocated_section_contents
2523 #define bfd_elf32_bfd_link_hash_table_create \
2524 					_bfd_mips_elf_link_hash_table_create
2525 #define bfd_elf32_bfd_final_link	_bfd_mips_elf_final_link
2526 #define bfd_elf32_bfd_merge_private_bfd_data \
2527 					_bfd_mips_elf_merge_private_bfd_data
2528 #define bfd_elf32_bfd_set_private_flags	_bfd_mips_elf_set_private_flags
2529 #define bfd_elf32_bfd_print_private_bfd_data \
2530 					_bfd_mips_elf_print_private_bfd_data
2531 #define bfd_elf32_bfd_relax_section     _bfd_mips_relax_section
2532 
2533 /* Support for SGI-ish mips targets using n32 ABI.  */
2534 
2535 #define TARGET_LITTLE_SYM               bfd_elf32_nlittlemips_vec
2536 #define TARGET_LITTLE_NAME              "elf32-nlittlemips"
2537 #define TARGET_BIG_SYM                  bfd_elf32_nbigmips_vec
2538 #define TARGET_BIG_NAME                 "elf32-nbigmips"
2539 
2540 #define ELF_MAXPAGESIZE			0x10000
2541 #define ELF_COMMONPAGESIZE		0x1000
2542 
2543 #include "elf32-target.h"
2544 
2545 /* Support for traditional mips targets using n32 ABI.  */
2546 #undef TARGET_LITTLE_SYM
2547 #undef TARGET_LITTLE_NAME
2548 #undef TARGET_BIG_SYM
2549 #undef TARGET_BIG_NAME
2550 
2551 #undef ELF_MAXPAGESIZE
2552 #undef ELF_COMMONPAGESIZE
2553 
2554 #define TARGET_LITTLE_SYM               bfd_elf32_ntradlittlemips_vec
2555 #define TARGET_LITTLE_NAME              "elf32-ntradlittlemips"
2556 #define TARGET_BIG_SYM                  bfd_elf32_ntradbigmips_vec
2557 #define TARGET_BIG_NAME                 "elf32-ntradbigmips"
2558 
2559 #define ELF_MAXPAGESIZE			0x10000
2560 #define ELF_COMMONPAGESIZE		0x1000
2561 #define elf32_bed			elf32_tradbed
2562 
2563 /* Include the target file again for this target.  */
2564 #include "elf32-target.h"
2565