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