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