elf64-ppc.c 429 KB
Newer Older
1
/* PowerPC64-specific support for 64-bit ELF.
2
   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
Alan Modra's avatar
bfd/  
Alan Modra committed
3
   2009, 2010, 2011, 2012 Free Software Foundation, Inc.
4 5
   Written by Linus Nordberg, Swox AB <info@swox.com>,
   based on elf32-ppc.c by Ian Lance Taylor.
6
   Largely rewritten by Alan Modra.
7

8
   This file is part of BFD, the Binary File Descriptor library.
9

10 11
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
12
   the Free Software Foundation; either version 3 of the License, or
13
   (at your option) any later version.
14

15 16 17 18
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
19

20 21
   You should have received a copy of the GNU General Public License along
   with this program; if not, write to the Free Software Foundation, Inc.,
22
   51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
23

24

25 26 27
/* The 64-bit PowerPC ELF ABI may be found at
   http://www.linuxbase.org/spec/ELF/ppc64/PPC-elf64abi.txt, and
   http://www.linuxbase.org/spec/ELF/ppc64/spec/book1.html  */
28

Alan Modra's avatar
 
Alan Modra committed
29
#include "sysdep.h"
30
#include <stdarg.h>
31 32 33 34
#include "bfd.h"
#include "bfdlink.h"
#include "libbfd.h"
#include "elf-bfd.h"
35
#include "elf/ppc64.h"
36
#include "elf64-ppc.h"
Alan Modra's avatar
bfd/  
Alan Modra committed
37
#include "dwarf2.h"
38

39
static bfd_reloc_status_type ppc64_elf_ha_reloc
40
  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
41 42
static bfd_reloc_status_type ppc64_elf_branch_reloc
  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
43
static bfd_reloc_status_type ppc64_elf_brtaken_reloc
44
  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
45
static bfd_reloc_status_type ppc64_elf_sectoff_reloc
46
  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
47
static bfd_reloc_status_type ppc64_elf_sectoff_ha_reloc
48
  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
49
static bfd_reloc_status_type ppc64_elf_toc_reloc
50
  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
51
static bfd_reloc_status_type ppc64_elf_toc_ha_reloc
52
  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
53
static bfd_reloc_status_type ppc64_elf_toc64_reloc
54
  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
55
static bfd_reloc_status_type ppc64_elf_unhandled_reloc
56
  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
57
static bfd_vma opd_entry_value
Alan Modra's avatar
Alan Modra committed
58
  (asection *, bfd_vma, asection **, bfd_vma *, bfd_boolean);
59

60 61 62 63 64
#define TARGET_LITTLE_SYM	bfd_elf64_powerpcle_vec
#define TARGET_LITTLE_NAME	"elf64-powerpcle"
#define TARGET_BIG_SYM		bfd_elf64_powerpc_vec
#define TARGET_BIG_NAME		"elf64-powerpc"
#define ELF_ARCH		bfd_arch_powerpc
H.J. Lu's avatar
H.J. Lu committed
65
#define ELF_TARGET_ID		PPC64_ELF_DATA
66 67
#define ELF_MACHINE_CODE	EM_PPC64
#define ELF_MAXPAGESIZE		0x10000
H.J. Lu's avatar
bfd/  
H.J. Lu committed
68
#define ELF_COMMONPAGESIZE	0x1000
69 70 71 72 73 74 75 76 77 78
#define elf_info_to_howto	ppc64_elf_info_to_howto

#define elf_backend_want_got_sym 0
#define elf_backend_want_plt_sym 0
#define elf_backend_plt_alignment 3
#define elf_backend_plt_not_loaded 1
#define elf_backend_got_header_size 8
#define elf_backend_can_gc_sections 1
#define elf_backend_can_refcount 1
#define elf_backend_rela_normal 1
79
#define elf_backend_default_execstack 0
80

81
#define bfd_elf64_mkobject		      ppc64_elf_mkobject
82
#define bfd_elf64_bfd_reloc_type_lookup	      ppc64_elf_reloc_type_lookup
83
#define bfd_elf64_bfd_reloc_name_lookup	      ppc64_elf_reloc_name_lookup
84 85
#define bfd_elf64_bfd_merge_private_bfd_data  ppc64_elf_merge_private_bfd_data
#define bfd_elf64_bfd_print_private_bfd_data  ppc64_elf_print_private_bfd_data
86 87 88
#define bfd_elf64_new_section_hook	      ppc64_elf_new_section_hook
#define bfd_elf64_bfd_link_hash_table_create  ppc64_elf_link_hash_table_create
#define bfd_elf64_bfd_link_hash_table_free    ppc64_elf_link_hash_table_free
Jakub Jelinek's avatar
bfd/  
Jakub Jelinek committed
89
#define bfd_elf64_get_synthetic_symtab	      ppc64_elf_get_synthetic_symtab
90
#define bfd_elf64_bfd_link_just_syms	      ppc64_elf_link_just_syms
91 92

#define elf_backend_object_p		      ppc64_elf_object_p
93 94
#define elf_backend_grok_prstatus	      ppc64_elf_grok_prstatus
#define elf_backend_grok_psinfo		      ppc64_elf_grok_psinfo
95
#define elf_backend_write_core_note	      ppc64_elf_write_core_note
96 97
#define elf_backend_create_dynamic_sections   ppc64_elf_create_dynamic_sections
#define elf_backend_copy_indirect_symbol      ppc64_elf_copy_indirect_symbol
98
#define elf_backend_add_symbol_hook	      ppc64_elf_add_symbol_hook
99
#define elf_backend_check_directives	      ppc64_elf_process_dot_syms
100
#define elf_backend_notice_as_needed	      ppc64_elf_notice_as_needed
101
#define elf_backend_archive_symbol_lookup     ppc64_elf_archive_symbol_lookup
102
#define elf_backend_check_relocs	      ppc64_elf_check_relocs
Alan Modra's avatar
bfd/  
Alan Modra committed
103
#define elf_backend_gc_keep		      ppc64_elf_gc_keep
104
#define elf_backend_gc_mark_dynamic_ref       ppc64_elf_gc_mark_dynamic_ref
105 106 107 108
#define elf_backend_gc_mark_hook	      ppc64_elf_gc_mark_hook
#define elf_backend_gc_sweep_hook	      ppc64_elf_gc_sweep_hook
#define elf_backend_adjust_dynamic_symbol     ppc64_elf_adjust_dynamic_symbol
#define elf_backend_hide_symbol		      ppc64_elf_hide_symbol
Alan Modra's avatar
Alan Modra committed
109
#define elf_backend_maybe_function_sym	      ppc64_elf_maybe_function_sym
110 111
#define elf_backend_always_size_sections      ppc64_elf_func_desc_adjust
#define elf_backend_size_dynamic_sections     ppc64_elf_size_dynamic_sections
112
#define elf_backend_hash_symbol		      ppc64_elf_hash_symbol
Alan Modra's avatar
bfd/  
Alan Modra committed
113
#define elf_backend_init_index_section	      _bfd_elf_init_2_index_sections
114
#define elf_backend_action_discarded	      ppc64_elf_action_discarded
115 116 117 118
#define elf_backend_relocate_section	      ppc64_elf_relocate_section
#define elf_backend_finish_dynamic_symbol     ppc64_elf_finish_dynamic_symbol
#define elf_backend_reloc_type_class	      ppc64_elf_reloc_type_class
#define elf_backend_finish_dynamic_sections   ppc64_elf_finish_dynamic_sections
119
#define elf_backend_link_output_symbol_hook   ppc64_elf_output_symbol_hook
120
#define elf_backend_special_sections	      ppc64_elf_special_sections
121
#define elf_backend_post_process_headers      _bfd_elf_set_osabi
Alan Modra's avatar
Alan Modra committed
122
#define elf_backend_merge_symbol_attribute    ppc64_elf_merge_symbol_attribute
123

