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