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