124 125 126 127 128
/* The name of the dynamic interpreter.  This is put in the .interp
   section.  */
#define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1"

/* The size in bytes of an entry in the procedure linkage table.  */
129
#define PLT_ENTRY_SIZE(htab) (htab->opd_abi ? 24 : 8)
130 131

/* The initial size of the plt reserved for the dynamic linker.  */
132
#define PLT_INITIAL_ENTRY_SIZE(htab) (htab->opd_abi ? 24 : 16)
133

Alan Modra's avatar
Alan Modra committed
134 135 136 137 138 139 140 141
/* Offsets to some stack save slots.  */
#define STK_LR 16
#define STK_TOC(htab) (htab->opd_abi ? 40 : 24)
/* This one is dodgy.  ABIv2 does not have a linker word, so use the
   CR save slot.  Used only by optimised __tls_get_addr call stub,
   relying on __tls_get_addr_opt not saving CR..  */
#define STK_LINKER(htab) (htab->opd_abi ? 32 : 8)

142
/* TOC base pointers offset from start of TOC.  */
143 144 145 146 147
#define TOC_BASE_OFF	0x8000

/* Offset of tp and dtp pointers from start of TLS block.  */
#define TP_OFFSET	0x7000
#define DTP_OFFSET	0x8000
148

149 150
/* .plt call stub instructions.  The normal stub is like this, but
   sometimes the .plt entry crosses a 64k boundary and we need to
151
   insert an addi to adjust r11.  */
Alan Modra's avatar
Alan Modra committed
152
#define STD_R2_0R1	0xf8410000	/* std	 %r2,0+40(%r1)	     */
153 154 155 156 157
#define ADDIS_R11_R2	0x3d620000	/* addis %r11,%r2,xxx@ha     */
#define LD_R12_0R11	0xe98b0000	/* ld	 %r12,xxx+0@l(%r11)  */
#define MTCTR_R12	0x7d8903a6	/* mtctr %r12		     */
#define LD_R2_0R11	0xe84b0000	/* ld	 %r2,xxx+8@l(%r11)   */
#define LD_R11_0R11	0xe96b0000	/* ld	 %r11,xxx+16@l(%r11) */
158 159
#define BCTR		0x4e800420	/* bctr			     */

160
#define ADDI_R11_R11	0x396b0000	/* addi %r11,%r11,off@l  */
161 162 163
#define ADDIS_R2_R2	0x3c420000	/* addis %r2,%r2,off@ha  */
#define ADDI_R2_R2	0x38420000	/* addi  %r2,%r2,off@l   */

164 165 166
#define XOR_R2_R12_R12	0x7d826278	/* xor   %r2,%r12,%r12   */
#define ADD_R11_R11_R2	0x7d6b1214	/* add   %r11,%r11,%r2   */
#define XOR_R11_R12_R12	0x7d8b6278	/* xor   %r11,%r12,%r12  */
Alan Modra's avatar
bfd/  
Alan Modra committed
167 168 169 170 171
#define ADD_R2_R2_R11	0x7c425a14	/* add   %r2,%r2,%r11    */
#define CMPLDI_R2_0	0x28220000	/* cmpldi %r2,0          */
#define BNECTR		0x4ca20420	/* bnectr+               */
#define BNECTR_P4	0x4ce20420	/* bnectr+               */

172
#define LD_R12_0R2	0xe9820000	/* ld	 %r12,xxx+0(%r2) */
Alan Modra's avatar
bfd/  
Alan Modra committed
173 174 175
#define LD_R11_0R2	0xe9620000	/* ld	 %r11,xxx+0(%r2) */
#define LD_R2_0R2	0xe8420000	/* ld	 %r2,xxx+0(%r2)  */

Alan Modra's avatar
Alan Modra committed
176
#define LD_R2_0R1	0xe8410000	/* ld    %r2,0(%r1)      */
177

178 179 180
#define ADDIS_R12_R12	0x3d8c0000	/* addis %r12,%r12,xxx@ha */
#define LD_R12_0R12	0xe98c0000	/* ld    %r12,xxx@l(%r12) */

Alan Modra's avatar
bfd/  
Alan Modra committed
181
/* glink call stub instructions.  We enter with the index in R0.  */
182
#define GLINK_CALL_STUB_SIZE (16*4)
Alan Modra's avatar
bfd/  
Alan Modra committed
183 184 185 186 187 188 189
					/* 0:				*/
					/*  .quad plt0-1f		*/
					/* __glink:			*/
#define MFLR_R12	0x7d8802a6	/*  mflr %12			*/
#define BCL_20_31	0x429f0005	/*  bcl 20,31,1f		*/
					/* 1:				*/
#define MFLR_R11	0x7d6802a6	/*  mflr %11			*/
190
					/*  ld %2,(0b-1b)(%11)		*/
Alan Modra's avatar
bfd/  
Alan Modra committed
191
#define MTLR_R12	0x7d8803a6	/*  mtlr %12			*/
192 193 194 195 196
#define ADD_R11_R2_R11	0x7d625a14	/*  add %11,%2,%11		*/
					/*  ld %12,0(%11)		*/
					/*  ld %2,8(%11)		*/
					/*  mtctr %12			*/
					/*  ld %11,16(%11)		*/
Alan Modra's avatar
bfd/  
Alan Modra committed
197
					/*  bctr			*/
198 199 200 201 202
#define MFLR_R0		0x7c0802a6	/*  mflr %r0			*/
#define MTLR_R0		0x7c0803a6	/*  mtlr %r0			*/
#define SUB_R12_R12_R11	0x7d8b6050	/*  subf %r12,%r11,%r12		*/
#define ADDI_R0_R12	0x380c0000	/*  addi %r0,%r12,0		*/
#define SRDI_R0_R0_2	0x7800f082	/*  rldicl %r0,%r0,62,2		*/
203 204 205 206

/* Pad with this.  */
#define NOP		0x60000000

