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