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