207 208 209 210
/* Some other nops.  */
#define CROR_151515	0x4def7b82
#define CROR_313131	0x4ffffb82

211
/* .glink entries for the first 32k functions are two instructions.  */
212 213 214 215 216 217
#define LI_R0_0		0x38000000	/* li    %r0,0		*/
#define B_DOT		0x48000000	/* b     .		*/

/* After that, we need two instructions to load the index, followed by
   a branch.  */
#define LIS_R0_0	0x3c000000	/* lis   %r0,0		*/
218
#define ORI_R0_R0_0	0x60000000	/* ori	 %r0,%r0,0	*/
219

220 221 222 223 224
/* Instructions used by the save and restore reg functions.  */
#define STD_R0_0R1	0xf8010000	/* std   %r0,0(%r1)	*/
#define STD_R0_0R12	0xf80c0000	/* std   %r0,0(%r12)	*/
#define LD_R0_0R1	0xe8010000	/* ld    %r0,0(%r1)	*/
#define LD_R0_0R12	0xe80c0000	/* ld    %r0,0(%r12)	*/
225 226
#define STFD_FR0_0R1	0xd8010000	/* stfd  %fr0,0(%r1)	*/
#define LFD_FR0_0R1	0xc8010000	/* lfd   %fr0,0(%r1)	*/
227 228 229 230
#define LI_R12_0	0x39800000	/* li    %r12,0		*/
#define STVX_VR0_R12_R0	0x7c0c01ce	/* stvx  %v0,%r12,%r0	*/
#define LVX_VR0_R12_R0	0x7c0c00ce	/* lvx   %v0,%r12,%r0	*/
#define MTLR_R0		0x7c0803a6	/* mtlr  %r0		*/
231 232
#define BLR		0x4e800020	/* blr			*/

233 234 235
/* Since .opd is an array of descriptors and each entry will end up
   with identical R_PPC64_RELATIVE relocs, there is really no need to
   propagate .opd relocs;  The dynamic linker should be taught to
236
   relocate .opd without reloc entries.  */
237 238 239
#ifndef NO_OPD_RELOCS
#define NO_OPD_RELOCS 0
#endif
240

241
#define ONES(n) (((bfd_vma) 1 << ((n) - 1) << 1) - 1)
242

243
/* Relocation HOWTO's.  */
244
static reloc_howto_type *ppc64_elf_howto_table[(int) R_PPC64_max];
245 246 247 248 249

