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