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