static reloc_howto_type ppc64_elf_howto_raw[] = {
  /* This reloc does nothing.  */
  HOWTO (R_PPC64_NONE,		/* type */
	 0,			/* rightshift */
250 251
	 2,			/* size (0 = byte, 1 = short, 2 = long) */
	 32,			/* bitsize */
252
	 FALSE,			/* pc_relative */
253
	 0,			/* bitpos */
254
	 complain_overflow_dont, /* complain_on_overflow */
255 256
	 bfd_elf_generic_reloc,	/* special_function */
	 "R_PPC64_NONE",	/* name */
257
	 FALSE,			/* partial_inplace */
258
	 0,			/* src_mask */
259
	 0,			/* dst_mask */
260
	 FALSE),		/* pcrel_offset */
261 262 263 264 265 266

  /* A standard 32 bit relocation.  */
  HOWTO (R_PPC64_ADDR32,	/* type */
	 0,			/* rightshift */
	 2,			/* size (0 = byte, 1 = short, 2 = long) */
	 32,			/* bitsize */
267
	 FALSE,			/* pc_relative */
268 269 270 271
	 0,			/* bitpos */
	 complain_overflow_bitfield, /* complain_on_overflow */
	 bfd_elf_generic_reloc,	/* special_function */
	 "R_PPC64_ADDR32",	/* name */
272
	 FALSE,			/* partial_inplace */
273 274
	 0,			/* src_mask */
	 0xffffffff,		/* dst_mask */
275
	 FALSE),		/* pcrel_offset */
276 277 278 279 280 281 282

  /* An absolute 26 bit branch; the lower two bits must be zero.
     FIXME: we don't check that, we just clear them.  */
  HOWTO (R_PPC64_ADDR24,	/* type */
	 0,			/* rightshift */
	 2,			/* size (0 = byte, 1 = short, 2 = long) */
	 26,			/* bitsize */
283
	 FALSE,			/* pc_relative */
284 285 286 287
	 0,			/* bitpos */
	 complain_overflow_bitfield, /* complain_on_overflow */
	 bfd_elf_generic_reloc,	/* special_function */
	 "R_PPC64_ADDR24",	/* name */
288
	 FALSE,			/* partial_inplace */
289
	 0,			/* src_mask */
290
	 0x03fffffc,		/* dst_mask */
291
	 FALSE),		/* pcrel_offset */
292 293 294 295 296 297

  /* A standard 16 bit relocation.  */
  HOWTO (R_PPC64_ADDR16,	/* type */
	 0,			/* rightshift */
	 1,			/* size (0 = byte, 1 = short, 2 = long) */
	 16,			/* bitsize */
298
	 FALSE,			/* pc_relative */
299 300 301 302
	 0,			/* bitpos */
	 complain_overflow_bitfield, /* complain_on_overflow */
	 bfd_elf_generic_reloc,	/* special_function */
	 "R_PPC64_ADDR16",	/* name */
303
	 FALSE,			/* partial_inplace */
304 305
	 0,			/* src_mask */
	 0xffff,		/* dst_mask */
306
	 FALSE),		/* pcrel_offset */
307 308 309 310 311 312

  /* A 16 bit relocation without overflow.  */
  HOWTO (R_PPC64_ADDR16_LO,	/* type */
	 0,			/* rightshift */
	 1,			/* size (0 = byte, 1 = short, 2 = long) */
	 16,			/* bitsize */
313
	 FALSE,			/* pc_relative */
314 315 316 317
	 0,			/* bitpos */
	 complain_overflow_dont,/* complain_on_overflow */
	 bfd_elf_generic_reloc,	/* special_function */
	 "R_PPC64_ADDR16_LO",	/* name */
318
	 FALSE,			/* partial_inplace */
319 320
	 0,			/* src_mask */
	 0xffff,		/* dst_mask */
321
	 FALSE),		/* pcrel_offset */
322 323 324 325 326 327

  /* Bits 16-31 of an address.  */
  HOWTO (R_PPC64_ADDR16_HI,	/* type */
	 16,			/* rightshift */
	 1,			/* size (0 = byte, 1 = short, 2 = long) */
	 16,			/* bitsize */
328
	 FALSE,			/* pc_relative */
329
	 0,			/* bitpos */
330
	 complain_overflow_signed, /* complain_on_overflow */
331 332
	 bfd_elf_generic_reloc,	/* special_function */
	 "R_PPC64_ADDR16_HI",	/* name */
333
	 FALSE,			/* partial_inplace */
334 335
	 0,			/* src_mask */
	 0xffff,		/* dst_mask */
336
	 FALSE),		/* pcrel_offset */
337 338 339 340 341 342 343

  /* Bits 16-31 of an address, plus 1 if the contents of the low 16
     bits, treated as a signed number, is negative.  */
  HOWTO (R_PPC64_ADDR16_HA,	/* type */
	 16,			/* rightshift */
	 1,			/* size (0 = byte, 1 = short, 2 = long) */
	 16,			/* bitsize */
344
	 FALSE,			/* pc_relative */
345
	 0,			/* bitpos */
346
	 complain_overflow_signed, /* complain_on_overflow */
347
	 ppc64_elf_ha_reloc,	/* special_function */
348
	 "R_PPC64_ADDR16_HA",	/* name */
349
	 FALSE,			/* partial_inplace */
350 351
	 0,			/* src_mask */
	 0xffff,		/* dst_mask */
352
	 FALSE),		/* pcrel_offset */
353 354 355 356 357 358 359

  /* An absolute 16 bit branch; the lower two bits must be zero.
     FIXME: we don't check that, we just clear them.  */
  HOWTO (R_PPC64_ADDR14,	/* type */
	 0,			/* rightshift */
	 2,			/* size (0 = byte, 1 = short, 2 = long) */
	 16,			/* bitsize */
360
	 FALSE,			/* pc_relative */
361 362
	 0,			/* bitpos */
	 complain_overflow_bitfield, /* complain_on_overflow */
363
	 ppc64_elf_branch_reloc, /* special_function */
364
	 "R_PPC64_ADDR14",	/* name */
365
	 FALSE,			/* partial_inplace */
366
	 0,			/* src_mask */
367
	 0x0000fffc,		/* dst_mask */
368
	 FALSE),		/* pcrel_offset */
369 370 371 372 373 374 375 376

  /* An absolute 16 bit branch, for which bit 10 should be set to
     indicate that the branch is expected to be taken.  The lower two
     bits must be zero.  */
  HOWTO (R_PPC64_ADDR14_BRTAKEN, /* type */
	 0,			/* rightshift */
	 2,			/* size (0 = byte, 1 = short, 2 = long) */
	 16,			/* bitsize */
377
	 FALSE,			/* pc_relative */
378 379
	 0,			/* bitpos */
	 complain_overflow_bitfield, /* complain_on_overflow */
380
	 ppc64_elf_brtaken_reloc, /* special_function */
381
	 "R_PPC64_ADDR14_BRTAKEN",/* name */
382
	 FALSE,			/* partial_inplace */
383
	 0,			/* src_mask */
384
	 0x0000fffc,		/* dst_mask */
385
	 FALSE),		/* pcrel_offset */
386 387 388 389 390 391 392 393

  /* An absolute 16 bit branch, for which bit 10 should be set to
     indicate that the branch is not expected to be taken.  The lower
     two bits must be zero.  */
  HOWTO (R_PPC64_ADDR14_BRNTAKEN, /* type */
	 0,			/* rightshift */
	 2,			/* size (0 = byte, 1 = short, 2 = long) */
	 16,			/* bitsize */
394
	 FALSE,			/* pc_relative */
395 396
	 0,			/* bitpos */
	 complain_overflow_bitfield, /* complain_on_overflow */
397
	 ppc64_elf_brtaken_reloc, /* special_function */
398
	 "R_PPC64_ADDR14_BRNTAKEN",/* name */
399
	 FALSE,			/* partial_inplace */
400
	 0,			/* src_mask */
401
	 0x0000fffc,		/* dst_mask */
402
	 FALSE),		/* pcrel_offset */
403 404 405 406 407 408

  /* A relative 26 bit branch; the lower two bits must be zero.  */
  HOWTO (R_PPC64_REL24,		/* type */
	 0,			/* rightshift */
	 2,			/* size (0 = byte, 1 = short, 2 = long) */
	 26,			/* bitsize */
409
	 TRUE,			/* pc_relative */
410 411
	 0,			/* bitpos */
	 complain_overflow_signed, /* complain_on_overflow */
412
	 ppc64_elf_branch_reloc, /* special_function */
413
	 "R_PPC64_REL24",	/* name */
414
	 FALSE,			/* partial_inplace */
415
	 0,			/* src_mask */
416
	 0x03fffffc,		/* dst_mask */
417
	 TRUE),			/* pcrel_offset */
418 419 420 421 422 423

  /* A relative 16 bit branch; the lower two bits must be zero.  */
  HOWTO (R_PPC64_REL14,		/* type */
	 0,			/* rightshift */
	 2,			/* size (0 = byte, 1 = short, 2 = long) */
	 16,			/* bitsize */
424
	 TRUE,			/* pc_relative */
425 426
	 0,			/* bitpos */
	 complain_overflow_signed, /* complain_on_overflow */
427
	 ppc64_elf_branch_reloc, /* special_function */
428
	 "R_PPC64_REL14",	/* name */
429
	 FALSE,			/* partial_inplace */
430
	 0,			/* src_mask */
431
	 0x0000fffc,		/* dst_mask */
432
	 TRUE),			/* pcrel_offset */
433 434 435 436 437 438 439 440

  /* A relative 16 bit branch.  Bit 10 should be set to indicate that
     the branch is expected to be taken.  The lower two bits must be
     zero.  */
  HOWTO (R_PPC64_REL14_BRTAKEN,	/* type */
	 0,			/* rightshift */
	 2,			/* size (0 = byte, 1 = short, 2 = long) */
	 16,			/* bitsize */
441
	 TRUE,			/* pc_relative */
442 443
	 0,			/* bitpos */
	 complain_overflow_signed, /* complain_on_overflow */
444
	 ppc64_elf_brtaken_reloc, /* special_function */
445
	 "R_PPC64_REL14_BRTAKEN", /* name */
446
	 FALSE,			/* partial_inplace */
447
	 0,			/* src_mask */
448
	 0x0000fffc,		/* dst_mask */
449
	 TRUE),			/* pcrel_offset */
450 451 452 453 454 455 456 457

  /* A relative 16 bit branch.  Bit 10 should be set to indicate that
     the branch is not expected to be taken.  The lower two bits must
     be zero.  */
  HOWTO (R_PPC64_REL14_BRNTAKEN, /* type */
	 0,			/* rightshift */
	 2,			/* size (0 = byte, 1 = short, 2 = long) */
	 16,			/* bitsize */
458
	 TRUE,			/* pc_relative */
459 460
	 0,			/* bitpos */
	 complain_overflow_signed, /* complain_on_overflow */
461
	 ppc64_elf_brtaken_reloc, /* special_function */
462
	 "R_PPC64_REL14_BRNTAKEN",/* name */
463
	 FALSE,			/* partial_inplace */
464
	 0,			/* src_mask */
465
	 0x0000fffc,		/* dst_mask */
466
	 TRUE),			/* pcrel_offset */
467 468 469 470 471 472 473

  /* Like R_PPC64_ADDR16, but referring to the GOT table entry for the
     symbol.  */
  HOWTO (R_PPC64_GOT16,		/* type */
	 0,			/* rightshift */
	 1,			/* size (0 = byte, 1 = short, 2 = long) */
	 16,			/* bitsize */
474
	 FALSE,			/* pc_relative */
475 476
	 0,			/* bitpos */
	 complain_overflow_signed, /* complain_on_overflow */
477
	 ppc64_elf_unhandled_reloc, /* special_function */
478
	 "R_PPC64_GOT16",	/* name */
479
	 FALSE,			/* partial_inplace */
480 481
	 0,			/* src_mask */
	 0xffff,		/* dst_mask */
482
	 FALSE),		/* pcrel_offset */
483 484 485 486 487 488 489

  /* Like R_PPC64_ADDR16_LO, but referring to the GOT table entry for
     the symbol.  */
  HOWTO (R_PPC64_GOT16_LO,	/* type */
	 0,			/* rightshift */
	 1,			/* size (0 = byte, 1 = short, 2 = long) */
	 16,			/* bitsize */
490
	 FALSE,			/* pc_relative */
491 492
	 0,			/* bitpos */
	 complain_overflow_dont, /* complain_on_overflow */
493
	 ppc64_elf_unhandled_reloc, /* special_function */
494
	 "R_PPC64_GOT16_LO",	/* name */
495
	 FALSE,			/* partial_inplace */
496 497
	 0,			/* src_mask */
	 0xffff,		/* dst_mask */
498
	 FALSE),		/* pcrel_offset */
499 500 501 502 503 504 505

  /* Like R_PPC64_ADDR16_HI, but referring to the GOT table entry for
     the symbol.  */
  HOWTO (R_PPC64_GOT16_HI,	/* type */
	 16,			/* rightshift */
	 1,			/* size (0 = byte, 1 = short, 2 = long) */
	 16,			/* bitsize */
506
	 FALSE,			/* pc_relative */
507
	 0,			/* bitpos */
508
	 complain_overflow_signed,/* complain_on_overflow */
509
	 ppc64_elf_unhandled_reloc, /* special_function */
510
	 "R_PPC64_GOT16_HI",	/* name */
511
	 FALSE,			/* partial_inplace */
512 513
	 0,			/* src_mask */
	 0xffff,		/* dst_mask */
514
	 FALSE),		/* pcrel_offset */
515 516 517 518 519 520 521

  /* Like R_PPC64_ADDR16_HA, but referring to the GOT table entry for
     the symbol.  */
  HOWTO (R_PPC64_GOT16_HA,	/* type */
	 16,			/* rightshift */
	 1,			/* size (0 = byte, 1 = short, 2 = long) */
	 16,			/* bitsize */
522
	 FALSE,			/* pc_relative */
523
	 0,			/* bitpos */
524
	 complain_overflow_signed,/* complain_on_overflow */
525
	 ppc64_elf_unhandled_reloc, /* special_function */
526
	 "R_PPC64_GOT16_HA",	/* name */
527
	 FALSE,			/* partial_inplace */
528 529
	 0,			/* src_mask */
	 0xffff,		/* dst_mask */
530
	 FALSE),		/* pcrel_offset */
531 532 533 534 535 536 537 538

  /* This is used only by the dynamic linker.  The symbol should exist
     both in the object being run and in some shared library.  The
     dynamic linker copies the data addressed by the symbol from the
     shared library into the object, because the object being
     run has to have the data at some particular address.  */
  HOWTO (R_PPC64_COPY,		/* type */
	 0,			/* rightshift */
539 540
	 0,			/* this one is variable size */
	 0,			/* bitsize */
541
	 FALSE,			/* pc_relative */
542
	 0,			/* bitpos */
543 544
	 complain_overflow_dont, /* complain_on_overflow */
	 ppc64_elf_unhandled_reloc, /* special_function */
545
	 "R_PPC64_COPY",	/* name */
546
	 FALSE,			/* partial_inplace */
547 548
	 0,			/* src_mask */
	 0,			/* dst_mask */
549
	 FALSE),		/* pcrel_offset */
550 551 552 553 554 555 556

  /* Like R_PPC64_ADDR64, but used when setting global offset table
     entries.  */
  HOWTO (R_PPC64_GLOB_DAT,	/* type */
	 0,			/* rightshift */
	 4,			/* size (0=byte, 1=short, 2=long, 4=64 bits) */
	 64,			/* bitsize */
557
	 FALSE,			/* pc_relative */
558 559
	 0,			/* bitpos */
	 complain_overflow_dont, /* complain_on_overflow */
560
	 ppc64_elf_unhandled_reloc,  /* special_function */
561
	 "R_PPC64_GLOB_DAT",	/* name */
562
	 FALSE,			/* partial_inplace */
563
	 0,			/* src_mask */
564
	 ONES (64),		/* dst_mask */
565
	 FALSE),		/* pcrel_offset */
566 567 568 569 570 571 572

  /* Created by the link editor.  Marks a procedure linkage table
     entry for a symbol.  */
  HOWTO (R_PPC64_JMP_SLOT,	/* type */
	 0,			/* rightshift */
	 0,			/* size (0 = byte, 1 = short, 2 = long) */
	 0,			/* bitsize */
573
	 FALSE,			/* pc_relative */
574 575
	 0,			/* bitpos */
	 complain_overflow_dont, /* complain_on_overflow */
576
	 ppc64_elf_unhandled_reloc, /* special_function */
577
	 "R_PPC64_JMP_SLOT",	/* name */
578
	 FALSE,			/* partial_inplace */
579 580
	 0,			/* src_mask */
	 0,			/* dst_mask */
581
	 FALSE),		/* pcrel_offset */
582 583 584 585 586 587 588 589

  /* Used only by the dynamic linker.  When the object is run, this
     doubleword64 is set to the load address of the object, plus the
     addend.  */
  HOWTO (R_PPC64_RELATIVE,	/* type */
	 0,			/* rightshift */
	 4,			/* size (0=byte, 1=short, 2=long, 4=64 bits) */
	 64,			/* bitsize */
590
	 FALSE,			/* pc_relative */
591 592 593 594
	 0,			/* bitpos */
	 complain_overflow_dont, /* complain_on_overflow */
	 bfd_elf_generic_reloc,	/* special_function */
	 "R_PPC64_RELATIVE",	/* name */
595
	 FALSE,			/* partial_inplace */
596
	 0,			/* src_mask */
597
	 ONES (64),		/* dst_mask */
598
	 FALSE),		/* pcrel_offset */
599 600 601 602 603 604

  /* Like R_PPC64_ADDR32, but may be unaligned.  */
  HOWTO (R_PPC64_UADDR32,	/* type */
	 0,			/* rightshift */
	 2,			/* size (0 = byte, 1 = short, 2 = long) */
	 32,			/* bitsize */
605
	 FALSE,			/* pc_relative */
606 607 608 609
	 0,			/* bitpos */
	 complain_overflow_bitfield, /* complain_on_overflow */
	 bfd_elf_generic_reloc,	/* special_function */
	 "R_PPC64_UADDR32",	/* name */
610
	 FALSE,			/* partial_inplace */
611 612
	 0,			/* src_mask */
	 0xffffffff,		/* dst_mask */
613
	 FALSE),		/* pcrel_offset */
614 615 616 617 618 619

  /* Like R_PPC64_ADDR16, but may be unaligned.  */
  HOWTO (R_PPC64_UADDR16,	/* type */
	 0,			/* rightshift */
	 1,			/* size (0 = byte, 1 = short, 2 = long) */
	 16,			/* bitsize */
620
	 FALSE,			/* pc_relative */
621 622 623 624
	 0,			/* bitpos */
	 complain_overflow_bitfield, /* complain_on_overflow */
	 bfd_elf_generic_reloc,	/* special_function */
	 "R_PPC64_UADDR16",	/* name */
625
	 FALSE,			/* partial_inplace */
626 627
	 0,			/* src_mask */
	 0xffff,		/* dst_mask */
628
	 FALSE),		/* pcrel_offset */
629 630 631 632 633 634

  /* 32-bit PC relative.  */
  HOWTO (R_PPC64_REL32,		/* type */
	 0,			/* rightshift */
	 2,			/* size (0 = byte, 1 = short, 2 = long) */
	 32,			/* bitsize */
635
	 TRUE,			/* pc_relative */
636
	 0,			/* bitpos */
637
	 /* FIXME: Verify.  Was complain_overflow_bitfield.  */
638 639 640
	 complain_overflow_signed, /* complain_on_overflow */
	 bfd_elf_generic_reloc,	/* special_function */
	 "R_PPC64_REL32",	/* name */
641
	 FALSE,			/* partial_inplace */
642 643
	 0,			/* src_mask */
	 0xffffffff,		/* dst_mask */
644
	 TRUE),			/* pcrel_offset */
645

646
  /* 32-bit relocation to the symbol's procedure linkage table.  */
647 648 649 650
  HOWTO (R_PPC64_PLT32,		/* type */
	 0,			/* rightshift */
	 2,			/* size (0 = byte, 1 = short, 2 = long) */
	 32,			/* bitsize */
651
	 FALSE,			/* pc_relative */
652 653
	 0,			/* bitpos */
	 complain_overflow_bitfield, /* complain_on_overflow */
654
	 ppc64_elf_unhandled_reloc, /* special_function */
655
	 "R_PPC64_PLT32",	/* name */
656
	 FALSE,			/* partial_inplace */
657
	 0,			/* src_mask */
658
	 0xffffffff,		/* dst_mask */
659
	 FALSE),		/* pcrel_offset */
660 661 662 663 664 665 666

  /* 32-bit PC relative relocation to the symbol's procedure linkage table.
     FIXME: R_PPC64_PLTREL32 not supported.  */
  HOWTO (R_PPC64_PLTREL32,	/* type */
	 0,			/* rightshift */
	 2,			/* size (0 = byte, 1 = short, 2 = long) */
	 32,			/* bitsize */
667
	 TRUE,			/* pc_relative */
668 669 670 671
	 0,			/* bitpos */
	 complain_overflow_signed, /* complain_on_overflow */
	 bfd_elf_generic_reloc,	/* special_function */
	 "R_PPC64_PLTREL32",	/* name */
672
	 FALSE,			/* partial_inplace */
673
	 0,			/* src_mask */
674
	 0xffffffff,		/* dst_mask */
675
	 TRUE),			/* pcrel_offset */
676 677 678 679 680 681 682

  /* Like R_PPC64_ADDR16_LO, but referring to the PLT table entry for
     the symbol.  */
  HOWTO (R_PPC64_PLT16_LO,	/* type */
	 0,			/* rightshift */
	 1,			/* size (0 = byte, 1 = short, 2 = long) */
	 16,			/* bitsize */
683
	 FALSE,			/* pc_relative */
684 685
	 0,			/* bitpos */
	 complain_overflow_dont, /* complain_on_overflow */
686
	 ppc64_elf_unhandled_reloc, /* special_function */
687
	 "R_PPC64_PLT16_LO",	/* name */
688
	 FALSE,			/* partial_inplace */
689 690
	 0,			/* src_mask */
	 0xffff,		/* dst_mask */
691
	 FALSE),		/* pcrel_offset */
692 693 694 695 696 697 698

  /* Like R_PPC64_ADDR16_HI, but referring to the PLT table entry for
     the symbol.  */
  HOWTO (R_PPC64_PLT16_HI,	/* type */
	 16,			/* rightshift */
	 1,			/* size (0 = byte, 1 = short, 2 = long) */
	 16,			/* bitsize */
699
	 FALSE,			/* pc_relative */
700
	 0,			/* bitpos */
701
	 complain_overflow_signed, /* complain_on_overflow */
702
	 ppc64_elf_unhandled_reloc, /* special_function */
703
	 "R_PPC64_PLT16_HI",	/* name */
704
	 FALSE,			/* partial_inplace */
705 706
	 0,			/* src_mask */
	 0xffff,		/* dst_mask */
707
	 FALSE),		/* pcrel_offset */
708 709 710 711 712 713 714

  /* Like R_PPC64_ADDR16_HA, but referring to the PLT table entry for
     the symbol.  */
  HOWTO (R_PPC64_PLT16_HA,	/* type */
	 16,			/* rightshift */
	 1,			/* size (0 = byte, 1 = short, 2 = long) */
	 16,			/* bitsize */
715
	 FALSE,			/* pc_relative */
716
	 0,			/* bitpos */
717
	 complain_overflow_signed, /* complain_on_overflow */
718
	 ppc64_elf_unhandled_reloc, /* special_function */
719
	 "R_PPC64_PLT16_HA",	/* name */
720
	 FALSE,			/* partial_inplace */
721 722
	 0,			/* src_mask */
	 0xffff,		/* dst_mask */
723
	 FALSE),		/* pcrel_offset */
724

725
  /* 16-bit section relative relocation.  */
726 727
  HOWTO (R_PPC64_SECTOFF,	/* type */
	 0,			/* rightshift */
728 729
	 1,			/* size (0 = byte, 1 = short, 2 = long) */
	 16,			/* bitsize */
730
	 FALSE,			/* pc_relative */
731 732
	 0,			/* bitpos */
	 complain_overflow_bitfield, /* complain_on_overflow */
733
	 ppc64_elf_sectoff_reloc, /* special_function */
734
	 "R_PPC64_SECTOFF",	/* name */
735
	 FALSE,			/* partial_inplace */
736
	 0,			/* src_mask */
737
	 0xffff,		/* dst_mask */
738
	 FALSE),		/* pcrel_offset */
739

740
  /* Like R_PPC64_SECTOFF, but no overflow warning.  */
741 742 743 744
  HOWTO (R_PPC64_SECTOFF_LO,	/* type */
	 0,			/* rightshift */
	 1,			/* size (0 = byte, 1 = short, 2 = long) */
	 16,			/* bitsize */
745
	 FALSE,			/* pc_relative */
746 747
	 0,			/* bitpos */
	 complain_overflow_dont, /* complain_on_overflow */
748
	 ppc64_elf_sectoff_reloc, /* special_function */
749
	 "R_PPC64_SECTOFF_LO",	/* name */
750
	 FALSE,			/* partial_inplace */
751 752
	 0,			/* src_mask */
	 0xffff,		/* dst_mask */
753
	 FALSE),		/* pcrel_offset */
754 755 756 757 758 759

  /* 16-bit upper half section relative relocation.  */
  HOWTO (R_PPC64_SECTOFF_HI,	/* type */
	 16,			/* rightshift */
	 1,			/* size (0 = byte, 1 = short, 2 = long) */
	 16,			/* bitsize */
760
	 FALSE,			/* pc_relative */
761
	 0,			/* bitpos */
762
	 complain_overflow_signed, /* complain_on_overflow */
763
	 ppc64_elf_sectoff_reloc, /* special_function */
764
	 "R_PPC64_SECTOFF_HI",	/* name */
765
	 FALSE,			/* partial_inplace */
766 767
	 0,			/* src_mask */
	 0xffff,		/* dst_mask */
768
	 FALSE),		/* pcrel_offset */
769 770 771 772 773 774

  /* 16-bit upper half adjusted section relative relocation.  */
  HOWTO (R_PPC64_SECTOFF_HA,	/* type */
	 16,			/* rightshift */
	 1,			/* size (0 = byte, 1 = short, 2 = long) */
	 16,			/* bitsize */
775
	 FALSE,			/* pc_relative */
776
	 0,			/* bitpos */
777
	 complain_overflow_signed, /* complain_on_overflow */
778
	 ppc64_elf_sectoff_ha_reloc, /* special_function */
779
	 "R_PPC64_SECTOFF_HA",	/* name */
780
	 FALSE,			/* partial_inplace */
781 782
	 0,			/* src_mask */
	 0xffff,		/* dst_mask */
783
	 FALSE),		/* pcrel_offset */
784

785 786
  /* Like R_PPC64_REL24 without touching the two least significant bits.  */
  HOWTO (R_PPC64_REL30,		/* type */
787 788 789
	 2,			/* rightshift */
	 2,			/* size (0 = byte, 1 = short, 2 = long) */
	 30,			/* bitsize */
790
	 TRUE,			/* pc_relative */
791 792 793
	 0,			/* bitpos */
	 complain_overflow_dont, /* complain_on_overflow */
	 bfd_elf_generic_reloc, /* special_function */
794
	 "R_PPC64_REL30",	/* name */
795
	 FALSE,			/* partial_inplace */
796
	 0,			/* src_mask */
797
	 0xfffffffc,		/* dst_mask */
798
	 TRUE),			/* pcrel_offset */
799 800 801 802 803 804 805 806

  /* Relocs in the 64-bit PowerPC ELF ABI, not in the 32-bit ABI.  */

  /* A standard 64-bit relocation.  */
  HOWTO (R_PPC64_ADDR64,	/* type */
	 0,			/* rightshift */
	 4,			/* size (0=byte, 1=short, 2=long, 4=64 bits) */
	 64,			/* bitsize */
807
	 FALSE,			/* pc_relative */
808 809 810 811
	 0,			/* bitpos */
	 complain_overflow_dont, /* complain_on_overflow */
	 bfd_elf_generic_reloc,	/* special_function */
	 "R_PPC64_ADDR64",	/* name */
812
	 FALSE,			/* partial_inplace */
813
	 0,			/* src_mask */
814
	 ONES (64),		/* dst_mask */
815
	 FALSE),		/* pcrel_offset */
816 817 818 819 820 821

  /* The bits 32-47 of an address.  */
  HOWTO (R_PPC64_ADDR16_HIGHER,	/* type */
	 32,			/* rightshift */
	 1,			/* size (0 = byte, 1 = short, 2 = long) */
	 16,			/* bitsize */
822
	 FALSE,			/* pc_relative */
823 824 825 826
	 0,			/* bitpos */
	 complain_overflow_dont, /* complain_on_overflow */
	 bfd_elf_generic_reloc,	/* special_function */
	 "R_PPC64_ADDR16_HIGHER", /* name */
827
	 FALSE,			/* partial_inplace */
828 829
	 0,			/* src_mask */
	 0xffff,		/* dst_mask */
830
	 FALSE),		/* pcrel_offset */
831 832 833 834 835 836 837

  /* The bits 32-47 of an address, plus 1 if the contents of the low
     16 bits, treated as a signed number, is negative.  */
  HOWTO (R_PPC64_ADDR16_HIGHERA, /* type */
	 32,			/* rightshift */
	 1,			/* size (0 = byte, 1 = short, 2 = long) */
	 16,			/* bitsize */
838
	 FALSE,			/* pc_relative */
839 840
	 0,			/* bitpos */
	 complain_overflow_dont, /* complain_on_overflow */
841
	 ppc64_elf_ha_reloc,	/* special_function */
842
	 "R_PPC64_ADDR16_HIGHERA", /* name */
843
	 FALSE,			/* partial_inplace */
844 845
	 0,			/* src_mask */
	 0xffff,		/* dst_mask */
846
	 FALSE),		/* pcrel_offset */
847 848 849 850 851 852

  /* The bits 48-63 of an address.  */
  HOWTO (R_PPC64_ADDR16_HIGHEST,/* type */
	 48,			/* rightshift */
	 1,			/* size (0 = byte, 1 = short, 2 = long) */
	 16,			/* bitsize */
853
	 FALSE,			/* pc_relative */
854 855 856 857
	 0,			/* bitpos */
	 complain_overflow_dont, /* complain_on_overflow */
	 bfd_elf_generic_reloc,	/* special_function */
	 "R_PPC64_ADDR16_HIGHEST", /* name */
858
	 FALSE,			/* partial_inplace */
859 860
	 0,			/* src_mask */
	 0xffff,		/* dst_mask */
861
	 FALSE),		/* pcrel_offset */
862 863 864 865 866 867 868

  /* The bits 48-63 of an address, plus 1 if the contents of the low
     16 bits, treated as a signed number, is negative.  */
  HOWTO (R_PPC64_ADDR16_HIGHESTA,/* type */
	 48,			/* rightshift */
	 1,			/* size (0 = byte, 1 = short, 2 = long) */
	 16,			/* bitsize */
869
	 FALSE,			/* pc_relative */
870 871
	 0,			/* bitpos */
	 complain_overflow_dont, /* complain_on_overflow */
872
	 ppc64_elf_ha_reloc,	/* special_function */
873
	 "R_PPC64_ADDR16_HIGHESTA", /* name */
874
	 FALSE,			/* partial_inplace */
875 876
	 0,			/* src_mask */
	 0xffff,		/* dst_mask */
877
	 FALSE),		/* pcrel_offset */
878 879 880 881 882 883

  /* Like ADDR64, but may be unaligned.  */
  HOWTO (R_PPC64_UADDR64,	/* type */
	 0,			/* rightshift */
	 4,			/* size (0=byte, 1=short, 2=long, 4=64 bits) */
	 64,			/* bitsize */
884
	 FALSE,			/* pc_relative */
885 886 887 888
	 0,			/* bitpos */
	 complain_overflow_dont, /* complain_on_overflow */
	 bfd_elf_generic_reloc,	/* special_function */
	 "R_PPC64_UADDR64",	/* name */
889
	 FALSE,			/* partial_inplace */
890
	 0,			/* src_mask */
891
	 ONES (64),		/* dst_mask */
892
	 FALSE),		/* pcrel_offset */
893 894 895 896 897 898

  /* 64-bit relative relocation.  */
  HOWTO (R_PPC64_REL64,		/* type */
	 0,			/* rightshift */
	 4,			/* size (0=byte, 1=short, 2=long, 4=64 bits) */
	 64,			/* bitsize */
899
	 TRUE,			/* pc_relative */
900 901 902 903
	 0,			/* bitpos */
	 complain_overflow_dont, /* complain_on_overflow */
	 bfd_elf_generic_reloc,	/* special_function */
	 "R_PPC64_REL64",	/* name */
904
	 FALSE,			/* partial_inplace */
905
	 0,			/* src_mask */
906
	 ONES (64),		/* dst_mask */
907
	 TRUE),			/* pcrel_offset */
908

909
  /* 64-bit relocation to the symbol's procedure linkage table.  */
910 911 912 913
  HOWTO (R_PPC64_PLT64,		/* type */
	 0,			/* rightshift */
	 4,			/* size (0=byte, 1=short, 2=long, 4=64 bits) */
	 64,			/* bitsize */
914
	 FALSE,			/* pc_relative */
915 916
	 0,			/* bitpos */
	 complain_overflow_dont, /* complain_on_overflow */
917
	 ppc64_elf_unhandled_reloc, /* special_function */
918
	 "R_PPC64_PLT64",	/* name */
919
	 FALSE,			/* partial_inplace */
920
	 0,			/* src_mask */
921
	 ONES (64),		/* dst_mask */
922
	 FALSE),		/* pcrel_offset */
923 924 925 926 927 928 929 930

  /* 64-bit PC relative relocation to the symbol's procedure linkage
     table.  */
  /* FIXME: R_PPC64_PLTREL64 not supported.  */
  HOWTO (R_PPC64_PLTREL64,	/* type */
	 0,			/* rightshift */
	 4,			/* size (0=byte, 1=short, 2=long, 4=64 bits) */
	 64,			/* bitsize */
931
	 TRUE,			/* pc_relative */
932 933
	 0,			/* bitpos */
	 complain_overflow_dont, /* complain_on_overflow */
934
	 ppc64_elf_unhandled_reloc, /* special_function */
935
	 "R_PPC64_PLTREL64",	/* name */
936
	 FALSE,			/* partial_inplace */
937
	 0,			/* src_mask */
938
	 ONES (64),		/* dst_mask */
939
	 TRUE),			/* pcrel_offset */
940 941 942 943 944 945 946 947

  /* 16 bit TOC-relative relocation.  */

  /* R_PPC64_TOC16	  47	   half16*	S + A - .TOC.  */
  HOWTO (R_PPC64_TOC16,		/* type */
	 0,			/* rightshift */
	 1,			/* size (0 = byte, 1 = short, 2 = long) */
	 16,			/* bitsize */
948
	 FALSE,			/* pc_relative */
949 950
	 0,			/* bitpos */
	 complain_overflow_signed, /* complain_on_overflow */
951
	 ppc64_elf_toc_reloc,	/* special_function */
952
	 "R_PPC64_TOC16",	/* name */
953
	 FALSE,			/* partial_inplace */
954 955
	 0,			/* src_mask */
	 0xffff,		/* dst_mask */
956
	 FALSE),		/* pcrel_offset */
957 958 959 960 961 962 963 964

  /* 16 bit TOC-relative relocation without overflow.  */

  /* R_PPC64_TOC16_LO	  48	   half16	 #lo (S + A - .TOC.)  */
  HOWTO (R_PPC64_TOC16_LO,	/* type */
	 0,			/* rightshift */
	 1,			/* size (0 = byte, 1 = short, 2 = long) */
	 16,			/* bitsize */
965
	 FALSE,			/* pc_relative */
966 967
	 0,			/* bitpos */
	 complain_overflow_dont, /* complain_on_overflow */
968
	 ppc64_elf_toc_reloc,	/* special_function */
969
	 "R_PPC64_TOC16_LO",	/* name */
970
	 FALSE,			/* partial_inplace */
971 972
	 0,			/* src_mask */
	 0xffff,		/* dst_mask */
973
	 FALSE),		/* pcrel_offset */
974 975 976 977 978 979 980 981

  /* 16 bit TOC-relative relocation, high 16 bits.  */

  /* R_PPC64_TOC16_HI	  49	   half16	 #hi (S + A - .TOC.)  */
  HOWTO (R_PPC64_TOC16_HI,	/* type */
	 16,			/* rightshift */
	 1,			/* size (0 = byte, 1 = short, 2 = long) */
	 16,			/* bitsize */
982
	 FALSE,			/* pc_relative */
983
	 0,			/* bitpos */
984
	 complain_overflow_signed, /* complain_on_overflow */
985
	 ppc64_elf_toc_reloc,	/* special_function */
986
	 "R_PPC64_TOC16_HI",	/* name */
987
	 FALSE,			/* partial_inplace */
988 989
	 0,			/* src_mask */
	 0xffff,		/* dst_mask */
990
	 FALSE),		/* pcrel_offset */
991 992 993 994 995 996 997 998 999 1000

  /* 16 bit TOC-relative relocation, high 16 bits, plus 1 if the
     contents of the low 16 bits, treated as a signed number, is
     negative.  */

  /* R_PPC64_TOC16_HA	  50	   half16	 #ha (S + A - .TOC.)  */
  HOWTO (R_PPC64_TOC16_HA,	/* type */
	 16,			/* rightshift */
	 1,			/* size (0 = byte, 1 = short, 2 = long) */
	 16,			/* bitsize */
1001
	 FALSE,			/* pc_relative */
1002
	 0,			/* bitpos */
1003
	 complain_overflow_signed, /* complain_on_overflow */
Alan Modra's avatar