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