1/* PowerPC64-specific support for 64-bit ELF. 2 Copyright 1999, 2000, 2001, 2002, 2003, 2004 3 Free Software Foundation, Inc. 4 Written by Linus Nordberg, Swox AB <info@swox.com>, 5 based on elf32-ppc.c by Ian Lance Taylor. 6 Largely rewritten by Alan Modra <amodra@bigpond.net.au> 7 8 This file is part of BFD, the Binary File Descriptor library. 9 10 This program is free software; you can redistribute it and/or modify 11 it under the terms of the GNU General Public License as published by 12 the Free Software Foundation; either version 2 of the License, or 13 (at your option) any later version. 14 15 This program is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 GNU General Public License for more details. 19 20 You should have received a copy of the GNU General Public License along 21 with this program; if not, write to the Free Software Foundation, Inc., 22 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 23 24/* The 64-bit PowerPC ELF ABI may be found at 25 http://www.linuxbase.org/spec/ELF/ppc64/PPC-elf64abi.txt, and 26 http://www.linuxbase.org/spec/ELF/ppc64/spec/book1.html */ 27 28#include "bfd.h" 29#include "sysdep.h" 30#include "bfdlink.h" 31#include "libbfd.h" 32#include "elf-bfd.h" 33#include "elf/ppc64.h" 34#include "elf64-ppc.h" 35 36static bfd_reloc_status_type ppc64_elf_ha_reloc 37 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); 38static bfd_reloc_status_type ppc64_elf_brtaken_reloc 39 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); 40static bfd_reloc_status_type ppc64_elf_sectoff_reloc 41 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); 42static bfd_reloc_status_type ppc64_elf_sectoff_ha_reloc 43 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); 44static bfd_reloc_status_type ppc64_elf_toc_reloc 45 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); 46static bfd_reloc_status_type ppc64_elf_toc_ha_reloc 47 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); 48static bfd_reloc_status_type ppc64_elf_toc64_reloc 49 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); 50static bfd_reloc_status_type ppc64_elf_unhandled_reloc 51 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); 52 53 54#define TARGET_LITTLE_SYM bfd_elf64_powerpcle_vec 55#define TARGET_LITTLE_NAME "elf64-powerpcle" 56#define TARGET_BIG_SYM bfd_elf64_powerpc_vec 57#define TARGET_BIG_NAME "elf64-powerpc" 58#define ELF_ARCH bfd_arch_powerpc 59#define ELF_MACHINE_CODE EM_PPC64 60#define ELF_MAXPAGESIZE 0x10000 61#define elf_info_to_howto ppc64_elf_info_to_howto 62 63#define elf_backend_want_got_sym 0 64#define elf_backend_want_plt_sym 0 65#define elf_backend_plt_alignment 3 66#define elf_backend_plt_not_loaded 1 67#define elf_backend_got_symbol_offset 0 68#define elf_backend_got_header_size 8 69#define elf_backend_can_gc_sections 1 70#define elf_backend_can_refcount 1 71#define elf_backend_rela_normal 1 72 73#define bfd_elf64_mkobject ppc64_elf_mkobject 74#define bfd_elf64_bfd_reloc_type_lookup ppc64_elf_reloc_type_lookup 75#define bfd_elf64_bfd_merge_private_bfd_data ppc64_elf_merge_private_bfd_data 76#define bfd_elf64_new_section_hook ppc64_elf_new_section_hook 77#define bfd_elf64_bfd_link_hash_table_create ppc64_elf_link_hash_table_create 78#define bfd_elf64_bfd_link_hash_table_free ppc64_elf_link_hash_table_free 79 80#define elf_backend_object_p ppc64_elf_object_p 81#define elf_backend_grok_prstatus ppc64_elf_grok_prstatus 82#define elf_backend_grok_psinfo ppc64_elf_grok_psinfo 83#define elf_backend_create_dynamic_sections ppc64_elf_create_dynamic_sections 84#define elf_backend_copy_indirect_symbol ppc64_elf_copy_indirect_symbol 85#define elf_backend_add_symbol_hook ppc64_elf_add_symbol_hook 86#define elf_backend_check_relocs ppc64_elf_check_relocs 87#define elf_backend_gc_mark_hook ppc64_elf_gc_mark_hook 88#define elf_backend_gc_sweep_hook ppc64_elf_gc_sweep_hook 89#define elf_backend_adjust_dynamic_symbol ppc64_elf_adjust_dynamic_symbol 90#define elf_backend_hide_symbol ppc64_elf_hide_symbol 91#define elf_backend_always_size_sections ppc64_elf_func_desc_adjust 92#define elf_backend_size_dynamic_sections ppc64_elf_size_dynamic_sections 93#define elf_backend_relocate_section ppc64_elf_relocate_section 94#define elf_backend_finish_dynamic_symbol ppc64_elf_finish_dynamic_symbol 95#define elf_backend_reloc_type_class ppc64_elf_reloc_type_class 96#define elf_backend_finish_dynamic_sections ppc64_elf_finish_dynamic_sections 97#define elf_backend_link_output_symbol_hook ppc64_elf_output_symbol_hook 98#define elf_backend_special_sections ppc64_elf_special_sections 99 100/* The name of the dynamic interpreter. This is put in the .interp 101 section. */ 102#define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1" 103 104/* The size in bytes of an entry in the procedure linkage table. */ 105#define PLT_ENTRY_SIZE 24 106 107/* The initial size of the plt reserved for the dynamic linker. */ 108#define PLT_INITIAL_ENTRY_SIZE PLT_ENTRY_SIZE 109 110/* TOC base pointers offset from start of TOC. */ 111#define TOC_BASE_OFF 0x8000 112 113/* Offset of tp and dtp pointers from start of TLS block. */ 114#define TP_OFFSET 0x7000 115#define DTP_OFFSET 0x8000 116 117/* .plt call stub instructions. The normal stub is like this, but 118 sometimes the .plt entry crosses a 64k boundary and we need to 119 insert an addis to adjust r12. */ 120#define PLT_CALL_STUB_SIZE (7*4) 121#define ADDIS_R12_R2 0x3d820000 /* addis %r12,%r2,xxx@ha */ 122#define STD_R2_40R1 0xf8410028 /* std %r2,40(%r1) */ 123#define LD_R11_0R12 0xe96c0000 /* ld %r11,xxx+0@l(%r12) */ 124#define LD_R2_0R12 0xe84c0000 /* ld %r2,xxx+8@l(%r12) */ 125#define MTCTR_R11 0x7d6903a6 /* mtctr %r11 */ 126 /* ld %r11,xxx+16@l(%r12) */ 127#define BCTR 0x4e800420 /* bctr */ 128 129 130#define ADDIS_R2_R2 0x3c420000 /* addis %r2,%r2,off@ha */ 131#define ADDI_R2_R2 0x38420000 /* addi %r2,%r2,off@l */ 132 133#define LD_R2_40R1 0xe8410028 /* ld %r2,40(%r1) */ 134 135/* glink call stub instructions. We enter with the index in R0, and the 136 address of glink entry in CTR. From that, we can calculate PLT0. */ 137#define GLINK_CALL_STUB_SIZE (16*4) 138#define MFCTR_R12 0x7d8902a6 /* mfctr %r12 */ 139#define SLDI_R11_R0_3 0x780b1f24 /* sldi %r11,%r0,3 */ 140#define ADDIC_R2_R0_32K 0x34408000 /* addic. %r2,%r0,-32768 */ 141#define SUB_R12_R12_R11 0x7d8b6050 /* sub %r12,%r12,%r11 */ 142#define SRADI_R2_R2_63 0x7c42fe76 /* sradi %r2,%r2,63 */ 143#define SLDI_R11_R0_2 0x780b1764 /* sldi %r11,%r0,2 */ 144#define AND_R2_R2_R11 0x7c425838 /* and %r2,%r2,%r11 */ 145 /* sub %r12,%r12,%r11 */ 146#define ADD_R12_R12_R2 0x7d8c1214 /* add %r12,%r12,%r2 */ 147#define ADDIS_R12_R12 0x3d8c0000 /* addis %r12,%r12,xxx@ha */ 148 /* ld %r11,xxx@l(%r12) */ 149#define ADDI_R12_R12 0x398c0000 /* addi %r12,%r12,xxx@l */ 150 /* ld %r2,8(%r12) */ 151 /* mtctr %r11 */ 152 /* ld %r11,16(%r12) */ 153 /* bctr */ 154 155/* Pad with this. */ 156#define NOP 0x60000000 157 158/* Some other nops. */ 159#define CROR_151515 0x4def7b82 160#define CROR_313131 0x4ffffb82 161 162/* .glink entries for the first 32k functions are two instructions. */ 163#define LI_R0_0 0x38000000 /* li %r0,0 */ 164#define B_DOT 0x48000000 /* b . */ 165 166/* After that, we need two instructions to load the index, followed by 167 a branch. */ 168#define LIS_R0_0 0x3c000000 /* lis %r0,0 */ 169#define ORI_R0_R0_0 0x60000000 /* ori %r0,%r0,0 */ 170 171/* Instructions to save and restore floating point regs. */ 172#define STFD_FR0_0R1 0xd8010000 /* stfd %fr0,0(%r1) */ 173#define LFD_FR0_0R1 0xc8010000 /* lfd %fr0,0(%r1) */ 174#define BLR 0x4e800020 /* blr */ 175 176/* Since .opd is an array of descriptors and each entry will end up 177 with identical R_PPC64_RELATIVE relocs, there is really no need to 178 propagate .opd relocs; The dynamic linker should be taught to 179 relocate .opd without reloc entries. */ 180#ifndef NO_OPD_RELOCS 181#define NO_OPD_RELOCS 0 182#endif 183 184#define ONES(n) (((bfd_vma) 1 << ((n) - 1) << 1) - 1) 185 186/* Relocation HOWTO's. */ 187static reloc_howto_type *ppc64_elf_howto_table[(int) R_PPC64_max]; 188 189static reloc_howto_type ppc64_elf_howto_raw[] = { 190 /* This reloc does nothing. */ 191 HOWTO (R_PPC64_NONE, /* type */ 192 0, /* rightshift */ 193 2, /* size (0 = byte, 1 = short, 2 = long) */ 194 32, /* bitsize */ 195 FALSE, /* pc_relative */ 196 0, /* bitpos */ 197 complain_overflow_dont, /* complain_on_overflow */ 198 bfd_elf_generic_reloc, /* special_function */ 199 "R_PPC64_NONE", /* name */ 200 FALSE, /* partial_inplace */ 201 0, /* src_mask */ 202 0, /* dst_mask */ 203 FALSE), /* pcrel_offset */ 204 205 /* A standard 32 bit relocation. */ 206 HOWTO (R_PPC64_ADDR32, /* type */ 207 0, /* rightshift */ 208 2, /* size (0 = byte, 1 = short, 2 = long) */ 209 32, /* bitsize */ 210 FALSE, /* pc_relative */ 211 0, /* bitpos */ 212 complain_overflow_bitfield, /* complain_on_overflow */ 213 bfd_elf_generic_reloc, /* special_function */ 214 "R_PPC64_ADDR32", /* name */ 215 FALSE, /* partial_inplace */ 216 0, /* src_mask */ 217 0xffffffff, /* dst_mask */ 218 FALSE), /* pcrel_offset */ 219 220 /* An absolute 26 bit branch; the lower two bits must be zero. 221 FIXME: we don't check that, we just clear them. */ 222 HOWTO (R_PPC64_ADDR24, /* type */ 223 0, /* rightshift */ 224 2, /* size (0 = byte, 1 = short, 2 = long) */ 225 26, /* bitsize */ 226 FALSE, /* pc_relative */ 227 0, /* bitpos */ 228 complain_overflow_bitfield, /* complain_on_overflow */ 229 bfd_elf_generic_reloc, /* special_function */ 230 "R_PPC64_ADDR24", /* name */ 231 FALSE, /* partial_inplace */ 232 0, /* src_mask */ 233 0x03fffffc, /* dst_mask */ 234 FALSE), /* pcrel_offset */ 235 236 /* A standard 16 bit relocation. */ 237 HOWTO (R_PPC64_ADDR16, /* type */ 238 0, /* rightshift */ 239 1, /* size (0 = byte, 1 = short, 2 = long) */ 240 16, /* bitsize */ 241 FALSE, /* pc_relative */ 242 0, /* bitpos */ 243 complain_overflow_bitfield, /* complain_on_overflow */ 244 bfd_elf_generic_reloc, /* special_function */ 245 "R_PPC64_ADDR16", /* name */ 246 FALSE, /* partial_inplace */ 247 0, /* src_mask */ 248 0xffff, /* dst_mask */ 249 FALSE), /* pcrel_offset */ 250 251 /* A 16 bit relocation without overflow. */ 252 HOWTO (R_PPC64_ADDR16_LO, /* type */ 253 0, /* rightshift */ 254 1, /* size (0 = byte, 1 = short, 2 = long) */ 255 16, /* bitsize */ 256 FALSE, /* pc_relative */ 257 0, /* bitpos */ 258 complain_overflow_dont,/* complain_on_overflow */ 259 bfd_elf_generic_reloc, /* special_function */ 260 "R_PPC64_ADDR16_LO", /* name */ 261 FALSE, /* partial_inplace */ 262 0, /* src_mask */ 263 0xffff, /* dst_mask */ 264 FALSE), /* pcrel_offset */ 265 266 /* Bits 16-31 of an address. */ 267 HOWTO (R_PPC64_ADDR16_HI, /* type */ 268 16, /* rightshift */ 269 1, /* size (0 = byte, 1 = short, 2 = long) */ 270 16, /* bitsize */ 271 FALSE, /* pc_relative */ 272 0, /* bitpos */ 273 complain_overflow_dont, /* complain_on_overflow */ 274 bfd_elf_generic_reloc, /* special_function */ 275 "R_PPC64_ADDR16_HI", /* name */ 276 FALSE, /* partial_inplace */ 277 0, /* src_mask */ 278 0xffff, /* dst_mask */ 279 FALSE), /* pcrel_offset */ 280 281 /* Bits 16-31 of an address, plus 1 if the contents of the low 16 282 bits, treated as a signed number, is negative. */ 283 HOWTO (R_PPC64_ADDR16_HA, /* type */ 284 16, /* rightshift */ 285 1, /* size (0 = byte, 1 = short, 2 = long) */ 286 16, /* bitsize */ 287 FALSE, /* pc_relative */ 288 0, /* bitpos */ 289 complain_overflow_dont, /* complain_on_overflow */ 290 ppc64_elf_ha_reloc, /* special_function */ 291 "R_PPC64_ADDR16_HA", /* name */ 292 FALSE, /* partial_inplace */ 293 0, /* src_mask */ 294 0xffff, /* dst_mask */ 295 FALSE), /* pcrel_offset */ 296 297 /* An absolute 16 bit branch; the lower two bits must be zero. 298 FIXME: we don't check that, we just clear them. */ 299 HOWTO (R_PPC64_ADDR14, /* type */ 300 0, /* rightshift */ 301 2, /* size (0 = byte, 1 = short, 2 = long) */ 302 16, /* bitsize */ 303 FALSE, /* pc_relative */ 304 0, /* bitpos */ 305 complain_overflow_bitfield, /* complain_on_overflow */ 306 bfd_elf_generic_reloc, /* special_function */ 307 "R_PPC64_ADDR14", /* name */ 308 FALSE, /* partial_inplace */ 309 0, /* src_mask */ 310 0x0000fffc, /* dst_mask */ 311 FALSE), /* pcrel_offset */ 312 313 /* An absolute 16 bit branch, for which bit 10 should be set to 314 indicate that the branch is expected to be taken. The lower two 315 bits must be zero. */ 316 HOWTO (R_PPC64_ADDR14_BRTAKEN, /* type */ 317 0, /* rightshift */ 318 2, /* size (0 = byte, 1 = short, 2 = long) */ 319 16, /* bitsize */ 320 FALSE, /* pc_relative */ 321 0, /* bitpos */ 322 complain_overflow_bitfield, /* complain_on_overflow */ 323 ppc64_elf_brtaken_reloc, /* special_function */ 324 "R_PPC64_ADDR14_BRTAKEN",/* name */ 325 FALSE, /* partial_inplace */ 326 0, /* src_mask */ 327 0x0000fffc, /* dst_mask */ 328 FALSE), /* pcrel_offset */ 329 330 /* An absolute 16 bit branch, for which bit 10 should be set to 331 indicate that the branch is not expected to be taken. The lower 332 two bits must be zero. */ 333 HOWTO (R_PPC64_ADDR14_BRNTAKEN, /* type */ 334 0, /* rightshift */ 335 2, /* size (0 = byte, 1 = short, 2 = long) */ 336 16, /* bitsize */ 337 FALSE, /* pc_relative */ 338 0, /* bitpos */ 339 complain_overflow_bitfield, /* complain_on_overflow */ 340 ppc64_elf_brtaken_reloc, /* special_function */ 341 "R_PPC64_ADDR14_BRNTAKEN",/* name */ 342 FALSE, /* partial_inplace */ 343 0, /* src_mask */ 344 0x0000fffc, /* dst_mask */ 345 FALSE), /* pcrel_offset */ 346 347 /* A relative 26 bit branch; the lower two bits must be zero. */ 348 HOWTO (R_PPC64_REL24, /* type */ 349 0, /* rightshift */ 350 2, /* size (0 = byte, 1 = short, 2 = long) */ 351 26, /* bitsize */ 352 TRUE, /* pc_relative */ 353 0, /* bitpos */ 354 complain_overflow_signed, /* complain_on_overflow */ 355 bfd_elf_generic_reloc, /* special_function */ 356 "R_PPC64_REL24", /* name */ 357 FALSE, /* partial_inplace */ 358 0, /* src_mask */ 359 0x03fffffc, /* dst_mask */ 360 TRUE), /* pcrel_offset */ 361 362 /* A relative 16 bit branch; the lower two bits must be zero. */ 363 HOWTO (R_PPC64_REL14, /* type */ 364 0, /* rightshift */ 365 2, /* size (0 = byte, 1 = short, 2 = long) */ 366 16, /* bitsize */ 367 TRUE, /* pc_relative */ 368 0, /* bitpos */ 369 complain_overflow_signed, /* complain_on_overflow */ 370 bfd_elf_generic_reloc, /* special_function */ 371 "R_PPC64_REL14", /* name */ 372 FALSE, /* partial_inplace */ 373 0, /* src_mask */ 374 0x0000fffc, /* dst_mask */ 375 TRUE), /* pcrel_offset */ 376 377 /* A relative 16 bit branch. Bit 10 should be set to indicate that 378 the branch is expected to be taken. The lower two bits must be 379 zero. */ 380 HOWTO (R_PPC64_REL14_BRTAKEN, /* type */ 381 0, /* rightshift */ 382 2, /* size (0 = byte, 1 = short, 2 = long) */ 383 16, /* bitsize */ 384 TRUE, /* pc_relative */ 385 0, /* bitpos */ 386 complain_overflow_signed, /* complain_on_overflow */ 387 ppc64_elf_brtaken_reloc, /* special_function */ 388 "R_PPC64_REL14_BRTAKEN", /* name */ 389 FALSE, /* partial_inplace */ 390 0, /* src_mask */ 391 0x0000fffc, /* dst_mask */ 392 TRUE), /* pcrel_offset */ 393 394 /* A relative 16 bit branch. Bit 10 should be set to indicate that 395 the branch is not expected to be taken. The lower two bits must 396 be zero. */ 397 HOWTO (R_PPC64_REL14_BRNTAKEN, /* type */ 398 0, /* rightshift */ 399 2, /* size (0 = byte, 1 = short, 2 = long) */ 400 16, /* bitsize */ 401 TRUE, /* pc_relative */ 402 0, /* bitpos */ 403 complain_overflow_signed, /* complain_on_overflow */ 404 ppc64_elf_brtaken_reloc, /* special_function */ 405 "R_PPC64_REL14_BRNTAKEN",/* name */ 406 FALSE, /* partial_inplace */ 407 0, /* src_mask */ 408 0x0000fffc, /* dst_mask */ 409 TRUE), /* pcrel_offset */ 410 411 /* Like R_PPC64_ADDR16, but referring to the GOT table entry for the 412 symbol. */ 413 HOWTO (R_PPC64_GOT16, /* type */ 414 0, /* rightshift */ 415 1, /* size (0 = byte, 1 = short, 2 = long) */ 416 16, /* bitsize */ 417 FALSE, /* pc_relative */ 418 0, /* bitpos */ 419 complain_overflow_signed, /* complain_on_overflow */ 420 ppc64_elf_unhandled_reloc, /* special_function */ 421 "R_PPC64_GOT16", /* name */ 422 FALSE, /* partial_inplace */ 423 0, /* src_mask */ 424 0xffff, /* dst_mask */ 425 FALSE), /* pcrel_offset */ 426 427 /* Like R_PPC64_ADDR16_LO, but referring to the GOT table entry for 428 the symbol. */ 429 HOWTO (R_PPC64_GOT16_LO, /* type */ 430 0, /* rightshift */ 431 1, /* size (0 = byte, 1 = short, 2 = long) */ 432 16, /* bitsize */ 433 FALSE, /* pc_relative */ 434 0, /* bitpos */ 435 complain_overflow_dont, /* complain_on_overflow */ 436 ppc64_elf_unhandled_reloc, /* special_function */ 437 "R_PPC64_GOT16_LO", /* name */ 438 FALSE, /* partial_inplace */ 439 0, /* src_mask */ 440 0xffff, /* dst_mask */ 441 FALSE), /* pcrel_offset */ 442 443 /* Like R_PPC64_ADDR16_HI, but referring to the GOT table entry for 444 the symbol. */ 445 HOWTO (R_PPC64_GOT16_HI, /* type */ 446 16, /* rightshift */ 447 1, /* size (0 = byte, 1 = short, 2 = long) */ 448 16, /* bitsize */ 449 FALSE, /* pc_relative */ 450 0, /* bitpos */ 451 complain_overflow_dont,/* complain_on_overflow */ 452 ppc64_elf_unhandled_reloc, /* special_function */ 453 "R_PPC64_GOT16_HI", /* name */ 454 FALSE, /* partial_inplace */ 455 0, /* src_mask */ 456 0xffff, /* dst_mask */ 457 FALSE), /* pcrel_offset */ 458 459 /* Like R_PPC64_ADDR16_HA, but referring to the GOT table entry for 460 the symbol. */ 461 HOWTO (R_PPC64_GOT16_HA, /* type */ 462 16, /* rightshift */ 463 1, /* size (0 = byte, 1 = short, 2 = long) */ 464 16, /* bitsize */ 465 FALSE, /* pc_relative */ 466 0, /* bitpos */ 467 complain_overflow_dont,/* complain_on_overflow */ 468 ppc64_elf_unhandled_reloc, /* special_function */ 469 "R_PPC64_GOT16_HA", /* name */ 470 FALSE, /* partial_inplace */ 471 0, /* src_mask */ 472 0xffff, /* dst_mask */ 473 FALSE), /* pcrel_offset */ 474 475 /* This is used only by the dynamic linker. The symbol should exist 476 both in the object being run and in some shared library. The 477 dynamic linker copies the data addressed by the symbol from the 478 shared library into the object, because the object being 479 run has to have the data at some particular address. */ 480 HOWTO (R_PPC64_COPY, /* type */ 481 0, /* rightshift */ 482 0, /* this one is variable size */ 483 0, /* bitsize */ 484 FALSE, /* pc_relative */ 485 0, /* bitpos */ 486 complain_overflow_dont, /* complain_on_overflow */ 487 ppc64_elf_unhandled_reloc, /* special_function */ 488 "R_PPC64_COPY", /* name */ 489 FALSE, /* partial_inplace */ 490 0, /* src_mask */ 491 0, /* dst_mask */ 492 FALSE), /* pcrel_offset */ 493 494 /* Like R_PPC64_ADDR64, but used when setting global offset table 495 entries. */ 496 HOWTO (R_PPC64_GLOB_DAT, /* type */ 497 0, /* rightshift */ 498 4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ 499 64, /* bitsize */ 500 FALSE, /* pc_relative */ 501 0, /* bitpos */ 502 complain_overflow_dont, /* complain_on_overflow */ 503 ppc64_elf_unhandled_reloc, /* special_function */ 504 "R_PPC64_GLOB_DAT", /* name */ 505 FALSE, /* partial_inplace */ 506 0, /* src_mask */ 507 ONES (64), /* dst_mask */ 508 FALSE), /* pcrel_offset */ 509 510 /* Created by the link editor. Marks a procedure linkage table 511 entry for a symbol. */ 512 HOWTO (R_PPC64_JMP_SLOT, /* type */ 513 0, /* rightshift */ 514 0, /* size (0 = byte, 1 = short, 2 = long) */ 515 0, /* bitsize */ 516 FALSE, /* pc_relative */ 517 0, /* bitpos */ 518 complain_overflow_dont, /* complain_on_overflow */ 519 ppc64_elf_unhandled_reloc, /* special_function */ 520 "R_PPC64_JMP_SLOT", /* name */ 521 FALSE, /* partial_inplace */ 522 0, /* src_mask */ 523 0, /* dst_mask */ 524 FALSE), /* pcrel_offset */ 525 526 /* Used only by the dynamic linker. When the object is run, this 527 doubleword64 is set to the load address of the object, plus the 528 addend. */ 529 HOWTO (R_PPC64_RELATIVE, /* type */ 530 0, /* rightshift */ 531 4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ 532 64, /* bitsize */ 533 FALSE, /* pc_relative */ 534 0, /* bitpos */ 535 complain_overflow_dont, /* complain_on_overflow */ 536 bfd_elf_generic_reloc, /* special_function */ 537 "R_PPC64_RELATIVE", /* name */ 538 FALSE, /* partial_inplace */ 539 0, /* src_mask */ 540 ONES (64), /* dst_mask */ 541 FALSE), /* pcrel_offset */ 542 543 /* Like R_PPC64_ADDR32, but may be unaligned. */ 544 HOWTO (R_PPC64_UADDR32, /* 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_bitfield, /* complain_on_overflow */ 551 bfd_elf_generic_reloc, /* special_function */ 552 "R_PPC64_UADDR32", /* name */ 553 FALSE, /* partial_inplace */ 554 0, /* src_mask */ 555 0xffffffff, /* dst_mask */ 556 FALSE), /* pcrel_offset */ 557 558 /* Like R_PPC64_ADDR16, but may be unaligned. */ 559 HOWTO (R_PPC64_UADDR16, /* type */ 560 0, /* rightshift */ 561 1, /* size (0 = byte, 1 = short, 2 = long) */ 562 16, /* bitsize */ 563 FALSE, /* pc_relative */ 564 0, /* bitpos */ 565 complain_overflow_bitfield, /* complain_on_overflow */ 566 bfd_elf_generic_reloc, /* special_function */ 567 "R_PPC64_UADDR16", /* name */ 568 FALSE, /* partial_inplace */ 569 0, /* src_mask */ 570 0xffff, /* dst_mask */ 571 FALSE), /* pcrel_offset */ 572 573 /* 32-bit PC relative. */ 574 HOWTO (R_PPC64_REL32, /* type */ 575 0, /* rightshift */ 576 2, /* size (0 = byte, 1 = short, 2 = long) */ 577 32, /* bitsize */ 578 TRUE, /* pc_relative */ 579 0, /* bitpos */ 580 /* FIXME: Verify. Was complain_overflow_bitfield. */ 581 complain_overflow_signed, /* complain_on_overflow */ 582 bfd_elf_generic_reloc, /* special_function */ 583 "R_PPC64_REL32", /* name */ 584 FALSE, /* partial_inplace */ 585 0, /* src_mask */ 586 0xffffffff, /* dst_mask */ 587 TRUE), /* pcrel_offset */ 588 589 /* 32-bit relocation to the symbol's procedure linkage table. */ 590 HOWTO (R_PPC64_PLT32, /* type */ 591 0, /* rightshift */ 592 2, /* size (0 = byte, 1 = short, 2 = long) */ 593 32, /* bitsize */ 594 FALSE, /* pc_relative */ 595 0, /* bitpos */ 596 complain_overflow_bitfield, /* complain_on_overflow */ 597 ppc64_elf_unhandled_reloc, /* special_function */ 598 "R_PPC64_PLT32", /* name */ 599 FALSE, /* partial_inplace */ 600 0, /* src_mask */ 601 0xffffffff, /* dst_mask */ 602 FALSE), /* pcrel_offset */ 603 604 /* 32-bit PC relative relocation to the symbol's procedure linkage table. 605 FIXME: R_PPC64_PLTREL32 not supported. */ 606 HOWTO (R_PPC64_PLTREL32, /* type */ 607 0, /* rightshift */ 608 2, /* size (0 = byte, 1 = short, 2 = long) */ 609 32, /* bitsize */ 610 TRUE, /* pc_relative */ 611 0, /* bitpos */ 612 complain_overflow_signed, /* complain_on_overflow */ 613 bfd_elf_generic_reloc, /* special_function */ 614 "R_PPC64_PLTREL32", /* name */ 615 FALSE, /* partial_inplace */ 616 0, /* src_mask */ 617 0xffffffff, /* dst_mask */ 618 TRUE), /* pcrel_offset */ 619 620 /* Like R_PPC64_ADDR16_LO, but referring to the PLT table entry for 621 the symbol. */ 622 HOWTO (R_PPC64_PLT16_LO, /* type */ 623 0, /* rightshift */ 624 1, /* size (0 = byte, 1 = short, 2 = long) */ 625 16, /* bitsize */ 626 FALSE, /* pc_relative */ 627 0, /* bitpos */ 628 complain_overflow_dont, /* complain_on_overflow */ 629 ppc64_elf_unhandled_reloc, /* special_function */ 630 "R_PPC64_PLT16_LO", /* name */ 631 FALSE, /* partial_inplace */ 632 0, /* src_mask */ 633 0xffff, /* dst_mask */ 634 FALSE), /* pcrel_offset */ 635 636 /* Like R_PPC64_ADDR16_HI, but referring to the PLT table entry for 637 the symbol. */ 638 HOWTO (R_PPC64_PLT16_HI, /* type */ 639 16, /* rightshift */ 640 1, /* size (0 = byte, 1 = short, 2 = long) */ 641 16, /* bitsize */ 642 FALSE, /* pc_relative */ 643 0, /* bitpos */ 644 complain_overflow_dont, /* complain_on_overflow */ 645 ppc64_elf_unhandled_reloc, /* special_function */ 646 "R_PPC64_PLT16_HI", /* name */ 647 FALSE, /* partial_inplace */ 648 0, /* src_mask */ 649 0xffff, /* dst_mask */ 650 FALSE), /* pcrel_offset */ 651 652 /* Like R_PPC64_ADDR16_HA, but referring to the PLT table entry for 653 the symbol. */ 654 HOWTO (R_PPC64_PLT16_HA, /* type */ 655 16, /* rightshift */ 656 1, /* size (0 = byte, 1 = short, 2 = long) */ 657 16, /* bitsize */ 658 FALSE, /* pc_relative */ 659 0, /* bitpos */ 660 complain_overflow_dont, /* complain_on_overflow */ 661 ppc64_elf_unhandled_reloc, /* special_function */ 662 "R_PPC64_PLT16_HA", /* name */ 663 FALSE, /* partial_inplace */ 664 0, /* src_mask */ 665 0xffff, /* dst_mask */ 666 FALSE), /* pcrel_offset */ 667 668 /* 16-bit section relative relocation. */ 669 HOWTO (R_PPC64_SECTOFF, /* type */ 670 0, /* rightshift */ 671 1, /* size (0 = byte, 1 = short, 2 = long) */ 672 16, /* bitsize */ 673 FALSE, /* pc_relative */ 674 0, /* bitpos */ 675 complain_overflow_bitfield, /* complain_on_overflow */ 676 ppc64_elf_sectoff_reloc, /* special_function */ 677 "R_PPC64_SECTOFF", /* name */ 678 FALSE, /* partial_inplace */ 679 0, /* src_mask */ 680 0xffff, /* dst_mask */ 681 FALSE), /* pcrel_offset */ 682 683 /* Like R_PPC64_SECTOFF, but no overflow warning. */ 684 HOWTO (R_PPC64_SECTOFF_LO, /* type */ 685 0, /* rightshift */ 686 1, /* size (0 = byte, 1 = short, 2 = long) */ 687 16, /* bitsize */ 688 FALSE, /* pc_relative */ 689 0, /* bitpos */ 690 complain_overflow_dont, /* complain_on_overflow */ 691 ppc64_elf_sectoff_reloc, /* special_function */ 692 "R_PPC64_SECTOFF_LO", /* name */ 693 FALSE, /* partial_inplace */ 694 0, /* src_mask */ 695 0xffff, /* dst_mask */ 696 FALSE), /* pcrel_offset */ 697 698 /* 16-bit upper half section relative relocation. */ 699 HOWTO (R_PPC64_SECTOFF_HI, /* type */ 700 16, /* rightshift */ 701 1, /* size (0 = byte, 1 = short, 2 = long) */ 702 16, /* bitsize */ 703 FALSE, /* pc_relative */ 704 0, /* bitpos */ 705 complain_overflow_dont, /* complain_on_overflow */ 706 ppc64_elf_sectoff_reloc, /* special_function */ 707 "R_PPC64_SECTOFF_HI", /* name */ 708 FALSE, /* partial_inplace */ 709 0, /* src_mask */ 710 0xffff, /* dst_mask */ 711 FALSE), /* pcrel_offset */ 712 713 /* 16-bit upper half adjusted section relative relocation. */ 714 HOWTO (R_PPC64_SECTOFF_HA, /* type */ 715 16, /* rightshift */ 716 1, /* size (0 = byte, 1 = short, 2 = long) */ 717 16, /* bitsize */ 718 FALSE, /* pc_relative */ 719 0, /* bitpos */ 720 complain_overflow_dont, /* complain_on_overflow */ 721 ppc64_elf_sectoff_ha_reloc, /* special_function */ 722 "R_PPC64_SECTOFF_HA", /* name */ 723 FALSE, /* partial_inplace */ 724 0, /* src_mask */ 725 0xffff, /* dst_mask */ 726 FALSE), /* pcrel_offset */ 727 728 /* Like R_PPC64_REL24 without touching the two least significant bits. */ 729 HOWTO (R_PPC64_REL30, /* type */ 730 2, /* rightshift */ 731 2, /* size (0 = byte, 1 = short, 2 = long) */ 732 30, /* bitsize */ 733 TRUE, /* pc_relative */ 734 0, /* bitpos */ 735 complain_overflow_dont, /* complain_on_overflow */ 736 bfd_elf_generic_reloc, /* special_function */ 737 "R_PPC64_REL30", /* name */ 738 FALSE, /* partial_inplace */ 739 0, /* src_mask */ 740 0xfffffffc, /* dst_mask */ 741 TRUE), /* pcrel_offset */ 742 743 /* Relocs in the 64-bit PowerPC ELF ABI, not in the 32-bit ABI. */ 744 745 /* A standard 64-bit relocation. */ 746 HOWTO (R_PPC64_ADDR64, /* type */ 747 0, /* rightshift */ 748 4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ 749 64, /* bitsize */ 750 FALSE, /* pc_relative */ 751 0, /* bitpos */ 752 complain_overflow_dont, /* complain_on_overflow */ 753 bfd_elf_generic_reloc, /* special_function */ 754 "R_PPC64_ADDR64", /* name */ 755 FALSE, /* partial_inplace */ 756 0, /* src_mask */ 757 ONES (64), /* dst_mask */ 758 FALSE), /* pcrel_offset */ 759 760 /* The bits 32-47 of an address. */ 761 HOWTO (R_PPC64_ADDR16_HIGHER, /* type */ 762 32, /* rightshift */ 763 1, /* size (0 = byte, 1 = short, 2 = long) */ 764 16, /* bitsize */ 765 FALSE, /* pc_relative */ 766 0, /* bitpos */ 767 complain_overflow_dont, /* complain_on_overflow */ 768 bfd_elf_generic_reloc, /* special_function */ 769 "R_PPC64_ADDR16_HIGHER", /* name */ 770 FALSE, /* partial_inplace */ 771 0, /* src_mask */ 772 0xffff, /* dst_mask */ 773 FALSE), /* pcrel_offset */ 774 775 /* The bits 32-47 of an address, plus 1 if the contents of the low 776 16 bits, treated as a signed number, is negative. */ 777 HOWTO (R_PPC64_ADDR16_HIGHERA, /* type */ 778 32, /* rightshift */ 779 1, /* size (0 = byte, 1 = short, 2 = long) */ 780 16, /* bitsize */ 781 FALSE, /* pc_relative */ 782 0, /* bitpos */ 783 complain_overflow_dont, /* complain_on_overflow */ 784 ppc64_elf_ha_reloc, /* special_function */ 785 "R_PPC64_ADDR16_HIGHERA", /* name */ 786 FALSE, /* partial_inplace */ 787 0, /* src_mask */ 788 0xffff, /* dst_mask */ 789 FALSE), /* pcrel_offset */ 790 791 /* The bits 48-63 of an address. */ 792 HOWTO (R_PPC64_ADDR16_HIGHEST,/* type */ 793 48, /* rightshift */ 794 1, /* size (0 = byte, 1 = short, 2 = long) */ 795 16, /* bitsize */ 796 FALSE, /* pc_relative */ 797 0, /* bitpos */ 798 complain_overflow_dont, /* complain_on_overflow */ 799 bfd_elf_generic_reloc, /* special_function */ 800 "R_PPC64_ADDR16_HIGHEST", /* name */ 801 FALSE, /* partial_inplace */ 802 0, /* src_mask */ 803 0xffff, /* dst_mask */ 804 FALSE), /* pcrel_offset */ 805 806 /* The bits 48-63 of an address, plus 1 if the contents of the low 807 16 bits, treated as a signed number, is negative. */ 808 HOWTO (R_PPC64_ADDR16_HIGHESTA,/* type */ 809 48, /* rightshift */ 810 1, /* size (0 = byte, 1 = short, 2 = long) */ 811 16, /* bitsize */ 812 FALSE, /* pc_relative */ 813 0, /* bitpos */ 814 complain_overflow_dont, /* complain_on_overflow */ 815 ppc64_elf_ha_reloc, /* special_function */ 816 "R_PPC64_ADDR16_HIGHESTA", /* name */ 817 FALSE, /* partial_inplace */ 818 0, /* src_mask */ 819 0xffff, /* dst_mask */ 820 FALSE), /* pcrel_offset */ 821 822 /* Like ADDR64, but may be unaligned. */ 823 HOWTO (R_PPC64_UADDR64, /* type */ 824 0, /* rightshift */ 825 4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ 826 64, /* bitsize */ 827 FALSE, /* pc_relative */ 828 0, /* bitpos */ 829 complain_overflow_dont, /* complain_on_overflow */ 830 bfd_elf_generic_reloc, /* special_function */ 831 "R_PPC64_UADDR64", /* name */ 832 FALSE, /* partial_inplace */ 833 0, /* src_mask */ 834 ONES (64), /* dst_mask */ 835 FALSE), /* pcrel_offset */ 836 837 /* 64-bit relative relocation. */ 838 HOWTO (R_PPC64_REL64, /* type */ 839 0, /* rightshift */ 840 4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ 841 64, /* bitsize */ 842 TRUE, /* pc_relative */ 843 0, /* bitpos */ 844 complain_overflow_dont, /* complain_on_overflow */ 845 bfd_elf_generic_reloc, /* special_function */ 846 "R_PPC64_REL64", /* name */ 847 FALSE, /* partial_inplace */ 848 0, /* src_mask */ 849 ONES (64), /* dst_mask */ 850 TRUE), /* pcrel_offset */ 851 852 /* 64-bit relocation to the symbol's procedure linkage table. */ 853 HOWTO (R_PPC64_PLT64, /* type */ 854 0, /* rightshift */ 855 4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ 856 64, /* bitsize */ 857 FALSE, /* pc_relative */ 858 0, /* bitpos */ 859 complain_overflow_dont, /* complain_on_overflow */ 860 ppc64_elf_unhandled_reloc, /* special_function */ 861 "R_PPC64_PLT64", /* name */ 862 FALSE, /* partial_inplace */ 863 0, /* src_mask */ 864 ONES (64), /* dst_mask */ 865 FALSE), /* pcrel_offset */ 866 867 /* 64-bit PC relative relocation to the symbol's procedure linkage 868 table. */ 869 /* FIXME: R_PPC64_PLTREL64 not supported. */ 870 HOWTO (R_PPC64_PLTREL64, /* type */ 871 0, /* rightshift */ 872 4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ 873 64, /* bitsize */ 874 TRUE, /* pc_relative */ 875 0, /* bitpos */ 876 complain_overflow_dont, /* complain_on_overflow */ 877 ppc64_elf_unhandled_reloc, /* special_function */ 878 "R_PPC64_PLTREL64", /* name */ 879 FALSE, /* partial_inplace */ 880 0, /* src_mask */ 881 ONES (64), /* dst_mask */ 882 TRUE), /* pcrel_offset */ 883 884 /* 16 bit TOC-relative relocation. */ 885 886 /* R_PPC64_TOC16 47 half16* S + A - .TOC. */ 887 HOWTO (R_PPC64_TOC16, /* type */ 888 0, /* rightshift */ 889 1, /* size (0 = byte, 1 = short, 2 = long) */ 890 16, /* bitsize */ 891 FALSE, /* pc_relative */ 892 0, /* bitpos */ 893 complain_overflow_signed, /* complain_on_overflow */ 894 ppc64_elf_toc_reloc, /* special_function */ 895 "R_PPC64_TOC16", /* name */ 896 FALSE, /* partial_inplace */ 897 0, /* src_mask */ 898 0xffff, /* dst_mask */ 899 FALSE), /* pcrel_offset */ 900 901 /* 16 bit TOC-relative relocation without overflow. */ 902 903 /* R_PPC64_TOC16_LO 48 half16 #lo (S + A - .TOC.) */ 904 HOWTO (R_PPC64_TOC16_LO, /* type */ 905 0, /* rightshift */ 906 1, /* size (0 = byte, 1 = short, 2 = long) */ 907 16, /* bitsize */ 908 FALSE, /* pc_relative */ 909 0, /* bitpos */ 910 complain_overflow_dont, /* complain_on_overflow */ 911 ppc64_elf_toc_reloc, /* special_function */ 912 "R_PPC64_TOC16_LO", /* name */ 913 FALSE, /* partial_inplace */ 914 0, /* src_mask */ 915 0xffff, /* dst_mask */ 916 FALSE), /* pcrel_offset */ 917 918 /* 16 bit TOC-relative relocation, high 16 bits. */ 919 920 /* R_PPC64_TOC16_HI 49 half16 #hi (S + A - .TOC.) */ 921 HOWTO (R_PPC64_TOC16_HI, /* type */ 922 16, /* rightshift */ 923 1, /* size (0 = byte, 1 = short, 2 = long) */ 924 16, /* bitsize */ 925 FALSE, /* pc_relative */ 926 0, /* bitpos */ 927 complain_overflow_dont, /* complain_on_overflow */ 928 ppc64_elf_toc_reloc, /* special_function */ 929 "R_PPC64_TOC16_HI", /* name */ 930 FALSE, /* partial_inplace */ 931 0, /* src_mask */ 932 0xffff, /* dst_mask */ 933 FALSE), /* pcrel_offset */ 934 935 /* 16 bit TOC-relative relocation, high 16 bits, plus 1 if the 936 contents of the low 16 bits, treated as a signed number, is 937 negative. */ 938 939 /* R_PPC64_TOC16_HA 50 half16 #ha (S + A - .TOC.) */ 940 HOWTO (R_PPC64_TOC16_HA, /* type */ 941 16, /* rightshift */ 942 1, /* size (0 = byte, 1 = short, 2 = long) */ 943 16, /* bitsize */ 944 FALSE, /* pc_relative */ 945 0, /* bitpos */ 946 complain_overflow_dont, /* complain_on_overflow */ 947 ppc64_elf_toc_ha_reloc, /* special_function */ 948 "R_PPC64_TOC16_HA", /* name */ 949 FALSE, /* partial_inplace */ 950 0, /* src_mask */ 951 0xffff, /* dst_mask */ 952 FALSE), /* pcrel_offset */ 953 954 /* 64-bit relocation; insert value of TOC base (.TOC.). */ 955 956 /* R_PPC64_TOC 51 doubleword64 .TOC. */ 957 HOWTO (R_PPC64_TOC, /* type */ 958 0, /* rightshift */ 959 4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ 960 64, /* bitsize */ 961 FALSE, /* pc_relative */ 962 0, /* bitpos */ 963 complain_overflow_bitfield, /* complain_on_overflow */ 964 ppc64_elf_toc64_reloc, /* special_function */ 965 "R_PPC64_TOC", /* name */ 966 FALSE, /* partial_inplace */ 967 0, /* src_mask */ 968 ONES (64), /* dst_mask */ 969 FALSE), /* pcrel_offset */ 970 971 /* Like R_PPC64_GOT16, but also informs the link editor that the 972 value to relocate may (!) refer to a PLT entry which the link 973 editor (a) may replace with the symbol value. If the link editor 974 is unable to fully resolve the symbol, it may (b) create a PLT 975 entry and store the address to the new PLT entry in the GOT. 976 This permits lazy resolution of function symbols at run time. 977 The link editor may also skip all of this and just (c) emit a 978 R_PPC64_GLOB_DAT to tie the symbol to the GOT entry. */ 979 /* FIXME: R_PPC64_PLTGOT16 not implemented. */ 980 HOWTO (R_PPC64_PLTGOT16, /* type */ 981 0, /* rightshift */ 982 1, /* size (0 = byte, 1 = short, 2 = long) */ 983 16, /* bitsize */ 984 FALSE, /* pc_relative */ 985 0, /* bitpos */ 986 complain_overflow_signed, /* complain_on_overflow */ 987 ppc64_elf_unhandled_reloc, /* special_function */ 988 "R_PPC64_PLTGOT16", /* name */ 989 FALSE, /* partial_inplace */ 990 0, /* src_mask */ 991 0xffff, /* dst_mask */ 992 FALSE), /* pcrel_offset */ 993 994 /* Like R_PPC64_PLTGOT16, but without overflow. */ 995 /* FIXME: R_PPC64_PLTGOT16_LO not implemented. */ 996 HOWTO (R_PPC64_PLTGOT16_LO, /* type */ 997 0, /* rightshift */ 998 1, /* size (0 = byte, 1 = short, 2 = long) */ 999 16, /* bitsize */ 1000 FALSE, /* pc_relative */ 1001 0, /* bitpos */ 1002 complain_overflow_dont, /* complain_on_overflow */ 1003 ppc64_elf_unhandled_reloc, /* special_function */ 1004 "R_PPC64_PLTGOT16_LO", /* name */ 1005 FALSE, /* partial_inplace */ 1006 0, /* src_mask */ 1007 0xffff, /* dst_mask */ 1008 FALSE), /* pcrel_offset */ 1009 1010 /* Like R_PPC64_PLT_GOT16, but using bits 16-31 of the address. */ 1011 /* FIXME: R_PPC64_PLTGOT16_HI not implemented. */ 1012 HOWTO (R_PPC64_PLTGOT16_HI, /* type */ 1013 16, /* rightshift */ 1014 1, /* size (0 = byte, 1 = short, 2 = long) */ 1015 16, /* bitsize */ 1016 FALSE, /* pc_relative */ 1017 0, /* bitpos */ 1018 complain_overflow_dont, /* complain_on_overflow */ 1019 ppc64_elf_unhandled_reloc, /* special_function */ 1020 "R_PPC64_PLTGOT16_HI", /* name */ 1021 FALSE, /* partial_inplace */ 1022 0, /* src_mask */ 1023 0xffff, /* dst_mask */ 1024 FALSE), /* pcrel_offset */ 1025 1026 /* Like R_PPC64_PLT_GOT16, but using bits 16-31 of the address, plus 1027 1 if the contents of the low 16 bits, treated as a signed number, 1028 is negative. */ 1029 /* FIXME: R_PPC64_PLTGOT16_HA not implemented. */ 1030 HOWTO (R_PPC64_PLTGOT16_HA, /* type */ 1031 16, /* rightshift */ 1032 1, /* size (0 = byte, 1 = short, 2 = long) */ 1033 16, /* bitsize */ 1034 FALSE, /* pc_relative */ 1035 0, /* bitpos */ 1036 complain_overflow_dont,/* complain_on_overflow */ 1037 ppc64_elf_unhandled_reloc, /* special_function */ 1038 "R_PPC64_PLTGOT16_HA", /* name */ 1039 FALSE, /* partial_inplace */ 1040 0, /* src_mask */ 1041 0xffff, /* dst_mask */ 1042 FALSE), /* pcrel_offset */ 1043 1044 /* Like R_PPC64_ADDR16, but for instructions with a DS field. */ 1045 HOWTO (R_PPC64_ADDR16_DS, /* type */ 1046 0, /* rightshift */ 1047 1, /* size (0 = byte, 1 = short, 2 = long) */ 1048 16, /* bitsize */ 1049 FALSE, /* pc_relative */ 1050 0, /* bitpos */ 1051 complain_overflow_bitfield, /* complain_on_overflow */ 1052 bfd_elf_generic_reloc, /* special_function */ 1053 "R_PPC64_ADDR16_DS", /* name */ 1054 FALSE, /* partial_inplace */ 1055 0, /* src_mask */ 1056 0xfffc, /* dst_mask */ 1057 FALSE), /* pcrel_offset */ 1058 1059 /* Like R_PPC64_ADDR16_LO, but for instructions with a DS field. */ 1060 HOWTO (R_PPC64_ADDR16_LO_DS, /* type */ 1061 0, /* rightshift */ 1062 1, /* size (0 = byte, 1 = short, 2 = long) */ 1063 16, /* bitsize */ 1064 FALSE, /* pc_relative */ 1065 0, /* bitpos */ 1066 complain_overflow_dont,/* complain_on_overflow */ 1067 bfd_elf_generic_reloc, /* special_function */ 1068 "R_PPC64_ADDR16_LO_DS",/* name */ 1069 FALSE, /* partial_inplace */ 1070 0, /* src_mask */ 1071 0xfffc, /* dst_mask */ 1072 FALSE), /* pcrel_offset */ 1073 1074 /* Like R_PPC64_GOT16, but for instructions with a DS field. */ 1075 HOWTO (R_PPC64_GOT16_DS, /* type */ 1076 0, /* rightshift */ 1077 1, /* size (0 = byte, 1 = short, 2 = long) */ 1078 16, /* bitsize */ 1079 FALSE, /* pc_relative */ 1080 0, /* bitpos */ 1081 complain_overflow_signed, /* complain_on_overflow */ 1082 ppc64_elf_unhandled_reloc, /* special_function */ 1083 "R_PPC64_GOT16_DS", /* name */ 1084 FALSE, /* partial_inplace */ 1085 0, /* src_mask */ 1086 0xfffc, /* dst_mask */ 1087 FALSE), /* pcrel_offset */ 1088 1089 /* Like R_PPC64_GOT16_LO, but for instructions with a DS field. */ 1090 HOWTO (R_PPC64_GOT16_LO_DS, /* type */ 1091 0, /* rightshift */ 1092 1, /* size (0 = byte, 1 = short, 2 = long) */ 1093 16, /* bitsize */ 1094 FALSE, /* pc_relative */ 1095 0, /* bitpos */ 1096 complain_overflow_dont, /* complain_on_overflow */ 1097 ppc64_elf_unhandled_reloc, /* special_function */ 1098 "R_PPC64_GOT16_LO_DS", /* name */ 1099 FALSE, /* partial_inplace */ 1100 0, /* src_mask */ 1101 0xfffc, /* dst_mask */ 1102 FALSE), /* pcrel_offset */ 1103 1104 /* Like R_PPC64_PLT16_LO, but for instructions with a DS field. */ 1105 HOWTO (R_PPC64_PLT16_LO_DS, /* type */ 1106 0, /* rightshift */ 1107 1, /* size (0 = byte, 1 = short, 2 = long) */ 1108 16, /* bitsize */ 1109 FALSE, /* pc_relative */ 1110 0, /* bitpos */ 1111 complain_overflow_dont, /* complain_on_overflow */ 1112 ppc64_elf_unhandled_reloc, /* special_function */ 1113 "R_PPC64_PLT16_LO_DS", /* name */ 1114 FALSE, /* partial_inplace */ 1115 0, /* src_mask */ 1116 0xfffc, /* dst_mask */ 1117 FALSE), /* pcrel_offset */ 1118 1119 /* Like R_PPC64_SECTOFF, but for instructions with a DS field. */ 1120 HOWTO (R_PPC64_SECTOFF_DS, /* type */ 1121 0, /* rightshift */ 1122 1, /* size (0 = byte, 1 = short, 2 = long) */ 1123 16, /* bitsize */ 1124 FALSE, /* pc_relative */ 1125 0, /* bitpos */ 1126 complain_overflow_bitfield, /* complain_on_overflow */ 1127 ppc64_elf_sectoff_reloc, /* special_function */ 1128 "R_PPC64_SECTOFF_DS", /* name */ 1129 FALSE, /* partial_inplace */ 1130 0, /* src_mask */ 1131 0xfffc, /* dst_mask */ 1132 FALSE), /* pcrel_offset */ 1133 1134 /* Like R_PPC64_SECTOFF_LO, but for instructions with a DS field. */ 1135 HOWTO (R_PPC64_SECTOFF_LO_DS, /* type */ 1136 0, /* rightshift */ 1137 1, /* size (0 = byte, 1 = short, 2 = long) */ 1138 16, /* bitsize */ 1139 FALSE, /* pc_relative */ 1140 0, /* bitpos */ 1141 complain_overflow_dont, /* complain_on_overflow */ 1142 ppc64_elf_sectoff_reloc, /* special_function */ 1143 "R_PPC64_SECTOFF_LO_DS",/* name */ 1144 FALSE, /* partial_inplace */ 1145 0, /* src_mask */ 1146 0xfffc, /* dst_mask */ 1147 FALSE), /* pcrel_offset */ 1148 1149 /* Like R_PPC64_TOC16, but for instructions with a DS field. */ 1150 HOWTO (R_PPC64_TOC16_DS, /* type */ 1151 0, /* rightshift */ 1152 1, /* size (0 = byte, 1 = short, 2 = long) */ 1153 16, /* bitsize */ 1154 FALSE, /* pc_relative */ 1155 0, /* bitpos */ 1156 complain_overflow_signed, /* complain_on_overflow */ 1157 ppc64_elf_toc_reloc, /* special_function */ 1158 "R_PPC64_TOC16_DS", /* name */ 1159 FALSE, /* partial_inplace */ 1160 0, /* src_mask */ 1161 0xfffc, /* dst_mask */ 1162 FALSE), /* pcrel_offset */ 1163 1164 /* Like R_PPC64_TOC16_LO, but for instructions with a DS field. */ 1165 HOWTO (R_PPC64_TOC16_LO_DS, /* type */ 1166 0, /* rightshift */ 1167 1, /* size (0 = byte, 1 = short, 2 = long) */ 1168 16, /* bitsize */ 1169 FALSE, /* pc_relative */ 1170 0, /* bitpos */ 1171 complain_overflow_dont, /* complain_on_overflow */ 1172 ppc64_elf_toc_reloc, /* special_function */ 1173 "R_PPC64_TOC16_LO_DS", /* name */ 1174 FALSE, /* partial_inplace */ 1175 0, /* src_mask */ 1176 0xfffc, /* dst_mask */ 1177 FALSE), /* pcrel_offset */ 1178 1179 /* Like R_PPC64_PLTGOT16, but for instructions with a DS field. */ 1180 /* FIXME: R_PPC64_PLTGOT16_DS not implemented. */ 1181 HOWTO (R_PPC64_PLTGOT16_DS, /* type */ 1182 0, /* rightshift */ 1183 1, /* size (0 = byte, 1 = short, 2 = long) */ 1184 16, /* bitsize */ 1185 FALSE, /* pc_relative */ 1186 0, /* bitpos */ 1187 complain_overflow_signed, /* complain_on_overflow */ 1188 ppc64_elf_unhandled_reloc, /* special_function */ 1189 "R_PPC64_PLTGOT16_DS", /* name */ 1190 FALSE, /* partial_inplace */ 1191 0, /* src_mask */ 1192 0xfffc, /* dst_mask */ 1193 FALSE), /* pcrel_offset */ 1194 1195 /* Like R_PPC64_PLTGOT16_LO, but for instructions with a DS field. */ 1196 /* FIXME: R_PPC64_PLTGOT16_LO not implemented. */ 1197 HOWTO (R_PPC64_PLTGOT16_LO_DS,/* type */ 1198 0, /* rightshift */ 1199 1, /* size (0 = byte, 1 = short, 2 = long) */ 1200 16, /* bitsize */ 1201 FALSE, /* pc_relative */ 1202 0, /* bitpos */ 1203 complain_overflow_dont, /* complain_on_overflow */ 1204 ppc64_elf_unhandled_reloc, /* special_function */ 1205 "R_PPC64_PLTGOT16_LO_DS",/* name */ 1206 FALSE, /* partial_inplace */ 1207 0, /* src_mask */ 1208 0xfffc, /* dst_mask */ 1209 FALSE), /* pcrel_offset */ 1210 1211 /* Marker reloc for TLS. */ 1212 HOWTO (R_PPC64_TLS, 1213 0, /* rightshift */ 1214 2, /* size (0 = byte, 1 = short, 2 = long) */ 1215 32, /* bitsize */ 1216 FALSE, /* pc_relative */ 1217 0, /* bitpos */ 1218 complain_overflow_dont, /* complain_on_overflow */ 1219 bfd_elf_generic_reloc, /* special_function */ 1220 "R_PPC64_TLS", /* name */ 1221 FALSE, /* partial_inplace */ 1222 0, /* src_mask */ 1223 0, /* dst_mask */ 1224 FALSE), /* pcrel_offset */ 1225 1226 /* Computes the load module index of the load module that contains the 1227 definition of its TLS sym. */ 1228 HOWTO (R_PPC64_DTPMOD64, 1229 0, /* rightshift */ 1230 4, /* size (0 = byte, 1 = short, 2 = long) */ 1231 64, /* bitsize */ 1232 FALSE, /* pc_relative */ 1233 0, /* bitpos */ 1234 complain_overflow_dont, /* complain_on_overflow */ 1235 ppc64_elf_unhandled_reloc, /* special_function */ 1236 "R_PPC64_DTPMOD64", /* name */ 1237 FALSE, /* partial_inplace */ 1238 0, /* src_mask */ 1239 ONES (64), /* dst_mask */ 1240 FALSE), /* pcrel_offset */ 1241 1242 /* Computes a dtv-relative displacement, the difference between the value 1243 of sym+add and the base address of the thread-local storage block that 1244 contains the definition of sym, minus 0x8000. */ 1245 HOWTO (R_PPC64_DTPREL64, 1246 0, /* rightshift */ 1247 4, /* size (0 = byte, 1 = short, 2 = long) */ 1248 64, /* bitsize */ 1249 FALSE, /* pc_relative */ 1250 0, /* bitpos */ 1251 complain_overflow_dont, /* complain_on_overflow */ 1252 ppc64_elf_unhandled_reloc, /* special_function */ 1253 "R_PPC64_DTPREL64", /* name */ 1254 FALSE, /* partial_inplace */ 1255 0, /* src_mask */ 1256 ONES (64), /* dst_mask */ 1257 FALSE), /* pcrel_offset */ 1258 1259 /* A 16 bit dtprel reloc. */ 1260 HOWTO (R_PPC64_DTPREL16, 1261 0, /* rightshift */ 1262 1, /* size (0 = byte, 1 = short, 2 = long) */ 1263 16, /* bitsize */ 1264 FALSE, /* pc_relative */ 1265 0, /* bitpos */ 1266 complain_overflow_signed, /* complain_on_overflow */ 1267 ppc64_elf_unhandled_reloc, /* special_function */ 1268 "R_PPC64_DTPREL16", /* name */ 1269 FALSE, /* partial_inplace */ 1270 0, /* src_mask */ 1271 0xffff, /* dst_mask */ 1272 FALSE), /* pcrel_offset */ 1273 1274 /* Like DTPREL16, but no overflow. */ 1275 HOWTO (R_PPC64_DTPREL16_LO, 1276 0, /* rightshift */ 1277 1, /* size (0 = byte, 1 = short, 2 = long) */ 1278 16, /* bitsize */ 1279 FALSE, /* pc_relative */ 1280 0, /* bitpos */ 1281 complain_overflow_dont, /* complain_on_overflow */ 1282 ppc64_elf_unhandled_reloc, /* special_function */ 1283 "R_PPC64_DTPREL16_LO", /* name */ 1284 FALSE, /* partial_inplace */ 1285 0, /* src_mask */ 1286 0xffff, /* dst_mask */ 1287 FALSE), /* pcrel_offset */ 1288 1289 /* Like DTPREL16_LO, but next higher group of 16 bits. */ 1290 HOWTO (R_PPC64_DTPREL16_HI, 1291 16, /* rightshift */ 1292 1, /* size (0 = byte, 1 = short, 2 = long) */ 1293 16, /* bitsize */ 1294 FALSE, /* pc_relative */ 1295 0, /* bitpos */ 1296 complain_overflow_dont, /* complain_on_overflow */ 1297 ppc64_elf_unhandled_reloc, /* special_function */ 1298 "R_PPC64_DTPREL16_HI", /* name */ 1299 FALSE, /* partial_inplace */ 1300 0, /* src_mask */ 1301 0xffff, /* dst_mask */ 1302 FALSE), /* pcrel_offset */ 1303 1304 /* Like DTPREL16_HI, but adjust for low 16 bits. */ 1305 HOWTO (R_PPC64_DTPREL16_HA, 1306 16, /* rightshift */ 1307 1, /* size (0 = byte, 1 = short, 2 = long) */ 1308 16, /* bitsize */ 1309 FALSE, /* pc_relative */ 1310 0, /* bitpos */ 1311 complain_overflow_dont, /* complain_on_overflow */ 1312 ppc64_elf_unhandled_reloc, /* special_function */ 1313 "R_PPC64_DTPREL16_HA", /* name */ 1314 FALSE, /* partial_inplace */ 1315 0, /* src_mask */ 1316 0xffff, /* dst_mask */ 1317 FALSE), /* pcrel_offset */ 1318 1319 /* Like DTPREL16_HI, but next higher group of 16 bits. */ 1320 HOWTO (R_PPC64_DTPREL16_HIGHER, 1321 32, /* rightshift */ 1322 1, /* size (0 = byte, 1 = short, 2 = long) */ 1323 16, /* bitsize */ 1324 FALSE, /* pc_relative */ 1325 0, /* bitpos */ 1326 complain_overflow_dont, /* complain_on_overflow */ 1327 ppc64_elf_unhandled_reloc, /* special_function */ 1328 "R_PPC64_DTPREL16_HIGHER", /* name */ 1329 FALSE, /* partial_inplace */ 1330 0, /* src_mask */ 1331 0xffff, /* dst_mask */ 1332 FALSE), /* pcrel_offset */ 1333 1334 /* Like DTPREL16_HIGHER, but adjust for low 16 bits. */ 1335 HOWTO (R_PPC64_DTPREL16_HIGHERA, 1336 32, /* rightshift */ 1337 1, /* size (0 = byte, 1 = short, 2 = long) */ 1338 16, /* bitsize */ 1339 FALSE, /* pc_relative */ 1340 0, /* bitpos */ 1341 complain_overflow_dont, /* complain_on_overflow */ 1342 ppc64_elf_unhandled_reloc, /* special_function */ 1343 "R_PPC64_DTPREL16_HIGHERA", /* name */ 1344 FALSE, /* partial_inplace */ 1345 0, /* src_mask */ 1346 0xffff, /* dst_mask */ 1347 FALSE), /* pcrel_offset */ 1348 1349 /* Like DTPREL16_HIGHER, but next higher group of 16 bits. */ 1350 HOWTO (R_PPC64_DTPREL16_HIGHEST, 1351 48, /* rightshift */ 1352 1, /* size (0 = byte, 1 = short, 2 = long) */ 1353 16, /* bitsize */ 1354 FALSE, /* pc_relative */ 1355 0, /* bitpos */ 1356 complain_overflow_dont, /* complain_on_overflow */ 1357 ppc64_elf_unhandled_reloc, /* special_function */ 1358 "R_PPC64_DTPREL16_HIGHEST", /* name */ 1359 FALSE, /* partial_inplace */ 1360 0, /* src_mask */ 1361 0xffff, /* dst_mask */ 1362 FALSE), /* pcrel_offset */ 1363 1364 /* Like DTPREL16_HIGHEST, but adjust for low 16 bits. */ 1365 HOWTO (R_PPC64_DTPREL16_HIGHESTA, 1366 48, /* rightshift */ 1367 1, /* size (0 = byte, 1 = short, 2 = long) */ 1368 16, /* bitsize */ 1369 FALSE, /* pc_relative */ 1370 0, /* bitpos */ 1371 complain_overflow_dont, /* complain_on_overflow */ 1372 ppc64_elf_unhandled_reloc, /* special_function */ 1373 "R_PPC64_DTPREL16_HIGHESTA", /* name */ 1374 FALSE, /* partial_inplace */ 1375 0, /* src_mask */ 1376 0xffff, /* dst_mask */ 1377 FALSE), /* pcrel_offset */ 1378 1379 /* Like DTPREL16, but for insns with a DS field. */ 1380 HOWTO (R_PPC64_DTPREL16_DS, 1381 0, /* rightshift */ 1382 1, /* size (0 = byte, 1 = short, 2 = long) */ 1383 16, /* bitsize */ 1384 FALSE, /* pc_relative */ 1385 0, /* bitpos */ 1386 complain_overflow_signed, /* complain_on_overflow */ 1387 ppc64_elf_unhandled_reloc, /* special_function */ 1388 "R_PPC64_DTPREL16_DS", /* name */ 1389 FALSE, /* partial_inplace */ 1390 0, /* src_mask */ 1391 0xfffc, /* dst_mask */ 1392 FALSE), /* pcrel_offset */ 1393 1394 /* Like DTPREL16_DS, but no overflow. */ 1395 HOWTO (R_PPC64_DTPREL16_LO_DS, 1396 0, /* rightshift */ 1397 1, /* size (0 = byte, 1 = short, 2 = long) */ 1398 16, /* bitsize */ 1399 FALSE, /* pc_relative */ 1400 0, /* bitpos */ 1401 complain_overflow_dont, /* complain_on_overflow */ 1402 ppc64_elf_unhandled_reloc, /* special_function */ 1403 "R_PPC64_DTPREL16_LO_DS", /* name */ 1404 FALSE, /* partial_inplace */ 1405 0, /* src_mask */ 1406 0xfffc, /* dst_mask */ 1407 FALSE), /* pcrel_offset */ 1408 1409 /* Computes a tp-relative displacement, the difference between the value of 1410 sym+add and the value of the thread pointer (r13). */ 1411 HOWTO (R_PPC64_TPREL64, 1412 0, /* rightshift */ 1413 4, /* size (0 = byte, 1 = short, 2 = long) */ 1414 64, /* bitsize */ 1415 FALSE, /* pc_relative */ 1416 0, /* bitpos */ 1417 complain_overflow_dont, /* complain_on_overflow */ 1418 ppc64_elf_unhandled_reloc, /* special_function */ 1419 "R_PPC64_TPREL64", /* name */ 1420 FALSE, /* partial_inplace */ 1421 0, /* src_mask */ 1422 ONES (64), /* dst_mask */ 1423 FALSE), /* pcrel_offset */ 1424 1425 /* A 16 bit tprel reloc. */ 1426 HOWTO (R_PPC64_TPREL16, 1427 0, /* rightshift */ 1428 1, /* size (0 = byte, 1 = short, 2 = long) */ 1429 16, /* bitsize */ 1430 FALSE, /* pc_relative */ 1431 0, /* bitpos */ 1432 complain_overflow_signed, /* complain_on_overflow */ 1433 ppc64_elf_unhandled_reloc, /* special_function */ 1434 "R_PPC64_TPREL16", /* name */ 1435 FALSE, /* partial_inplace */ 1436 0, /* src_mask */ 1437 0xffff, /* dst_mask */ 1438 FALSE), /* pcrel_offset */ 1439 1440 /* Like TPREL16, but no overflow. */ 1441 HOWTO (R_PPC64_TPREL16_LO, 1442 0, /* rightshift */ 1443 1, /* size (0 = byte, 1 = short, 2 = long) */ 1444 16, /* bitsize */ 1445 FALSE, /* pc_relative */ 1446 0, /* bitpos */ 1447 complain_overflow_dont, /* complain_on_overflow */ 1448 ppc64_elf_unhandled_reloc, /* special_function */ 1449 "R_PPC64_TPREL16_LO", /* name */ 1450 FALSE, /* partial_inplace */ 1451 0, /* src_mask */ 1452 0xffff, /* dst_mask */ 1453 FALSE), /* pcrel_offset */ 1454 1455 /* Like TPREL16_LO, but next higher group of 16 bits. */ 1456 HOWTO (R_PPC64_TPREL16_HI, 1457 16, /* rightshift */ 1458 1, /* size (0 = byte, 1 = short, 2 = long) */ 1459 16, /* bitsize */ 1460 FALSE, /* pc_relative */ 1461 0, /* bitpos */ 1462 complain_overflow_dont, /* complain_on_overflow */ 1463 ppc64_elf_unhandled_reloc, /* special_function */ 1464 "R_PPC64_TPREL16_HI", /* name */ 1465 FALSE, /* partial_inplace */ 1466 0, /* src_mask */ 1467 0xffff, /* dst_mask */ 1468 FALSE), /* pcrel_offset */ 1469 1470 /* Like TPREL16_HI, but adjust for low 16 bits. */ 1471 HOWTO (R_PPC64_TPREL16_HA, 1472 16, /* rightshift */ 1473 1, /* size (0 = byte, 1 = short, 2 = long) */ 1474 16, /* bitsize */ 1475 FALSE, /* pc_relative */ 1476 0, /* bitpos */ 1477 complain_overflow_dont, /* complain_on_overflow */ 1478 ppc64_elf_unhandled_reloc, /* special_function */ 1479 "R_PPC64_TPREL16_HA", /* name */ 1480 FALSE, /* partial_inplace */ 1481 0, /* src_mask */ 1482 0xffff, /* dst_mask */ 1483 FALSE), /* pcrel_offset */ 1484 1485 /* Like TPREL16_HI, but next higher group of 16 bits. */ 1486 HOWTO (R_PPC64_TPREL16_HIGHER, 1487 32, /* rightshift */ 1488 1, /* size (0 = byte, 1 = short, 2 = long) */ 1489 16, /* bitsize */ 1490 FALSE, /* pc_relative */ 1491 0, /* bitpos */ 1492 complain_overflow_dont, /* complain_on_overflow */ 1493 ppc64_elf_unhandled_reloc, /* special_function */ 1494 "R_PPC64_TPREL16_HIGHER", /* name */ 1495 FALSE, /* partial_inplace */ 1496 0, /* src_mask */ 1497 0xffff, /* dst_mask */ 1498 FALSE), /* pcrel_offset */ 1499 1500 /* Like TPREL16_HIGHER, but adjust for low 16 bits. */ 1501 HOWTO (R_PPC64_TPREL16_HIGHERA, 1502 32, /* rightshift */ 1503 1, /* size (0 = byte, 1 = short, 2 = long) */ 1504 16, /* bitsize */ 1505 FALSE, /* pc_relative */ 1506 0, /* bitpos */ 1507 complain_overflow_dont, /* complain_on_overflow */ 1508 ppc64_elf_unhandled_reloc, /* special_function */ 1509 "R_PPC64_TPREL16_HIGHERA", /* name */ 1510 FALSE, /* partial_inplace */ 1511 0, /* src_mask */ 1512 0xffff, /* dst_mask */ 1513 FALSE), /* pcrel_offset */ 1514 1515 /* Like TPREL16_HIGHER, but next higher group of 16 bits. */ 1516 HOWTO (R_PPC64_TPREL16_HIGHEST, 1517 48, /* rightshift */ 1518 1, /* size (0 = byte, 1 = short, 2 = long) */ 1519 16, /* bitsize */ 1520 FALSE, /* pc_relative */ 1521 0, /* bitpos */ 1522 complain_overflow_dont, /* complain_on_overflow */ 1523 ppc64_elf_unhandled_reloc, /* special_function */ 1524 "R_PPC64_TPREL16_HIGHEST", /* name */ 1525 FALSE, /* partial_inplace */ 1526 0, /* src_mask */ 1527 0xffff, /* dst_mask */ 1528 FALSE), /* pcrel_offset */ 1529 1530 /* Like TPREL16_HIGHEST, but adjust for low 16 bits. */ 1531 HOWTO (R_PPC64_TPREL16_HIGHESTA, 1532 48, /* rightshift */ 1533 1, /* size (0 = byte, 1 = short, 2 = long) */ 1534 16, /* bitsize */ 1535 FALSE, /* pc_relative */ 1536 0, /* bitpos */ 1537 complain_overflow_dont, /* complain_on_overflow */ 1538 ppc64_elf_unhandled_reloc, /* special_function */ 1539 "R_PPC64_TPREL16_HIGHESTA", /* name */ 1540 FALSE, /* partial_inplace */ 1541 0, /* src_mask */ 1542 0xffff, /* dst_mask */ 1543 FALSE), /* pcrel_offset */ 1544 1545 /* Like TPREL16, but for insns with a DS field. */ 1546 HOWTO (R_PPC64_TPREL16_DS, 1547 0, /* rightshift */ 1548 1, /* size (0 = byte, 1 = short, 2 = long) */ 1549 16, /* bitsize */ 1550 FALSE, /* pc_relative */ 1551 0, /* bitpos */ 1552 complain_overflow_signed, /* complain_on_overflow */ 1553 ppc64_elf_unhandled_reloc, /* special_function */ 1554 "R_PPC64_TPREL16_DS", /* name */ 1555 FALSE, /* partial_inplace */ 1556 0, /* src_mask */ 1557 0xfffc, /* dst_mask */ 1558 FALSE), /* pcrel_offset */ 1559 1560 /* Like TPREL16_DS, but no overflow. */ 1561 HOWTO (R_PPC64_TPREL16_LO_DS, 1562 0, /* rightshift */ 1563 1, /* size (0 = byte, 1 = short, 2 = long) */ 1564 16, /* bitsize */ 1565 FALSE, /* pc_relative */ 1566 0, /* bitpos */ 1567 complain_overflow_dont, /* complain_on_overflow */ 1568 ppc64_elf_unhandled_reloc, /* special_function */ 1569 "R_PPC64_TPREL16_LO_DS", /* name */ 1570 FALSE, /* partial_inplace */ 1571 0, /* src_mask */ 1572 0xfffc, /* dst_mask */ 1573 FALSE), /* pcrel_offset */ 1574 1575 /* Allocates two contiguous entries in the GOT to hold a tls_index structure, 1576 with values (sym+add)@dtpmod and (sym+add)@dtprel, and computes the offset 1577 to the first entry relative to the TOC base (r2). */ 1578 HOWTO (R_PPC64_GOT_TLSGD16, 1579 0, /* rightshift */ 1580 1, /* size (0 = byte, 1 = short, 2 = long) */ 1581 16, /* bitsize */ 1582 FALSE, /* pc_relative */ 1583 0, /* bitpos */ 1584 complain_overflow_signed, /* complain_on_overflow */ 1585 ppc64_elf_unhandled_reloc, /* special_function */ 1586 "R_PPC64_GOT_TLSGD16", /* name */ 1587 FALSE, /* partial_inplace */ 1588 0, /* src_mask */ 1589 0xffff, /* dst_mask */ 1590 FALSE), /* pcrel_offset */ 1591 1592 /* Like GOT_TLSGD16, but no overflow. */ 1593 HOWTO (R_PPC64_GOT_TLSGD16_LO, 1594 0, /* rightshift */ 1595 1, /* size (0 = byte, 1 = short, 2 = long) */ 1596 16, /* bitsize */ 1597 FALSE, /* pc_relative */ 1598 0, /* bitpos */ 1599 complain_overflow_dont, /* complain_on_overflow */ 1600 ppc64_elf_unhandled_reloc, /* special_function */ 1601 "R_PPC64_GOT_TLSGD16_LO", /* name */ 1602 FALSE, /* partial_inplace */ 1603 0, /* src_mask */ 1604 0xffff, /* dst_mask */ 1605 FALSE), /* pcrel_offset */ 1606 1607 /* Like GOT_TLSGD16_LO, but next higher group of 16 bits. */ 1608 HOWTO (R_PPC64_GOT_TLSGD16_HI, 1609 16, /* rightshift */ 1610 1, /* size (0 = byte, 1 = short, 2 = long) */ 1611 16, /* bitsize */ 1612 FALSE, /* pc_relative */ 1613 0, /* bitpos */ 1614 complain_overflow_dont, /* complain_on_overflow */ 1615 ppc64_elf_unhandled_reloc, /* special_function */ 1616 "R_PPC64_GOT_TLSGD16_HI", /* name */ 1617 FALSE, /* partial_inplace */ 1618 0, /* src_mask */ 1619 0xffff, /* dst_mask */ 1620 FALSE), /* pcrel_offset */ 1621 1622 /* Like GOT_TLSGD16_HI, but adjust for low 16 bits. */ 1623 HOWTO (R_PPC64_GOT_TLSGD16_HA, 1624 16, /* rightshift */ 1625 1, /* size (0 = byte, 1 = short, 2 = long) */ 1626 16, /* bitsize */ 1627 FALSE, /* pc_relative */ 1628 0, /* bitpos */ 1629 complain_overflow_dont, /* complain_on_overflow */ 1630 ppc64_elf_unhandled_reloc, /* special_function */ 1631 "R_PPC64_GOT_TLSGD16_HA", /* name */ 1632 FALSE, /* partial_inplace */ 1633 0, /* src_mask */ 1634 0xffff, /* dst_mask */ 1635 FALSE), /* pcrel_offset */ 1636 1637 /* Allocates two contiguous entries in the GOT to hold a tls_index structure, 1638 with values (sym+add)@dtpmod and zero, and computes the offset to the 1639 first entry relative to the TOC base (r2). */ 1640 HOWTO (R_PPC64_GOT_TLSLD16, 1641 0, /* rightshift */ 1642 1, /* size (0 = byte, 1 = short, 2 = long) */ 1643 16, /* bitsize */ 1644 FALSE, /* pc_relative */ 1645 0, /* bitpos */ 1646 complain_overflow_signed, /* complain_on_overflow */ 1647 ppc64_elf_unhandled_reloc, /* special_function */ 1648 "R_PPC64_GOT_TLSLD16", /* name */ 1649 FALSE, /* partial_inplace */ 1650 0, /* src_mask */ 1651 0xffff, /* dst_mask */ 1652 FALSE), /* pcrel_offset */ 1653 1654 /* Like GOT_TLSLD16, but no overflow. */ 1655 HOWTO (R_PPC64_GOT_TLSLD16_LO, 1656 0, /* rightshift */ 1657 1, /* size (0 = byte, 1 = short, 2 = long) */ 1658 16, /* bitsize */ 1659 FALSE, /* pc_relative */ 1660 0, /* bitpos */ 1661 complain_overflow_dont, /* complain_on_overflow */ 1662 ppc64_elf_unhandled_reloc, /* special_function */ 1663 "R_PPC64_GOT_TLSLD16_LO", /* name */ 1664 FALSE, /* partial_inplace */ 1665 0, /* src_mask */ 1666 0xffff, /* dst_mask */ 1667 FALSE), /* pcrel_offset */ 1668 1669 /* Like GOT_TLSLD16_LO, but next higher group of 16 bits. */ 1670 HOWTO (R_PPC64_GOT_TLSLD16_HI, 1671 16, /* rightshift */ 1672 1, /* size (0 = byte, 1 = short, 2 = long) */ 1673 16, /* bitsize */ 1674 FALSE, /* pc_relative */ 1675 0, /* bitpos */ 1676 complain_overflow_dont, /* complain_on_overflow */ 1677 ppc64_elf_unhandled_reloc, /* special_function */ 1678 "R_PPC64_GOT_TLSLD16_HI", /* name */ 1679 FALSE, /* partial_inplace */ 1680 0, /* src_mask */ 1681 0xffff, /* dst_mask */ 1682 FALSE), /* pcrel_offset */ 1683 1684 /* Like GOT_TLSLD16_HI, but adjust for low 16 bits. */ 1685 HOWTO (R_PPC64_GOT_TLSLD16_HA, 1686 16, /* rightshift */ 1687 1, /* size (0 = byte, 1 = short, 2 = long) */ 1688 16, /* bitsize */ 1689 FALSE, /* pc_relative */ 1690 0, /* bitpos */ 1691 complain_overflow_dont, /* complain_on_overflow */ 1692 ppc64_elf_unhandled_reloc, /* special_function */ 1693 "R_PPC64_GOT_TLSLD16_HA", /* name */ 1694 FALSE, /* partial_inplace */ 1695 0, /* src_mask */ 1696 0xffff, /* dst_mask */ 1697 FALSE), /* pcrel_offset */ 1698 1699 /* Allocates an entry in the GOT with value (sym+add)@dtprel, and computes 1700 the offset to the entry relative to the TOC base (r2). */ 1701 HOWTO (R_PPC64_GOT_DTPREL16_DS, 1702 0, /* rightshift */ 1703 1, /* size (0 = byte, 1 = short, 2 = long) */ 1704 16, /* bitsize */ 1705 FALSE, /* pc_relative */ 1706 0, /* bitpos */ 1707 complain_overflow_signed, /* complain_on_overflow */ 1708 ppc64_elf_unhandled_reloc, /* special_function */ 1709 "R_PPC64_GOT_DTPREL16_DS", /* name */ 1710 FALSE, /* partial_inplace */ 1711 0, /* src_mask */ 1712 0xfffc, /* dst_mask */ 1713 FALSE), /* pcrel_offset */ 1714 1715 /* Like GOT_DTPREL16_DS, but no overflow. */ 1716 HOWTO (R_PPC64_GOT_DTPREL16_LO_DS, 1717 0, /* rightshift */ 1718 1, /* size (0 = byte, 1 = short, 2 = long) */ 1719 16, /* bitsize */ 1720 FALSE, /* pc_relative */ 1721 0, /* bitpos */ 1722 complain_overflow_dont, /* complain_on_overflow */ 1723 ppc64_elf_unhandled_reloc, /* special_function */ 1724 "R_PPC64_GOT_DTPREL16_LO_DS", /* name */ 1725 FALSE, /* partial_inplace */ 1726 0, /* src_mask */ 1727 0xfffc, /* dst_mask */ 1728 FALSE), /* pcrel_offset */ 1729 1730 /* Like GOT_DTPREL16_LO_DS, but next higher group of 16 bits. */ 1731 HOWTO (R_PPC64_GOT_DTPREL16_HI, 1732 16, /* rightshift */ 1733 1, /* size (0 = byte, 1 = short, 2 = long) */ 1734 16, /* bitsize */ 1735 FALSE, /* pc_relative */ 1736 0, /* bitpos */ 1737 complain_overflow_dont, /* complain_on_overflow */ 1738 ppc64_elf_unhandled_reloc, /* special_function */ 1739 "R_PPC64_GOT_DTPREL16_HI", /* name */ 1740 FALSE, /* partial_inplace */ 1741 0, /* src_mask */ 1742 0xffff, /* dst_mask */ 1743 FALSE), /* pcrel_offset */ 1744 1745 /* Like GOT_DTPREL16_HI, but adjust for low 16 bits. */ 1746 HOWTO (R_PPC64_GOT_DTPREL16_HA, 1747 16, /* rightshift */ 1748 1, /* size (0 = byte, 1 = short, 2 = long) */ 1749 16, /* bitsize */ 1750 FALSE, /* pc_relative */ 1751 0, /* bitpos */ 1752 complain_overflow_dont, /* complain_on_overflow */ 1753 ppc64_elf_unhandled_reloc, /* special_function */ 1754 "R_PPC64_GOT_DTPREL16_HA", /* name */ 1755 FALSE, /* partial_inplace */ 1756 0, /* src_mask */ 1757 0xffff, /* dst_mask */ 1758 FALSE), /* pcrel_offset */ 1759 1760 /* Allocates an entry in the GOT with value (sym+add)@tprel, and computes the 1761 offset to the entry relative to the TOC base (r2). */ 1762 HOWTO (R_PPC64_GOT_TPREL16_DS, 1763 0, /* rightshift */ 1764 1, /* size (0 = byte, 1 = short, 2 = long) */ 1765 16, /* bitsize */ 1766 FALSE, /* pc_relative */ 1767 0, /* bitpos */ 1768 complain_overflow_signed, /* complain_on_overflow */ 1769 ppc64_elf_unhandled_reloc, /* special_function */ 1770 "R_PPC64_GOT_TPREL16_DS", /* name */ 1771 FALSE, /* partial_inplace */ 1772 0, /* src_mask */ 1773 0xfffc, /* dst_mask */ 1774 FALSE), /* pcrel_offset */ 1775 1776 /* Like GOT_TPREL16_DS, but no overflow. */ 1777 HOWTO (R_PPC64_GOT_TPREL16_LO_DS, 1778 0, /* rightshift */ 1779 1, /* size (0 = byte, 1 = short, 2 = long) */ 1780 16, /* bitsize */ 1781 FALSE, /* pc_relative */ 1782 0, /* bitpos */ 1783 complain_overflow_dont, /* complain_on_overflow */ 1784 ppc64_elf_unhandled_reloc, /* special_function */ 1785 "R_PPC64_GOT_TPREL16_LO_DS", /* name */ 1786 FALSE, /* partial_inplace */ 1787 0, /* src_mask */ 1788 0xfffc, /* dst_mask */ 1789 FALSE), /* pcrel_offset */ 1790 1791 /* Like GOT_TPREL16_LO_DS, but next higher group of 16 bits. */ 1792 HOWTO (R_PPC64_GOT_TPREL16_HI, 1793 16, /* rightshift */ 1794 1, /* size (0 = byte, 1 = short, 2 = long) */ 1795 16, /* bitsize */ 1796 FALSE, /* pc_relative */ 1797 0, /* bitpos */ 1798 complain_overflow_dont, /* complain_on_overflow */ 1799 ppc64_elf_unhandled_reloc, /* special_function */ 1800 "R_PPC64_GOT_TPREL16_HI", /* name */ 1801 FALSE, /* partial_inplace */ 1802 0, /* src_mask */ 1803 0xffff, /* dst_mask */ 1804 FALSE), /* pcrel_offset */ 1805 1806 /* Like GOT_TPREL16_HI, but adjust for low 16 bits. */ 1807 HOWTO (R_PPC64_GOT_TPREL16_HA, 1808 16, /* rightshift */ 1809 1, /* size (0 = byte, 1 = short, 2 = long) */ 1810 16, /* bitsize */ 1811 FALSE, /* pc_relative */ 1812 0, /* bitpos */ 1813 complain_overflow_dont, /* complain_on_overflow */ 1814 ppc64_elf_unhandled_reloc, /* special_function */ 1815 "R_PPC64_GOT_TPREL16_HA", /* name */ 1816 FALSE, /* partial_inplace */ 1817 0, /* src_mask */ 1818 0xffff, /* dst_mask */ 1819 FALSE), /* pcrel_offset */ 1820 1821 /* GNU extension to record C++ vtable hierarchy. */ 1822 HOWTO (R_PPC64_GNU_VTINHERIT, /* type */ 1823 0, /* rightshift */ 1824 0, /* size (0 = byte, 1 = short, 2 = long) */ 1825 0, /* bitsize */ 1826 FALSE, /* pc_relative */ 1827 0, /* bitpos */ 1828 complain_overflow_dont, /* complain_on_overflow */ 1829 NULL, /* special_function */ 1830 "R_PPC64_GNU_VTINHERIT", /* name */ 1831 FALSE, /* partial_inplace */ 1832 0, /* src_mask */ 1833 0, /* dst_mask */ 1834 FALSE), /* pcrel_offset */ 1835 1836 /* GNU extension to record C++ vtable member usage. */ 1837 HOWTO (R_PPC64_GNU_VTENTRY, /* type */ 1838 0, /* rightshift */ 1839 0, /* size (0 = byte, 1 = short, 2 = long) */ 1840 0, /* bitsize */ 1841 FALSE, /* pc_relative */ 1842 0, /* bitpos */ 1843 complain_overflow_dont, /* complain_on_overflow */ 1844 NULL, /* special_function */ 1845 "R_PPC64_GNU_VTENTRY", /* name */ 1846 FALSE, /* partial_inplace */ 1847 0, /* src_mask */ 1848 0, /* dst_mask */ 1849 FALSE), /* pcrel_offset */ 1850}; 1851 1852 1853/* Initialize the ppc64_elf_howto_table, so that linear accesses can 1854 be done. */ 1855 1856static void 1857ppc_howto_init (void) 1858{ 1859 unsigned int i, type; 1860 1861 for (i = 0; 1862 i < sizeof (ppc64_elf_howto_raw) / sizeof (ppc64_elf_howto_raw[0]); 1863 i++) 1864 { 1865 type = ppc64_elf_howto_raw[i].type; 1866 BFD_ASSERT (type < (sizeof (ppc64_elf_howto_table) 1867 / sizeof (ppc64_elf_howto_table[0]))); 1868 ppc64_elf_howto_table[type] = &ppc64_elf_howto_raw[i]; 1869 } 1870} 1871 1872static reloc_howto_type * 1873ppc64_elf_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, 1874 bfd_reloc_code_real_type code) 1875{ 1876 enum elf_ppc64_reloc_type r = R_PPC64_NONE; 1877 1878 if (!ppc64_elf_howto_table[R_PPC64_ADDR32]) 1879 /* Initialize howto table if needed. */ 1880 ppc_howto_init (); 1881 1882 switch (code) 1883 { 1884 default: 1885 return NULL; 1886 1887 case BFD_RELOC_NONE: r = R_PPC64_NONE; 1888 break; 1889 case BFD_RELOC_32: r = R_PPC64_ADDR32; 1890 break; 1891 case BFD_RELOC_PPC_BA26: r = R_PPC64_ADDR24; 1892 break; 1893 case BFD_RELOC_16: r = R_PPC64_ADDR16; 1894 break; 1895 case BFD_RELOC_LO16: r = R_PPC64_ADDR16_LO; 1896 break; 1897 case BFD_RELOC_HI16: r = R_PPC64_ADDR16_HI; 1898 break; 1899 case BFD_RELOC_HI16_S: r = R_PPC64_ADDR16_HA; 1900 break; 1901 case BFD_RELOC_PPC_BA16: r = R_PPC64_ADDR14; 1902 break; 1903 case BFD_RELOC_PPC_BA16_BRTAKEN: r = R_PPC64_ADDR14_BRTAKEN; 1904 break; 1905 case BFD_RELOC_PPC_BA16_BRNTAKEN: r = R_PPC64_ADDR14_BRNTAKEN; 1906 break; 1907 case BFD_RELOC_PPC_B26: r = R_PPC64_REL24; 1908 break; 1909 case BFD_RELOC_PPC_B16: r = R_PPC64_REL14; 1910 break; 1911 case BFD_RELOC_PPC_B16_BRTAKEN: r = R_PPC64_REL14_BRTAKEN; 1912 break; 1913 case BFD_RELOC_PPC_B16_BRNTAKEN: r = R_PPC64_REL14_BRNTAKEN; 1914 break; 1915 case BFD_RELOC_16_GOTOFF: r = R_PPC64_GOT16; 1916 break; 1917 case BFD_RELOC_LO16_GOTOFF: r = R_PPC64_GOT16_LO; 1918 break; 1919 case BFD_RELOC_HI16_GOTOFF: r = R_PPC64_GOT16_HI; 1920 break; 1921 case BFD_RELOC_HI16_S_GOTOFF: r = R_PPC64_GOT16_HA; 1922 break; 1923 case BFD_RELOC_PPC_COPY: r = R_PPC64_COPY; 1924 break; 1925 case BFD_RELOC_PPC_GLOB_DAT: r = R_PPC64_GLOB_DAT; 1926 break; 1927 case BFD_RELOC_32_PCREL: r = R_PPC64_REL32; 1928 break; 1929 case BFD_RELOC_32_PLTOFF: r = R_PPC64_PLT32; 1930 break; 1931 case BFD_RELOC_32_PLT_PCREL: r = R_PPC64_PLTREL32; 1932 break; 1933 case BFD_RELOC_LO16_PLTOFF: r = R_PPC64_PLT16_LO; 1934 break; 1935 case BFD_RELOC_HI16_PLTOFF: r = R_PPC64_PLT16_HI; 1936 break; 1937 case BFD_RELOC_HI16_S_PLTOFF: r = R_PPC64_PLT16_HA; 1938 break; 1939 case BFD_RELOC_16_BASEREL: r = R_PPC64_SECTOFF; 1940 break; 1941 case BFD_RELOC_LO16_BASEREL: r = R_PPC64_SECTOFF_LO; 1942 break; 1943 case BFD_RELOC_HI16_BASEREL: r = R_PPC64_SECTOFF_HI; 1944 break; 1945 case BFD_RELOC_HI16_S_BASEREL: r = R_PPC64_SECTOFF_HA; 1946 break; 1947 case BFD_RELOC_CTOR: r = R_PPC64_ADDR64; 1948 break; 1949 case BFD_RELOC_64: r = R_PPC64_ADDR64; 1950 break; 1951 case BFD_RELOC_PPC64_HIGHER: r = R_PPC64_ADDR16_HIGHER; 1952 break; 1953 case BFD_RELOC_PPC64_HIGHER_S: r = R_PPC64_ADDR16_HIGHERA; 1954 break; 1955 case BFD_RELOC_PPC64_HIGHEST: r = R_PPC64_ADDR16_HIGHEST; 1956 break; 1957 case BFD_RELOC_PPC64_HIGHEST_S: r = R_PPC64_ADDR16_HIGHESTA; 1958 break; 1959 case BFD_RELOC_64_PCREL: r = R_PPC64_REL64; 1960 break; 1961 case BFD_RELOC_64_PLTOFF: r = R_PPC64_PLT64; 1962 break; 1963 case BFD_RELOC_64_PLT_PCREL: r = R_PPC64_PLTREL64; 1964 break; 1965 case BFD_RELOC_PPC_TOC16: r = R_PPC64_TOC16; 1966 break; 1967 case BFD_RELOC_PPC64_TOC16_LO: r = R_PPC64_TOC16_LO; 1968 break; 1969 case BFD_RELOC_PPC64_TOC16_HI: r = R_PPC64_TOC16_HI; 1970 break; 1971 case BFD_RELOC_PPC64_TOC16_HA: r = R_PPC64_TOC16_HA; 1972 break; 1973 case BFD_RELOC_PPC64_TOC: r = R_PPC64_TOC; 1974 break; 1975 case BFD_RELOC_PPC64_PLTGOT16: r = R_PPC64_PLTGOT16; 1976 break; 1977 case BFD_RELOC_PPC64_PLTGOT16_LO: r = R_PPC64_PLTGOT16_LO; 1978 break; 1979 case BFD_RELOC_PPC64_PLTGOT16_HI: r = R_PPC64_PLTGOT16_HI; 1980 break; 1981 case BFD_RELOC_PPC64_PLTGOT16_HA: r = R_PPC64_PLTGOT16_HA; 1982 break; 1983 case BFD_RELOC_PPC64_ADDR16_DS: r = R_PPC64_ADDR16_DS; 1984 break; 1985 case BFD_RELOC_PPC64_ADDR16_LO_DS: r = R_PPC64_ADDR16_LO_DS; 1986 break; 1987 case BFD_RELOC_PPC64_GOT16_DS: r = R_PPC64_GOT16_DS; 1988 break; 1989 case BFD_RELOC_PPC64_GOT16_LO_DS: r = R_PPC64_GOT16_LO_DS; 1990 break; 1991 case BFD_RELOC_PPC64_PLT16_LO_DS: r = R_PPC64_PLT16_LO_DS; 1992 break; 1993 case BFD_RELOC_PPC64_SECTOFF_DS: r = R_PPC64_SECTOFF_DS; 1994 break; 1995 case BFD_RELOC_PPC64_SECTOFF_LO_DS: r = R_PPC64_SECTOFF_LO_DS; 1996 break; 1997 case BFD_RELOC_PPC64_TOC16_DS: r = R_PPC64_TOC16_DS; 1998 break; 1999 case BFD_RELOC_PPC64_TOC16_LO_DS: r = R_PPC64_TOC16_LO_DS; 2000 break; 2001 case BFD_RELOC_PPC64_PLTGOT16_DS: r = R_PPC64_PLTGOT16_DS; 2002 break; 2003 case BFD_RELOC_PPC64_PLTGOT16_LO_DS: r = R_PPC64_PLTGOT16_LO_DS; 2004 break; 2005 case BFD_RELOC_PPC_TLS: r = R_PPC64_TLS; 2006 break; 2007 case BFD_RELOC_PPC_DTPMOD: r = R_PPC64_DTPMOD64; 2008 break; 2009 case BFD_RELOC_PPC_TPREL16: r = R_PPC64_TPREL16; 2010 break; 2011 case BFD_RELOC_PPC_TPREL16_LO: r = R_PPC64_TPREL16_LO; 2012 break; 2013 case BFD_RELOC_PPC_TPREL16_HI: r = R_PPC64_TPREL16_HI; 2014 break; 2015 case BFD_RELOC_PPC_TPREL16_HA: r = R_PPC64_TPREL16_HA; 2016 break; 2017 case BFD_RELOC_PPC_TPREL: r = R_PPC64_TPREL64; 2018 break; 2019 case BFD_RELOC_PPC_DTPREL16: r = R_PPC64_DTPREL16; 2020 break; 2021 case BFD_RELOC_PPC_DTPREL16_LO: r = R_PPC64_DTPREL16_LO; 2022 break; 2023 case BFD_RELOC_PPC_DTPREL16_HI: r = R_PPC64_DTPREL16_HI; 2024 break; 2025 case BFD_RELOC_PPC_DTPREL16_HA: r = R_PPC64_DTPREL16_HA; 2026 break; 2027 case BFD_RELOC_PPC_DTPREL: r = R_PPC64_DTPREL64; 2028 break; 2029 case BFD_RELOC_PPC_GOT_TLSGD16: r = R_PPC64_GOT_TLSGD16; 2030 break; 2031 case BFD_RELOC_PPC_GOT_TLSGD16_LO: r = R_PPC64_GOT_TLSGD16_LO; 2032 break; 2033 case BFD_RELOC_PPC_GOT_TLSGD16_HI: r = R_PPC64_GOT_TLSGD16_HI; 2034 break; 2035 case BFD_RELOC_PPC_GOT_TLSGD16_HA: r = R_PPC64_GOT_TLSGD16_HA; 2036 break; 2037 case BFD_RELOC_PPC_GOT_TLSLD16: r = R_PPC64_GOT_TLSLD16; 2038 break; 2039 case BFD_RELOC_PPC_GOT_TLSLD16_LO: r = R_PPC64_GOT_TLSLD16_LO; 2040 break; 2041 case BFD_RELOC_PPC_GOT_TLSLD16_HI: r = R_PPC64_GOT_TLSLD16_HI; 2042 break; 2043 case BFD_RELOC_PPC_GOT_TLSLD16_HA: r = R_PPC64_GOT_TLSLD16_HA; 2044 break; 2045 case BFD_RELOC_PPC_GOT_TPREL16: r = R_PPC64_GOT_TPREL16_DS; 2046 break; 2047 case BFD_RELOC_PPC_GOT_TPREL16_LO: r = R_PPC64_GOT_TPREL16_LO_DS; 2048 break; 2049 case BFD_RELOC_PPC_GOT_TPREL16_HI: r = R_PPC64_GOT_TPREL16_HI; 2050 break; 2051 case BFD_RELOC_PPC_GOT_TPREL16_HA: r = R_PPC64_GOT_TPREL16_HA; 2052 break; 2053 case BFD_RELOC_PPC_GOT_DTPREL16: r = R_PPC64_GOT_DTPREL16_DS; 2054 break; 2055 case BFD_RELOC_PPC_GOT_DTPREL16_LO: r = R_PPC64_GOT_DTPREL16_LO_DS; 2056 break; 2057 case BFD_RELOC_PPC_GOT_DTPREL16_HI: r = R_PPC64_GOT_DTPREL16_HI; 2058 break; 2059 case BFD_RELOC_PPC_GOT_DTPREL16_HA: r = R_PPC64_GOT_DTPREL16_HA; 2060 break; 2061 case BFD_RELOC_PPC64_TPREL16_DS: r = R_PPC64_TPREL16_DS; 2062 break; 2063 case BFD_RELOC_PPC64_TPREL16_LO_DS: r = R_PPC64_TPREL16_LO_DS; 2064 break; 2065 case BFD_RELOC_PPC64_TPREL16_HIGHER: r = R_PPC64_TPREL16_HIGHER; 2066 break; 2067 case BFD_RELOC_PPC64_TPREL16_HIGHERA: r = R_PPC64_TPREL16_HIGHERA; 2068 break; 2069 case BFD_RELOC_PPC64_TPREL16_HIGHEST: r = R_PPC64_TPREL16_HIGHEST; 2070 break; 2071 case BFD_RELOC_PPC64_TPREL16_HIGHESTA: r = R_PPC64_TPREL16_HIGHESTA; 2072 break; 2073 case BFD_RELOC_PPC64_DTPREL16_DS: r = R_PPC64_DTPREL16_DS; 2074 break; 2075 case BFD_RELOC_PPC64_DTPREL16_LO_DS: r = R_PPC64_DTPREL16_LO_DS; 2076 break; 2077 case BFD_RELOC_PPC64_DTPREL16_HIGHER: r = R_PPC64_DTPREL16_HIGHER; 2078 break; 2079 case BFD_RELOC_PPC64_DTPREL16_HIGHERA: r = R_PPC64_DTPREL16_HIGHERA; 2080 break; 2081 case BFD_RELOC_PPC64_DTPREL16_HIGHEST: r = R_PPC64_DTPREL16_HIGHEST; 2082 break; 2083 case BFD_RELOC_PPC64_DTPREL16_HIGHESTA: r = R_PPC64_DTPREL16_HIGHESTA; 2084 break; 2085 case BFD_RELOC_VTABLE_INHERIT: r = R_PPC64_GNU_VTINHERIT; 2086 break; 2087 case BFD_RELOC_VTABLE_ENTRY: r = R_PPC64_GNU_VTENTRY; 2088 break; 2089 } 2090 2091 return ppc64_elf_howto_table[r]; 2092}; 2093 2094/* Set the howto pointer for a PowerPC ELF reloc. */ 2095 2096static void 2097ppc64_elf_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr, 2098 Elf_Internal_Rela *dst) 2099{ 2100 unsigned int type; 2101 2102 /* Initialize howto table if needed. */ 2103 if (!ppc64_elf_howto_table[R_PPC64_ADDR32]) 2104 ppc_howto_init (); 2105 2106 type = ELF64_R_TYPE (dst->r_info); 2107 BFD_ASSERT (type < (sizeof (ppc64_elf_howto_table) 2108 / sizeof (ppc64_elf_howto_table[0]))); 2109 cache_ptr->howto = ppc64_elf_howto_table[type]; 2110} 2111 2112/* Handle the R_PPC64_ADDR16_HA and similar relocs. */ 2113 2114static bfd_reloc_status_type 2115ppc64_elf_ha_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, 2116 void *data, asection *input_section, 2117 bfd *output_bfd, char **error_message) 2118{ 2119 /* If this is a relocatable link (output_bfd test tells us), just 2120 call the generic function. Any adjustment will be done at final 2121 link time. */ 2122 if (output_bfd != NULL) 2123 return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, 2124 input_section, output_bfd, error_message); 2125 2126 /* Adjust the addend for sign extension of the low 16 bits. 2127 We won't actually be using the low 16 bits, so trashing them 2128 doesn't matter. */ 2129 reloc_entry->addend += 0x8000; 2130 return bfd_reloc_continue; 2131} 2132 2133static bfd_reloc_status_type 2134ppc64_elf_brtaken_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, 2135 void *data, asection *input_section, 2136 bfd *output_bfd, char **error_message) 2137{ 2138 long insn; 2139 enum elf_ppc64_reloc_type r_type; 2140 bfd_size_type octets; 2141 /* Disabled until we sort out how ld should choose 'y' vs 'at'. */ 2142 bfd_boolean is_power4 = FALSE; 2143 2144 /* If this is a relocatable link (output_bfd test tells us), just 2145 call the generic function. Any adjustment will be done at final 2146 link time. */ 2147 if (output_bfd != NULL) 2148 return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, 2149 input_section, output_bfd, error_message); 2150 2151 octets = reloc_entry->address * bfd_octets_per_byte (abfd); 2152 insn = bfd_get_32 (abfd, (bfd_byte *) data + octets); 2153 insn &= ~(0x01 << 21); 2154 r_type = reloc_entry->howto->type; 2155 if (r_type == R_PPC64_ADDR14_BRTAKEN 2156 || r_type == R_PPC64_REL14_BRTAKEN) 2157 insn |= 0x01 << 21; /* 'y' or 't' bit, lowest bit of BO field. */ 2158 2159 if (is_power4) 2160 { 2161 /* Set 'a' bit. This is 0b00010 in BO field for branch 2162 on CR(BI) insns (BO == 001at or 011at), and 0b01000 2163 for branch on CTR insns (BO == 1a00t or 1a01t). */ 2164 if ((insn & (0x14 << 21)) == (0x04 << 21)) 2165 insn |= 0x02 << 21; 2166 else if ((insn & (0x14 << 21)) == (0x10 << 21)) 2167 insn |= 0x08 << 21; 2168 else 2169 return bfd_reloc_continue; 2170 } 2171 else 2172 { 2173 bfd_vma target = 0; 2174 bfd_vma from; 2175 2176 if (!bfd_is_com_section (symbol->section)) 2177 target = symbol->value; 2178 target += symbol->section->output_section->vma; 2179 target += symbol->section->output_offset; 2180 target += reloc_entry->addend; 2181 2182 from = (reloc_entry->address 2183 + input_section->output_offset 2184 + input_section->output_section->vma); 2185 2186 /* Invert 'y' bit if not the default. */ 2187 if ((bfd_signed_vma) (target - from) < 0) 2188 insn ^= 0x01 << 21; 2189 } 2190 bfd_put_32 (abfd, insn, (bfd_byte *) data + octets); 2191 return bfd_reloc_continue; 2192} 2193 2194static bfd_reloc_status_type 2195ppc64_elf_sectoff_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, 2196 void *data, asection *input_section, 2197 bfd *output_bfd, char **error_message) 2198{ 2199 /* If this is a relocatable link (output_bfd test tells us), just 2200 call the generic function. Any adjustment will be done at final 2201 link time. */ 2202 if (output_bfd != NULL) 2203 return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, 2204 input_section, output_bfd, error_message); 2205 2206 /* Subtract the symbol section base address. */ 2207 reloc_entry->addend -= symbol->section->output_section->vma; 2208 return bfd_reloc_continue; 2209} 2210 2211static bfd_reloc_status_type 2212ppc64_elf_sectoff_ha_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, 2213 void *data, asection *input_section, 2214 bfd *output_bfd, char **error_message) 2215{ 2216 /* If this is a relocatable link (output_bfd test tells us), just 2217 call the generic function. Any adjustment will be done at final 2218 link time. */ 2219 if (output_bfd != NULL) 2220 return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, 2221 input_section, output_bfd, error_message); 2222 2223 /* Subtract the symbol section base address. */ 2224 reloc_entry->addend -= symbol->section->output_section->vma; 2225 2226 /* Adjust the addend for sign extension of the low 16 bits. */ 2227 reloc_entry->addend += 0x8000; 2228 return bfd_reloc_continue; 2229} 2230 2231static bfd_reloc_status_type 2232ppc64_elf_toc_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, 2233 void *data, asection *input_section, 2234 bfd *output_bfd, char **error_message) 2235{ 2236 bfd_vma TOCstart; 2237 2238 /* If this is a relocatable link (output_bfd test tells us), just 2239 call the generic function. Any adjustment will be done at final 2240 link time. */ 2241 if (output_bfd != NULL) 2242 return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, 2243 input_section, output_bfd, error_message); 2244 2245 TOCstart = _bfd_get_gp_value (input_section->output_section->owner); 2246 if (TOCstart == 0) 2247 TOCstart = ppc64_elf_toc (input_section->output_section->owner); 2248 2249 /* Subtract the TOC base address. */ 2250 reloc_entry->addend -= TOCstart + TOC_BASE_OFF; 2251 return bfd_reloc_continue; 2252} 2253 2254static bfd_reloc_status_type 2255ppc64_elf_toc_ha_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, 2256 void *data, asection *input_section, 2257 bfd *output_bfd, char **error_message) 2258{ 2259 bfd_vma TOCstart; 2260 2261 /* If this is a relocatable link (output_bfd test tells us), just 2262 call the generic function. Any adjustment will be done at final 2263 link time. */ 2264 if (output_bfd != NULL) 2265 return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, 2266 input_section, output_bfd, error_message); 2267 2268 TOCstart = _bfd_get_gp_value (input_section->output_section->owner); 2269 if (TOCstart == 0) 2270 TOCstart = ppc64_elf_toc (input_section->output_section->owner); 2271 2272 /* Subtract the TOC base address. */ 2273 reloc_entry->addend -= TOCstart + TOC_BASE_OFF; 2274 2275 /* Adjust the addend for sign extension of the low 16 bits. */ 2276 reloc_entry->addend += 0x8000; 2277 return bfd_reloc_continue; 2278} 2279 2280static bfd_reloc_status_type 2281ppc64_elf_toc64_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, 2282 void *data, asection *input_section, 2283 bfd *output_bfd, char **error_message) 2284{ 2285 bfd_vma TOCstart; 2286 bfd_size_type octets; 2287 2288 /* If this is a relocatable link (output_bfd test tells us), just 2289 call the generic function. Any adjustment will be done at final 2290 link time. */ 2291 if (output_bfd != NULL) 2292 return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, 2293 input_section, output_bfd, error_message); 2294 2295 TOCstart = _bfd_get_gp_value (input_section->output_section->owner); 2296 if (TOCstart == 0) 2297 TOCstart = ppc64_elf_toc (input_section->output_section->owner); 2298 2299 octets = reloc_entry->address * bfd_octets_per_byte (abfd); 2300 bfd_put_64 (abfd, TOCstart + TOC_BASE_OFF, (bfd_byte *) data + octets); 2301 return bfd_reloc_ok; 2302} 2303 2304static bfd_reloc_status_type 2305ppc64_elf_unhandled_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, 2306 void *data, asection *input_section, 2307 bfd *output_bfd, char **error_message) 2308{ 2309 /* If this is a relocatable link (output_bfd test tells us), just 2310 call the generic function. Any adjustment will be done at final 2311 link time. */ 2312 if (output_bfd != NULL) 2313 return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, 2314 input_section, output_bfd, error_message); 2315 2316 if (error_message != NULL) 2317 { 2318 static char buf[60]; 2319 sprintf (buf, "generic linker can't handle %s", 2320 reloc_entry->howto->name); 2321 *error_message = buf; 2322 } 2323 return bfd_reloc_dangerous; 2324} 2325 2326struct ppc64_elf_obj_tdata 2327{ 2328 struct elf_obj_tdata elf; 2329 2330 /* Shortcuts to dynamic linker sections. */ 2331 asection *got; 2332 asection *relgot; 2333 2334 /* TLS local dynamic got entry handling. Suppose for multiple GOT 2335 sections means we potentially need one of these for each input bfd. */ 2336 union { 2337 bfd_signed_vma refcount; 2338 bfd_vma offset; 2339 } tlsld_got; 2340}; 2341 2342#define ppc64_elf_tdata(bfd) \ 2343 ((struct ppc64_elf_obj_tdata *) (bfd)->tdata.any) 2344 2345#define ppc64_tlsld_got(bfd) \ 2346 (&ppc64_elf_tdata (bfd)->tlsld_got) 2347 2348/* Override the generic function because we store some extras. */ 2349 2350static bfd_boolean 2351ppc64_elf_mkobject (bfd *abfd) 2352{ 2353 bfd_size_type amt = sizeof (struct ppc64_elf_obj_tdata); 2354 abfd->tdata.any = bfd_zalloc (abfd, amt); 2355 if (abfd->tdata.any == NULL) 2356 return FALSE; 2357 return TRUE; 2358} 2359 2360/* Fix bad default arch selected for a 64 bit input bfd when the 2361 default is 32 bit. */ 2362 2363static bfd_boolean 2364ppc64_elf_object_p (bfd *abfd) 2365{ 2366 if (abfd->arch_info->the_default && abfd->arch_info->bits_per_word == 32) 2367 { 2368 Elf_Internal_Ehdr *i_ehdr = elf_elfheader (abfd); 2369 2370 if (i_ehdr->e_ident[EI_CLASS] == ELFCLASS64) 2371 { 2372 /* Relies on arch after 32 bit default being 64 bit default. */ 2373 abfd->arch_info = abfd->arch_info->next; 2374 BFD_ASSERT (abfd->arch_info->bits_per_word == 64); 2375 } 2376 } 2377 return TRUE; 2378} 2379 2380/* Support for core dump NOTE sections. */ 2381 2382static bfd_boolean 2383ppc64_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note) 2384{ 2385 size_t offset, raw_size; 2386 2387 if (note->descsz != 504) 2388 return FALSE; 2389 2390 /* pr_cursig */ 2391 elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12); 2392 2393 /* pr_pid */ 2394 elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 32); 2395 2396 /* pr_reg */ 2397 offset = 112; 2398 raw_size = 384; 2399 2400 /* Make a ".reg/999" section. */ 2401 return _bfd_elfcore_make_pseudosection (abfd, ".reg", 2402 raw_size, note->descpos + offset); 2403} 2404 2405static bfd_boolean 2406ppc64_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note) 2407{ 2408 if (note->descsz != 136) 2409 return FALSE; 2410 2411 elf_tdata (abfd)->core_program 2412 = _bfd_elfcore_strndup (abfd, note->descdata + 40, 16); 2413 elf_tdata (abfd)->core_command 2414 = _bfd_elfcore_strndup (abfd, note->descdata + 56, 80); 2415 2416 return TRUE; 2417} 2418 2419/* Merge backend specific data from an object file to the output 2420 object file when linking. */ 2421 2422static bfd_boolean 2423ppc64_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd) 2424{ 2425 /* Check if we have the same endianess. */ 2426 if (ibfd->xvec->byteorder != obfd->xvec->byteorder 2427 && ibfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN 2428 && obfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN) 2429 { 2430 const char *msg; 2431 2432 if (bfd_big_endian (ibfd)) 2433 msg = _("%s: compiled for a big endian system " 2434 "and target is little endian"); 2435 else 2436 msg = _("%s: compiled for a little endian system " 2437 "and target is big endian"); 2438 2439 (*_bfd_error_handler) (msg, bfd_archive_filename (ibfd)); 2440 2441 bfd_set_error (bfd_error_wrong_format); 2442 return FALSE; 2443 } 2444 2445 return TRUE; 2446} 2447 2448/* Add extra PPC sections. */ 2449 2450static struct bfd_elf_special_section const ppc64_elf_special_sections[]= 2451{ 2452 { ".sdata", 6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, 2453 { ".sbss", 5, -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, 2454 { ".plt", 4, 0, SHT_NOBITS, 0 }, 2455 { ".toc", 4, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, 2456 { ".toc1", 5, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, 2457 { ".tocbss", 7, 0, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, 2458 { NULL, 0, 0, 0, 0 } 2459}; 2460 2461struct _ppc64_elf_section_data 2462{ 2463 struct bfd_elf_section_data elf; 2464 2465 /* An array with one entry for each opd function descriptor. */ 2466 union 2467 { 2468 /* Points to the function code section for local opd entries. */ 2469 asection **func_sec; 2470 /* After editing .opd, adjust references to opd local syms. */ 2471 long *adjust; 2472 } opd; 2473 2474 /* An array for toc sections, indexed by offset/8. 2475 Specifies the relocation symbol index used at a given toc offset. */ 2476 unsigned *t_symndx; 2477}; 2478 2479#define ppc64_elf_section_data(sec) \ 2480 ((struct _ppc64_elf_section_data *) elf_section_data (sec)) 2481 2482static bfd_boolean 2483ppc64_elf_new_section_hook (bfd *abfd, asection *sec) 2484{ 2485 struct _ppc64_elf_section_data *sdata; 2486 bfd_size_type amt = sizeof (*sdata); 2487 2488 sdata = bfd_zalloc (abfd, amt); 2489 if (sdata == NULL) 2490 return FALSE; 2491 sec->used_by_bfd = sdata; 2492 2493 return _bfd_elf_new_section_hook (abfd, sec); 2494} 2495 2496/* The following functions are specific to the ELF linker, while 2497 functions above are used generally. Those named ppc64_elf_* are 2498 called by the main ELF linker code. They appear in this file more 2499 or less in the order in which they are called. eg. 2500 ppc64_elf_check_relocs is called early in the link process, 2501 ppc64_elf_finish_dynamic_sections is one of the last functions 2502 called. 2503 2504 PowerPC64-ELF uses a similar scheme to PowerPC64-XCOFF in that 2505 functions have both a function code symbol and a function descriptor 2506 symbol. A call to foo in a relocatable object file looks like: 2507 2508 . .text 2509 . x: 2510 . bl .foo 2511 . nop 2512 2513 The function definition in another object file might be: 2514 2515 . .section .opd 2516 . foo: .quad .foo 2517 . .quad .TOC.@tocbase 2518 . .quad 0 2519 . 2520 . .text 2521 . .foo: blr 2522 2523 When the linker resolves the call during a static link, the branch 2524 unsurprisingly just goes to .foo and the .opd information is unused. 2525 If the function definition is in a shared library, things are a little 2526 different: The call goes via a plt call stub, the opd information gets 2527 copied to the plt, and the linker patches the nop. 2528 2529 . x: 2530 . bl .foo_stub 2531 . ld 2,40(1) 2532 . 2533 . 2534 . .foo_stub: 2535 . addis 12,2,Lfoo@toc@ha # in practice, the call stub 2536 . addi 12,12,Lfoo@toc@l # is slightly optimized, but 2537 . std 2,40(1) # this is the general idea 2538 . ld 11,0(12) 2539 . ld 2,8(12) 2540 . mtctr 11 2541 . ld 11,16(12) 2542 . bctr 2543 . 2544 . .section .plt 2545 . Lfoo: reloc (R_PPC64_JMP_SLOT, foo) 2546 2547 The "reloc ()" notation is supposed to indicate that the linker emits 2548 an R_PPC64_JMP_SLOT reloc against foo. The dynamic linker does the opd 2549 copying. 2550 2551 What are the difficulties here? Well, firstly, the relocations 2552 examined by the linker in check_relocs are against the function code 2553 sym .foo, while the dynamic relocation in the plt is emitted against 2554 the function descriptor symbol, foo. Somewhere along the line, we need 2555 to carefully copy dynamic link information from one symbol to the other. 2556 Secondly, the generic part of the elf linker will make .foo a dynamic 2557 symbol as is normal for most other backends. We need foo dynamic 2558 instead, at least for an application final link. However, when 2559 creating a shared library containing foo, we need to have both symbols 2560 dynamic so that references to .foo are satisfied during the early 2561 stages of linking. Otherwise the linker might decide to pull in a 2562 definition from some other object, eg. a static library. */ 2563 2564/* The linker needs to keep track of the number of relocs that it 2565 decides to copy as dynamic relocs in check_relocs for each symbol. 2566 This is so that it can later discard them if they are found to be 2567 unnecessary. We store the information in a field extending the 2568 regular ELF linker hash table. */ 2569 2570struct ppc_dyn_relocs 2571{ 2572 struct ppc_dyn_relocs *next; 2573 2574 /* The input section of the reloc. */ 2575 asection *sec; 2576 2577 /* Total number of relocs copied for the input section. */ 2578 bfd_size_type count; 2579 2580 /* Number of pc-relative relocs copied for the input section. */ 2581 bfd_size_type pc_count; 2582}; 2583 2584/* Track GOT entries needed for a given symbol. We might need more 2585 than one got entry per symbol. */ 2586struct got_entry 2587{ 2588 struct got_entry *next; 2589 2590 /* The symbol addend that we'll be placing in the GOT. */ 2591 bfd_vma addend; 2592 2593 /* Unlike other ELF targets, we use separate GOT entries for the same 2594 symbol referenced from different input files. This is to support 2595 automatic multiple TOC/GOT sections, where the TOC base can vary 2596 from one input file to another. 2597 2598 Point to the BFD owning this GOT entry. */ 2599 bfd *owner; 2600 2601 /* Zero for non-tls entries, or TLS_TLS and one of TLS_GD, TLS_LD, 2602 TLS_TPREL or TLS_DTPREL for tls entries. */ 2603 char tls_type; 2604 2605 /* Reference count until size_dynamic_sections, GOT offset thereafter. */ 2606 union 2607 { 2608 bfd_signed_vma refcount; 2609 bfd_vma offset; 2610 } got; 2611}; 2612 2613/* The same for PLT. */ 2614struct plt_entry 2615{ 2616 struct plt_entry *next; 2617 2618 bfd_vma addend; 2619 2620 union 2621 { 2622 bfd_signed_vma refcount; 2623 bfd_vma offset; 2624 } plt; 2625}; 2626 2627/* Of those relocs that might be copied as dynamic relocs, this macro 2628 selects those that must be copied when linking a shared library, 2629 even when the symbol is local. */ 2630 2631#define MUST_BE_DYN_RELOC(RTYPE) \ 2632 ((RTYPE) != R_PPC64_REL32 \ 2633 && (RTYPE) != R_PPC64_REL64 \ 2634 && (RTYPE) != R_PPC64_REL30) 2635 2636/* If ELIMINATE_COPY_RELOCS is non-zero, the linker will try to avoid 2637 copying dynamic variables from a shared lib into an app's dynbss 2638 section, and instead use a dynamic relocation to point into the 2639 shared lib. With code that gcc generates, it's vital that this be 2640 enabled; In the PowerPC64 ABI, the address of a function is actually 2641 the address of a function descriptor, which resides in the .opd 2642 section. gcc uses the descriptor directly rather than going via the 2643 GOT as some other ABI's do, which means that initialized function 2644 pointers must reference the descriptor. Thus, a function pointer 2645 initialized to the address of a function in a shared library will 2646 either require a copy reloc, or a dynamic reloc. Using a copy reloc 2647 redefines the function descriptor symbol to point to the copy. This 2648 presents a problem as a plt entry for that function is also 2649 initialized from the function descriptor symbol and the copy reloc 2650 may not be initialized first. */ 2651#define ELIMINATE_COPY_RELOCS 1 2652 2653/* Section name for stubs is the associated section name plus this 2654 string. */ 2655#define STUB_SUFFIX ".stub" 2656 2657/* Linker stubs. 2658 ppc_stub_long_branch: 2659 Used when a 14 bit branch (or even a 24 bit branch) can't reach its 2660 destination, but a 24 bit branch in a stub section will reach. 2661 . b dest 2662 2663 ppc_stub_plt_branch: 2664 Similar to the above, but a 24 bit branch in the stub section won't 2665 reach its destination. 2666 . addis %r12,%r2,xxx@toc@ha 2667 . ld %r11,xxx@toc@l(%r12) 2668 . mtctr %r11 2669 . bctr 2670 2671 ppc_stub_plt_call: 2672 Used to call a function in a shared library. 2673 . addis %r12,%r2,xxx@toc@ha 2674 . std %r2,40(%r1) 2675 . ld %r11,xxx+0@toc@l(%r12) 2676 . ld %r2,xxx+8@toc@l(%r12) 2677 . mtctr %r11 2678 . ld %r11,xxx+16@toc@l(%r12) 2679 . bctr 2680 2681 ppc_stub_long_branch and ppc_stub_plt_branch may also have additional 2682 code to adjust the value and save r2 to support multiple toc sections. 2683 A ppc_stub_long_branch with an r2 offset looks like: 2684 . std %r2,40(%r1) 2685 . addis %r2,%r2,off@ha 2686 . addi %r2,%r2,off@l 2687 . b dest 2688 2689 A ppc_stub_plt_branch with an r2 offset looks like: 2690 . std %r2,40(%r1) 2691 . addis %r12,%r2,xxx@toc@ha 2692 . ld %r11,xxx@toc@l(%r12) 2693 . addis %r2,%r2,off@ha 2694 . addi %r2,%r2,off@l 2695 . mtctr %r11 2696 . bctr 2697*/ 2698 2699enum ppc_stub_type { 2700 ppc_stub_none, 2701 ppc_stub_long_branch, 2702 ppc_stub_long_branch_r2off, 2703 ppc_stub_plt_branch, 2704 ppc_stub_plt_branch_r2off, 2705 ppc_stub_plt_call 2706}; 2707 2708struct ppc_stub_hash_entry { 2709 2710 /* Base hash table entry structure. */ 2711 struct bfd_hash_entry root; 2712 2713 enum ppc_stub_type stub_type; 2714 2715 /* The stub section. */ 2716 asection *stub_sec; 2717 2718 /* Offset within stub_sec of the beginning of this stub. */ 2719 bfd_vma stub_offset; 2720 2721 /* Given the symbol's value and its section we can determine its final 2722 value when building the stubs (so the stub knows where to jump. */ 2723 bfd_vma target_value; 2724 asection *target_section; 2725 2726 /* The symbol table entry, if any, that this was derived from. */ 2727 struct ppc_link_hash_entry *h; 2728 2729 /* And the reloc addend that this was derived from. */ 2730 bfd_vma addend; 2731 2732 /* Where this stub is being called from, or, in the case of combined 2733 stub sections, the first input section in the group. */ 2734 asection *id_sec; 2735}; 2736 2737struct ppc_branch_hash_entry { 2738 2739 /* Base hash table entry structure. */ 2740 struct bfd_hash_entry root; 2741 2742 /* Offset within .branch_lt. */ 2743 unsigned int offset; 2744 2745 /* Generation marker. */ 2746 unsigned int iter; 2747}; 2748 2749struct ppc_link_hash_entry 2750{ 2751 struct elf_link_hash_entry elf; 2752 2753 /* A pointer to the most recently used stub hash entry against this 2754 symbol. */ 2755 struct ppc_stub_hash_entry *stub_cache; 2756 2757 /* Track dynamic relocs copied for this symbol. */ 2758 struct ppc_dyn_relocs *dyn_relocs; 2759 2760 /* Link between function code and descriptor symbols. */ 2761 struct elf_link_hash_entry *oh; 2762 2763 /* Flag function code and descriptor symbols. */ 2764 unsigned int is_func:1; 2765 unsigned int is_func_descriptor:1; 2766 unsigned int is_entry:1; 2767 2768 /* Whether global opd sym has been adjusted or not. */ 2769 unsigned int adjust_done:1; 2770 2771 /* Contexts in which symbol is used in the GOT (or TOC). 2772 TLS_GD .. TLS_EXPLICIT bits are or'd into the mask as the 2773 corresponding relocs are encountered during check_relocs. 2774 tls_optimize clears TLS_GD .. TLS_TPREL when optimizing to 2775 indicate the corresponding GOT entry type is not needed. 2776 tls_optimize may also set TLS_TPRELGD when a GD reloc turns into 2777 a TPREL one. We use a separate flag rather than setting TPREL 2778 just for convenience in distinguishing the two cases. */ 2779#define TLS_GD 1 /* GD reloc. */ 2780#define TLS_LD 2 /* LD reloc. */ 2781#define TLS_TPREL 4 /* TPREL reloc, => IE. */ 2782#define TLS_DTPREL 8 /* DTPREL reloc, => LD. */ 2783#define TLS_TLS 16 /* Any TLS reloc. */ 2784#define TLS_EXPLICIT 32 /* Marks TOC section TLS relocs. */ 2785#define TLS_TPRELGD 64 /* TPREL reloc resulting from GD->IE. */ 2786 char tls_mask; 2787}; 2788 2789/* ppc64 ELF linker hash table. */ 2790 2791struct ppc_link_hash_table 2792{ 2793 struct elf_link_hash_table elf; 2794 2795 /* The stub hash table. */ 2796 struct bfd_hash_table stub_hash_table; 2797 2798 /* Another hash table for plt_branch stubs. */ 2799 struct bfd_hash_table branch_hash_table; 2800 2801 /* Linker stub bfd. */ 2802 bfd *stub_bfd; 2803 2804 /* Linker call-backs. */ 2805 asection * (*add_stub_section) (const char *, asection *); 2806 void (*layout_sections_again) (void); 2807 2808 /* Array to keep track of which stub sections have been created, and 2809 information on stub grouping. */ 2810 struct map_stub { 2811 /* This is the section to which stubs in the group will be attached. */ 2812 asection *link_sec; 2813 /* The stub section. */ 2814 asection *stub_sec; 2815 /* Along with elf_gp, specifies the TOC pointer used in this group. */ 2816 bfd_vma toc_off; 2817 } *stub_group; 2818 2819 /* Support for multiple toc sections. */ 2820 unsigned int no_multi_toc; 2821 unsigned int multi_toc_needed; 2822 2823 /* Temp used when calculating TOC pointers. */ 2824 bfd_vma toc_curr; 2825 2826 /* Highest input section id. */ 2827 int top_id; 2828 2829 /* Highest output section index. */ 2830 int top_index; 2831 2832 /* List of input sections for each output section. */ 2833 asection **input_list; 2834 2835 /* Short-cuts to get to dynamic linker sections. */ 2836 asection *got; 2837 asection *plt; 2838 asection *relplt; 2839 asection *dynbss; 2840 asection *relbss; 2841 asection *glink; 2842 asection *sfpr; 2843 asection *brlt; 2844 asection *relbrlt; 2845 2846 /* Shortcut to .__tls_get_addr. */ 2847 struct elf_link_hash_entry *tls_get_addr; 2848 2849 /* Statistics. */ 2850 unsigned long stub_count[ppc_stub_plt_call]; 2851 2852 /* Set if we should emit symbols for stubs. */ 2853 unsigned int emit_stub_syms; 2854 2855 /* Set on error. */ 2856 unsigned int stub_error; 2857 2858 /* Flag set when small branches are detected. Used to 2859 select suitable defaults for the stub group size. */ 2860 unsigned int has_14bit_branch; 2861 2862 /* Set if we detect a reference undefined weak symbol. */ 2863 unsigned int have_undefweak; 2864 2865 /* Incremented every time we size stubs. */ 2866 unsigned int stub_iteration; 2867 2868 /* Small local sym to section mapping cache. */ 2869 struct sym_sec_cache sym_sec; 2870}; 2871 2872/* Get the ppc64 ELF linker hash table from a link_info structure. */ 2873 2874#define ppc_hash_table(p) \ 2875 ((struct ppc_link_hash_table *) ((p)->hash)) 2876 2877#define ppc_stub_hash_lookup(table, string, create, copy) \ 2878 ((struct ppc_stub_hash_entry *) \ 2879 bfd_hash_lookup ((table), (string), (create), (copy))) 2880 2881#define ppc_branch_hash_lookup(table, string, create, copy) \ 2882 ((struct ppc_branch_hash_entry *) \ 2883 bfd_hash_lookup ((table), (string), (create), (copy))) 2884 2885/* Create an entry in the stub hash table. */ 2886 2887static struct bfd_hash_entry * 2888stub_hash_newfunc (struct bfd_hash_entry *entry, 2889 struct bfd_hash_table *table, 2890 const char *string) 2891{ 2892 /* Allocate the structure if it has not already been allocated by a 2893 subclass. */ 2894 if (entry == NULL) 2895 { 2896 entry = bfd_hash_allocate (table, sizeof (struct ppc_stub_hash_entry)); 2897 if (entry == NULL) 2898 return entry; 2899 } 2900 2901 /* Call the allocation method of the superclass. */ 2902 entry = bfd_hash_newfunc (entry, table, string); 2903 if (entry != NULL) 2904 { 2905 struct ppc_stub_hash_entry *eh; 2906 2907 /* Initialize the local fields. */ 2908 eh = (struct ppc_stub_hash_entry *) entry; 2909 eh->stub_type = ppc_stub_none; 2910 eh->stub_sec = NULL; 2911 eh->stub_offset = 0; 2912 eh->target_value = 0; 2913 eh->target_section = NULL; 2914 eh->h = NULL; 2915 eh->id_sec = NULL; 2916 } 2917 2918 return entry; 2919} 2920 2921/* Create an entry in the branch hash table. */ 2922 2923static struct bfd_hash_entry * 2924branch_hash_newfunc (struct bfd_hash_entry *entry, 2925 struct bfd_hash_table *table, 2926 const char *string) 2927{ 2928 /* Allocate the structure if it has not already been allocated by a 2929 subclass. */ 2930 if (entry == NULL) 2931 { 2932 entry = bfd_hash_allocate (table, sizeof (struct ppc_branch_hash_entry)); 2933 if (entry == NULL) 2934 return entry; 2935 } 2936 2937 /* Call the allocation method of the superclass. */ 2938 entry = bfd_hash_newfunc (entry, table, string); 2939 if (entry != NULL) 2940 { 2941 struct ppc_branch_hash_entry *eh; 2942 2943 /* Initialize the local fields. */ 2944 eh = (struct ppc_branch_hash_entry *) entry; 2945 eh->offset = 0; 2946 eh->iter = 0; 2947 } 2948 2949 return entry; 2950} 2951 2952/* Create an entry in a ppc64 ELF linker hash table. */ 2953 2954static struct bfd_hash_entry * 2955link_hash_newfunc (struct bfd_hash_entry *entry, 2956 struct bfd_hash_table *table, 2957 const char *string) 2958{ 2959 /* Allocate the structure if it has not already been allocated by a 2960 subclass. */ 2961 if (entry == NULL) 2962 { 2963 entry = bfd_hash_allocate (table, sizeof (struct ppc_link_hash_entry)); 2964 if (entry == NULL) 2965 return entry; 2966 } 2967 2968 /* Call the allocation method of the superclass. */ 2969 entry = _bfd_elf_link_hash_newfunc (entry, table, string); 2970 if (entry != NULL) 2971 { 2972 struct ppc_link_hash_entry *eh = (struct ppc_link_hash_entry *) entry; 2973 2974 eh->stub_cache = NULL; 2975 eh->dyn_relocs = NULL; 2976 eh->oh = NULL; 2977 eh->is_func = 0; 2978 eh->is_func_descriptor = 0; 2979 eh->is_entry = 0; 2980 eh->adjust_done = 0; 2981 eh->tls_mask = 0; 2982 } 2983 2984 return entry; 2985} 2986 2987/* Create a ppc64 ELF linker hash table. */ 2988 2989static struct bfd_link_hash_table * 2990ppc64_elf_link_hash_table_create (bfd *abfd) 2991{ 2992 struct ppc_link_hash_table *htab; 2993 bfd_size_type amt = sizeof (struct ppc_link_hash_table); 2994 2995 htab = bfd_zmalloc (amt); 2996 if (htab == NULL) 2997 return NULL; 2998 2999 if (! _bfd_elf_link_hash_table_init (&htab->elf, abfd, link_hash_newfunc)) 3000 { 3001 free (htab); 3002 return NULL; 3003 } 3004 3005 /* Init the stub hash table too. */ 3006 if (!bfd_hash_table_init (&htab->stub_hash_table, stub_hash_newfunc)) 3007 return NULL; 3008 3009 /* And the branch hash table. */ 3010 if (!bfd_hash_table_init (&htab->branch_hash_table, branch_hash_newfunc)) 3011 return NULL; 3012 3013 /* Initializing two fields of the union is just cosmetic. We really 3014 only care about glist, but when compiled on a 32-bit host the 3015 bfd_vma fields are larger. Setting the bfd_vma to zero makes 3016 debugger inspection of these fields look nicer. */ 3017 htab->elf.init_refcount.refcount = 0; 3018 htab->elf.init_refcount.glist = NULL; 3019 htab->elf.init_offset.offset = 0; 3020 htab->elf.init_offset.glist = NULL; 3021 3022 return &htab->elf.root; 3023} 3024 3025/* Free the derived linker hash table. */ 3026 3027static void 3028ppc64_elf_link_hash_table_free (struct bfd_link_hash_table *hash) 3029{ 3030 struct ppc_link_hash_table *ret = (struct ppc_link_hash_table *) hash; 3031 3032 bfd_hash_table_free (&ret->stub_hash_table); 3033 bfd_hash_table_free (&ret->branch_hash_table); 3034 _bfd_generic_link_hash_table_free (hash); 3035} 3036 3037/* Satisfy the ELF linker by filling in some fields in our fake bfd. */ 3038 3039void 3040ppc64_elf_init_stub_bfd (bfd *abfd, struct bfd_link_info *info) 3041{ 3042 struct ppc_link_hash_table *htab; 3043 3044 elf_elfheader (abfd)->e_ident[EI_CLASS] = ELFCLASS64; 3045 3046/* Always hook our dynamic sections into the first bfd, which is the 3047 linker created stub bfd. This ensures that the GOT header is at 3048 the start of the output TOC section. */ 3049 htab = ppc_hash_table (info); 3050 htab->stub_bfd = abfd; 3051 htab->elf.dynobj = abfd; 3052} 3053 3054/* Build a name for an entry in the stub hash table. */ 3055 3056static char * 3057ppc_stub_name (const asection *input_section, 3058 const asection *sym_sec, 3059 const struct ppc_link_hash_entry *h, 3060 const Elf_Internal_Rela *rel) 3061{ 3062 char *stub_name; 3063 bfd_size_type len; 3064 3065 /* rel->r_addend is actually 64 bit, but who uses more than +/- 2^31 3066 offsets from a sym as a branch target? In fact, we could 3067 probably assume the addend is always zero. */ 3068 BFD_ASSERT (((int) rel->r_addend & 0xffffffff) == rel->r_addend); 3069 3070 if (h) 3071 { 3072 len = 8 + 1 + strlen (h->elf.root.root.string) + 1 + 8 + 1; 3073 stub_name = bfd_malloc (len); 3074 if (stub_name != NULL) 3075 { 3076 sprintf (stub_name, "%08x.%s+%x", 3077 input_section->id & 0xffffffff, 3078 h->elf.root.root.string, 3079 (int) rel->r_addend & 0xffffffff); 3080 } 3081 } 3082 else 3083 { 3084 len = 8 + 1 + 8 + 1 + 8 + 1 + 8 + 1; 3085 stub_name = bfd_malloc (len); 3086 if (stub_name != NULL) 3087 { 3088 sprintf (stub_name, "%08x.%x:%x+%x", 3089 input_section->id & 0xffffffff, 3090 sym_sec->id & 0xffffffff, 3091 (int) ELF64_R_SYM (rel->r_info) & 0xffffffff, 3092 (int) rel->r_addend & 0xffffffff); 3093 } 3094 } 3095 return stub_name; 3096} 3097 3098/* Look up an entry in the stub hash. Stub entries are cached because 3099 creating the stub name takes a bit of time. */ 3100 3101static struct ppc_stub_hash_entry * 3102ppc_get_stub_entry (const asection *input_section, 3103 const asection *sym_sec, 3104 struct elf_link_hash_entry *hash, 3105 const Elf_Internal_Rela *rel, 3106 struct ppc_link_hash_table *htab) 3107{ 3108 struct ppc_stub_hash_entry *stub_entry; 3109 struct ppc_link_hash_entry *h = (struct ppc_link_hash_entry *) hash; 3110 const asection *id_sec; 3111 3112 /* If this input section is part of a group of sections sharing one 3113 stub section, then use the id of the first section in the group. 3114 Stub names need to include a section id, as there may well be 3115 more than one stub used to reach say, printf, and we need to 3116 distinguish between them. */ 3117 id_sec = htab->stub_group[input_section->id].link_sec; 3118 3119 if (h != NULL && h->stub_cache != NULL 3120 && h->stub_cache->h == h 3121 && h->stub_cache->id_sec == id_sec) 3122 { 3123 stub_entry = h->stub_cache; 3124 } 3125 else 3126 { 3127 char *stub_name; 3128 3129 stub_name = ppc_stub_name (id_sec, sym_sec, h, rel); 3130 if (stub_name == NULL) 3131 return NULL; 3132 3133 stub_entry = ppc_stub_hash_lookup (&htab->stub_hash_table, 3134 stub_name, FALSE, FALSE); 3135 if (h != NULL) 3136 h->stub_cache = stub_entry; 3137 3138 free (stub_name); 3139 } 3140 3141 return stub_entry; 3142} 3143 3144/* Add a new stub entry to the stub hash. Not all fields of the new 3145 stub entry are initialised. */ 3146 3147static struct ppc_stub_hash_entry * 3148ppc_add_stub (const char *stub_name, 3149 asection *section, 3150 struct ppc_link_hash_table *htab) 3151{ 3152 asection *link_sec; 3153 asection *stub_sec; 3154 struct ppc_stub_hash_entry *stub_entry; 3155 3156 link_sec = htab->stub_group[section->id].link_sec; 3157 stub_sec = htab->stub_group[section->id].stub_sec; 3158 if (stub_sec == NULL) 3159 { 3160 stub_sec = htab->stub_group[link_sec->id].stub_sec; 3161 if (stub_sec == NULL) 3162 { 3163 size_t namelen; 3164 bfd_size_type len; 3165 char *s_name; 3166 3167 namelen = strlen (link_sec->name); 3168 len = namelen + sizeof (STUB_SUFFIX); 3169 s_name = bfd_alloc (htab->stub_bfd, len); 3170 if (s_name == NULL) 3171 return NULL; 3172 3173 memcpy (s_name, link_sec->name, namelen); 3174 memcpy (s_name + namelen, STUB_SUFFIX, sizeof (STUB_SUFFIX)); 3175 stub_sec = (*htab->add_stub_section) (s_name, link_sec); 3176 if (stub_sec == NULL) 3177 return NULL; 3178 htab->stub_group[link_sec->id].stub_sec = stub_sec; 3179 } 3180 htab->stub_group[section->id].stub_sec = stub_sec; 3181 } 3182 3183 /* Enter this entry into the linker stub hash table. */ 3184 stub_entry = ppc_stub_hash_lookup (&htab->stub_hash_table, stub_name, 3185 TRUE, FALSE); 3186 if (stub_entry == NULL) 3187 { 3188 (*_bfd_error_handler) (_("%s: cannot create stub entry %s"), 3189 bfd_archive_filename (section->owner), 3190 stub_name); 3191 return NULL; 3192 } 3193 3194 stub_entry->stub_sec = stub_sec; 3195 stub_entry->stub_offset = 0; 3196 stub_entry->id_sec = link_sec; 3197 return stub_entry; 3198} 3199 3200/* Create sections for linker generated code. */ 3201 3202static bfd_boolean 3203create_linkage_sections (bfd *dynobj, struct bfd_link_info *info) 3204{ 3205 struct ppc_link_hash_table *htab; 3206 flagword flags; 3207 3208 htab = ppc_hash_table (info); 3209 3210 /* Create .sfpr for code to save and restore fp regs. */ 3211 flags = (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_READONLY 3212 | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED); 3213 htab->sfpr = bfd_make_section_anyway (dynobj, ".sfpr"); 3214 if (htab->sfpr == NULL 3215 || ! bfd_set_section_flags (dynobj, htab->sfpr, flags) 3216 || ! bfd_set_section_alignment (dynobj, htab->sfpr, 2)) 3217 return FALSE; 3218 3219 /* Create .glink for lazy dynamic linking support. */ 3220 htab->glink = bfd_make_section_anyway (dynobj, ".glink"); 3221 if (htab->glink == NULL 3222 || ! bfd_set_section_flags (dynobj, htab->glink, flags) 3223 || ! bfd_set_section_alignment (dynobj, htab->glink, 2)) 3224 return FALSE; 3225 3226 /* Create .branch_lt for plt_branch stubs. */ 3227 flags = (SEC_ALLOC | SEC_LOAD 3228 | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED); 3229 htab->brlt = bfd_make_section_anyway (dynobj, ".branch_lt"); 3230 if (htab->brlt == NULL 3231 || ! bfd_set_section_flags (dynobj, htab->brlt, flags) 3232 || ! bfd_set_section_alignment (dynobj, htab->brlt, 3)) 3233 return FALSE; 3234 3235 if (info->shared) 3236 { 3237 flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY 3238 | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED); 3239 htab->relbrlt = bfd_make_section_anyway (dynobj, ".rela.branch_lt"); 3240 if (!htab->relbrlt 3241 || ! bfd_set_section_flags (dynobj, htab->relbrlt, flags) 3242 || ! bfd_set_section_alignment (dynobj, htab->relbrlt, 3)) 3243 return FALSE; 3244 } 3245 return TRUE; 3246} 3247 3248/* Create .got and .rela.got sections in ABFD, and .got in dynobj if 3249 not already done. */ 3250 3251static bfd_boolean 3252create_got_section (bfd *abfd, struct bfd_link_info *info) 3253{ 3254 asection *got, *relgot; 3255 flagword flags; 3256 struct ppc_link_hash_table *htab = ppc_hash_table (info); 3257 3258 if (!htab->got) 3259 { 3260 if (! _bfd_elf_create_got_section (htab->elf.dynobj, info)) 3261 return FALSE; 3262 3263 htab->got = bfd_get_section_by_name (htab->elf.dynobj, ".got"); 3264 if (!htab->got) 3265 abort (); 3266 } 3267 3268 flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY 3269 | SEC_LINKER_CREATED); 3270
| 1/* PowerPC64-specific support for 64-bit ELF. 2 Copyright 1999, 2000, 2001, 2002, 2003, 2004 3 Free Software Foundation, Inc. 4 Written by Linus Nordberg, Swox AB <info@swox.com>, 5 based on elf32-ppc.c by Ian Lance Taylor. 6 Largely rewritten by Alan Modra <amodra@bigpond.net.au> 7 8 This file is part of BFD, the Binary File Descriptor library. 9 10 This program is free software; you can redistribute it and/or modify 11 it under the terms of the GNU General Public License as published by 12 the Free Software Foundation; either version 2 of the License, or 13 (at your option) any later version. 14 15 This program is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 GNU General Public License for more details. 19 20 You should have received a copy of the GNU General Public License along 21 with this program; if not, write to the Free Software Foundation, Inc., 22 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 23 24/* The 64-bit PowerPC ELF ABI may be found at 25 http://www.linuxbase.org/spec/ELF/ppc64/PPC-elf64abi.txt, and 26 http://www.linuxbase.org/spec/ELF/ppc64/spec/book1.html */ 27 28#include "bfd.h" 29#include "sysdep.h" 30#include "bfdlink.h" 31#include "libbfd.h" 32#include "elf-bfd.h" 33#include "elf/ppc64.h" 34#include "elf64-ppc.h" 35 36static bfd_reloc_status_type ppc64_elf_ha_reloc 37 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); 38static bfd_reloc_status_type ppc64_elf_brtaken_reloc 39 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); 40static bfd_reloc_status_type ppc64_elf_sectoff_reloc 41 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); 42static bfd_reloc_status_type ppc64_elf_sectoff_ha_reloc 43 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); 44static bfd_reloc_status_type ppc64_elf_toc_reloc 45 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); 46static bfd_reloc_status_type ppc64_elf_toc_ha_reloc 47 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); 48static bfd_reloc_status_type ppc64_elf_toc64_reloc 49 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); 50static bfd_reloc_status_type ppc64_elf_unhandled_reloc 51 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); 52 53 54#define TARGET_LITTLE_SYM bfd_elf64_powerpcle_vec 55#define TARGET_LITTLE_NAME "elf64-powerpcle" 56#define TARGET_BIG_SYM bfd_elf64_powerpc_vec 57#define TARGET_BIG_NAME "elf64-powerpc" 58#define ELF_ARCH bfd_arch_powerpc 59#define ELF_MACHINE_CODE EM_PPC64 60#define ELF_MAXPAGESIZE 0x10000 61#define elf_info_to_howto ppc64_elf_info_to_howto 62 63#define elf_backend_want_got_sym 0 64#define elf_backend_want_plt_sym 0 65#define elf_backend_plt_alignment 3 66#define elf_backend_plt_not_loaded 1 67#define elf_backend_got_symbol_offset 0 68#define elf_backend_got_header_size 8 69#define elf_backend_can_gc_sections 1 70#define elf_backend_can_refcount 1 71#define elf_backend_rela_normal 1 72 73#define bfd_elf64_mkobject ppc64_elf_mkobject 74#define bfd_elf64_bfd_reloc_type_lookup ppc64_elf_reloc_type_lookup 75#define bfd_elf64_bfd_merge_private_bfd_data ppc64_elf_merge_private_bfd_data 76#define bfd_elf64_new_section_hook ppc64_elf_new_section_hook 77#define bfd_elf64_bfd_link_hash_table_create ppc64_elf_link_hash_table_create 78#define bfd_elf64_bfd_link_hash_table_free ppc64_elf_link_hash_table_free 79 80#define elf_backend_object_p ppc64_elf_object_p 81#define elf_backend_grok_prstatus ppc64_elf_grok_prstatus 82#define elf_backend_grok_psinfo ppc64_elf_grok_psinfo 83#define elf_backend_create_dynamic_sections ppc64_elf_create_dynamic_sections 84#define elf_backend_copy_indirect_symbol ppc64_elf_copy_indirect_symbol 85#define elf_backend_add_symbol_hook ppc64_elf_add_symbol_hook 86#define elf_backend_check_relocs ppc64_elf_check_relocs 87#define elf_backend_gc_mark_hook ppc64_elf_gc_mark_hook 88#define elf_backend_gc_sweep_hook ppc64_elf_gc_sweep_hook 89#define elf_backend_adjust_dynamic_symbol ppc64_elf_adjust_dynamic_symbol 90#define elf_backend_hide_symbol ppc64_elf_hide_symbol 91#define elf_backend_always_size_sections ppc64_elf_func_desc_adjust 92#define elf_backend_size_dynamic_sections ppc64_elf_size_dynamic_sections 93#define elf_backend_relocate_section ppc64_elf_relocate_section 94#define elf_backend_finish_dynamic_symbol ppc64_elf_finish_dynamic_symbol 95#define elf_backend_reloc_type_class ppc64_elf_reloc_type_class 96#define elf_backend_finish_dynamic_sections ppc64_elf_finish_dynamic_sections 97#define elf_backend_link_output_symbol_hook ppc64_elf_output_symbol_hook 98#define elf_backend_special_sections ppc64_elf_special_sections 99 100/* The name of the dynamic interpreter. This is put in the .interp 101 section. */ 102#define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1" 103 104/* The size in bytes of an entry in the procedure linkage table. */ 105#define PLT_ENTRY_SIZE 24 106 107/* The initial size of the plt reserved for the dynamic linker. */ 108#define PLT_INITIAL_ENTRY_SIZE PLT_ENTRY_SIZE 109 110/* TOC base pointers offset from start of TOC. */ 111#define TOC_BASE_OFF 0x8000 112 113/* Offset of tp and dtp pointers from start of TLS block. */ 114#define TP_OFFSET 0x7000 115#define DTP_OFFSET 0x8000 116 117/* .plt call stub instructions. The normal stub is like this, but 118 sometimes the .plt entry crosses a 64k boundary and we need to 119 insert an addis to adjust r12. */ 120#define PLT_CALL_STUB_SIZE (7*4) 121#define ADDIS_R12_R2 0x3d820000 /* addis %r12,%r2,xxx@ha */ 122#define STD_R2_40R1 0xf8410028 /* std %r2,40(%r1) */ 123#define LD_R11_0R12 0xe96c0000 /* ld %r11,xxx+0@l(%r12) */ 124#define LD_R2_0R12 0xe84c0000 /* ld %r2,xxx+8@l(%r12) */ 125#define MTCTR_R11 0x7d6903a6 /* mtctr %r11 */ 126 /* ld %r11,xxx+16@l(%r12) */ 127#define BCTR 0x4e800420 /* bctr */ 128 129 130#define ADDIS_R2_R2 0x3c420000 /* addis %r2,%r2,off@ha */ 131#define ADDI_R2_R2 0x38420000 /* addi %r2,%r2,off@l */ 132 133#define LD_R2_40R1 0xe8410028 /* ld %r2,40(%r1) */ 134 135/* glink call stub instructions. We enter with the index in R0, and the 136 address of glink entry in CTR. From that, we can calculate PLT0. */ 137#define GLINK_CALL_STUB_SIZE (16*4) 138#define MFCTR_R12 0x7d8902a6 /* mfctr %r12 */ 139#define SLDI_R11_R0_3 0x780b1f24 /* sldi %r11,%r0,3 */ 140#define ADDIC_R2_R0_32K 0x34408000 /* addic. %r2,%r0,-32768 */ 141#define SUB_R12_R12_R11 0x7d8b6050 /* sub %r12,%r12,%r11 */ 142#define SRADI_R2_R2_63 0x7c42fe76 /* sradi %r2,%r2,63 */ 143#define SLDI_R11_R0_2 0x780b1764 /* sldi %r11,%r0,2 */ 144#define AND_R2_R2_R11 0x7c425838 /* and %r2,%r2,%r11 */ 145 /* sub %r12,%r12,%r11 */ 146#define ADD_R12_R12_R2 0x7d8c1214 /* add %r12,%r12,%r2 */ 147#define ADDIS_R12_R12 0x3d8c0000 /* addis %r12,%r12,xxx@ha */ 148 /* ld %r11,xxx@l(%r12) */ 149#define ADDI_R12_R12 0x398c0000 /* addi %r12,%r12,xxx@l */ 150 /* ld %r2,8(%r12) */ 151 /* mtctr %r11 */ 152 /* ld %r11,16(%r12) */ 153 /* bctr */ 154 155/* Pad with this. */ 156#define NOP 0x60000000 157 158/* Some other nops. */ 159#define CROR_151515 0x4def7b82 160#define CROR_313131 0x4ffffb82 161 162/* .glink entries for the first 32k functions are two instructions. */ 163#define LI_R0_0 0x38000000 /* li %r0,0 */ 164#define B_DOT 0x48000000 /* b . */ 165 166/* After that, we need two instructions to load the index, followed by 167 a branch. */ 168#define LIS_R0_0 0x3c000000 /* lis %r0,0 */ 169#define ORI_R0_R0_0 0x60000000 /* ori %r0,%r0,0 */ 170 171/* Instructions to save and restore floating point regs. */ 172#define STFD_FR0_0R1 0xd8010000 /* stfd %fr0,0(%r1) */ 173#define LFD_FR0_0R1 0xc8010000 /* lfd %fr0,0(%r1) */ 174#define BLR 0x4e800020 /* blr */ 175 176/* Since .opd is an array of descriptors and each entry will end up 177 with identical R_PPC64_RELATIVE relocs, there is really no need to 178 propagate .opd relocs; The dynamic linker should be taught to 179 relocate .opd without reloc entries. */ 180#ifndef NO_OPD_RELOCS 181#define NO_OPD_RELOCS 0 182#endif 183 184#define ONES(n) (((bfd_vma) 1 << ((n) - 1) << 1) - 1) 185 186/* Relocation HOWTO's. */ 187static reloc_howto_type *ppc64_elf_howto_table[(int) R_PPC64_max]; 188 189static reloc_howto_type ppc64_elf_howto_raw[] = { 190 /* This reloc does nothing. */ 191 HOWTO (R_PPC64_NONE, /* type */ 192 0, /* rightshift */ 193 2, /* size (0 = byte, 1 = short, 2 = long) */ 194 32, /* bitsize */ 195 FALSE, /* pc_relative */ 196 0, /* bitpos */ 197 complain_overflow_dont, /* complain_on_overflow */ 198 bfd_elf_generic_reloc, /* special_function */ 199 "R_PPC64_NONE", /* name */ 200 FALSE, /* partial_inplace */ 201 0, /* src_mask */ 202 0, /* dst_mask */ 203 FALSE), /* pcrel_offset */ 204 205 /* A standard 32 bit relocation. */ 206 HOWTO (R_PPC64_ADDR32, /* type */ 207 0, /* rightshift */ 208 2, /* size (0 = byte, 1 = short, 2 = long) */ 209 32, /* bitsize */ 210 FALSE, /* pc_relative */ 211 0, /* bitpos */ 212 complain_overflow_bitfield, /* complain_on_overflow */ 213 bfd_elf_generic_reloc, /* special_function */ 214 "R_PPC64_ADDR32", /* name */ 215 FALSE, /* partial_inplace */ 216 0, /* src_mask */ 217 0xffffffff, /* dst_mask */ 218 FALSE), /* pcrel_offset */ 219 220 /* An absolute 26 bit branch; the lower two bits must be zero. 221 FIXME: we don't check that, we just clear them. */ 222 HOWTO (R_PPC64_ADDR24, /* type */ 223 0, /* rightshift */ 224 2, /* size (0 = byte, 1 = short, 2 = long) */ 225 26, /* bitsize */ 226 FALSE, /* pc_relative */ 227 0, /* bitpos */ 228 complain_overflow_bitfield, /* complain_on_overflow */ 229 bfd_elf_generic_reloc, /* special_function */ 230 "R_PPC64_ADDR24", /* name */ 231 FALSE, /* partial_inplace */ 232 0, /* src_mask */ 233 0x03fffffc, /* dst_mask */ 234 FALSE), /* pcrel_offset */ 235 236 /* A standard 16 bit relocation. */ 237 HOWTO (R_PPC64_ADDR16, /* type */ 238 0, /* rightshift */ 239 1, /* size (0 = byte, 1 = short, 2 = long) */ 240 16, /* bitsize */ 241 FALSE, /* pc_relative */ 242 0, /* bitpos */ 243 complain_overflow_bitfield, /* complain_on_overflow */ 244 bfd_elf_generic_reloc, /* special_function */ 245 "R_PPC64_ADDR16", /* name */ 246 FALSE, /* partial_inplace */ 247 0, /* src_mask */ 248 0xffff, /* dst_mask */ 249 FALSE), /* pcrel_offset */ 250 251 /* A 16 bit relocation without overflow. */ 252 HOWTO (R_PPC64_ADDR16_LO, /* type */ 253 0, /* rightshift */ 254 1, /* size (0 = byte, 1 = short, 2 = long) */ 255 16, /* bitsize */ 256 FALSE, /* pc_relative */ 257 0, /* bitpos */ 258 complain_overflow_dont,/* complain_on_overflow */ 259 bfd_elf_generic_reloc, /* special_function */ 260 "R_PPC64_ADDR16_LO", /* name */ 261 FALSE, /* partial_inplace */ 262 0, /* src_mask */ 263 0xffff, /* dst_mask */ 264 FALSE), /* pcrel_offset */ 265 266 /* Bits 16-31 of an address. */ 267 HOWTO (R_PPC64_ADDR16_HI, /* type */ 268 16, /* rightshift */ 269 1, /* size (0 = byte, 1 = short, 2 = long) */ 270 16, /* bitsize */ 271 FALSE, /* pc_relative */ 272 0, /* bitpos */ 273 complain_overflow_dont, /* complain_on_overflow */ 274 bfd_elf_generic_reloc, /* special_function */ 275 "R_PPC64_ADDR16_HI", /* name */ 276 FALSE, /* partial_inplace */ 277 0, /* src_mask */ 278 0xffff, /* dst_mask */ 279 FALSE), /* pcrel_offset */ 280 281 /* Bits 16-31 of an address, plus 1 if the contents of the low 16 282 bits, treated as a signed number, is negative. */ 283 HOWTO (R_PPC64_ADDR16_HA, /* type */ 284 16, /* rightshift */ 285 1, /* size (0 = byte, 1 = short, 2 = long) */ 286 16, /* bitsize */ 287 FALSE, /* pc_relative */ 288 0, /* bitpos */ 289 complain_overflow_dont, /* complain_on_overflow */ 290 ppc64_elf_ha_reloc, /* special_function */ 291 "R_PPC64_ADDR16_HA", /* name */ 292 FALSE, /* partial_inplace */ 293 0, /* src_mask */ 294 0xffff, /* dst_mask */ 295 FALSE), /* pcrel_offset */ 296 297 /* An absolute 16 bit branch; the lower two bits must be zero. 298 FIXME: we don't check that, we just clear them. */ 299 HOWTO (R_PPC64_ADDR14, /* type */ 300 0, /* rightshift */ 301 2, /* size (0 = byte, 1 = short, 2 = long) */ 302 16, /* bitsize */ 303 FALSE, /* pc_relative */ 304 0, /* bitpos */ 305 complain_overflow_bitfield, /* complain_on_overflow */ 306 bfd_elf_generic_reloc, /* special_function */ 307 "R_PPC64_ADDR14", /* name */ 308 FALSE, /* partial_inplace */ 309 0, /* src_mask */ 310 0x0000fffc, /* dst_mask */ 311 FALSE), /* pcrel_offset */ 312 313 /* An absolute 16 bit branch, for which bit 10 should be set to 314 indicate that the branch is expected to be taken. The lower two 315 bits must be zero. */ 316 HOWTO (R_PPC64_ADDR14_BRTAKEN, /* type */ 317 0, /* rightshift */ 318 2, /* size (0 = byte, 1 = short, 2 = long) */ 319 16, /* bitsize */ 320 FALSE, /* pc_relative */ 321 0, /* bitpos */ 322 complain_overflow_bitfield, /* complain_on_overflow */ 323 ppc64_elf_brtaken_reloc, /* special_function */ 324 "R_PPC64_ADDR14_BRTAKEN",/* name */ 325 FALSE, /* partial_inplace */ 326 0, /* src_mask */ 327 0x0000fffc, /* dst_mask */ 328 FALSE), /* pcrel_offset */ 329 330 /* An absolute 16 bit branch, for which bit 10 should be set to 331 indicate that the branch is not expected to be taken. The lower 332 two bits must be zero. */ 333 HOWTO (R_PPC64_ADDR14_BRNTAKEN, /* type */ 334 0, /* rightshift */ 335 2, /* size (0 = byte, 1 = short, 2 = long) */ 336 16, /* bitsize */ 337 FALSE, /* pc_relative */ 338 0, /* bitpos */ 339 complain_overflow_bitfield, /* complain_on_overflow */ 340 ppc64_elf_brtaken_reloc, /* special_function */ 341 "R_PPC64_ADDR14_BRNTAKEN",/* name */ 342 FALSE, /* partial_inplace */ 343 0, /* src_mask */ 344 0x0000fffc, /* dst_mask */ 345 FALSE), /* pcrel_offset */ 346 347 /* A relative 26 bit branch; the lower two bits must be zero. */ 348 HOWTO (R_PPC64_REL24, /* type */ 349 0, /* rightshift */ 350 2, /* size (0 = byte, 1 = short, 2 = long) */ 351 26, /* bitsize */ 352 TRUE, /* pc_relative */ 353 0, /* bitpos */ 354 complain_overflow_signed, /* complain_on_overflow */ 355 bfd_elf_generic_reloc, /* special_function */ 356 "R_PPC64_REL24", /* name */ 357 FALSE, /* partial_inplace */ 358 0, /* src_mask */ 359 0x03fffffc, /* dst_mask */ 360 TRUE), /* pcrel_offset */ 361 362 /* A relative 16 bit branch; the lower two bits must be zero. */ 363 HOWTO (R_PPC64_REL14, /* type */ 364 0, /* rightshift */ 365 2, /* size (0 = byte, 1 = short, 2 = long) */ 366 16, /* bitsize */ 367 TRUE, /* pc_relative */ 368 0, /* bitpos */ 369 complain_overflow_signed, /* complain_on_overflow */ 370 bfd_elf_generic_reloc, /* special_function */ 371 "R_PPC64_REL14", /* name */ 372 FALSE, /* partial_inplace */ 373 0, /* src_mask */ 374 0x0000fffc, /* dst_mask */ 375 TRUE), /* pcrel_offset */ 376 377 /* A relative 16 bit branch. Bit 10 should be set to indicate that 378 the branch is expected to be taken. The lower two bits must be 379 zero. */ 380 HOWTO (R_PPC64_REL14_BRTAKEN, /* type */ 381 0, /* rightshift */ 382 2, /* size (0 = byte, 1 = short, 2 = long) */ 383 16, /* bitsize */ 384 TRUE, /* pc_relative */ 385 0, /* bitpos */ 386 complain_overflow_signed, /* complain_on_overflow */ 387 ppc64_elf_brtaken_reloc, /* special_function */ 388 "R_PPC64_REL14_BRTAKEN", /* name */ 389 FALSE, /* partial_inplace */ 390 0, /* src_mask */ 391 0x0000fffc, /* dst_mask */ 392 TRUE), /* pcrel_offset */ 393 394 /* A relative 16 bit branch. Bit 10 should be set to indicate that 395 the branch is not expected to be taken. The lower two bits must 396 be zero. */ 397 HOWTO (R_PPC64_REL14_BRNTAKEN, /* type */ 398 0, /* rightshift */ 399 2, /* size (0 = byte, 1 = short, 2 = long) */ 400 16, /* bitsize */ 401 TRUE, /* pc_relative */ 402 0, /* bitpos */ 403 complain_overflow_signed, /* complain_on_overflow */ 404 ppc64_elf_brtaken_reloc, /* special_function */ 405 "R_PPC64_REL14_BRNTAKEN",/* name */ 406 FALSE, /* partial_inplace */ 407 0, /* src_mask */ 408 0x0000fffc, /* dst_mask */ 409 TRUE), /* pcrel_offset */ 410 411 /* Like R_PPC64_ADDR16, but referring to the GOT table entry for the 412 symbol. */ 413 HOWTO (R_PPC64_GOT16, /* type */ 414 0, /* rightshift */ 415 1, /* size (0 = byte, 1 = short, 2 = long) */ 416 16, /* bitsize */ 417 FALSE, /* pc_relative */ 418 0, /* bitpos */ 419 complain_overflow_signed, /* complain_on_overflow */ 420 ppc64_elf_unhandled_reloc, /* special_function */ 421 "R_PPC64_GOT16", /* name */ 422 FALSE, /* partial_inplace */ 423 0, /* src_mask */ 424 0xffff, /* dst_mask */ 425 FALSE), /* pcrel_offset */ 426 427 /* Like R_PPC64_ADDR16_LO, but referring to the GOT table entry for 428 the symbol. */ 429 HOWTO (R_PPC64_GOT16_LO, /* type */ 430 0, /* rightshift */ 431 1, /* size (0 = byte, 1 = short, 2 = long) */ 432 16, /* bitsize */ 433 FALSE, /* pc_relative */ 434 0, /* bitpos */ 435 complain_overflow_dont, /* complain_on_overflow */ 436 ppc64_elf_unhandled_reloc, /* special_function */ 437 "R_PPC64_GOT16_LO", /* name */ 438 FALSE, /* partial_inplace */ 439 0, /* src_mask */ 440 0xffff, /* dst_mask */ 441 FALSE), /* pcrel_offset */ 442 443 /* Like R_PPC64_ADDR16_HI, but referring to the GOT table entry for 444 the symbol. */ 445 HOWTO (R_PPC64_GOT16_HI, /* type */ 446 16, /* rightshift */ 447 1, /* size (0 = byte, 1 = short, 2 = long) */ 448 16, /* bitsize */ 449 FALSE, /* pc_relative */ 450 0, /* bitpos */ 451 complain_overflow_dont,/* complain_on_overflow */ 452 ppc64_elf_unhandled_reloc, /* special_function */ 453 "R_PPC64_GOT16_HI", /* name */ 454 FALSE, /* partial_inplace */ 455 0, /* src_mask */ 456 0xffff, /* dst_mask */ 457 FALSE), /* pcrel_offset */ 458 459 /* Like R_PPC64_ADDR16_HA, but referring to the GOT table entry for 460 the symbol. */ 461 HOWTO (R_PPC64_GOT16_HA, /* type */ 462 16, /* rightshift */ 463 1, /* size (0 = byte, 1 = short, 2 = long) */ 464 16, /* bitsize */ 465 FALSE, /* pc_relative */ 466 0, /* bitpos */ 467 complain_overflow_dont,/* complain_on_overflow */ 468 ppc64_elf_unhandled_reloc, /* special_function */ 469 "R_PPC64_GOT16_HA", /* name */ 470 FALSE, /* partial_inplace */ 471 0, /* src_mask */ 472 0xffff, /* dst_mask */ 473 FALSE), /* pcrel_offset */ 474 475 /* This is used only by the dynamic linker. The symbol should exist 476 both in the object being run and in some shared library. The 477 dynamic linker copies the data addressed by the symbol from the 478 shared library into the object, because the object being 479 run has to have the data at some particular address. */ 480 HOWTO (R_PPC64_COPY, /* type */ 481 0, /* rightshift */ 482 0, /* this one is variable size */ 483 0, /* bitsize */ 484 FALSE, /* pc_relative */ 485 0, /* bitpos */ 486 complain_overflow_dont, /* complain_on_overflow */ 487 ppc64_elf_unhandled_reloc, /* special_function */ 488 "R_PPC64_COPY", /* name */ 489 FALSE, /* partial_inplace */ 490 0, /* src_mask */ 491 0, /* dst_mask */ 492 FALSE), /* pcrel_offset */ 493 494 /* Like R_PPC64_ADDR64, but used when setting global offset table 495 entries. */ 496 HOWTO (R_PPC64_GLOB_DAT, /* type */ 497 0, /* rightshift */ 498 4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ 499 64, /* bitsize */ 500 FALSE, /* pc_relative */ 501 0, /* bitpos */ 502 complain_overflow_dont, /* complain_on_overflow */ 503 ppc64_elf_unhandled_reloc, /* special_function */ 504 "R_PPC64_GLOB_DAT", /* name */ 505 FALSE, /* partial_inplace */ 506 0, /* src_mask */ 507 ONES (64), /* dst_mask */ 508 FALSE), /* pcrel_offset */ 509 510 /* Created by the link editor. Marks a procedure linkage table 511 entry for a symbol. */ 512 HOWTO (R_PPC64_JMP_SLOT, /* type */ 513 0, /* rightshift */ 514 0, /* size (0 = byte, 1 = short, 2 = long) */ 515 0, /* bitsize */ 516 FALSE, /* pc_relative */ 517 0, /* bitpos */ 518 complain_overflow_dont, /* complain_on_overflow */ 519 ppc64_elf_unhandled_reloc, /* special_function */ 520 "R_PPC64_JMP_SLOT", /* name */ 521 FALSE, /* partial_inplace */ 522 0, /* src_mask */ 523 0, /* dst_mask */ 524 FALSE), /* pcrel_offset */ 525 526 /* Used only by the dynamic linker. When the object is run, this 527 doubleword64 is set to the load address of the object, plus the 528 addend. */ 529 HOWTO (R_PPC64_RELATIVE, /* type */ 530 0, /* rightshift */ 531 4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ 532 64, /* bitsize */ 533 FALSE, /* pc_relative */ 534 0, /* bitpos */ 535 complain_overflow_dont, /* complain_on_overflow */ 536 bfd_elf_generic_reloc, /* special_function */ 537 "R_PPC64_RELATIVE", /* name */ 538 FALSE, /* partial_inplace */ 539 0, /* src_mask */ 540 ONES (64), /* dst_mask */ 541 FALSE), /* pcrel_offset */ 542 543 /* Like R_PPC64_ADDR32, but may be unaligned. */ 544 HOWTO (R_PPC64_UADDR32, /* 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_bitfield, /* complain_on_overflow */ 551 bfd_elf_generic_reloc, /* special_function */ 552 "R_PPC64_UADDR32", /* name */ 553 FALSE, /* partial_inplace */ 554 0, /* src_mask */ 555 0xffffffff, /* dst_mask */ 556 FALSE), /* pcrel_offset */ 557 558 /* Like R_PPC64_ADDR16, but may be unaligned. */ 559 HOWTO (R_PPC64_UADDR16, /* type */ 560 0, /* rightshift */ 561 1, /* size (0 = byte, 1 = short, 2 = long) */ 562 16, /* bitsize */ 563 FALSE, /* pc_relative */ 564 0, /* bitpos */ 565 complain_overflow_bitfield, /* complain_on_overflow */ 566 bfd_elf_generic_reloc, /* special_function */ 567 "R_PPC64_UADDR16", /* name */ 568 FALSE, /* partial_inplace */ 569 0, /* src_mask */ 570 0xffff, /* dst_mask */ 571 FALSE), /* pcrel_offset */ 572 573 /* 32-bit PC relative. */ 574 HOWTO (R_PPC64_REL32, /* type */ 575 0, /* rightshift */ 576 2, /* size (0 = byte, 1 = short, 2 = long) */ 577 32, /* bitsize */ 578 TRUE, /* pc_relative */ 579 0, /* bitpos */ 580 /* FIXME: Verify. Was complain_overflow_bitfield. */ 581 complain_overflow_signed, /* complain_on_overflow */ 582 bfd_elf_generic_reloc, /* special_function */ 583 "R_PPC64_REL32", /* name */ 584 FALSE, /* partial_inplace */ 585 0, /* src_mask */ 586 0xffffffff, /* dst_mask */ 587 TRUE), /* pcrel_offset */ 588 589 /* 32-bit relocation to the symbol's procedure linkage table. */ 590 HOWTO (R_PPC64_PLT32, /* type */ 591 0, /* rightshift */ 592 2, /* size (0 = byte, 1 = short, 2 = long) */ 593 32, /* bitsize */ 594 FALSE, /* pc_relative */ 595 0, /* bitpos */ 596 complain_overflow_bitfield, /* complain_on_overflow */ 597 ppc64_elf_unhandled_reloc, /* special_function */ 598 "R_PPC64_PLT32", /* name */ 599 FALSE, /* partial_inplace */ 600 0, /* src_mask */ 601 0xffffffff, /* dst_mask */ 602 FALSE), /* pcrel_offset */ 603 604 /* 32-bit PC relative relocation to the symbol's procedure linkage table. 605 FIXME: R_PPC64_PLTREL32 not supported. */ 606 HOWTO (R_PPC64_PLTREL32, /* type */ 607 0, /* rightshift */ 608 2, /* size (0 = byte, 1 = short, 2 = long) */ 609 32, /* bitsize */ 610 TRUE, /* pc_relative */ 611 0, /* bitpos */ 612 complain_overflow_signed, /* complain_on_overflow */ 613 bfd_elf_generic_reloc, /* special_function */ 614 "R_PPC64_PLTREL32", /* name */ 615 FALSE, /* partial_inplace */ 616 0, /* src_mask */ 617 0xffffffff, /* dst_mask */ 618 TRUE), /* pcrel_offset */ 619 620 /* Like R_PPC64_ADDR16_LO, but referring to the PLT table entry for 621 the symbol. */ 622 HOWTO (R_PPC64_PLT16_LO, /* type */ 623 0, /* rightshift */ 624 1, /* size (0 = byte, 1 = short, 2 = long) */ 625 16, /* bitsize */ 626 FALSE, /* pc_relative */ 627 0, /* bitpos */ 628 complain_overflow_dont, /* complain_on_overflow */ 629 ppc64_elf_unhandled_reloc, /* special_function */ 630 "R_PPC64_PLT16_LO", /* name */ 631 FALSE, /* partial_inplace */ 632 0, /* src_mask */ 633 0xffff, /* dst_mask */ 634 FALSE), /* pcrel_offset */ 635 636 /* Like R_PPC64_ADDR16_HI, but referring to the PLT table entry for 637 the symbol. */ 638 HOWTO (R_PPC64_PLT16_HI, /* type */ 639 16, /* rightshift */ 640 1, /* size (0 = byte, 1 = short, 2 = long) */ 641 16, /* bitsize */ 642 FALSE, /* pc_relative */ 643 0, /* bitpos */ 644 complain_overflow_dont, /* complain_on_overflow */ 645 ppc64_elf_unhandled_reloc, /* special_function */ 646 "R_PPC64_PLT16_HI", /* name */ 647 FALSE, /* partial_inplace */ 648 0, /* src_mask */ 649 0xffff, /* dst_mask */ 650 FALSE), /* pcrel_offset */ 651 652 /* Like R_PPC64_ADDR16_HA, but referring to the PLT table entry for 653 the symbol. */ 654 HOWTO (R_PPC64_PLT16_HA, /* type */ 655 16, /* rightshift */ 656 1, /* size (0 = byte, 1 = short, 2 = long) */ 657 16, /* bitsize */ 658 FALSE, /* pc_relative */ 659 0, /* bitpos */ 660 complain_overflow_dont, /* complain_on_overflow */ 661 ppc64_elf_unhandled_reloc, /* special_function */ 662 "R_PPC64_PLT16_HA", /* name */ 663 FALSE, /* partial_inplace */ 664 0, /* src_mask */ 665 0xffff, /* dst_mask */ 666 FALSE), /* pcrel_offset */ 667 668 /* 16-bit section relative relocation. */ 669 HOWTO (R_PPC64_SECTOFF, /* type */ 670 0, /* rightshift */ 671 1, /* size (0 = byte, 1 = short, 2 = long) */ 672 16, /* bitsize */ 673 FALSE, /* pc_relative */ 674 0, /* bitpos */ 675 complain_overflow_bitfield, /* complain_on_overflow */ 676 ppc64_elf_sectoff_reloc, /* special_function */ 677 "R_PPC64_SECTOFF", /* name */ 678 FALSE, /* partial_inplace */ 679 0, /* src_mask */ 680 0xffff, /* dst_mask */ 681 FALSE), /* pcrel_offset */ 682 683 /* Like R_PPC64_SECTOFF, but no overflow warning. */ 684 HOWTO (R_PPC64_SECTOFF_LO, /* type */ 685 0, /* rightshift */ 686 1, /* size (0 = byte, 1 = short, 2 = long) */ 687 16, /* bitsize */ 688 FALSE, /* pc_relative */ 689 0, /* bitpos */ 690 complain_overflow_dont, /* complain_on_overflow */ 691 ppc64_elf_sectoff_reloc, /* special_function */ 692 "R_PPC64_SECTOFF_LO", /* name */ 693 FALSE, /* partial_inplace */ 694 0, /* src_mask */ 695 0xffff, /* dst_mask */ 696 FALSE), /* pcrel_offset */ 697 698 /* 16-bit upper half section relative relocation. */ 699 HOWTO (R_PPC64_SECTOFF_HI, /* type */ 700 16, /* rightshift */ 701 1, /* size (0 = byte, 1 = short, 2 = long) */ 702 16, /* bitsize */ 703 FALSE, /* pc_relative */ 704 0, /* bitpos */ 705 complain_overflow_dont, /* complain_on_overflow */ 706 ppc64_elf_sectoff_reloc, /* special_function */ 707 "R_PPC64_SECTOFF_HI", /* name */ 708 FALSE, /* partial_inplace */ 709 0, /* src_mask */ 710 0xffff, /* dst_mask */ 711 FALSE), /* pcrel_offset */ 712 713 /* 16-bit upper half adjusted section relative relocation. */ 714 HOWTO (R_PPC64_SECTOFF_HA, /* type */ 715 16, /* rightshift */ 716 1, /* size (0 = byte, 1 = short, 2 = long) */ 717 16, /* bitsize */ 718 FALSE, /* pc_relative */ 719 0, /* bitpos */ 720 complain_overflow_dont, /* complain_on_overflow */ 721 ppc64_elf_sectoff_ha_reloc, /* special_function */ 722 "R_PPC64_SECTOFF_HA", /* name */ 723 FALSE, /* partial_inplace */ 724 0, /* src_mask */ 725 0xffff, /* dst_mask */ 726 FALSE), /* pcrel_offset */ 727 728 /* Like R_PPC64_REL24 without touching the two least significant bits. */ 729 HOWTO (R_PPC64_REL30, /* type */ 730 2, /* rightshift */ 731 2, /* size (0 = byte, 1 = short, 2 = long) */ 732 30, /* bitsize */ 733 TRUE, /* pc_relative */ 734 0, /* bitpos */ 735 complain_overflow_dont, /* complain_on_overflow */ 736 bfd_elf_generic_reloc, /* special_function */ 737 "R_PPC64_REL30", /* name */ 738 FALSE, /* partial_inplace */ 739 0, /* src_mask */ 740 0xfffffffc, /* dst_mask */ 741 TRUE), /* pcrel_offset */ 742 743 /* Relocs in the 64-bit PowerPC ELF ABI, not in the 32-bit ABI. */ 744 745 /* A standard 64-bit relocation. */ 746 HOWTO (R_PPC64_ADDR64, /* type */ 747 0, /* rightshift */ 748 4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ 749 64, /* bitsize */ 750 FALSE, /* pc_relative */ 751 0, /* bitpos */ 752 complain_overflow_dont, /* complain_on_overflow */ 753 bfd_elf_generic_reloc, /* special_function */ 754 "R_PPC64_ADDR64", /* name */ 755 FALSE, /* partial_inplace */ 756 0, /* src_mask */ 757 ONES (64), /* dst_mask */ 758 FALSE), /* pcrel_offset */ 759 760 /* The bits 32-47 of an address. */ 761 HOWTO (R_PPC64_ADDR16_HIGHER, /* type */ 762 32, /* rightshift */ 763 1, /* size (0 = byte, 1 = short, 2 = long) */ 764 16, /* bitsize */ 765 FALSE, /* pc_relative */ 766 0, /* bitpos */ 767 complain_overflow_dont, /* complain_on_overflow */ 768 bfd_elf_generic_reloc, /* special_function */ 769 "R_PPC64_ADDR16_HIGHER", /* name */ 770 FALSE, /* partial_inplace */ 771 0, /* src_mask */ 772 0xffff, /* dst_mask */ 773 FALSE), /* pcrel_offset */ 774 775 /* The bits 32-47 of an address, plus 1 if the contents of the low 776 16 bits, treated as a signed number, is negative. */ 777 HOWTO (R_PPC64_ADDR16_HIGHERA, /* type */ 778 32, /* rightshift */ 779 1, /* size (0 = byte, 1 = short, 2 = long) */ 780 16, /* bitsize */ 781 FALSE, /* pc_relative */ 782 0, /* bitpos */ 783 complain_overflow_dont, /* complain_on_overflow */ 784 ppc64_elf_ha_reloc, /* special_function */ 785 "R_PPC64_ADDR16_HIGHERA", /* name */ 786 FALSE, /* partial_inplace */ 787 0, /* src_mask */ 788 0xffff, /* dst_mask */ 789 FALSE), /* pcrel_offset */ 790 791 /* The bits 48-63 of an address. */ 792 HOWTO (R_PPC64_ADDR16_HIGHEST,/* type */ 793 48, /* rightshift */ 794 1, /* size (0 = byte, 1 = short, 2 = long) */ 795 16, /* bitsize */ 796 FALSE, /* pc_relative */ 797 0, /* bitpos */ 798 complain_overflow_dont, /* complain_on_overflow */ 799 bfd_elf_generic_reloc, /* special_function */ 800 "R_PPC64_ADDR16_HIGHEST", /* name */ 801 FALSE, /* partial_inplace */ 802 0, /* src_mask */ 803 0xffff, /* dst_mask */ 804 FALSE), /* pcrel_offset */ 805 806 /* The bits 48-63 of an address, plus 1 if the contents of the low 807 16 bits, treated as a signed number, is negative. */ 808 HOWTO (R_PPC64_ADDR16_HIGHESTA,/* type */ 809 48, /* rightshift */ 810 1, /* size (0 = byte, 1 = short, 2 = long) */ 811 16, /* bitsize */ 812 FALSE, /* pc_relative */ 813 0, /* bitpos */ 814 complain_overflow_dont, /* complain_on_overflow */ 815 ppc64_elf_ha_reloc, /* special_function */ 816 "R_PPC64_ADDR16_HIGHESTA", /* name */ 817 FALSE, /* partial_inplace */ 818 0, /* src_mask */ 819 0xffff, /* dst_mask */ 820 FALSE), /* pcrel_offset */ 821 822 /* Like ADDR64, but may be unaligned. */ 823 HOWTO (R_PPC64_UADDR64, /* type */ 824 0, /* rightshift */ 825 4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ 826 64, /* bitsize */ 827 FALSE, /* pc_relative */ 828 0, /* bitpos */ 829 complain_overflow_dont, /* complain_on_overflow */ 830 bfd_elf_generic_reloc, /* special_function */ 831 "R_PPC64_UADDR64", /* name */ 832 FALSE, /* partial_inplace */ 833 0, /* src_mask */ 834 ONES (64), /* dst_mask */ 835 FALSE), /* pcrel_offset */ 836 837 /* 64-bit relative relocation. */ 838 HOWTO (R_PPC64_REL64, /* type */ 839 0, /* rightshift */ 840 4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ 841 64, /* bitsize */ 842 TRUE, /* pc_relative */ 843 0, /* bitpos */ 844 complain_overflow_dont, /* complain_on_overflow */ 845 bfd_elf_generic_reloc, /* special_function */ 846 "R_PPC64_REL64", /* name */ 847 FALSE, /* partial_inplace */ 848 0, /* src_mask */ 849 ONES (64), /* dst_mask */ 850 TRUE), /* pcrel_offset */ 851 852 /* 64-bit relocation to the symbol's procedure linkage table. */ 853 HOWTO (R_PPC64_PLT64, /* type */ 854 0, /* rightshift */ 855 4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ 856 64, /* bitsize */ 857 FALSE, /* pc_relative */ 858 0, /* bitpos */ 859 complain_overflow_dont, /* complain_on_overflow */ 860 ppc64_elf_unhandled_reloc, /* special_function */ 861 "R_PPC64_PLT64", /* name */ 862 FALSE, /* partial_inplace */ 863 0, /* src_mask */ 864 ONES (64), /* dst_mask */ 865 FALSE), /* pcrel_offset */ 866 867 /* 64-bit PC relative relocation to the symbol's procedure linkage 868 table. */ 869 /* FIXME: R_PPC64_PLTREL64 not supported. */ 870 HOWTO (R_PPC64_PLTREL64, /* type */ 871 0, /* rightshift */ 872 4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ 873 64, /* bitsize */ 874 TRUE, /* pc_relative */ 875 0, /* bitpos */ 876 complain_overflow_dont, /* complain_on_overflow */ 877 ppc64_elf_unhandled_reloc, /* special_function */ 878 "R_PPC64_PLTREL64", /* name */ 879 FALSE, /* partial_inplace */ 880 0, /* src_mask */ 881 ONES (64), /* dst_mask */ 882 TRUE), /* pcrel_offset */ 883 884 /* 16 bit TOC-relative relocation. */ 885 886 /* R_PPC64_TOC16 47 half16* S + A - .TOC. */ 887 HOWTO (R_PPC64_TOC16, /* type */ 888 0, /* rightshift */ 889 1, /* size (0 = byte, 1 = short, 2 = long) */ 890 16, /* bitsize */ 891 FALSE, /* pc_relative */ 892 0, /* bitpos */ 893 complain_overflow_signed, /* complain_on_overflow */ 894 ppc64_elf_toc_reloc, /* special_function */ 895 "R_PPC64_TOC16", /* name */ 896 FALSE, /* partial_inplace */ 897 0, /* src_mask */ 898 0xffff, /* dst_mask */ 899 FALSE), /* pcrel_offset */ 900 901 /* 16 bit TOC-relative relocation without overflow. */ 902 903 /* R_PPC64_TOC16_LO 48 half16 #lo (S + A - .TOC.) */ 904 HOWTO (R_PPC64_TOC16_LO, /* type */ 905 0, /* rightshift */ 906 1, /* size (0 = byte, 1 = short, 2 = long) */ 907 16, /* bitsize */ 908 FALSE, /* pc_relative */ 909 0, /* bitpos */ 910 complain_overflow_dont, /* complain_on_overflow */ 911 ppc64_elf_toc_reloc, /* special_function */ 912 "R_PPC64_TOC16_LO", /* name */ 913 FALSE, /* partial_inplace */ 914 0, /* src_mask */ 915 0xffff, /* dst_mask */ 916 FALSE), /* pcrel_offset */ 917 918 /* 16 bit TOC-relative relocation, high 16 bits. */ 919 920 /* R_PPC64_TOC16_HI 49 half16 #hi (S + A - .TOC.) */ 921 HOWTO (R_PPC64_TOC16_HI, /* type */ 922 16, /* rightshift */ 923 1, /* size (0 = byte, 1 = short, 2 = long) */ 924 16, /* bitsize */ 925 FALSE, /* pc_relative */ 926 0, /* bitpos */ 927 complain_overflow_dont, /* complain_on_overflow */ 928 ppc64_elf_toc_reloc, /* special_function */ 929 "R_PPC64_TOC16_HI", /* name */ 930 FALSE, /* partial_inplace */ 931 0, /* src_mask */ 932 0xffff, /* dst_mask */ 933 FALSE), /* pcrel_offset */ 934 935 /* 16 bit TOC-relative relocation, high 16 bits, plus 1 if the 936 contents of the low 16 bits, treated as a signed number, is 937 negative. */ 938 939 /* R_PPC64_TOC16_HA 50 half16 #ha (S + A - .TOC.) */ 940 HOWTO (R_PPC64_TOC16_HA, /* type */ 941 16, /* rightshift */ 942 1, /* size (0 = byte, 1 = short, 2 = long) */ 943 16, /* bitsize */ 944 FALSE, /* pc_relative */ 945 0, /* bitpos */ 946 complain_overflow_dont, /* complain_on_overflow */ 947 ppc64_elf_toc_ha_reloc, /* special_function */ 948 "R_PPC64_TOC16_HA", /* name */ 949 FALSE, /* partial_inplace */ 950 0, /* src_mask */ 951 0xffff, /* dst_mask */ 952 FALSE), /* pcrel_offset */ 953 954 /* 64-bit relocation; insert value of TOC base (.TOC.). */ 955 956 /* R_PPC64_TOC 51 doubleword64 .TOC. */ 957 HOWTO (R_PPC64_TOC, /* type */ 958 0, /* rightshift */ 959 4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */ 960 64, /* bitsize */ 961 FALSE, /* pc_relative */ 962 0, /* bitpos */ 963 complain_overflow_bitfield, /* complain_on_overflow */ 964 ppc64_elf_toc64_reloc, /* special_function */ 965 "R_PPC64_TOC", /* name */ 966 FALSE, /* partial_inplace */ 967 0, /* src_mask */ 968 ONES (64), /* dst_mask */ 969 FALSE), /* pcrel_offset */ 970 971 /* Like R_PPC64_GOT16, but also informs the link editor that the 972 value to relocate may (!) refer to a PLT entry which the link 973 editor (a) may replace with the symbol value. If the link editor 974 is unable to fully resolve the symbol, it may (b) create a PLT 975 entry and store the address to the new PLT entry in the GOT. 976 This permits lazy resolution of function symbols at run time. 977 The link editor may also skip all of this and just (c) emit a 978 R_PPC64_GLOB_DAT to tie the symbol to the GOT entry. */ 979 /* FIXME: R_PPC64_PLTGOT16 not implemented. */ 980 HOWTO (R_PPC64_PLTGOT16, /* type */ 981 0, /* rightshift */ 982 1, /* size (0 = byte, 1 = short, 2 = long) */ 983 16, /* bitsize */ 984 FALSE, /* pc_relative */ 985 0, /* bitpos */ 986 complain_overflow_signed, /* complain_on_overflow */ 987 ppc64_elf_unhandled_reloc, /* special_function */ 988 "R_PPC64_PLTGOT16", /* name */ 989 FALSE, /* partial_inplace */ 990 0, /* src_mask */ 991 0xffff, /* dst_mask */ 992 FALSE), /* pcrel_offset */ 993 994 /* Like R_PPC64_PLTGOT16, but without overflow. */ 995 /* FIXME: R_PPC64_PLTGOT16_LO not implemented. */ 996 HOWTO (R_PPC64_PLTGOT16_LO, /* type */ 997 0, /* rightshift */ 998 1, /* size (0 = byte, 1 = short, 2 = long) */ 999 16, /* bitsize */ 1000 FALSE, /* pc_relative */ 1001 0, /* bitpos */ 1002 complain_overflow_dont, /* complain_on_overflow */ 1003 ppc64_elf_unhandled_reloc, /* special_function */ 1004 "R_PPC64_PLTGOT16_LO", /* name */ 1005 FALSE, /* partial_inplace */ 1006 0, /* src_mask */ 1007 0xffff, /* dst_mask */ 1008 FALSE), /* pcrel_offset */ 1009 1010 /* Like R_PPC64_PLT_GOT16, but using bits 16-31 of the address. */ 1011 /* FIXME: R_PPC64_PLTGOT16_HI not implemented. */ 1012 HOWTO (R_PPC64_PLTGOT16_HI, /* type */ 1013 16, /* rightshift */ 1014 1, /* size (0 = byte, 1 = short, 2 = long) */ 1015 16, /* bitsize */ 1016 FALSE, /* pc_relative */ 1017 0, /* bitpos */ 1018 complain_overflow_dont, /* complain_on_overflow */ 1019 ppc64_elf_unhandled_reloc, /* special_function */ 1020 "R_PPC64_PLTGOT16_HI", /* name */ 1021 FALSE, /* partial_inplace */ 1022 0, /* src_mask */ 1023 0xffff, /* dst_mask */ 1024 FALSE), /* pcrel_offset */ 1025 1026 /* Like R_PPC64_PLT_GOT16, but using bits 16-31 of the address, plus 1027 1 if the contents of the low 16 bits, treated as a signed number, 1028 is negative. */ 1029 /* FIXME: R_PPC64_PLTGOT16_HA not implemented. */ 1030 HOWTO (R_PPC64_PLTGOT16_HA, /* type */ 1031 16, /* rightshift */ 1032 1, /* size (0 = byte, 1 = short, 2 = long) */ 1033 16, /* bitsize */ 1034 FALSE, /* pc_relative */ 1035 0, /* bitpos */ 1036 complain_overflow_dont,/* complain_on_overflow */ 1037 ppc64_elf_unhandled_reloc, /* special_function */ 1038 "R_PPC64_PLTGOT16_HA", /* name */ 1039 FALSE, /* partial_inplace */ 1040 0, /* src_mask */ 1041 0xffff, /* dst_mask */ 1042 FALSE), /* pcrel_offset */ 1043 1044 /* Like R_PPC64_ADDR16, but for instructions with a DS field. */ 1045 HOWTO (R_PPC64_ADDR16_DS, /* type */ 1046 0, /* rightshift */ 1047 1, /* size (0 = byte, 1 = short, 2 = long) */ 1048 16, /* bitsize */ 1049 FALSE, /* pc_relative */ 1050 0, /* bitpos */ 1051 complain_overflow_bitfield, /* complain_on_overflow */ 1052 bfd_elf_generic_reloc, /* special_function */ 1053 "R_PPC64_ADDR16_DS", /* name */ 1054 FALSE, /* partial_inplace */ 1055 0, /* src_mask */ 1056 0xfffc, /* dst_mask */ 1057 FALSE), /* pcrel_offset */ 1058 1059 /* Like R_PPC64_ADDR16_LO, but for instructions with a DS field. */ 1060 HOWTO (R_PPC64_ADDR16_LO_DS, /* type */ 1061 0, /* rightshift */ 1062 1, /* size (0 = byte, 1 = short, 2 = long) */ 1063 16, /* bitsize */ 1064 FALSE, /* pc_relative */ 1065 0, /* bitpos */ 1066 complain_overflow_dont,/* complain_on_overflow */ 1067 bfd_elf_generic_reloc, /* special_function */ 1068 "R_PPC64_ADDR16_LO_DS",/* name */ 1069 FALSE, /* partial_inplace */ 1070 0, /* src_mask */ 1071 0xfffc, /* dst_mask */ 1072 FALSE), /* pcrel_offset */ 1073 1074 /* Like R_PPC64_GOT16, but for instructions with a DS field. */ 1075 HOWTO (R_PPC64_GOT16_DS, /* type */ 1076 0, /* rightshift */ 1077 1, /* size (0 = byte, 1 = short, 2 = long) */ 1078 16, /* bitsize */ 1079 FALSE, /* pc_relative */ 1080 0, /* bitpos */ 1081 complain_overflow_signed, /* complain_on_overflow */ 1082 ppc64_elf_unhandled_reloc, /* special_function */ 1083 "R_PPC64_GOT16_DS", /* name */ 1084 FALSE, /* partial_inplace */ 1085 0, /* src_mask */ 1086 0xfffc, /* dst_mask */ 1087 FALSE), /* pcrel_offset */ 1088 1089 /* Like R_PPC64_GOT16_LO, but for instructions with a DS field. */ 1090 HOWTO (R_PPC64_GOT16_LO_DS, /* type */ 1091 0, /* rightshift */ 1092 1, /* size (0 = byte, 1 = short, 2 = long) */ 1093 16, /* bitsize */ 1094 FALSE, /* pc_relative */ 1095 0, /* bitpos */ 1096 complain_overflow_dont, /* complain_on_overflow */ 1097 ppc64_elf_unhandled_reloc, /* special_function */ 1098 "R_PPC64_GOT16_LO_DS", /* name */ 1099 FALSE, /* partial_inplace */ 1100 0, /* src_mask */ 1101 0xfffc, /* dst_mask */ 1102 FALSE), /* pcrel_offset */ 1103 1104 /* Like R_PPC64_PLT16_LO, but for instructions with a DS field. */ 1105 HOWTO (R_PPC64_PLT16_LO_DS, /* type */ 1106 0, /* rightshift */ 1107 1, /* size (0 = byte, 1 = short, 2 = long) */ 1108 16, /* bitsize */ 1109 FALSE, /* pc_relative */ 1110 0, /* bitpos */ 1111 complain_overflow_dont, /* complain_on_overflow */ 1112 ppc64_elf_unhandled_reloc, /* special_function */ 1113 "R_PPC64_PLT16_LO_DS", /* name */ 1114 FALSE, /* partial_inplace */ 1115 0, /* src_mask */ 1116 0xfffc, /* dst_mask */ 1117 FALSE), /* pcrel_offset */ 1118 1119 /* Like R_PPC64_SECTOFF, but for instructions with a DS field. */ 1120 HOWTO (R_PPC64_SECTOFF_DS, /* type */ 1121 0, /* rightshift */ 1122 1, /* size (0 = byte, 1 = short, 2 = long) */ 1123 16, /* bitsize */ 1124 FALSE, /* pc_relative */ 1125 0, /* bitpos */ 1126 complain_overflow_bitfield, /* complain_on_overflow */ 1127 ppc64_elf_sectoff_reloc, /* special_function */ 1128 "R_PPC64_SECTOFF_DS", /* name */ 1129 FALSE, /* partial_inplace */ 1130 0, /* src_mask */ 1131 0xfffc, /* dst_mask */ 1132 FALSE), /* pcrel_offset */ 1133 1134 /* Like R_PPC64_SECTOFF_LO, but for instructions with a DS field. */ 1135 HOWTO (R_PPC64_SECTOFF_LO_DS, /* type */ 1136 0, /* rightshift */ 1137 1, /* size (0 = byte, 1 = short, 2 = long) */ 1138 16, /* bitsize */ 1139 FALSE, /* pc_relative */ 1140 0, /* bitpos */ 1141 complain_overflow_dont, /* complain_on_overflow */ 1142 ppc64_elf_sectoff_reloc, /* special_function */ 1143 "R_PPC64_SECTOFF_LO_DS",/* name */ 1144 FALSE, /* partial_inplace */ 1145 0, /* src_mask */ 1146 0xfffc, /* dst_mask */ 1147 FALSE), /* pcrel_offset */ 1148 1149 /* Like R_PPC64_TOC16, but for instructions with a DS field. */ 1150 HOWTO (R_PPC64_TOC16_DS, /* type */ 1151 0, /* rightshift */ 1152 1, /* size (0 = byte, 1 = short, 2 = long) */ 1153 16, /* bitsize */ 1154 FALSE, /* pc_relative */ 1155 0, /* bitpos */ 1156 complain_overflow_signed, /* complain_on_overflow */ 1157 ppc64_elf_toc_reloc, /* special_function */ 1158 "R_PPC64_TOC16_DS", /* name */ 1159 FALSE, /* partial_inplace */ 1160 0, /* src_mask */ 1161 0xfffc, /* dst_mask */ 1162 FALSE), /* pcrel_offset */ 1163 1164 /* Like R_PPC64_TOC16_LO, but for instructions with a DS field. */ 1165 HOWTO (R_PPC64_TOC16_LO_DS, /* type */ 1166 0, /* rightshift */ 1167 1, /* size (0 = byte, 1 = short, 2 = long) */ 1168 16, /* bitsize */ 1169 FALSE, /* pc_relative */ 1170 0, /* bitpos */ 1171 complain_overflow_dont, /* complain_on_overflow */ 1172 ppc64_elf_toc_reloc, /* special_function */ 1173 "R_PPC64_TOC16_LO_DS", /* name */ 1174 FALSE, /* partial_inplace */ 1175 0, /* src_mask */ 1176 0xfffc, /* dst_mask */ 1177 FALSE), /* pcrel_offset */ 1178 1179 /* Like R_PPC64_PLTGOT16, but for instructions with a DS field. */ 1180 /* FIXME: R_PPC64_PLTGOT16_DS not implemented. */ 1181 HOWTO (R_PPC64_PLTGOT16_DS, /* type */ 1182 0, /* rightshift */ 1183 1, /* size (0 = byte, 1 = short, 2 = long) */ 1184 16, /* bitsize */ 1185 FALSE, /* pc_relative */ 1186 0, /* bitpos */ 1187 complain_overflow_signed, /* complain_on_overflow */ 1188 ppc64_elf_unhandled_reloc, /* special_function */ 1189 "R_PPC64_PLTGOT16_DS", /* name */ 1190 FALSE, /* partial_inplace */ 1191 0, /* src_mask */ 1192 0xfffc, /* dst_mask */ 1193 FALSE), /* pcrel_offset */ 1194 1195 /* Like R_PPC64_PLTGOT16_LO, but for instructions with a DS field. */ 1196 /* FIXME: R_PPC64_PLTGOT16_LO not implemented. */ 1197 HOWTO (R_PPC64_PLTGOT16_LO_DS,/* type */ 1198 0, /* rightshift */ 1199 1, /* size (0 = byte, 1 = short, 2 = long) */ 1200 16, /* bitsize */ 1201 FALSE, /* pc_relative */ 1202 0, /* bitpos */ 1203 complain_overflow_dont, /* complain_on_overflow */ 1204 ppc64_elf_unhandled_reloc, /* special_function */ 1205 "R_PPC64_PLTGOT16_LO_DS",/* name */ 1206 FALSE, /* partial_inplace */ 1207 0, /* src_mask */ 1208 0xfffc, /* dst_mask */ 1209 FALSE), /* pcrel_offset */ 1210 1211 /* Marker reloc for TLS. */ 1212 HOWTO (R_PPC64_TLS, 1213 0, /* rightshift */ 1214 2, /* size (0 = byte, 1 = short, 2 = long) */ 1215 32, /* bitsize */ 1216 FALSE, /* pc_relative */ 1217 0, /* bitpos */ 1218 complain_overflow_dont, /* complain_on_overflow */ 1219 bfd_elf_generic_reloc, /* special_function */ 1220 "R_PPC64_TLS", /* name */ 1221 FALSE, /* partial_inplace */ 1222 0, /* src_mask */ 1223 0, /* dst_mask */ 1224 FALSE), /* pcrel_offset */ 1225 1226 /* Computes the load module index of the load module that contains the 1227 definition of its TLS sym. */ 1228 HOWTO (R_PPC64_DTPMOD64, 1229 0, /* rightshift */ 1230 4, /* size (0 = byte, 1 = short, 2 = long) */ 1231 64, /* bitsize */ 1232 FALSE, /* pc_relative */ 1233 0, /* bitpos */ 1234 complain_overflow_dont, /* complain_on_overflow */ 1235 ppc64_elf_unhandled_reloc, /* special_function */ 1236 "R_PPC64_DTPMOD64", /* name */ 1237 FALSE, /* partial_inplace */ 1238 0, /* src_mask */ 1239 ONES (64), /* dst_mask */ 1240 FALSE), /* pcrel_offset */ 1241 1242 /* Computes a dtv-relative displacement, the difference between the value 1243 of sym+add and the base address of the thread-local storage block that 1244 contains the definition of sym, minus 0x8000. */ 1245 HOWTO (R_PPC64_DTPREL64, 1246 0, /* rightshift */ 1247 4, /* size (0 = byte, 1 = short, 2 = long) */ 1248 64, /* bitsize */ 1249 FALSE, /* pc_relative */ 1250 0, /* bitpos */ 1251 complain_overflow_dont, /* complain_on_overflow */ 1252 ppc64_elf_unhandled_reloc, /* special_function */ 1253 "R_PPC64_DTPREL64", /* name */ 1254 FALSE, /* partial_inplace */ 1255 0, /* src_mask */ 1256 ONES (64), /* dst_mask */ 1257 FALSE), /* pcrel_offset */ 1258 1259 /* A 16 bit dtprel reloc. */ 1260 HOWTO (R_PPC64_DTPREL16, 1261 0, /* rightshift */ 1262 1, /* size (0 = byte, 1 = short, 2 = long) */ 1263 16, /* bitsize */ 1264 FALSE, /* pc_relative */ 1265 0, /* bitpos */ 1266 complain_overflow_signed, /* complain_on_overflow */ 1267 ppc64_elf_unhandled_reloc, /* special_function */ 1268 "R_PPC64_DTPREL16", /* name */ 1269 FALSE, /* partial_inplace */ 1270 0, /* src_mask */ 1271 0xffff, /* dst_mask */ 1272 FALSE), /* pcrel_offset */ 1273 1274 /* Like DTPREL16, but no overflow. */ 1275 HOWTO (R_PPC64_DTPREL16_LO, 1276 0, /* rightshift */ 1277 1, /* size (0 = byte, 1 = short, 2 = long) */ 1278 16, /* bitsize */ 1279 FALSE, /* pc_relative */ 1280 0, /* bitpos */ 1281 complain_overflow_dont, /* complain_on_overflow */ 1282 ppc64_elf_unhandled_reloc, /* special_function */ 1283 "R_PPC64_DTPREL16_LO", /* name */ 1284 FALSE, /* partial_inplace */ 1285 0, /* src_mask */ 1286 0xffff, /* dst_mask */ 1287 FALSE), /* pcrel_offset */ 1288 1289 /* Like DTPREL16_LO, but next higher group of 16 bits. */ 1290 HOWTO (R_PPC64_DTPREL16_HI, 1291 16, /* rightshift */ 1292 1, /* size (0 = byte, 1 = short, 2 = long) */ 1293 16, /* bitsize */ 1294 FALSE, /* pc_relative */ 1295 0, /* bitpos */ 1296 complain_overflow_dont, /* complain_on_overflow */ 1297 ppc64_elf_unhandled_reloc, /* special_function */ 1298 "R_PPC64_DTPREL16_HI", /* name */ 1299 FALSE, /* partial_inplace */ 1300 0, /* src_mask */ 1301 0xffff, /* dst_mask */ 1302 FALSE), /* pcrel_offset */ 1303 1304 /* Like DTPREL16_HI, but adjust for low 16 bits. */ 1305 HOWTO (R_PPC64_DTPREL16_HA, 1306 16, /* rightshift */ 1307 1, /* size (0 = byte, 1 = short, 2 = long) */ 1308 16, /* bitsize */ 1309 FALSE, /* pc_relative */ 1310 0, /* bitpos */ 1311 complain_overflow_dont, /* complain_on_overflow */ 1312 ppc64_elf_unhandled_reloc, /* special_function */ 1313 "R_PPC64_DTPREL16_HA", /* name */ 1314 FALSE, /* partial_inplace */ 1315 0, /* src_mask */ 1316 0xffff, /* dst_mask */ 1317 FALSE), /* pcrel_offset */ 1318 1319 /* Like DTPREL16_HI, but next higher group of 16 bits. */ 1320 HOWTO (R_PPC64_DTPREL16_HIGHER, 1321 32, /* rightshift */ 1322 1, /* size (0 = byte, 1 = short, 2 = long) */ 1323 16, /* bitsize */ 1324 FALSE, /* pc_relative */ 1325 0, /* bitpos */ 1326 complain_overflow_dont, /* complain_on_overflow */ 1327 ppc64_elf_unhandled_reloc, /* special_function */ 1328 "R_PPC64_DTPREL16_HIGHER", /* name */ 1329 FALSE, /* partial_inplace */ 1330 0, /* src_mask */ 1331 0xffff, /* dst_mask */ 1332 FALSE), /* pcrel_offset */ 1333 1334 /* Like DTPREL16_HIGHER, but adjust for low 16 bits. */ 1335 HOWTO (R_PPC64_DTPREL16_HIGHERA, 1336 32, /* rightshift */ 1337 1, /* size (0 = byte, 1 = short, 2 = long) */ 1338 16, /* bitsize */ 1339 FALSE, /* pc_relative */ 1340 0, /* bitpos */ 1341 complain_overflow_dont, /* complain_on_overflow */ 1342 ppc64_elf_unhandled_reloc, /* special_function */ 1343 "R_PPC64_DTPREL16_HIGHERA", /* name */ 1344 FALSE, /* partial_inplace */ 1345 0, /* src_mask */ 1346 0xffff, /* dst_mask */ 1347 FALSE), /* pcrel_offset */ 1348 1349 /* Like DTPREL16_HIGHER, but next higher group of 16 bits. */ 1350 HOWTO (R_PPC64_DTPREL16_HIGHEST, 1351 48, /* rightshift */ 1352 1, /* size (0 = byte, 1 = short, 2 = long) */ 1353 16, /* bitsize */ 1354 FALSE, /* pc_relative */ 1355 0, /* bitpos */ 1356 complain_overflow_dont, /* complain_on_overflow */ 1357 ppc64_elf_unhandled_reloc, /* special_function */ 1358 "R_PPC64_DTPREL16_HIGHEST", /* name */ 1359 FALSE, /* partial_inplace */ 1360 0, /* src_mask */ 1361 0xffff, /* dst_mask */ 1362 FALSE), /* pcrel_offset */ 1363 1364 /* Like DTPREL16_HIGHEST, but adjust for low 16 bits. */ 1365 HOWTO (R_PPC64_DTPREL16_HIGHESTA, 1366 48, /* rightshift */ 1367 1, /* size (0 = byte, 1 = short, 2 = long) */ 1368 16, /* bitsize */ 1369 FALSE, /* pc_relative */ 1370 0, /* bitpos */ 1371 complain_overflow_dont, /* complain_on_overflow */ 1372 ppc64_elf_unhandled_reloc, /* special_function */ 1373 "R_PPC64_DTPREL16_HIGHESTA", /* name */ 1374 FALSE, /* partial_inplace */ 1375 0, /* src_mask */ 1376 0xffff, /* dst_mask */ 1377 FALSE), /* pcrel_offset */ 1378 1379 /* Like DTPREL16, but for insns with a DS field. */ 1380 HOWTO (R_PPC64_DTPREL16_DS, 1381 0, /* rightshift */ 1382 1, /* size (0 = byte, 1 = short, 2 = long) */ 1383 16, /* bitsize */ 1384 FALSE, /* pc_relative */ 1385 0, /* bitpos */ 1386 complain_overflow_signed, /* complain_on_overflow */ 1387 ppc64_elf_unhandled_reloc, /* special_function */ 1388 "R_PPC64_DTPREL16_DS", /* name */ 1389 FALSE, /* partial_inplace */ 1390 0, /* src_mask */ 1391 0xfffc, /* dst_mask */ 1392 FALSE), /* pcrel_offset */ 1393 1394 /* Like DTPREL16_DS, but no overflow. */ 1395 HOWTO (R_PPC64_DTPREL16_LO_DS, 1396 0, /* rightshift */ 1397 1, /* size (0 = byte, 1 = short, 2 = long) */ 1398 16, /* bitsize */ 1399 FALSE, /* pc_relative */ 1400 0, /* bitpos */ 1401 complain_overflow_dont, /* complain_on_overflow */ 1402 ppc64_elf_unhandled_reloc, /* special_function */ 1403 "R_PPC64_DTPREL16_LO_DS", /* name */ 1404 FALSE, /* partial_inplace */ 1405 0, /* src_mask */ 1406 0xfffc, /* dst_mask */ 1407 FALSE), /* pcrel_offset */ 1408 1409 /* Computes a tp-relative displacement, the difference between the value of 1410 sym+add and the value of the thread pointer (r13). */ 1411 HOWTO (R_PPC64_TPREL64, 1412 0, /* rightshift */ 1413 4, /* size (0 = byte, 1 = short, 2 = long) */ 1414 64, /* bitsize */ 1415 FALSE, /* pc_relative */ 1416 0, /* bitpos */ 1417 complain_overflow_dont, /* complain_on_overflow */ 1418 ppc64_elf_unhandled_reloc, /* special_function */ 1419 "R_PPC64_TPREL64", /* name */ 1420 FALSE, /* partial_inplace */ 1421 0, /* src_mask */ 1422 ONES (64), /* dst_mask */ 1423 FALSE), /* pcrel_offset */ 1424 1425 /* A 16 bit tprel reloc. */ 1426 HOWTO (R_PPC64_TPREL16, 1427 0, /* rightshift */ 1428 1, /* size (0 = byte, 1 = short, 2 = long) */ 1429 16, /* bitsize */ 1430 FALSE, /* pc_relative */ 1431 0, /* bitpos */ 1432 complain_overflow_signed, /* complain_on_overflow */ 1433 ppc64_elf_unhandled_reloc, /* special_function */ 1434 "R_PPC64_TPREL16", /* name */ 1435 FALSE, /* partial_inplace */ 1436 0, /* src_mask */ 1437 0xffff, /* dst_mask */ 1438 FALSE), /* pcrel_offset */ 1439 1440 /* Like TPREL16, but no overflow. */ 1441 HOWTO (R_PPC64_TPREL16_LO, 1442 0, /* rightshift */ 1443 1, /* size (0 = byte, 1 = short, 2 = long) */ 1444 16, /* bitsize */ 1445 FALSE, /* pc_relative */ 1446 0, /* bitpos */ 1447 complain_overflow_dont, /* complain_on_overflow */ 1448 ppc64_elf_unhandled_reloc, /* special_function */ 1449 "R_PPC64_TPREL16_LO", /* name */ 1450 FALSE, /* partial_inplace */ 1451 0, /* src_mask */ 1452 0xffff, /* dst_mask */ 1453 FALSE), /* pcrel_offset */ 1454 1455 /* Like TPREL16_LO, but next higher group of 16 bits. */ 1456 HOWTO (R_PPC64_TPREL16_HI, 1457 16, /* rightshift */ 1458 1, /* size (0 = byte, 1 = short, 2 = long) */ 1459 16, /* bitsize */ 1460 FALSE, /* pc_relative */ 1461 0, /* bitpos */ 1462 complain_overflow_dont, /* complain_on_overflow */ 1463 ppc64_elf_unhandled_reloc, /* special_function */ 1464 "R_PPC64_TPREL16_HI", /* name */ 1465 FALSE, /* partial_inplace */ 1466 0, /* src_mask */ 1467 0xffff, /* dst_mask */ 1468 FALSE), /* pcrel_offset */ 1469 1470 /* Like TPREL16_HI, but adjust for low 16 bits. */ 1471 HOWTO (R_PPC64_TPREL16_HA, 1472 16, /* rightshift */ 1473 1, /* size (0 = byte, 1 = short, 2 = long) */ 1474 16, /* bitsize */ 1475 FALSE, /* pc_relative */ 1476 0, /* bitpos */ 1477 complain_overflow_dont, /* complain_on_overflow */ 1478 ppc64_elf_unhandled_reloc, /* special_function */ 1479 "R_PPC64_TPREL16_HA", /* name */ 1480 FALSE, /* partial_inplace */ 1481 0, /* src_mask */ 1482 0xffff, /* dst_mask */ 1483 FALSE), /* pcrel_offset */ 1484 1485 /* Like TPREL16_HI, but next higher group of 16 bits. */ 1486 HOWTO (R_PPC64_TPREL16_HIGHER, 1487 32, /* rightshift */ 1488 1, /* size (0 = byte, 1 = short, 2 = long) */ 1489 16, /* bitsize */ 1490 FALSE, /* pc_relative */ 1491 0, /* bitpos */ 1492 complain_overflow_dont, /* complain_on_overflow */ 1493 ppc64_elf_unhandled_reloc, /* special_function */ 1494 "R_PPC64_TPREL16_HIGHER", /* name */ 1495 FALSE, /* partial_inplace */ 1496 0, /* src_mask */ 1497 0xffff, /* dst_mask */ 1498 FALSE), /* pcrel_offset */ 1499 1500 /* Like TPREL16_HIGHER, but adjust for low 16 bits. */ 1501 HOWTO (R_PPC64_TPREL16_HIGHERA, 1502 32, /* rightshift */ 1503 1, /* size (0 = byte, 1 = short, 2 = long) */ 1504 16, /* bitsize */ 1505 FALSE, /* pc_relative */ 1506 0, /* bitpos */ 1507 complain_overflow_dont, /* complain_on_overflow */ 1508 ppc64_elf_unhandled_reloc, /* special_function */ 1509 "R_PPC64_TPREL16_HIGHERA", /* name */ 1510 FALSE, /* partial_inplace */ 1511 0, /* src_mask */ 1512 0xffff, /* dst_mask */ 1513 FALSE), /* pcrel_offset */ 1514 1515 /* Like TPREL16_HIGHER, but next higher group of 16 bits. */ 1516 HOWTO (R_PPC64_TPREL16_HIGHEST, 1517 48, /* rightshift */ 1518 1, /* size (0 = byte, 1 = short, 2 = long) */ 1519 16, /* bitsize */ 1520 FALSE, /* pc_relative */ 1521 0, /* bitpos */ 1522 complain_overflow_dont, /* complain_on_overflow */ 1523 ppc64_elf_unhandled_reloc, /* special_function */ 1524 "R_PPC64_TPREL16_HIGHEST", /* name */ 1525 FALSE, /* partial_inplace */ 1526 0, /* src_mask */ 1527 0xffff, /* dst_mask */ 1528 FALSE), /* pcrel_offset */ 1529 1530 /* Like TPREL16_HIGHEST, but adjust for low 16 bits. */ 1531 HOWTO (R_PPC64_TPREL16_HIGHESTA, 1532 48, /* rightshift */ 1533 1, /* size (0 = byte, 1 = short, 2 = long) */ 1534 16, /* bitsize */ 1535 FALSE, /* pc_relative */ 1536 0, /* bitpos */ 1537 complain_overflow_dont, /* complain_on_overflow */ 1538 ppc64_elf_unhandled_reloc, /* special_function */ 1539 "R_PPC64_TPREL16_HIGHESTA", /* name */ 1540 FALSE, /* partial_inplace */ 1541 0, /* src_mask */ 1542 0xffff, /* dst_mask */ 1543 FALSE), /* pcrel_offset */ 1544 1545 /* Like TPREL16, but for insns with a DS field. */ 1546 HOWTO (R_PPC64_TPREL16_DS, 1547 0, /* rightshift */ 1548 1, /* size (0 = byte, 1 = short, 2 = long) */ 1549 16, /* bitsize */ 1550 FALSE, /* pc_relative */ 1551 0, /* bitpos */ 1552 complain_overflow_signed, /* complain_on_overflow */ 1553 ppc64_elf_unhandled_reloc, /* special_function */ 1554 "R_PPC64_TPREL16_DS", /* name */ 1555 FALSE, /* partial_inplace */ 1556 0, /* src_mask */ 1557 0xfffc, /* dst_mask */ 1558 FALSE), /* pcrel_offset */ 1559 1560 /* Like TPREL16_DS, but no overflow. */ 1561 HOWTO (R_PPC64_TPREL16_LO_DS, 1562 0, /* rightshift */ 1563 1, /* size (0 = byte, 1 = short, 2 = long) */ 1564 16, /* bitsize */ 1565 FALSE, /* pc_relative */ 1566 0, /* bitpos */ 1567 complain_overflow_dont, /* complain_on_overflow */ 1568 ppc64_elf_unhandled_reloc, /* special_function */ 1569 "R_PPC64_TPREL16_LO_DS", /* name */ 1570 FALSE, /* partial_inplace */ 1571 0, /* src_mask */ 1572 0xfffc, /* dst_mask */ 1573 FALSE), /* pcrel_offset */ 1574 1575 /* Allocates two contiguous entries in the GOT to hold a tls_index structure, 1576 with values (sym+add)@dtpmod and (sym+add)@dtprel, and computes the offset 1577 to the first entry relative to the TOC base (r2). */ 1578 HOWTO (R_PPC64_GOT_TLSGD16, 1579 0, /* rightshift */ 1580 1, /* size (0 = byte, 1 = short, 2 = long) */ 1581 16, /* bitsize */ 1582 FALSE, /* pc_relative */ 1583 0, /* bitpos */ 1584 complain_overflow_signed, /* complain_on_overflow */ 1585 ppc64_elf_unhandled_reloc, /* special_function */ 1586 "R_PPC64_GOT_TLSGD16", /* name */ 1587 FALSE, /* partial_inplace */ 1588 0, /* src_mask */ 1589 0xffff, /* dst_mask */ 1590 FALSE), /* pcrel_offset */ 1591 1592 /* Like GOT_TLSGD16, but no overflow. */ 1593 HOWTO (R_PPC64_GOT_TLSGD16_LO, 1594 0, /* rightshift */ 1595 1, /* size (0 = byte, 1 = short, 2 = long) */ 1596 16, /* bitsize */ 1597 FALSE, /* pc_relative */ 1598 0, /* bitpos */ 1599 complain_overflow_dont, /* complain_on_overflow */ 1600 ppc64_elf_unhandled_reloc, /* special_function */ 1601 "R_PPC64_GOT_TLSGD16_LO", /* name */ 1602 FALSE, /* partial_inplace */ 1603 0, /* src_mask */ 1604 0xffff, /* dst_mask */ 1605 FALSE), /* pcrel_offset */ 1606 1607 /* Like GOT_TLSGD16_LO, but next higher group of 16 bits. */ 1608 HOWTO (R_PPC64_GOT_TLSGD16_HI, 1609 16, /* rightshift */ 1610 1, /* size (0 = byte, 1 = short, 2 = long) */ 1611 16, /* bitsize */ 1612 FALSE, /* pc_relative */ 1613 0, /* bitpos */ 1614 complain_overflow_dont, /* complain_on_overflow */ 1615 ppc64_elf_unhandled_reloc, /* special_function */ 1616 "R_PPC64_GOT_TLSGD16_HI", /* name */ 1617 FALSE, /* partial_inplace */ 1618 0, /* src_mask */ 1619 0xffff, /* dst_mask */ 1620 FALSE), /* pcrel_offset */ 1621 1622 /* Like GOT_TLSGD16_HI, but adjust for low 16 bits. */ 1623 HOWTO (R_PPC64_GOT_TLSGD16_HA, 1624 16, /* rightshift */ 1625 1, /* size (0 = byte, 1 = short, 2 = long) */ 1626 16, /* bitsize */ 1627 FALSE, /* pc_relative */ 1628 0, /* bitpos */ 1629 complain_overflow_dont, /* complain_on_overflow */ 1630 ppc64_elf_unhandled_reloc, /* special_function */ 1631 "R_PPC64_GOT_TLSGD16_HA", /* name */ 1632 FALSE, /* partial_inplace */ 1633 0, /* src_mask */ 1634 0xffff, /* dst_mask */ 1635 FALSE), /* pcrel_offset */ 1636 1637 /* Allocates two contiguous entries in the GOT to hold a tls_index structure, 1638 with values (sym+add)@dtpmod and zero, and computes the offset to the 1639 first entry relative to the TOC base (r2). */ 1640 HOWTO (R_PPC64_GOT_TLSLD16, 1641 0, /* rightshift */ 1642 1, /* size (0 = byte, 1 = short, 2 = long) */ 1643 16, /* bitsize */ 1644 FALSE, /* pc_relative */ 1645 0, /* bitpos */ 1646 complain_overflow_signed, /* complain_on_overflow */ 1647 ppc64_elf_unhandled_reloc, /* special_function */ 1648 "R_PPC64_GOT_TLSLD16", /* name */ 1649 FALSE, /* partial_inplace */ 1650 0, /* src_mask */ 1651 0xffff, /* dst_mask */ 1652 FALSE), /* pcrel_offset */ 1653 1654 /* Like GOT_TLSLD16, but no overflow. */ 1655 HOWTO (R_PPC64_GOT_TLSLD16_LO, 1656 0, /* rightshift */ 1657 1, /* size (0 = byte, 1 = short, 2 = long) */ 1658 16, /* bitsize */ 1659 FALSE, /* pc_relative */ 1660 0, /* bitpos */ 1661 complain_overflow_dont, /* complain_on_overflow */ 1662 ppc64_elf_unhandled_reloc, /* special_function */ 1663 "R_PPC64_GOT_TLSLD16_LO", /* name */ 1664 FALSE, /* partial_inplace */ 1665 0, /* src_mask */ 1666 0xffff, /* dst_mask */ 1667 FALSE), /* pcrel_offset */ 1668 1669 /* Like GOT_TLSLD16_LO, but next higher group of 16 bits. */ 1670 HOWTO (R_PPC64_GOT_TLSLD16_HI, 1671 16, /* rightshift */ 1672 1, /* size (0 = byte, 1 = short, 2 = long) */ 1673 16, /* bitsize */ 1674 FALSE, /* pc_relative */ 1675 0, /* bitpos */ 1676 complain_overflow_dont, /* complain_on_overflow */ 1677 ppc64_elf_unhandled_reloc, /* special_function */ 1678 "R_PPC64_GOT_TLSLD16_HI", /* name */ 1679 FALSE, /* partial_inplace */ 1680 0, /* src_mask */ 1681 0xffff, /* dst_mask */ 1682 FALSE), /* pcrel_offset */ 1683 1684 /* Like GOT_TLSLD16_HI, but adjust for low 16 bits. */ 1685 HOWTO (R_PPC64_GOT_TLSLD16_HA, 1686 16, /* rightshift */ 1687 1, /* size (0 = byte, 1 = short, 2 = long) */ 1688 16, /* bitsize */ 1689 FALSE, /* pc_relative */ 1690 0, /* bitpos */ 1691 complain_overflow_dont, /* complain_on_overflow */ 1692 ppc64_elf_unhandled_reloc, /* special_function */ 1693 "R_PPC64_GOT_TLSLD16_HA", /* name */ 1694 FALSE, /* partial_inplace */ 1695 0, /* src_mask */ 1696 0xffff, /* dst_mask */ 1697 FALSE), /* pcrel_offset */ 1698 1699 /* Allocates an entry in the GOT with value (sym+add)@dtprel, and computes 1700 the offset to the entry relative to the TOC base (r2). */ 1701 HOWTO (R_PPC64_GOT_DTPREL16_DS, 1702 0, /* rightshift */ 1703 1, /* size (0 = byte, 1 = short, 2 = long) */ 1704 16, /* bitsize */ 1705 FALSE, /* pc_relative */ 1706 0, /* bitpos */ 1707 complain_overflow_signed, /* complain_on_overflow */ 1708 ppc64_elf_unhandled_reloc, /* special_function */ 1709 "R_PPC64_GOT_DTPREL16_DS", /* name */ 1710 FALSE, /* partial_inplace */ 1711 0, /* src_mask */ 1712 0xfffc, /* dst_mask */ 1713 FALSE), /* pcrel_offset */ 1714 1715 /* Like GOT_DTPREL16_DS, but no overflow. */ 1716 HOWTO (R_PPC64_GOT_DTPREL16_LO_DS, 1717 0, /* rightshift */ 1718 1, /* size (0 = byte, 1 = short, 2 = long) */ 1719 16, /* bitsize */ 1720 FALSE, /* pc_relative */ 1721 0, /* bitpos */ 1722 complain_overflow_dont, /* complain_on_overflow */ 1723 ppc64_elf_unhandled_reloc, /* special_function */ 1724 "R_PPC64_GOT_DTPREL16_LO_DS", /* name */ 1725 FALSE, /* partial_inplace */ 1726 0, /* src_mask */ 1727 0xfffc, /* dst_mask */ 1728 FALSE), /* pcrel_offset */ 1729 1730 /* Like GOT_DTPREL16_LO_DS, but next higher group of 16 bits. */ 1731 HOWTO (R_PPC64_GOT_DTPREL16_HI, 1732 16, /* rightshift */ 1733 1, /* size (0 = byte, 1 = short, 2 = long) */ 1734 16, /* bitsize */ 1735 FALSE, /* pc_relative */ 1736 0, /* bitpos */ 1737 complain_overflow_dont, /* complain_on_overflow */ 1738 ppc64_elf_unhandled_reloc, /* special_function */ 1739 "R_PPC64_GOT_DTPREL16_HI", /* name */ 1740 FALSE, /* partial_inplace */ 1741 0, /* src_mask */ 1742 0xffff, /* dst_mask */ 1743 FALSE), /* pcrel_offset */ 1744 1745 /* Like GOT_DTPREL16_HI, but adjust for low 16 bits. */ 1746 HOWTO (R_PPC64_GOT_DTPREL16_HA, 1747 16, /* rightshift */ 1748 1, /* size (0 = byte, 1 = short, 2 = long) */ 1749 16, /* bitsize */ 1750 FALSE, /* pc_relative */ 1751 0, /* bitpos */ 1752 complain_overflow_dont, /* complain_on_overflow */ 1753 ppc64_elf_unhandled_reloc, /* special_function */ 1754 "R_PPC64_GOT_DTPREL16_HA", /* name */ 1755 FALSE, /* partial_inplace */ 1756 0, /* src_mask */ 1757 0xffff, /* dst_mask */ 1758 FALSE), /* pcrel_offset */ 1759 1760 /* Allocates an entry in the GOT with value (sym+add)@tprel, and computes the 1761 offset to the entry relative to the TOC base (r2). */ 1762 HOWTO (R_PPC64_GOT_TPREL16_DS, 1763 0, /* rightshift */ 1764 1, /* size (0 = byte, 1 = short, 2 = long) */ 1765 16, /* bitsize */ 1766 FALSE, /* pc_relative */ 1767 0, /* bitpos */ 1768 complain_overflow_signed, /* complain_on_overflow */ 1769 ppc64_elf_unhandled_reloc, /* special_function */ 1770 "R_PPC64_GOT_TPREL16_DS", /* name */ 1771 FALSE, /* partial_inplace */ 1772 0, /* src_mask */ 1773 0xfffc, /* dst_mask */ 1774 FALSE), /* pcrel_offset */ 1775 1776 /* Like GOT_TPREL16_DS, but no overflow. */ 1777 HOWTO (R_PPC64_GOT_TPREL16_LO_DS, 1778 0, /* rightshift */ 1779 1, /* size (0 = byte, 1 = short, 2 = long) */ 1780 16, /* bitsize */ 1781 FALSE, /* pc_relative */ 1782 0, /* bitpos */ 1783 complain_overflow_dont, /* complain_on_overflow */ 1784 ppc64_elf_unhandled_reloc, /* special_function */ 1785 "R_PPC64_GOT_TPREL16_LO_DS", /* name */ 1786 FALSE, /* partial_inplace */ 1787 0, /* src_mask */ 1788 0xfffc, /* dst_mask */ 1789 FALSE), /* pcrel_offset */ 1790 1791 /* Like GOT_TPREL16_LO_DS, but next higher group of 16 bits. */ 1792 HOWTO (R_PPC64_GOT_TPREL16_HI, 1793 16, /* rightshift */ 1794 1, /* size (0 = byte, 1 = short, 2 = long) */ 1795 16, /* bitsize */ 1796 FALSE, /* pc_relative */ 1797 0, /* bitpos */ 1798 complain_overflow_dont, /* complain_on_overflow */ 1799 ppc64_elf_unhandled_reloc, /* special_function */ 1800 "R_PPC64_GOT_TPREL16_HI", /* name */ 1801 FALSE, /* partial_inplace */ 1802 0, /* src_mask */ 1803 0xffff, /* dst_mask */ 1804 FALSE), /* pcrel_offset */ 1805 1806 /* Like GOT_TPREL16_HI, but adjust for low 16 bits. */ 1807 HOWTO (R_PPC64_GOT_TPREL16_HA, 1808 16, /* rightshift */ 1809 1, /* size (0 = byte, 1 = short, 2 = long) */ 1810 16, /* bitsize */ 1811 FALSE, /* pc_relative */ 1812 0, /* bitpos */ 1813 complain_overflow_dont, /* complain_on_overflow */ 1814 ppc64_elf_unhandled_reloc, /* special_function */ 1815 "R_PPC64_GOT_TPREL16_HA", /* name */ 1816 FALSE, /* partial_inplace */ 1817 0, /* src_mask */ 1818 0xffff, /* dst_mask */ 1819 FALSE), /* pcrel_offset */ 1820 1821 /* GNU extension to record C++ vtable hierarchy. */ 1822 HOWTO (R_PPC64_GNU_VTINHERIT, /* type */ 1823 0, /* rightshift */ 1824 0, /* size (0 = byte, 1 = short, 2 = long) */ 1825 0, /* bitsize */ 1826 FALSE, /* pc_relative */ 1827 0, /* bitpos */ 1828 complain_overflow_dont, /* complain_on_overflow */ 1829 NULL, /* special_function */ 1830 "R_PPC64_GNU_VTINHERIT", /* name */ 1831 FALSE, /* partial_inplace */ 1832 0, /* src_mask */ 1833 0, /* dst_mask */ 1834 FALSE), /* pcrel_offset */ 1835 1836 /* GNU extension to record C++ vtable member usage. */ 1837 HOWTO (R_PPC64_GNU_VTENTRY, /* type */ 1838 0, /* rightshift */ 1839 0, /* size (0 = byte, 1 = short, 2 = long) */ 1840 0, /* bitsize */ 1841 FALSE, /* pc_relative */ 1842 0, /* bitpos */ 1843 complain_overflow_dont, /* complain_on_overflow */ 1844 NULL, /* special_function */ 1845 "R_PPC64_GNU_VTENTRY", /* name */ 1846 FALSE, /* partial_inplace */ 1847 0, /* src_mask */ 1848 0, /* dst_mask */ 1849 FALSE), /* pcrel_offset */ 1850}; 1851 1852 1853/* Initialize the ppc64_elf_howto_table, so that linear accesses can 1854 be done. */ 1855 1856static void 1857ppc_howto_init (void) 1858{ 1859 unsigned int i, type; 1860 1861 for (i = 0; 1862 i < sizeof (ppc64_elf_howto_raw) / sizeof (ppc64_elf_howto_raw[0]); 1863 i++) 1864 { 1865 type = ppc64_elf_howto_raw[i].type; 1866 BFD_ASSERT (type < (sizeof (ppc64_elf_howto_table) 1867 / sizeof (ppc64_elf_howto_table[0]))); 1868 ppc64_elf_howto_table[type] = &ppc64_elf_howto_raw[i]; 1869 } 1870} 1871 1872static reloc_howto_type * 1873ppc64_elf_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, 1874 bfd_reloc_code_real_type code) 1875{ 1876 enum elf_ppc64_reloc_type r = R_PPC64_NONE; 1877 1878 if (!ppc64_elf_howto_table[R_PPC64_ADDR32]) 1879 /* Initialize howto table if needed. */ 1880 ppc_howto_init (); 1881 1882 switch (code) 1883 { 1884 default: 1885 return NULL; 1886 1887 case BFD_RELOC_NONE: r = R_PPC64_NONE; 1888 break; 1889 case BFD_RELOC_32: r = R_PPC64_ADDR32; 1890 break; 1891 case BFD_RELOC_PPC_BA26: r = R_PPC64_ADDR24; 1892 break; 1893 case BFD_RELOC_16: r = R_PPC64_ADDR16; 1894 break; 1895 case BFD_RELOC_LO16: r = R_PPC64_ADDR16_LO; 1896 break; 1897 case BFD_RELOC_HI16: r = R_PPC64_ADDR16_HI; 1898 break; 1899 case BFD_RELOC_HI16_S: r = R_PPC64_ADDR16_HA; 1900 break; 1901 case BFD_RELOC_PPC_BA16: r = R_PPC64_ADDR14; 1902 break; 1903 case BFD_RELOC_PPC_BA16_BRTAKEN: r = R_PPC64_ADDR14_BRTAKEN; 1904 break; 1905 case BFD_RELOC_PPC_BA16_BRNTAKEN: r = R_PPC64_ADDR14_BRNTAKEN; 1906 break; 1907 case BFD_RELOC_PPC_B26: r = R_PPC64_REL24; 1908 break; 1909 case BFD_RELOC_PPC_B16: r = R_PPC64_REL14; 1910 break; 1911 case BFD_RELOC_PPC_B16_BRTAKEN: r = R_PPC64_REL14_BRTAKEN; 1912 break; 1913 case BFD_RELOC_PPC_B16_BRNTAKEN: r = R_PPC64_REL14_BRNTAKEN; 1914 break; 1915 case BFD_RELOC_16_GOTOFF: r = R_PPC64_GOT16; 1916 break; 1917 case BFD_RELOC_LO16_GOTOFF: r = R_PPC64_GOT16_LO; 1918 break; 1919 case BFD_RELOC_HI16_GOTOFF: r = R_PPC64_GOT16_HI; 1920 break; 1921 case BFD_RELOC_HI16_S_GOTOFF: r = R_PPC64_GOT16_HA; 1922 break; 1923 case BFD_RELOC_PPC_COPY: r = R_PPC64_COPY; 1924 break; 1925 case BFD_RELOC_PPC_GLOB_DAT: r = R_PPC64_GLOB_DAT; 1926 break; 1927 case BFD_RELOC_32_PCREL: r = R_PPC64_REL32; 1928 break; 1929 case BFD_RELOC_32_PLTOFF: r = R_PPC64_PLT32; 1930 break; 1931 case BFD_RELOC_32_PLT_PCREL: r = R_PPC64_PLTREL32; 1932 break; 1933 case BFD_RELOC_LO16_PLTOFF: r = R_PPC64_PLT16_LO; 1934 break; 1935 case BFD_RELOC_HI16_PLTOFF: r = R_PPC64_PLT16_HI; 1936 break; 1937 case BFD_RELOC_HI16_S_PLTOFF: r = R_PPC64_PLT16_HA; 1938 break; 1939 case BFD_RELOC_16_BASEREL: r = R_PPC64_SECTOFF; 1940 break; 1941 case BFD_RELOC_LO16_BASEREL: r = R_PPC64_SECTOFF_LO; 1942 break; 1943 case BFD_RELOC_HI16_BASEREL: r = R_PPC64_SECTOFF_HI; 1944 break; 1945 case BFD_RELOC_HI16_S_BASEREL: r = R_PPC64_SECTOFF_HA; 1946 break; 1947 case BFD_RELOC_CTOR: r = R_PPC64_ADDR64; 1948 break; 1949 case BFD_RELOC_64: r = R_PPC64_ADDR64; 1950 break; 1951 case BFD_RELOC_PPC64_HIGHER: r = R_PPC64_ADDR16_HIGHER; 1952 break; 1953 case BFD_RELOC_PPC64_HIGHER_S: r = R_PPC64_ADDR16_HIGHERA; 1954 break; 1955 case BFD_RELOC_PPC64_HIGHEST: r = R_PPC64_ADDR16_HIGHEST; 1956 break; 1957 case BFD_RELOC_PPC64_HIGHEST_S: r = R_PPC64_ADDR16_HIGHESTA; 1958 break; 1959 case BFD_RELOC_64_PCREL: r = R_PPC64_REL64; 1960 break; 1961 case BFD_RELOC_64_PLTOFF: r = R_PPC64_PLT64; 1962 break; 1963 case BFD_RELOC_64_PLT_PCREL: r = R_PPC64_PLTREL64; 1964 break; 1965 case BFD_RELOC_PPC_TOC16: r = R_PPC64_TOC16; 1966 break; 1967 case BFD_RELOC_PPC64_TOC16_LO: r = R_PPC64_TOC16_LO; 1968 break; 1969 case BFD_RELOC_PPC64_TOC16_HI: r = R_PPC64_TOC16_HI; 1970 break; 1971 case BFD_RELOC_PPC64_TOC16_HA: r = R_PPC64_TOC16_HA; 1972 break; 1973 case BFD_RELOC_PPC64_TOC: r = R_PPC64_TOC; 1974 break; 1975 case BFD_RELOC_PPC64_PLTGOT16: r = R_PPC64_PLTGOT16; 1976 break; 1977 case BFD_RELOC_PPC64_PLTGOT16_LO: r = R_PPC64_PLTGOT16_LO; 1978 break; 1979 case BFD_RELOC_PPC64_PLTGOT16_HI: r = R_PPC64_PLTGOT16_HI; 1980 break; 1981 case BFD_RELOC_PPC64_PLTGOT16_HA: r = R_PPC64_PLTGOT16_HA; 1982 break; 1983 case BFD_RELOC_PPC64_ADDR16_DS: r = R_PPC64_ADDR16_DS; 1984 break; 1985 case BFD_RELOC_PPC64_ADDR16_LO_DS: r = R_PPC64_ADDR16_LO_DS; 1986 break; 1987 case BFD_RELOC_PPC64_GOT16_DS: r = R_PPC64_GOT16_DS; 1988 break; 1989 case BFD_RELOC_PPC64_GOT16_LO_DS: r = R_PPC64_GOT16_LO_DS; 1990 break; 1991 case BFD_RELOC_PPC64_PLT16_LO_DS: r = R_PPC64_PLT16_LO_DS; 1992 break; 1993 case BFD_RELOC_PPC64_SECTOFF_DS: r = R_PPC64_SECTOFF_DS; 1994 break; 1995 case BFD_RELOC_PPC64_SECTOFF_LO_DS: r = R_PPC64_SECTOFF_LO_DS; 1996 break; 1997 case BFD_RELOC_PPC64_TOC16_DS: r = R_PPC64_TOC16_DS; 1998 break; 1999 case BFD_RELOC_PPC64_TOC16_LO_DS: r = R_PPC64_TOC16_LO_DS; 2000 break; 2001 case BFD_RELOC_PPC64_PLTGOT16_DS: r = R_PPC64_PLTGOT16_DS; 2002 break; 2003 case BFD_RELOC_PPC64_PLTGOT16_LO_DS: r = R_PPC64_PLTGOT16_LO_DS; 2004 break; 2005 case BFD_RELOC_PPC_TLS: r = R_PPC64_TLS; 2006 break; 2007 case BFD_RELOC_PPC_DTPMOD: r = R_PPC64_DTPMOD64; 2008 break; 2009 case BFD_RELOC_PPC_TPREL16: r = R_PPC64_TPREL16; 2010 break; 2011 case BFD_RELOC_PPC_TPREL16_LO: r = R_PPC64_TPREL16_LO; 2012 break; 2013 case BFD_RELOC_PPC_TPREL16_HI: r = R_PPC64_TPREL16_HI; 2014 break; 2015 case BFD_RELOC_PPC_TPREL16_HA: r = R_PPC64_TPREL16_HA; 2016 break; 2017 case BFD_RELOC_PPC_TPREL: r = R_PPC64_TPREL64; 2018 break; 2019 case BFD_RELOC_PPC_DTPREL16: r = R_PPC64_DTPREL16; 2020 break; 2021 case BFD_RELOC_PPC_DTPREL16_LO: r = R_PPC64_DTPREL16_LO; 2022 break; 2023 case BFD_RELOC_PPC_DTPREL16_HI: r = R_PPC64_DTPREL16_HI; 2024 break; 2025 case BFD_RELOC_PPC_DTPREL16_HA: r = R_PPC64_DTPREL16_HA; 2026 break; 2027 case BFD_RELOC_PPC_DTPREL: r = R_PPC64_DTPREL64; 2028 break; 2029 case BFD_RELOC_PPC_GOT_TLSGD16: r = R_PPC64_GOT_TLSGD16; 2030 break; 2031 case BFD_RELOC_PPC_GOT_TLSGD16_LO: r = R_PPC64_GOT_TLSGD16_LO; 2032 break; 2033 case BFD_RELOC_PPC_GOT_TLSGD16_HI: r = R_PPC64_GOT_TLSGD16_HI; 2034 break; 2035 case BFD_RELOC_PPC_GOT_TLSGD16_HA: r = R_PPC64_GOT_TLSGD16_HA; 2036 break; 2037 case BFD_RELOC_PPC_GOT_TLSLD16: r = R_PPC64_GOT_TLSLD16; 2038 break; 2039 case BFD_RELOC_PPC_GOT_TLSLD16_LO: r = R_PPC64_GOT_TLSLD16_LO; 2040 break; 2041 case BFD_RELOC_PPC_GOT_TLSLD16_HI: r = R_PPC64_GOT_TLSLD16_HI; 2042 break; 2043 case BFD_RELOC_PPC_GOT_TLSLD16_HA: r = R_PPC64_GOT_TLSLD16_HA; 2044 break; 2045 case BFD_RELOC_PPC_GOT_TPREL16: r = R_PPC64_GOT_TPREL16_DS; 2046 break; 2047 case BFD_RELOC_PPC_GOT_TPREL16_LO: r = R_PPC64_GOT_TPREL16_LO_DS; 2048 break; 2049 case BFD_RELOC_PPC_GOT_TPREL16_HI: r = R_PPC64_GOT_TPREL16_HI; 2050 break; 2051 case BFD_RELOC_PPC_GOT_TPREL16_HA: r = R_PPC64_GOT_TPREL16_HA; 2052 break; 2053 case BFD_RELOC_PPC_GOT_DTPREL16: r = R_PPC64_GOT_DTPREL16_DS; 2054 break; 2055 case BFD_RELOC_PPC_GOT_DTPREL16_LO: r = R_PPC64_GOT_DTPREL16_LO_DS; 2056 break; 2057 case BFD_RELOC_PPC_GOT_DTPREL16_HI: r = R_PPC64_GOT_DTPREL16_HI; 2058 break; 2059 case BFD_RELOC_PPC_GOT_DTPREL16_HA: r = R_PPC64_GOT_DTPREL16_HA; 2060 break; 2061 case BFD_RELOC_PPC64_TPREL16_DS: r = R_PPC64_TPREL16_DS; 2062 break; 2063 case BFD_RELOC_PPC64_TPREL16_LO_DS: r = R_PPC64_TPREL16_LO_DS; 2064 break; 2065 case BFD_RELOC_PPC64_TPREL16_HIGHER: r = R_PPC64_TPREL16_HIGHER; 2066 break; 2067 case BFD_RELOC_PPC64_TPREL16_HIGHERA: r = R_PPC64_TPREL16_HIGHERA; 2068 break; 2069 case BFD_RELOC_PPC64_TPREL16_HIGHEST: r = R_PPC64_TPREL16_HIGHEST; 2070 break; 2071 case BFD_RELOC_PPC64_TPREL16_HIGHESTA: r = R_PPC64_TPREL16_HIGHESTA; 2072 break; 2073 case BFD_RELOC_PPC64_DTPREL16_DS: r = R_PPC64_DTPREL16_DS; 2074 break; 2075 case BFD_RELOC_PPC64_DTPREL16_LO_DS: r = R_PPC64_DTPREL16_LO_DS; 2076 break; 2077 case BFD_RELOC_PPC64_DTPREL16_HIGHER: r = R_PPC64_DTPREL16_HIGHER; 2078 break; 2079 case BFD_RELOC_PPC64_DTPREL16_HIGHERA: r = R_PPC64_DTPREL16_HIGHERA; 2080 break; 2081 case BFD_RELOC_PPC64_DTPREL16_HIGHEST: r = R_PPC64_DTPREL16_HIGHEST; 2082 break; 2083 case BFD_RELOC_PPC64_DTPREL16_HIGHESTA: r = R_PPC64_DTPREL16_HIGHESTA; 2084 break; 2085 case BFD_RELOC_VTABLE_INHERIT: r = R_PPC64_GNU_VTINHERIT; 2086 break; 2087 case BFD_RELOC_VTABLE_ENTRY: r = R_PPC64_GNU_VTENTRY; 2088 break; 2089 } 2090 2091 return ppc64_elf_howto_table[r]; 2092}; 2093 2094/* Set the howto pointer for a PowerPC ELF reloc. */ 2095 2096static void 2097ppc64_elf_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr, 2098 Elf_Internal_Rela *dst) 2099{ 2100 unsigned int type; 2101 2102 /* Initialize howto table if needed. */ 2103 if (!ppc64_elf_howto_table[R_PPC64_ADDR32]) 2104 ppc_howto_init (); 2105 2106 type = ELF64_R_TYPE (dst->r_info); 2107 BFD_ASSERT (type < (sizeof (ppc64_elf_howto_table) 2108 / sizeof (ppc64_elf_howto_table[0]))); 2109 cache_ptr->howto = ppc64_elf_howto_table[type]; 2110} 2111 2112/* Handle the R_PPC64_ADDR16_HA and similar relocs. */ 2113 2114static bfd_reloc_status_type 2115ppc64_elf_ha_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, 2116 void *data, asection *input_section, 2117 bfd *output_bfd, char **error_message) 2118{ 2119 /* If this is a relocatable link (output_bfd test tells us), just 2120 call the generic function. Any adjustment will be done at final 2121 link time. */ 2122 if (output_bfd != NULL) 2123 return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, 2124 input_section, output_bfd, error_message); 2125 2126 /* Adjust the addend for sign extension of the low 16 bits. 2127 We won't actually be using the low 16 bits, so trashing them 2128 doesn't matter. */ 2129 reloc_entry->addend += 0x8000; 2130 return bfd_reloc_continue; 2131} 2132 2133static bfd_reloc_status_type 2134ppc64_elf_brtaken_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, 2135 void *data, asection *input_section, 2136 bfd *output_bfd, char **error_message) 2137{ 2138 long insn; 2139 enum elf_ppc64_reloc_type r_type; 2140 bfd_size_type octets; 2141 /* Disabled until we sort out how ld should choose 'y' vs 'at'. */ 2142 bfd_boolean is_power4 = FALSE; 2143 2144 /* If this is a relocatable link (output_bfd test tells us), just 2145 call the generic function. Any adjustment will be done at final 2146 link time. */ 2147 if (output_bfd != NULL) 2148 return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, 2149 input_section, output_bfd, error_message); 2150 2151 octets = reloc_entry->address * bfd_octets_per_byte (abfd); 2152 insn = bfd_get_32 (abfd, (bfd_byte *) data + octets); 2153 insn &= ~(0x01 << 21); 2154 r_type = reloc_entry->howto->type; 2155 if (r_type == R_PPC64_ADDR14_BRTAKEN 2156 || r_type == R_PPC64_REL14_BRTAKEN) 2157 insn |= 0x01 << 21; /* 'y' or 't' bit, lowest bit of BO field. */ 2158 2159 if (is_power4) 2160 { 2161 /* Set 'a' bit. This is 0b00010 in BO field for branch 2162 on CR(BI) insns (BO == 001at or 011at), and 0b01000 2163 for branch on CTR insns (BO == 1a00t or 1a01t). */ 2164 if ((insn & (0x14 << 21)) == (0x04 << 21)) 2165 insn |= 0x02 << 21; 2166 else if ((insn & (0x14 << 21)) == (0x10 << 21)) 2167 insn |= 0x08 << 21; 2168 else 2169 return bfd_reloc_continue; 2170 } 2171 else 2172 { 2173 bfd_vma target = 0; 2174 bfd_vma from; 2175 2176 if (!bfd_is_com_section (symbol->section)) 2177 target = symbol->value; 2178 target += symbol->section->output_section->vma; 2179 target += symbol->section->output_offset; 2180 target += reloc_entry->addend; 2181 2182 from = (reloc_entry->address 2183 + input_section->output_offset 2184 + input_section->output_section->vma); 2185 2186 /* Invert 'y' bit if not the default. */ 2187 if ((bfd_signed_vma) (target - from) < 0) 2188 insn ^= 0x01 << 21; 2189 } 2190 bfd_put_32 (abfd, insn, (bfd_byte *) data + octets); 2191 return bfd_reloc_continue; 2192} 2193 2194static bfd_reloc_status_type 2195ppc64_elf_sectoff_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, 2196 void *data, asection *input_section, 2197 bfd *output_bfd, char **error_message) 2198{ 2199 /* If this is a relocatable link (output_bfd test tells us), just 2200 call the generic function. Any adjustment will be done at final 2201 link time. */ 2202 if (output_bfd != NULL) 2203 return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, 2204 input_section, output_bfd, error_message); 2205 2206 /* Subtract the symbol section base address. */ 2207 reloc_entry->addend -= symbol->section->output_section->vma; 2208 return bfd_reloc_continue; 2209} 2210 2211static bfd_reloc_status_type 2212ppc64_elf_sectoff_ha_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, 2213 void *data, asection *input_section, 2214 bfd *output_bfd, char **error_message) 2215{ 2216 /* If this is a relocatable link (output_bfd test tells us), just 2217 call the generic function. Any adjustment will be done at final 2218 link time. */ 2219 if (output_bfd != NULL) 2220 return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, 2221 input_section, output_bfd, error_message); 2222 2223 /* Subtract the symbol section base address. */ 2224 reloc_entry->addend -= symbol->section->output_section->vma; 2225 2226 /* Adjust the addend for sign extension of the low 16 bits. */ 2227 reloc_entry->addend += 0x8000; 2228 return bfd_reloc_continue; 2229} 2230 2231static bfd_reloc_status_type 2232ppc64_elf_toc_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, 2233 void *data, asection *input_section, 2234 bfd *output_bfd, char **error_message) 2235{ 2236 bfd_vma TOCstart; 2237 2238 /* If this is a relocatable link (output_bfd test tells us), just 2239 call the generic function. Any adjustment will be done at final 2240 link time. */ 2241 if (output_bfd != NULL) 2242 return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, 2243 input_section, output_bfd, error_message); 2244 2245 TOCstart = _bfd_get_gp_value (input_section->output_section->owner); 2246 if (TOCstart == 0) 2247 TOCstart = ppc64_elf_toc (input_section->output_section->owner); 2248 2249 /* Subtract the TOC base address. */ 2250 reloc_entry->addend -= TOCstart + TOC_BASE_OFF; 2251 return bfd_reloc_continue; 2252} 2253 2254static bfd_reloc_status_type 2255ppc64_elf_toc_ha_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, 2256 void *data, asection *input_section, 2257 bfd *output_bfd, char **error_message) 2258{ 2259 bfd_vma TOCstart; 2260 2261 /* If this is a relocatable link (output_bfd test tells us), just 2262 call the generic function. Any adjustment will be done at final 2263 link time. */ 2264 if (output_bfd != NULL) 2265 return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, 2266 input_section, output_bfd, error_message); 2267 2268 TOCstart = _bfd_get_gp_value (input_section->output_section->owner); 2269 if (TOCstart == 0) 2270 TOCstart = ppc64_elf_toc (input_section->output_section->owner); 2271 2272 /* Subtract the TOC base address. */ 2273 reloc_entry->addend -= TOCstart + TOC_BASE_OFF; 2274 2275 /* Adjust the addend for sign extension of the low 16 bits. */ 2276 reloc_entry->addend += 0x8000; 2277 return bfd_reloc_continue; 2278} 2279 2280static bfd_reloc_status_type 2281ppc64_elf_toc64_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, 2282 void *data, asection *input_section, 2283 bfd *output_bfd, char **error_message) 2284{ 2285 bfd_vma TOCstart; 2286 bfd_size_type octets; 2287 2288 /* If this is a relocatable link (output_bfd test tells us), just 2289 call the generic function. Any adjustment will be done at final 2290 link time. */ 2291 if (output_bfd != NULL) 2292 return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, 2293 input_section, output_bfd, error_message); 2294 2295 TOCstart = _bfd_get_gp_value (input_section->output_section->owner); 2296 if (TOCstart == 0) 2297 TOCstart = ppc64_elf_toc (input_section->output_section->owner); 2298 2299 octets = reloc_entry->address * bfd_octets_per_byte (abfd); 2300 bfd_put_64 (abfd, TOCstart + TOC_BASE_OFF, (bfd_byte *) data + octets); 2301 return bfd_reloc_ok; 2302} 2303 2304static bfd_reloc_status_type 2305ppc64_elf_unhandled_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, 2306 void *data, asection *input_section, 2307 bfd *output_bfd, char **error_message) 2308{ 2309 /* If this is a relocatable link (output_bfd test tells us), just 2310 call the generic function. Any adjustment will be done at final 2311 link time. */ 2312 if (output_bfd != NULL) 2313 return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, 2314 input_section, output_bfd, error_message); 2315 2316 if (error_message != NULL) 2317 { 2318 static char buf[60]; 2319 sprintf (buf, "generic linker can't handle %s", 2320 reloc_entry->howto->name); 2321 *error_message = buf; 2322 } 2323 return bfd_reloc_dangerous; 2324} 2325 2326struct ppc64_elf_obj_tdata 2327{ 2328 struct elf_obj_tdata elf; 2329 2330 /* Shortcuts to dynamic linker sections. */ 2331 asection *got; 2332 asection *relgot; 2333 2334 /* TLS local dynamic got entry handling. Suppose for multiple GOT 2335 sections means we potentially need one of these for each input bfd. */ 2336 union { 2337 bfd_signed_vma refcount; 2338 bfd_vma offset; 2339 } tlsld_got; 2340}; 2341 2342#define ppc64_elf_tdata(bfd) \ 2343 ((struct ppc64_elf_obj_tdata *) (bfd)->tdata.any) 2344 2345#define ppc64_tlsld_got(bfd) \ 2346 (&ppc64_elf_tdata (bfd)->tlsld_got) 2347 2348/* Override the generic function because we store some extras. */ 2349 2350static bfd_boolean 2351ppc64_elf_mkobject (bfd *abfd) 2352{ 2353 bfd_size_type amt = sizeof (struct ppc64_elf_obj_tdata); 2354 abfd->tdata.any = bfd_zalloc (abfd, amt); 2355 if (abfd->tdata.any == NULL) 2356 return FALSE; 2357 return TRUE; 2358} 2359 2360/* Fix bad default arch selected for a 64 bit input bfd when the 2361 default is 32 bit. */ 2362 2363static bfd_boolean 2364ppc64_elf_object_p (bfd *abfd) 2365{ 2366 if (abfd->arch_info->the_default && abfd->arch_info->bits_per_word == 32) 2367 { 2368 Elf_Internal_Ehdr *i_ehdr = elf_elfheader (abfd); 2369 2370 if (i_ehdr->e_ident[EI_CLASS] == ELFCLASS64) 2371 { 2372 /* Relies on arch after 32 bit default being 64 bit default. */ 2373 abfd->arch_info = abfd->arch_info->next; 2374 BFD_ASSERT (abfd->arch_info->bits_per_word == 64); 2375 } 2376 } 2377 return TRUE; 2378} 2379 2380/* Support for core dump NOTE sections. */ 2381 2382static bfd_boolean 2383ppc64_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note) 2384{ 2385 size_t offset, raw_size; 2386 2387 if (note->descsz != 504) 2388 return FALSE; 2389 2390 /* pr_cursig */ 2391 elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12); 2392 2393 /* pr_pid */ 2394 elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 32); 2395 2396 /* pr_reg */ 2397 offset = 112; 2398 raw_size = 384; 2399 2400 /* Make a ".reg/999" section. */ 2401 return _bfd_elfcore_make_pseudosection (abfd, ".reg", 2402 raw_size, note->descpos + offset); 2403} 2404 2405static bfd_boolean 2406ppc64_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note) 2407{ 2408 if (note->descsz != 136) 2409 return FALSE; 2410 2411 elf_tdata (abfd)->core_program 2412 = _bfd_elfcore_strndup (abfd, note->descdata + 40, 16); 2413 elf_tdata (abfd)->core_command 2414 = _bfd_elfcore_strndup (abfd, note->descdata + 56, 80); 2415 2416 return TRUE; 2417} 2418 2419/* Merge backend specific data from an object file to the output 2420 object file when linking. */ 2421 2422static bfd_boolean 2423ppc64_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd) 2424{ 2425 /* Check if we have the same endianess. */ 2426 if (ibfd->xvec->byteorder != obfd->xvec->byteorder 2427 && ibfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN 2428 && obfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN) 2429 { 2430 const char *msg; 2431 2432 if (bfd_big_endian (ibfd)) 2433 msg = _("%s: compiled for a big endian system " 2434 "and target is little endian"); 2435 else 2436 msg = _("%s: compiled for a little endian system " 2437 "and target is big endian"); 2438 2439 (*_bfd_error_handler) (msg, bfd_archive_filename (ibfd)); 2440 2441 bfd_set_error (bfd_error_wrong_format); 2442 return FALSE; 2443 } 2444 2445 return TRUE; 2446} 2447 2448/* Add extra PPC sections. */ 2449 2450static struct bfd_elf_special_section const ppc64_elf_special_sections[]= 2451{ 2452 { ".sdata", 6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, 2453 { ".sbss", 5, -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, 2454 { ".plt", 4, 0, SHT_NOBITS, 0 }, 2455 { ".toc", 4, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, 2456 { ".toc1", 5, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, 2457 { ".tocbss", 7, 0, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, 2458 { NULL, 0, 0, 0, 0 } 2459}; 2460 2461struct _ppc64_elf_section_data 2462{ 2463 struct bfd_elf_section_data elf; 2464 2465 /* An array with one entry for each opd function descriptor. */ 2466 union 2467 { 2468 /* Points to the function code section for local opd entries. */ 2469 asection **func_sec; 2470 /* After editing .opd, adjust references to opd local syms. */ 2471 long *adjust; 2472 } opd; 2473 2474 /* An array for toc sections, indexed by offset/8. 2475 Specifies the relocation symbol index used at a given toc offset. */ 2476 unsigned *t_symndx; 2477}; 2478 2479#define ppc64_elf_section_data(sec) \ 2480 ((struct _ppc64_elf_section_data *) elf_section_data (sec)) 2481 2482static bfd_boolean 2483ppc64_elf_new_section_hook (bfd *abfd, asection *sec) 2484{ 2485 struct _ppc64_elf_section_data *sdata; 2486 bfd_size_type amt = sizeof (*sdata); 2487 2488 sdata = bfd_zalloc (abfd, amt); 2489 if (sdata == NULL) 2490 return FALSE; 2491 sec->used_by_bfd = sdata; 2492 2493 return _bfd_elf_new_section_hook (abfd, sec); 2494} 2495 2496/* The following functions are specific to the ELF linker, while 2497 functions above are used generally. Those named ppc64_elf_* are 2498 called by the main ELF linker code. They appear in this file more 2499 or less in the order in which they are called. eg. 2500 ppc64_elf_check_relocs is called early in the link process, 2501 ppc64_elf_finish_dynamic_sections is one of the last functions 2502 called. 2503 2504 PowerPC64-ELF uses a similar scheme to PowerPC64-XCOFF in that 2505 functions have both a function code symbol and a function descriptor 2506 symbol. A call to foo in a relocatable object file looks like: 2507 2508 . .text 2509 . x: 2510 . bl .foo 2511 . nop 2512 2513 The function definition in another object file might be: 2514 2515 . .section .opd 2516 . foo: .quad .foo 2517 . .quad .TOC.@tocbase 2518 . .quad 0 2519 . 2520 . .text 2521 . .foo: blr 2522 2523 When the linker resolves the call during a static link, the branch 2524 unsurprisingly just goes to .foo and the .opd information is unused. 2525 If the function definition is in a shared library, things are a little 2526 different: The call goes via a plt call stub, the opd information gets 2527 copied to the plt, and the linker patches the nop. 2528 2529 . x: 2530 . bl .foo_stub 2531 . ld 2,40(1) 2532 . 2533 . 2534 . .foo_stub: 2535 . addis 12,2,Lfoo@toc@ha # in practice, the call stub 2536 . addi 12,12,Lfoo@toc@l # is slightly optimized, but 2537 . std 2,40(1) # this is the general idea 2538 . ld 11,0(12) 2539 . ld 2,8(12) 2540 . mtctr 11 2541 . ld 11,16(12) 2542 . bctr 2543 . 2544 . .section .plt 2545 . Lfoo: reloc (R_PPC64_JMP_SLOT, foo) 2546 2547 The "reloc ()" notation is supposed to indicate that the linker emits 2548 an R_PPC64_JMP_SLOT reloc against foo. The dynamic linker does the opd 2549 copying. 2550 2551 What are the difficulties here? Well, firstly, the relocations 2552 examined by the linker in check_relocs are against the function code 2553 sym .foo, while the dynamic relocation in the plt is emitted against 2554 the function descriptor symbol, foo. Somewhere along the line, we need 2555 to carefully copy dynamic link information from one symbol to the other. 2556 Secondly, the generic part of the elf linker will make .foo a dynamic 2557 symbol as is normal for most other backends. We need foo dynamic 2558 instead, at least for an application final link. However, when 2559 creating a shared library containing foo, we need to have both symbols 2560 dynamic so that references to .foo are satisfied during the early 2561 stages of linking. Otherwise the linker might decide to pull in a 2562 definition from some other object, eg. a static library. */ 2563 2564/* The linker needs to keep track of the number of relocs that it 2565 decides to copy as dynamic relocs in check_relocs for each symbol. 2566 This is so that it can later discard them if they are found to be 2567 unnecessary. We store the information in a field extending the 2568 regular ELF linker hash table. */ 2569 2570struct ppc_dyn_relocs 2571{ 2572 struct ppc_dyn_relocs *next; 2573 2574 /* The input section of the reloc. */ 2575 asection *sec; 2576 2577 /* Total number of relocs copied for the input section. */ 2578 bfd_size_type count; 2579 2580 /* Number of pc-relative relocs copied for the input section. */ 2581 bfd_size_type pc_count; 2582}; 2583 2584/* Track GOT entries needed for a given symbol. We might need more 2585 than one got entry per symbol. */ 2586struct got_entry 2587{ 2588 struct got_entry *next; 2589 2590 /* The symbol addend that we'll be placing in the GOT. */ 2591 bfd_vma addend; 2592 2593 /* Unlike other ELF targets, we use separate GOT entries for the same 2594 symbol referenced from different input files. This is to support 2595 automatic multiple TOC/GOT sections, where the TOC base can vary 2596 from one input file to another. 2597 2598 Point to the BFD owning this GOT entry. */ 2599 bfd *owner; 2600 2601 /* Zero for non-tls entries, or TLS_TLS and one of TLS_GD, TLS_LD, 2602 TLS_TPREL or TLS_DTPREL for tls entries. */ 2603 char tls_type; 2604 2605 /* Reference count until size_dynamic_sections, GOT offset thereafter. */ 2606 union 2607 { 2608 bfd_signed_vma refcount; 2609 bfd_vma offset; 2610 } got; 2611}; 2612 2613/* The same for PLT. */ 2614struct plt_entry 2615{ 2616 struct plt_entry *next; 2617 2618 bfd_vma addend; 2619 2620 union 2621 { 2622 bfd_signed_vma refcount; 2623 bfd_vma offset; 2624 } plt; 2625}; 2626 2627/* Of those relocs that might be copied as dynamic relocs, this macro 2628 selects those that must be copied when linking a shared library, 2629 even when the symbol is local. */ 2630 2631#define MUST_BE_DYN_RELOC(RTYPE) \ 2632 ((RTYPE) != R_PPC64_REL32 \ 2633 && (RTYPE) != R_PPC64_REL64 \ 2634 && (RTYPE) != R_PPC64_REL30) 2635 2636/* If ELIMINATE_COPY_RELOCS is non-zero, the linker will try to avoid 2637 copying dynamic variables from a shared lib into an app's dynbss 2638 section, and instead use a dynamic relocation to point into the 2639 shared lib. With code that gcc generates, it's vital that this be 2640 enabled; In the PowerPC64 ABI, the address of a function is actually 2641 the address of a function descriptor, which resides in the .opd 2642 section. gcc uses the descriptor directly rather than going via the 2643 GOT as some other ABI's do, which means that initialized function 2644 pointers must reference the descriptor. Thus, a function pointer 2645 initialized to the address of a function in a shared library will 2646 either require a copy reloc, or a dynamic reloc. Using a copy reloc 2647 redefines the function descriptor symbol to point to the copy. This 2648 presents a problem as a plt entry for that function is also 2649 initialized from the function descriptor symbol and the copy reloc 2650 may not be initialized first. */ 2651#define ELIMINATE_COPY_RELOCS 1 2652 2653/* Section name for stubs is the associated section name plus this 2654 string. */ 2655#define STUB_SUFFIX ".stub" 2656 2657/* Linker stubs. 2658 ppc_stub_long_branch: 2659 Used when a 14 bit branch (or even a 24 bit branch) can't reach its 2660 destination, but a 24 bit branch in a stub section will reach. 2661 . b dest 2662 2663 ppc_stub_plt_branch: 2664 Similar to the above, but a 24 bit branch in the stub section won't 2665 reach its destination. 2666 . addis %r12,%r2,xxx@toc@ha 2667 . ld %r11,xxx@toc@l(%r12) 2668 . mtctr %r11 2669 . bctr 2670 2671 ppc_stub_plt_call: 2672 Used to call a function in a shared library. 2673 . addis %r12,%r2,xxx@toc@ha 2674 . std %r2,40(%r1) 2675 . ld %r11,xxx+0@toc@l(%r12) 2676 . ld %r2,xxx+8@toc@l(%r12) 2677 . mtctr %r11 2678 . ld %r11,xxx+16@toc@l(%r12) 2679 . bctr 2680 2681 ppc_stub_long_branch and ppc_stub_plt_branch may also have additional 2682 code to adjust the value and save r2 to support multiple toc sections. 2683 A ppc_stub_long_branch with an r2 offset looks like: 2684 . std %r2,40(%r1) 2685 . addis %r2,%r2,off@ha 2686 . addi %r2,%r2,off@l 2687 . b dest 2688 2689 A ppc_stub_plt_branch with an r2 offset looks like: 2690 . std %r2,40(%r1) 2691 . addis %r12,%r2,xxx@toc@ha 2692 . ld %r11,xxx@toc@l(%r12) 2693 . addis %r2,%r2,off@ha 2694 . addi %r2,%r2,off@l 2695 . mtctr %r11 2696 . bctr 2697*/ 2698 2699enum ppc_stub_type { 2700 ppc_stub_none, 2701 ppc_stub_long_branch, 2702 ppc_stub_long_branch_r2off, 2703 ppc_stub_plt_branch, 2704 ppc_stub_plt_branch_r2off, 2705 ppc_stub_plt_call 2706}; 2707 2708struct ppc_stub_hash_entry { 2709 2710 /* Base hash table entry structure. */ 2711 struct bfd_hash_entry root; 2712 2713 enum ppc_stub_type stub_type; 2714 2715 /* The stub section. */ 2716 asection *stub_sec; 2717 2718 /* Offset within stub_sec of the beginning of this stub. */ 2719 bfd_vma stub_offset; 2720 2721 /* Given the symbol's value and its section we can determine its final 2722 value when building the stubs (so the stub knows where to jump. */ 2723 bfd_vma target_value; 2724 asection *target_section; 2725 2726 /* The symbol table entry, if any, that this was derived from. */ 2727 struct ppc_link_hash_entry *h; 2728 2729 /* And the reloc addend that this was derived from. */ 2730 bfd_vma addend; 2731 2732 /* Where this stub is being called from, or, in the case of combined 2733 stub sections, the first input section in the group. */ 2734 asection *id_sec; 2735}; 2736 2737struct ppc_branch_hash_entry { 2738 2739 /* Base hash table entry structure. */ 2740 struct bfd_hash_entry root; 2741 2742 /* Offset within .branch_lt. */ 2743 unsigned int offset; 2744 2745 /* Generation marker. */ 2746 unsigned int iter; 2747}; 2748 2749struct ppc_link_hash_entry 2750{ 2751 struct elf_link_hash_entry elf; 2752 2753 /* A pointer to the most recently used stub hash entry against this 2754 symbol. */ 2755 struct ppc_stub_hash_entry *stub_cache; 2756 2757 /* Track dynamic relocs copied for this symbol. */ 2758 struct ppc_dyn_relocs *dyn_relocs; 2759 2760 /* Link between function code and descriptor symbols. */ 2761 struct elf_link_hash_entry *oh; 2762 2763 /* Flag function code and descriptor symbols. */ 2764 unsigned int is_func:1; 2765 unsigned int is_func_descriptor:1; 2766 unsigned int is_entry:1; 2767 2768 /* Whether global opd sym has been adjusted or not. */ 2769 unsigned int adjust_done:1; 2770 2771 /* Contexts in which symbol is used in the GOT (or TOC). 2772 TLS_GD .. TLS_EXPLICIT bits are or'd into the mask as the 2773 corresponding relocs are encountered during check_relocs. 2774 tls_optimize clears TLS_GD .. TLS_TPREL when optimizing to 2775 indicate the corresponding GOT entry type is not needed. 2776 tls_optimize may also set TLS_TPRELGD when a GD reloc turns into 2777 a TPREL one. We use a separate flag rather than setting TPREL 2778 just for convenience in distinguishing the two cases. */ 2779#define TLS_GD 1 /* GD reloc. */ 2780#define TLS_LD 2 /* LD reloc. */ 2781#define TLS_TPREL 4 /* TPREL reloc, => IE. */ 2782#define TLS_DTPREL 8 /* DTPREL reloc, => LD. */ 2783#define TLS_TLS 16 /* Any TLS reloc. */ 2784#define TLS_EXPLICIT 32 /* Marks TOC section TLS relocs. */ 2785#define TLS_TPRELGD 64 /* TPREL reloc resulting from GD->IE. */ 2786 char tls_mask; 2787}; 2788 2789/* ppc64 ELF linker hash table. */ 2790 2791struct ppc_link_hash_table 2792{ 2793 struct elf_link_hash_table elf; 2794 2795 /* The stub hash table. */ 2796 struct bfd_hash_table stub_hash_table; 2797 2798 /* Another hash table for plt_branch stubs. */ 2799 struct bfd_hash_table branch_hash_table; 2800 2801 /* Linker stub bfd. */ 2802 bfd *stub_bfd; 2803 2804 /* Linker call-backs. */ 2805 asection * (*add_stub_section) (const char *, asection *); 2806 void (*layout_sections_again) (void); 2807 2808 /* Array to keep track of which stub sections have been created, and 2809 information on stub grouping. */ 2810 struct map_stub { 2811 /* This is the section to which stubs in the group will be attached. */ 2812 asection *link_sec; 2813 /* The stub section. */ 2814 asection *stub_sec; 2815 /* Along with elf_gp, specifies the TOC pointer used in this group. */ 2816 bfd_vma toc_off; 2817 } *stub_group; 2818 2819 /* Support for multiple toc sections. */ 2820 unsigned int no_multi_toc; 2821 unsigned int multi_toc_needed; 2822 2823 /* Temp used when calculating TOC pointers. */ 2824 bfd_vma toc_curr; 2825 2826 /* Highest input section id. */ 2827 int top_id; 2828 2829 /* Highest output section index. */ 2830 int top_index; 2831 2832 /* List of input sections for each output section. */ 2833 asection **input_list; 2834 2835 /* Short-cuts to get to dynamic linker sections. */ 2836 asection *got; 2837 asection *plt; 2838 asection *relplt; 2839 asection *dynbss; 2840 asection *relbss; 2841 asection *glink; 2842 asection *sfpr; 2843 asection *brlt; 2844 asection *relbrlt; 2845 2846 /* Shortcut to .__tls_get_addr. */ 2847 struct elf_link_hash_entry *tls_get_addr; 2848 2849 /* Statistics. */ 2850 unsigned long stub_count[ppc_stub_plt_call]; 2851 2852 /* Set if we should emit symbols for stubs. */ 2853 unsigned int emit_stub_syms; 2854 2855 /* Set on error. */ 2856 unsigned int stub_error; 2857 2858 /* Flag set when small branches are detected. Used to 2859 select suitable defaults for the stub group size. */ 2860 unsigned int has_14bit_branch; 2861 2862 /* Set if we detect a reference undefined weak symbol. */ 2863 unsigned int have_undefweak; 2864 2865 /* Incremented every time we size stubs. */ 2866 unsigned int stub_iteration; 2867 2868 /* Small local sym to section mapping cache. */ 2869 struct sym_sec_cache sym_sec; 2870}; 2871 2872/* Get the ppc64 ELF linker hash table from a link_info structure. */ 2873 2874#define ppc_hash_table(p) \ 2875 ((struct ppc_link_hash_table *) ((p)->hash)) 2876 2877#define ppc_stub_hash_lookup(table, string, create, copy) \ 2878 ((struct ppc_stub_hash_entry *) \ 2879 bfd_hash_lookup ((table), (string), (create), (copy))) 2880 2881#define ppc_branch_hash_lookup(table, string, create, copy) \ 2882 ((struct ppc_branch_hash_entry *) \ 2883 bfd_hash_lookup ((table), (string), (create), (copy))) 2884 2885/* Create an entry in the stub hash table. */ 2886 2887static struct bfd_hash_entry * 2888stub_hash_newfunc (struct bfd_hash_entry *entry, 2889 struct bfd_hash_table *table, 2890 const char *string) 2891{ 2892 /* Allocate the structure if it has not already been allocated by a 2893 subclass. */ 2894 if (entry == NULL) 2895 { 2896 entry = bfd_hash_allocate (table, sizeof (struct ppc_stub_hash_entry)); 2897 if (entry == NULL) 2898 return entry; 2899 } 2900 2901 /* Call the allocation method of the superclass. */ 2902 entry = bfd_hash_newfunc (entry, table, string); 2903 if (entry != NULL) 2904 { 2905 struct ppc_stub_hash_entry *eh; 2906 2907 /* Initialize the local fields. */ 2908 eh = (struct ppc_stub_hash_entry *) entry; 2909 eh->stub_type = ppc_stub_none; 2910 eh->stub_sec = NULL; 2911 eh->stub_offset = 0; 2912 eh->target_value = 0; 2913 eh->target_section = NULL; 2914 eh->h = NULL; 2915 eh->id_sec = NULL; 2916 } 2917 2918 return entry; 2919} 2920 2921/* Create an entry in the branch hash table. */ 2922 2923static struct bfd_hash_entry * 2924branch_hash_newfunc (struct bfd_hash_entry *entry, 2925 struct bfd_hash_table *table, 2926 const char *string) 2927{ 2928 /* Allocate the structure if it has not already been allocated by a 2929 subclass. */ 2930 if (entry == NULL) 2931 { 2932 entry = bfd_hash_allocate (table, sizeof (struct ppc_branch_hash_entry)); 2933 if (entry == NULL) 2934 return entry; 2935 } 2936 2937 /* Call the allocation method of the superclass. */ 2938 entry = bfd_hash_newfunc (entry, table, string); 2939 if (entry != NULL) 2940 { 2941 struct ppc_branch_hash_entry *eh; 2942 2943 /* Initialize the local fields. */ 2944 eh = (struct ppc_branch_hash_entry *) entry; 2945 eh->offset = 0; 2946 eh->iter = 0; 2947 } 2948 2949 return entry; 2950} 2951 2952/* Create an entry in a ppc64 ELF linker hash table. */ 2953 2954static struct bfd_hash_entry * 2955link_hash_newfunc (struct bfd_hash_entry *entry, 2956 struct bfd_hash_table *table, 2957 const char *string) 2958{ 2959 /* Allocate the structure if it has not already been allocated by a 2960 subclass. */ 2961 if (entry == NULL) 2962 { 2963 entry = bfd_hash_allocate (table, sizeof (struct ppc_link_hash_entry)); 2964 if (entry == NULL) 2965 return entry; 2966 } 2967 2968 /* Call the allocation method of the superclass. */ 2969 entry = _bfd_elf_link_hash_newfunc (entry, table, string); 2970 if (entry != NULL) 2971 { 2972 struct ppc_link_hash_entry *eh = (struct ppc_link_hash_entry *) entry; 2973 2974 eh->stub_cache = NULL; 2975 eh->dyn_relocs = NULL; 2976 eh->oh = NULL; 2977 eh->is_func = 0; 2978 eh->is_func_descriptor = 0; 2979 eh->is_entry = 0; 2980 eh->adjust_done = 0; 2981 eh->tls_mask = 0; 2982 } 2983 2984 return entry; 2985} 2986 2987/* Create a ppc64 ELF linker hash table. */ 2988 2989static struct bfd_link_hash_table * 2990ppc64_elf_link_hash_table_create (bfd *abfd) 2991{ 2992 struct ppc_link_hash_table *htab; 2993 bfd_size_type amt = sizeof (struct ppc_link_hash_table); 2994 2995 htab = bfd_zmalloc (amt); 2996 if (htab == NULL) 2997 return NULL; 2998 2999 if (! _bfd_elf_link_hash_table_init (&htab->elf, abfd, link_hash_newfunc)) 3000 { 3001 free (htab); 3002 return NULL; 3003 } 3004 3005 /* Init the stub hash table too. */ 3006 if (!bfd_hash_table_init (&htab->stub_hash_table, stub_hash_newfunc)) 3007 return NULL; 3008 3009 /* And the branch hash table. */ 3010 if (!bfd_hash_table_init (&htab->branch_hash_table, branch_hash_newfunc)) 3011 return NULL; 3012 3013 /* Initializing two fields of the union is just cosmetic. We really 3014 only care about glist, but when compiled on a 32-bit host the 3015 bfd_vma fields are larger. Setting the bfd_vma to zero makes 3016 debugger inspection of these fields look nicer. */ 3017 htab->elf.init_refcount.refcount = 0; 3018 htab->elf.init_refcount.glist = NULL; 3019 htab->elf.init_offset.offset = 0; 3020 htab->elf.init_offset.glist = NULL; 3021 3022 return &htab->elf.root; 3023} 3024 3025/* Free the derived linker hash table. */ 3026 3027static void 3028ppc64_elf_link_hash_table_free (struct bfd_link_hash_table *hash) 3029{ 3030 struct ppc_link_hash_table *ret = (struct ppc_link_hash_table *) hash; 3031 3032 bfd_hash_table_free (&ret->stub_hash_table); 3033 bfd_hash_table_free (&ret->branch_hash_table); 3034 _bfd_generic_link_hash_table_free (hash); 3035} 3036 3037/* Satisfy the ELF linker by filling in some fields in our fake bfd. */ 3038 3039void 3040ppc64_elf_init_stub_bfd (bfd *abfd, struct bfd_link_info *info) 3041{ 3042 struct ppc_link_hash_table *htab; 3043 3044 elf_elfheader (abfd)->e_ident[EI_CLASS] = ELFCLASS64; 3045 3046/* Always hook our dynamic sections into the first bfd, which is the 3047 linker created stub bfd. This ensures that the GOT header is at 3048 the start of the output TOC section. */ 3049 htab = ppc_hash_table (info); 3050 htab->stub_bfd = abfd; 3051 htab->elf.dynobj = abfd; 3052} 3053 3054/* Build a name for an entry in the stub hash table. */ 3055 3056static char * 3057ppc_stub_name (const asection *input_section, 3058 const asection *sym_sec, 3059 const struct ppc_link_hash_entry *h, 3060 const Elf_Internal_Rela *rel) 3061{ 3062 char *stub_name; 3063 bfd_size_type len; 3064 3065 /* rel->r_addend is actually 64 bit, but who uses more than +/- 2^31 3066 offsets from a sym as a branch target? In fact, we could 3067 probably assume the addend is always zero. */ 3068 BFD_ASSERT (((int) rel->r_addend & 0xffffffff) == rel->r_addend); 3069 3070 if (h) 3071 { 3072 len = 8 + 1 + strlen (h->elf.root.root.string) + 1 + 8 + 1; 3073 stub_name = bfd_malloc (len); 3074 if (stub_name != NULL) 3075 { 3076 sprintf (stub_name, "%08x.%s+%x", 3077 input_section->id & 0xffffffff, 3078 h->elf.root.root.string, 3079 (int) rel->r_addend & 0xffffffff); 3080 } 3081 } 3082 else 3083 { 3084 len = 8 + 1 + 8 + 1 + 8 + 1 + 8 + 1; 3085 stub_name = bfd_malloc (len); 3086 if (stub_name != NULL) 3087 { 3088 sprintf (stub_name, "%08x.%x:%x+%x", 3089 input_section->id & 0xffffffff, 3090 sym_sec->id & 0xffffffff, 3091 (int) ELF64_R_SYM (rel->r_info) & 0xffffffff, 3092 (int) rel->r_addend & 0xffffffff); 3093 } 3094 } 3095 return stub_name; 3096} 3097 3098/* Look up an entry in the stub hash. Stub entries are cached because 3099 creating the stub name takes a bit of time. */ 3100 3101static struct ppc_stub_hash_entry * 3102ppc_get_stub_entry (const asection *input_section, 3103 const asection *sym_sec, 3104 struct elf_link_hash_entry *hash, 3105 const Elf_Internal_Rela *rel, 3106 struct ppc_link_hash_table *htab) 3107{ 3108 struct ppc_stub_hash_entry *stub_entry; 3109 struct ppc_link_hash_entry *h = (struct ppc_link_hash_entry *) hash; 3110 const asection *id_sec; 3111 3112 /* If this input section is part of a group of sections sharing one 3113 stub section, then use the id of the first section in the group. 3114 Stub names need to include a section id, as there may well be 3115 more than one stub used to reach say, printf, and we need to 3116 distinguish between them. */ 3117 id_sec = htab->stub_group[input_section->id].link_sec; 3118 3119 if (h != NULL && h->stub_cache != NULL 3120 && h->stub_cache->h == h 3121 && h->stub_cache->id_sec == id_sec) 3122 { 3123 stub_entry = h->stub_cache; 3124 } 3125 else 3126 { 3127 char *stub_name; 3128 3129 stub_name = ppc_stub_name (id_sec, sym_sec, h, rel); 3130 if (stub_name == NULL) 3131 return NULL; 3132 3133 stub_entry = ppc_stub_hash_lookup (&htab->stub_hash_table, 3134 stub_name, FALSE, FALSE); 3135 if (h != NULL) 3136 h->stub_cache = stub_entry; 3137 3138 free (stub_name); 3139 } 3140 3141 return stub_entry; 3142} 3143 3144/* Add a new stub entry to the stub hash. Not all fields of the new 3145 stub entry are initialised. */ 3146 3147static struct ppc_stub_hash_entry * 3148ppc_add_stub (const char *stub_name, 3149 asection *section, 3150 struct ppc_link_hash_table *htab) 3151{ 3152 asection *link_sec; 3153 asection *stub_sec; 3154 struct ppc_stub_hash_entry *stub_entry; 3155 3156 link_sec = htab->stub_group[section->id].link_sec; 3157 stub_sec = htab->stub_group[section->id].stub_sec; 3158 if (stub_sec == NULL) 3159 { 3160 stub_sec = htab->stub_group[link_sec->id].stub_sec; 3161 if (stub_sec == NULL) 3162 { 3163 size_t namelen; 3164 bfd_size_type len; 3165 char *s_name; 3166 3167 namelen = strlen (link_sec->name); 3168 len = namelen + sizeof (STUB_SUFFIX); 3169 s_name = bfd_alloc (htab->stub_bfd, len); 3170 if (s_name == NULL) 3171 return NULL; 3172 3173 memcpy (s_name, link_sec->name, namelen); 3174 memcpy (s_name + namelen, STUB_SUFFIX, sizeof (STUB_SUFFIX)); 3175 stub_sec = (*htab->add_stub_section) (s_name, link_sec); 3176 if (stub_sec == NULL) 3177 return NULL; 3178 htab->stub_group[link_sec->id].stub_sec = stub_sec; 3179 } 3180 htab->stub_group[section->id].stub_sec = stub_sec; 3181 } 3182 3183 /* Enter this entry into the linker stub hash table. */ 3184 stub_entry = ppc_stub_hash_lookup (&htab->stub_hash_table, stub_name, 3185 TRUE, FALSE); 3186 if (stub_entry == NULL) 3187 { 3188 (*_bfd_error_handler) (_("%s: cannot create stub entry %s"), 3189 bfd_archive_filename (section->owner), 3190 stub_name); 3191 return NULL; 3192 } 3193 3194 stub_entry->stub_sec = stub_sec; 3195 stub_entry->stub_offset = 0; 3196 stub_entry->id_sec = link_sec; 3197 return stub_entry; 3198} 3199 3200/* Create sections for linker generated code. */ 3201 3202static bfd_boolean 3203create_linkage_sections (bfd *dynobj, struct bfd_link_info *info) 3204{ 3205 struct ppc_link_hash_table *htab; 3206 flagword flags; 3207 3208 htab = ppc_hash_table (info); 3209 3210 /* Create .sfpr for code to save and restore fp regs. */ 3211 flags = (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_READONLY 3212 | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED); 3213 htab->sfpr = bfd_make_section_anyway (dynobj, ".sfpr"); 3214 if (htab->sfpr == NULL 3215 || ! bfd_set_section_flags (dynobj, htab->sfpr, flags) 3216 || ! bfd_set_section_alignment (dynobj, htab->sfpr, 2)) 3217 return FALSE; 3218 3219 /* Create .glink for lazy dynamic linking support. */ 3220 htab->glink = bfd_make_section_anyway (dynobj, ".glink"); 3221 if (htab->glink == NULL 3222 || ! bfd_set_section_flags (dynobj, htab->glink, flags) 3223 || ! bfd_set_section_alignment (dynobj, htab->glink, 2)) 3224 return FALSE; 3225 3226 /* Create .branch_lt for plt_branch stubs. */ 3227 flags = (SEC_ALLOC | SEC_LOAD 3228 | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED); 3229 htab->brlt = bfd_make_section_anyway (dynobj, ".branch_lt"); 3230 if (htab->brlt == NULL 3231 || ! bfd_set_section_flags (dynobj, htab->brlt, flags) 3232 || ! bfd_set_section_alignment (dynobj, htab->brlt, 3)) 3233 return FALSE; 3234 3235 if (info->shared) 3236 { 3237 flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY 3238 | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED); 3239 htab->relbrlt = bfd_make_section_anyway (dynobj, ".rela.branch_lt"); 3240 if (!htab->relbrlt 3241 || ! bfd_set_section_flags (dynobj, htab->relbrlt, flags) 3242 || ! bfd_set_section_alignment (dynobj, htab->relbrlt, 3)) 3243 return FALSE; 3244 } 3245 return TRUE; 3246} 3247 3248/* Create .got and .rela.got sections in ABFD, and .got in dynobj if 3249 not already done. */ 3250 3251static bfd_boolean 3252create_got_section (bfd *abfd, struct bfd_link_info *info) 3253{ 3254 asection *got, *relgot; 3255 flagword flags; 3256 struct ppc_link_hash_table *htab = ppc_hash_table (info); 3257 3258 if (!htab->got) 3259 { 3260 if (! _bfd_elf_create_got_section (htab->elf.dynobj, info)) 3261 return FALSE; 3262 3263 htab->got = bfd_get_section_by_name (htab->elf.dynobj, ".got"); 3264 if (!htab->got) 3265 abort (); 3266 } 3267 3268 flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY 3269 | SEC_LINKER_CREATED); 3270
|