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