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