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