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