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