1 /* X86-64 specific support for 64-bit ELF
2 Copyright 2000, 2001, 2002, 2003, 2004, 2005
3 Free Software Foundation, Inc.
4 Contributed by Jan Hubicka <jh@suse.cz>.
6 This file is part of BFD, the Binary File Descriptor library.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
28 #include "elf/x86-64.h"
30 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value. */
31 #define MINUS_ONE (~ (bfd_vma) 0)
33 /* The relocation "howto" table. Order of fields:
34 type, size, bitsize, pc_relative, complain_on_overflow,
35 special_function, name, partial_inplace, src_mask, dst_pack, pcrel_offset. */
36 static reloc_howto_type x86_64_elf_howto_table
[] =
38 HOWTO(R_X86_64_NONE
, 0, 0, 0, FALSE
, 0, complain_overflow_dont
,
39 bfd_elf_generic_reloc
, "R_X86_64_NONE", FALSE
, 0x00000000, 0x00000000,
41 HOWTO(R_X86_64_64
, 0, 4, 64, FALSE
, 0, complain_overflow_bitfield
,
42 bfd_elf_generic_reloc
, "R_X86_64_64", FALSE
, MINUS_ONE
, MINUS_ONE
,
44 HOWTO(R_X86_64_PC32
, 0, 2, 32, TRUE
, 0, complain_overflow_signed
,
45 bfd_elf_generic_reloc
, "R_X86_64_PC32", FALSE
, 0xffffffff, 0xffffffff,
47 HOWTO(R_X86_64_GOT32
, 0, 2, 32, FALSE
, 0, complain_overflow_signed
,
48 bfd_elf_generic_reloc
, "R_X86_64_GOT32", FALSE
, 0xffffffff, 0xffffffff,
50 HOWTO(R_X86_64_PLT32
, 0, 2, 32, TRUE
, 0, complain_overflow_signed
,
51 bfd_elf_generic_reloc
, "R_X86_64_PLT32", FALSE
, 0xffffffff, 0xffffffff,
53 HOWTO(R_X86_64_COPY
, 0, 2, 32, FALSE
, 0, complain_overflow_bitfield
,
54 bfd_elf_generic_reloc
, "R_X86_64_COPY", FALSE
, 0xffffffff, 0xffffffff,
56 HOWTO(R_X86_64_GLOB_DAT
, 0, 4, 64, FALSE
, 0, complain_overflow_bitfield
,
57 bfd_elf_generic_reloc
, "R_X86_64_GLOB_DAT", FALSE
, MINUS_ONE
,
59 HOWTO(R_X86_64_JUMP_SLOT
, 0, 4, 64, FALSE
, 0, complain_overflow_bitfield
,
60 bfd_elf_generic_reloc
, "R_X86_64_JUMP_SLOT", FALSE
, MINUS_ONE
,
62 HOWTO(R_X86_64_RELATIVE
, 0, 4, 64, FALSE
, 0, complain_overflow_bitfield
,
63 bfd_elf_generic_reloc
, "R_X86_64_RELATIVE", FALSE
, MINUS_ONE
,
65 HOWTO(R_X86_64_GOTPCREL
, 0, 2, 32, TRUE
, 0, complain_overflow_signed
,
66 bfd_elf_generic_reloc
, "R_X86_64_GOTPCREL", FALSE
, 0xffffffff,
68 HOWTO(R_X86_64_32
, 0, 2, 32, FALSE
, 0, complain_overflow_unsigned
,
69 bfd_elf_generic_reloc
, "R_X86_64_32", FALSE
, 0xffffffff, 0xffffffff,
71 HOWTO(R_X86_64_32S
, 0, 2, 32, FALSE
, 0, complain_overflow_signed
,
72 bfd_elf_generic_reloc
, "R_X86_64_32S", FALSE
, 0xffffffff, 0xffffffff,
74 HOWTO(R_X86_64_16
, 0, 1, 16, FALSE
, 0, complain_overflow_bitfield
,
75 bfd_elf_generic_reloc
, "R_X86_64_16", FALSE
, 0xffff, 0xffff, FALSE
),
76 HOWTO(R_X86_64_PC16
,0, 1, 16, TRUE
, 0, complain_overflow_bitfield
,
77 bfd_elf_generic_reloc
, "R_X86_64_PC16", FALSE
, 0xffff, 0xffff, TRUE
),
78 HOWTO(R_X86_64_8
, 0, 0, 8, FALSE
, 0, complain_overflow_signed
,
79 bfd_elf_generic_reloc
, "R_X86_64_8", FALSE
, 0xff, 0xff, FALSE
),
80 HOWTO(R_X86_64_PC8
, 0, 0, 8, TRUE
, 0, complain_overflow_signed
,
81 bfd_elf_generic_reloc
, "R_X86_64_PC8", FALSE
, 0xff, 0xff, TRUE
),
82 HOWTO(R_X86_64_DTPMOD64
, 0, 4, 64, FALSE
, 0, complain_overflow_bitfield
,
83 bfd_elf_generic_reloc
, "R_X86_64_DTPMOD64", FALSE
, MINUS_ONE
,
85 HOWTO(R_X86_64_DTPOFF64
, 0, 4, 64, FALSE
, 0, complain_overflow_bitfield
,
86 bfd_elf_generic_reloc
, "R_X86_64_DTPOFF64", FALSE
, MINUS_ONE
,
88 HOWTO(R_X86_64_TPOFF64
, 0, 4, 64, FALSE
, 0, complain_overflow_bitfield
,
89 bfd_elf_generic_reloc
, "R_X86_64_TPOFF64", FALSE
, MINUS_ONE
,
91 HOWTO(R_X86_64_TLSGD
, 0, 2, 32, TRUE
, 0, complain_overflow_signed
,
92 bfd_elf_generic_reloc
, "R_X86_64_TLSGD", FALSE
, 0xffffffff,
94 HOWTO(R_X86_64_TLSLD
, 0, 2, 32, TRUE
, 0, complain_overflow_signed
,
95 bfd_elf_generic_reloc
, "R_X86_64_TLSLD", FALSE
, 0xffffffff,
97 HOWTO(R_X86_64_DTPOFF32
, 0, 2, 32, FALSE
, 0, complain_overflow_bitfield
,
98 bfd_elf_generic_reloc
, "R_X86_64_DTPOFF32", FALSE
, 0xffffffff,
100 HOWTO(R_X86_64_GOTTPOFF
, 0, 2, 32, TRUE
, 0, complain_overflow_signed
,
101 bfd_elf_generic_reloc
, "R_X86_64_GOTTPOFF", FALSE
, 0xffffffff,
103 HOWTO(R_X86_64_TPOFF32
, 0, 2, 32, FALSE
, 0, complain_overflow_signed
,
104 bfd_elf_generic_reloc
, "R_X86_64_TPOFF32", FALSE
, 0xffffffff,
107 /* GNU extension to record C++ vtable hierarchy. */
108 HOWTO (R_X86_64_GNU_VTINHERIT
, 0, 4, 0, FALSE
, 0, complain_overflow_dont
,
109 NULL
, "R_X86_64_GNU_VTINHERIT", FALSE
, 0, 0, FALSE
),
111 /* GNU extension to record C++ vtable member usage. */
112 HOWTO (R_X86_64_GNU_VTENTRY
, 0, 4, 0, FALSE
, 0, complain_overflow_dont
,
113 _bfd_elf_rel_vtable_reloc_fn
, "R_X86_64_GNU_VTENTRY", FALSE
, 0, 0,
117 /* Map BFD relocs to the x86_64 elf relocs. */
120 bfd_reloc_code_real_type bfd_reloc_val
;
121 unsigned char elf_reloc_val
;
124 static const struct elf_reloc_map x86_64_reloc_map
[] =
126 { BFD_RELOC_NONE
, R_X86_64_NONE
, },
127 { BFD_RELOC_64
, R_X86_64_64
, },
128 { BFD_RELOC_32_PCREL
, R_X86_64_PC32
, },
129 { BFD_RELOC_X86_64_GOT32
, R_X86_64_GOT32
,},
130 { BFD_RELOC_X86_64_PLT32
, R_X86_64_PLT32
,},
131 { BFD_RELOC_X86_64_COPY
, R_X86_64_COPY
, },
132 { BFD_RELOC_X86_64_GLOB_DAT
, R_X86_64_GLOB_DAT
, },
133 { BFD_RELOC_X86_64_JUMP_SLOT
, R_X86_64_JUMP_SLOT
, },
134 { BFD_RELOC_X86_64_RELATIVE
, R_X86_64_RELATIVE
, },
135 { BFD_RELOC_X86_64_GOTPCREL
, R_X86_64_GOTPCREL
, },
136 { BFD_RELOC_32
, R_X86_64_32
, },
137 { BFD_RELOC_X86_64_32S
, R_X86_64_32S
, },
138 { BFD_RELOC_16
, R_X86_64_16
, },
139 { BFD_RELOC_16_PCREL
, R_X86_64_PC16
, },
140 { BFD_RELOC_8
, R_X86_64_8
, },
141 { BFD_RELOC_8_PCREL
, R_X86_64_PC8
, },
142 { BFD_RELOC_X86_64_DTPMOD64
, R_X86_64_DTPMOD64
, },
143 { BFD_RELOC_X86_64_DTPOFF64
, R_X86_64_DTPOFF64
, },
144 { BFD_RELOC_X86_64_TPOFF64
, R_X86_64_TPOFF64
, },
145 { BFD_RELOC_X86_64_TLSGD
, R_X86_64_TLSGD
, },
146 { BFD_RELOC_X86_64_TLSLD
, R_X86_64_TLSLD
, },
147 { BFD_RELOC_X86_64_DTPOFF32
, R_X86_64_DTPOFF32
, },
148 { BFD_RELOC_X86_64_GOTTPOFF
, R_X86_64_GOTTPOFF
, },
149 { BFD_RELOC_X86_64_TPOFF32
, R_X86_64_TPOFF32
, },
150 { BFD_RELOC_VTABLE_INHERIT
, R_X86_64_GNU_VTINHERIT
, },
151 { BFD_RELOC_VTABLE_ENTRY
, R_X86_64_GNU_VTENTRY
, },
155 /* Given a BFD reloc type, return a HOWTO structure. */
156 static reloc_howto_type
*
157 elf64_x86_64_reloc_type_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
158 bfd_reloc_code_real_type code
)
162 for (i
= 0; i
< sizeof (x86_64_reloc_map
) / sizeof (struct elf_reloc_map
);
165 if (x86_64_reloc_map
[i
].bfd_reloc_val
== code
)
166 return &x86_64_elf_howto_table
[i
];
171 /* Given an x86_64 ELF reloc type, fill in an arelent structure. */
174 elf64_x86_64_info_to_howto (bfd
*abfd ATTRIBUTE_UNUSED
, arelent
*cache_ptr
,
175 Elf_Internal_Rela
*dst
)
179 r_type
= ELF64_R_TYPE (dst
->r_info
);
180 if (r_type
< (unsigned int) R_X86_64_GNU_VTINHERIT
)
182 BFD_ASSERT (r_type
<= (unsigned int) R_X86_64_TPOFF32
);
187 BFD_ASSERT (r_type
< (unsigned int) R_X86_64_max
);
188 i
= r_type
- ((unsigned int) R_X86_64_GNU_VTINHERIT
- R_X86_64_TPOFF32
- 1);
190 cache_ptr
->howto
= &x86_64_elf_howto_table
[i
];
191 BFD_ASSERT (r_type
== cache_ptr
->howto
->type
);
194 /* Support for core dump NOTE sections. */
196 elf64_x86_64_grok_prstatus (bfd
*abfd
, Elf_Internal_Note
*note
)
201 switch (note
->descsz
)
206 case 336: /* sizeof(istruct elf_prstatus) on Linux/x86_64 */
208 elf_tdata (abfd
)->core_signal
209 = bfd_get_16 (abfd
, note
->descdata
+ 12);
212 elf_tdata (abfd
)->core_pid
213 = bfd_get_32 (abfd
, note
->descdata
+ 32);
222 /* Make a ".reg/999" section. */
223 return _bfd_elfcore_make_pseudosection (abfd
, ".reg",
224 size
, note
->descpos
+ offset
);
228 elf64_x86_64_grok_psinfo (bfd
*abfd
, Elf_Internal_Note
*note
)
230 switch (note
->descsz
)
235 case 136: /* sizeof(struct elf_prpsinfo) on Linux/x86_64 */
236 elf_tdata (abfd
)->core_program
237 = _bfd_elfcore_strndup (abfd
, note
->descdata
+ 40, 16);
238 elf_tdata (abfd
)->core_command
239 = _bfd_elfcore_strndup (abfd
, note
->descdata
+ 56, 80);
242 /* Note that for some reason, a spurious space is tacked
243 onto the end of the args in some (at least one anyway)
244 implementations, so strip it off if it exists. */
247 char *command
= elf_tdata (abfd
)->core_command
;
248 int n
= strlen (command
);
250 if (0 < n
&& command
[n
- 1] == ' ')
251 command
[n
- 1] = '\0';
257 /* Functions for the x86-64 ELF linker. */
259 /* The name of the dynamic interpreter. This is put in the .interp
262 #define ELF_DYNAMIC_INTERPRETER "/lib/ld64.so.1"
264 /* If ELIMINATE_COPY_RELOCS is non-zero, the linker will try to avoid
265 copying dynamic variables from a shared lib into an app's dynbss
266 section, and instead use a dynamic relocation to point into the
268 #define ELIMINATE_COPY_RELOCS 1
270 /* The size in bytes of an entry in the global offset table. */
272 #define GOT_ENTRY_SIZE 8
274 /* The size in bytes of an entry in the procedure linkage table. */
276 #define PLT_ENTRY_SIZE 16
278 /* The first entry in a procedure linkage table looks like this. See the
279 SVR4 ABI i386 supplement and the x86-64 ABI to see how this works. */
281 static const bfd_byte elf64_x86_64_plt0_entry
[PLT_ENTRY_SIZE
] =
283 0xff, 0x35, 8, 0, 0, 0, /* pushq GOT+8(%rip) */
284 0xff, 0x25, 16, 0, 0, 0, /* jmpq *GOT+16(%rip) */
285 0x90, 0x90, 0x90, 0x90 /* pad out to 16 bytes with nops. */
288 /* Subsequent entries in a procedure linkage table look like this. */
290 static const bfd_byte elf64_x86_64_plt_entry
[PLT_ENTRY_SIZE
] =
292 0xff, 0x25, /* jmpq *name@GOTPC(%rip) */
293 0, 0, 0, 0, /* replaced with offset to this symbol in .got. */
294 0x68, /* pushq immediate */
295 0, 0, 0, 0, /* replaced with index into relocation table. */
296 0xe9, /* jmp relative */
297 0, 0, 0, 0 /* replaced with offset to start of .plt0. */
300 /* The x86-64 linker needs to keep track of the number of relocs that
301 it decides to copy as dynamic relocs in check_relocs for each symbol.
302 This is so that it can later discard them if they are found to be
303 unnecessary. We store the information in a field extending the
304 regular ELF linker hash table. */
306 struct elf64_x86_64_dyn_relocs
309 struct elf64_x86_64_dyn_relocs
*next
;
311 /* The input section of the reloc. */
314 /* Total number of relocs copied for the input section. */
317 /* Number of pc-relative relocs copied for the input section. */
318 bfd_size_type pc_count
;
321 /* x86-64 ELF linker hash entry. */
323 struct elf64_x86_64_link_hash_entry
325 struct elf_link_hash_entry elf
;
327 /* Track dynamic relocs copied for this symbol. */
328 struct elf64_x86_64_dyn_relocs
*dyn_relocs
;
330 #define GOT_UNKNOWN 0
334 unsigned char tls_type
;
337 #define elf64_x86_64_hash_entry(ent) \
338 ((struct elf64_x86_64_link_hash_entry *)(ent))
340 struct elf64_x86_64_obj_tdata
342 struct elf_obj_tdata root
;
344 /* tls_type for each local got entry. */
345 char *local_got_tls_type
;
348 #define elf64_x86_64_tdata(abfd) \
349 ((struct elf64_x86_64_obj_tdata *) (abfd)->tdata.any)
351 #define elf64_x86_64_local_got_tls_type(abfd) \
352 (elf64_x86_64_tdata (abfd)->local_got_tls_type)
355 /* x86-64 ELF linker hash table. */
357 struct elf64_x86_64_link_hash_table
359 struct elf_link_hash_table elf
;
361 /* Short-cuts to get to dynamic linker sections. */
371 bfd_signed_vma refcount
;
375 /* Small local sym to section mapping cache. */
376 struct sym_sec_cache sym_sec
;
379 /* Get the x86-64 ELF linker hash table from a link_info structure. */
381 #define elf64_x86_64_hash_table(p) \
382 ((struct elf64_x86_64_link_hash_table *) ((p)->hash))
384 /* Create an entry in an x86-64 ELF linker hash table. */
386 static struct bfd_hash_entry
*
387 link_hash_newfunc (struct bfd_hash_entry
*entry
, struct bfd_hash_table
*table
,
390 /* Allocate the structure if it has not already been allocated by a
394 entry
= bfd_hash_allocate (table
,
395 sizeof (struct elf64_x86_64_link_hash_entry
));
400 /* Call the allocation method of the superclass. */
401 entry
= _bfd_elf_link_hash_newfunc (entry
, table
, string
);
404 struct elf64_x86_64_link_hash_entry
*eh
;
406 eh
= (struct elf64_x86_64_link_hash_entry
*) entry
;
407 eh
->dyn_relocs
= NULL
;
408 eh
->tls_type
= GOT_UNKNOWN
;
414 /* Create an X86-64 ELF linker hash table. */
416 static struct bfd_link_hash_table
*
417 elf64_x86_64_link_hash_table_create (bfd
*abfd
)
419 struct elf64_x86_64_link_hash_table
*ret
;
420 bfd_size_type amt
= sizeof (struct elf64_x86_64_link_hash_table
);
422 ret
= (struct elf64_x86_64_link_hash_table
*) bfd_malloc (amt
);
426 if (! _bfd_elf_link_hash_table_init (&ret
->elf
, abfd
, link_hash_newfunc
))
439 ret
->sym_sec
.abfd
= NULL
;
440 ret
->tls_ld_got
.refcount
= 0;
442 return &ret
->elf
.root
;
445 /* Create .got, .gotplt, and .rela.got sections in DYNOBJ, and set up
446 shortcuts to them in our hash table. */
449 create_got_section (bfd
*dynobj
, struct bfd_link_info
*info
)
451 struct elf64_x86_64_link_hash_table
*htab
;
453 if (! _bfd_elf_create_got_section (dynobj
, info
))
456 htab
= elf64_x86_64_hash_table (info
);
457 htab
->sgot
= bfd_get_section_by_name (dynobj
, ".got");
458 htab
->sgotplt
= bfd_get_section_by_name (dynobj
, ".got.plt");
459 if (!htab
->sgot
|| !htab
->sgotplt
)
462 htab
->srelgot
= bfd_make_section_with_flags (dynobj
, ".rela.got",
463 (SEC_ALLOC
| SEC_LOAD
468 if (htab
->srelgot
== NULL
469 || ! bfd_set_section_alignment (dynobj
, htab
->srelgot
, 3))
474 /* Create .plt, .rela.plt, .got, .got.plt, .rela.got, .dynbss, and
475 .rela.bss sections in DYNOBJ, and set up shortcuts to them in our
479 elf64_x86_64_create_dynamic_sections (bfd
*dynobj
, struct bfd_link_info
*info
)
481 struct elf64_x86_64_link_hash_table
*htab
;
483 htab
= elf64_x86_64_hash_table (info
);
484 if (!htab
->sgot
&& !create_got_section (dynobj
, info
))
487 if (!_bfd_elf_create_dynamic_sections (dynobj
, info
))
490 htab
->splt
= bfd_get_section_by_name (dynobj
, ".plt");
491 htab
->srelplt
= bfd_get_section_by_name (dynobj
, ".rela.plt");
492 htab
->sdynbss
= bfd_get_section_by_name (dynobj
, ".dynbss");
494 htab
->srelbss
= bfd_get_section_by_name (dynobj
, ".rela.bss");
496 if (!htab
->splt
|| !htab
->srelplt
|| !htab
->sdynbss
497 || (!info
->shared
&& !htab
->srelbss
))
503 /* Copy the extra info we tack onto an elf_link_hash_entry. */
506 elf64_x86_64_copy_indirect_symbol (const struct elf_backend_data
*bed
,
507 struct elf_link_hash_entry
*dir
,
508 struct elf_link_hash_entry
*ind
)
510 struct elf64_x86_64_link_hash_entry
*edir
, *eind
;
512 edir
= (struct elf64_x86_64_link_hash_entry
*) dir
;
513 eind
= (struct elf64_x86_64_link_hash_entry
*) ind
;
515 if (eind
->dyn_relocs
!= NULL
)
517 if (edir
->dyn_relocs
!= NULL
)
519 struct elf64_x86_64_dyn_relocs
**pp
;
520 struct elf64_x86_64_dyn_relocs
*p
;
522 if (ind
->root
.type
== bfd_link_hash_indirect
)
525 /* Add reloc counts against the weak sym to the strong sym
526 list. Merge any entries against the same section. */
527 for (pp
= &eind
->dyn_relocs
; (p
= *pp
) != NULL
; )
529 struct elf64_x86_64_dyn_relocs
*q
;
531 for (q
= edir
->dyn_relocs
; q
!= NULL
; q
= q
->next
)
532 if (q
->sec
== p
->sec
)
534 q
->pc_count
+= p
->pc_count
;
535 q
->count
+= p
->count
;
542 *pp
= edir
->dyn_relocs
;
545 edir
->dyn_relocs
= eind
->dyn_relocs
;
546 eind
->dyn_relocs
= NULL
;
549 if (ind
->root
.type
== bfd_link_hash_indirect
550 && dir
->got
.refcount
<= 0)
552 edir
->tls_type
= eind
->tls_type
;
553 eind
->tls_type
= GOT_UNKNOWN
;
556 if (ELIMINATE_COPY_RELOCS
557 && ind
->root
.type
!= bfd_link_hash_indirect
558 && dir
->dynamic_adjusted
)
560 /* If called to transfer flags for a weakdef during processing
561 of elf_adjust_dynamic_symbol, don't copy non_got_ref.
562 We clear it ourselves for ELIMINATE_COPY_RELOCS. */
563 dir
->ref_dynamic
|= ind
->ref_dynamic
;
564 dir
->ref_regular
|= ind
->ref_regular
;
565 dir
->ref_regular_nonweak
|= ind
->ref_regular_nonweak
;
566 dir
->needs_plt
|= ind
->needs_plt
;
567 dir
->pointer_equality_needed
|= ind
->pointer_equality_needed
;
570 _bfd_elf_link_hash_copy_indirect (bed
, dir
, ind
);
574 elf64_x86_64_mkobject (bfd
*abfd
)
576 bfd_size_type amt
= sizeof (struct elf64_x86_64_obj_tdata
);
577 abfd
->tdata
.any
= bfd_zalloc (abfd
, amt
);
578 if (abfd
->tdata
.any
== NULL
)
584 elf64_x86_64_elf_object_p (bfd
*abfd
)
586 /* Set the right machine number for an x86-64 elf64 file. */
587 bfd_default_set_arch_mach (abfd
, bfd_arch_i386
, bfd_mach_x86_64
);
592 elf64_x86_64_tls_transition (struct bfd_link_info
*info
, int r_type
, int is_local
)
600 case R_X86_64_GOTTPOFF
:
602 return R_X86_64_TPOFF32
;
603 return R_X86_64_GOTTPOFF
;
605 return R_X86_64_TPOFF32
;
611 /* Look through the relocs for a section during the first phase, and
612 calculate needed space in the global offset table, procedure
613 linkage table, and dynamic reloc sections. */
616 elf64_x86_64_check_relocs (bfd
*abfd
, struct bfd_link_info
*info
, asection
*sec
,
617 const Elf_Internal_Rela
*relocs
)
619 struct elf64_x86_64_link_hash_table
*htab
;
620 Elf_Internal_Shdr
*symtab_hdr
;
621 struct elf_link_hash_entry
**sym_hashes
;
622 const Elf_Internal_Rela
*rel
;
623 const Elf_Internal_Rela
*rel_end
;
626 if (info
->relocatable
)
629 htab
= elf64_x86_64_hash_table (info
);
630 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
631 sym_hashes
= elf_sym_hashes (abfd
);
635 rel_end
= relocs
+ sec
->reloc_count
;
636 for (rel
= relocs
; rel
< rel_end
; rel
++)
639 unsigned long r_symndx
;
640 struct elf_link_hash_entry
*h
;
642 r_symndx
= ELF64_R_SYM (rel
->r_info
);
643 r_type
= ELF64_R_TYPE (rel
->r_info
);
645 if (r_symndx
>= NUM_SHDR_ENTRIES (symtab_hdr
))
647 (*_bfd_error_handler
) (_("%B: bad symbol index: %d"),
652 if (r_symndx
< symtab_hdr
->sh_info
)
655 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
657 r_type
= elf64_x86_64_tls_transition (info
, r_type
, h
== NULL
);
661 htab
->tls_ld_got
.refcount
+= 1;
664 case R_X86_64_TPOFF32
:
667 (*_bfd_error_handler
)
668 (_("%B: relocation %s against `%s' can not be used when making a shared object; recompile with -fPIC"),
670 x86_64_elf_howto_table
[r_type
].name
,
671 (h
) ? h
->root
.root
.string
: "a local symbol");
672 bfd_set_error (bfd_error_bad_value
);
677 case R_X86_64_GOTTPOFF
:
679 info
->flags
|= DF_STATIC_TLS
;
683 case R_X86_64_GOTPCREL
:
685 /* This symbol requires a global offset table entry. */
687 int tls_type
, old_tls_type
;
691 default: tls_type
= GOT_NORMAL
; break;
692 case R_X86_64_TLSGD
: tls_type
= GOT_TLS_GD
; break;
693 case R_X86_64_GOTTPOFF
: tls_type
= GOT_TLS_IE
; break;
698 h
->got
.refcount
+= 1;
699 old_tls_type
= elf64_x86_64_hash_entry (h
)->tls_type
;
703 bfd_signed_vma
*local_got_refcounts
;
705 /* This is a global offset table entry for a local symbol. */
706 local_got_refcounts
= elf_local_got_refcounts (abfd
);
707 if (local_got_refcounts
== NULL
)
711 size
= symtab_hdr
->sh_info
;
712 size
*= sizeof (bfd_signed_vma
) + sizeof (char);
713 local_got_refcounts
= ((bfd_signed_vma
*)
714 bfd_zalloc (abfd
, size
));
715 if (local_got_refcounts
== NULL
)
717 elf_local_got_refcounts (abfd
) = local_got_refcounts
;
718 elf64_x86_64_local_got_tls_type (abfd
)
719 = (char *) (local_got_refcounts
+ symtab_hdr
->sh_info
);
721 local_got_refcounts
[r_symndx
] += 1;
723 = elf64_x86_64_local_got_tls_type (abfd
) [r_symndx
];
726 /* If a TLS symbol is accessed using IE at least once,
727 there is no point to use dynamic model for it. */
728 if (old_tls_type
!= tls_type
&& old_tls_type
!= GOT_UNKNOWN
729 && (old_tls_type
!= GOT_TLS_GD
|| tls_type
!= GOT_TLS_IE
))
731 if (old_tls_type
== GOT_TLS_IE
&& tls_type
== GOT_TLS_GD
)
732 tls_type
= old_tls_type
;
735 (*_bfd_error_handler
)
736 (_("%B: %s' accessed both as normal and thread local symbol"),
737 abfd
, h
? h
->root
.root
.string
: "<local>");
742 if (old_tls_type
!= tls_type
)
745 elf64_x86_64_hash_entry (h
)->tls_type
= tls_type
;
747 elf64_x86_64_local_got_tls_type (abfd
) [r_symndx
] = tls_type
;
752 //case R_X86_64_GOTPCREL:
754 if (htab
->sgot
== NULL
)
756 if (htab
->elf
.dynobj
== NULL
)
757 htab
->elf
.dynobj
= abfd
;
758 if (!create_got_section (htab
->elf
.dynobj
, info
))
764 /* This symbol requires a procedure linkage table entry. We
765 actually build the entry in adjust_dynamic_symbol,
766 because this might be a case of linking PIC code which is
767 never referenced by a dynamic object, in which case we
768 don't need to generate a procedure linkage table entry
771 /* If this is a local symbol, we resolve it directly without
772 creating a procedure linkage table entry. */
777 h
->plt
.refcount
+= 1;
784 /* Let's help debug shared library creation. These relocs
785 cannot be used in shared libs. Don't error out for
786 sections we don't care about, such as debug sections or
787 non-constant sections. */
789 && (sec
->flags
& SEC_ALLOC
) != 0
790 && (sec
->flags
& SEC_READONLY
) != 0)
792 (*_bfd_error_handler
)
793 (_("%B: relocation %s against `%s' can not be used when making a shared object; recompile with -fPIC"),
795 x86_64_elf_howto_table
[r_type
].name
,
796 (h
) ? h
->root
.root
.string
: "a local symbol");
797 bfd_set_error (bfd_error_bad_value
);
806 if (h
!= NULL
&& !info
->shared
)
808 /* If this reloc is in a read-only section, we might
809 need a copy reloc. We can't check reliably at this
810 stage whether the section is read-only, as input
811 sections have not yet been mapped to output sections.
812 Tentatively set the flag for now, and correct in
813 adjust_dynamic_symbol. */
816 /* We may need a .plt entry if the function this reloc
817 refers to is in a shared lib. */
818 h
->plt
.refcount
+= 1;
819 if (r_type
!= R_X86_64_PC32
)
820 h
->pointer_equality_needed
= 1;
823 /* If we are creating a shared library, and this is a reloc
824 against a global symbol, or a non PC relative reloc
825 against a local symbol, then we need to copy the reloc
826 into the shared library. However, if we are linking with
827 -Bsymbolic, we do not need to copy a reloc against a
828 global symbol which is defined in an object we are
829 including in the link (i.e., DEF_REGULAR is set). At
830 this point we have not seen all the input files, so it is
831 possible that DEF_REGULAR is not set now but will be set
832 later (it is never cleared). In case of a weak definition,
833 DEF_REGULAR may be cleared later by a strong definition in
834 a shared library. We account for that possibility below by
835 storing information in the relocs_copied field of the hash
836 table entry. A similar situation occurs when creating
837 shared libraries and symbol visibility changes render the
840 If on the other hand, we are creating an executable, we
841 may need to keep relocations for symbols satisfied by a
842 dynamic library if we manage to avoid copy relocs for the
845 && (sec
->flags
& SEC_ALLOC
) != 0
846 && (((r_type
!= R_X86_64_PC8
)
847 && (r_type
!= R_X86_64_PC16
)
848 && (r_type
!= R_X86_64_PC32
))
851 || h
->root
.type
== bfd_link_hash_defweak
852 || !h
->def_regular
))))
853 || (ELIMINATE_COPY_RELOCS
855 && (sec
->flags
& SEC_ALLOC
) != 0
857 && (h
->root
.type
== bfd_link_hash_defweak
858 || !h
->def_regular
)))
860 struct elf64_x86_64_dyn_relocs
*p
;
861 struct elf64_x86_64_dyn_relocs
**head
;
863 /* We must copy these reloc types into the output file.
864 Create a reloc section in dynobj and make room for
871 name
= (bfd_elf_string_from_elf_section
873 elf_elfheader (abfd
)->e_shstrndx
,
874 elf_section_data (sec
)->rel_hdr
.sh_name
));
878 if (strncmp (name
, ".rela", 5) != 0
879 || strcmp (bfd_get_section_name (abfd
, sec
),
882 (*_bfd_error_handler
)
883 (_("%B: bad relocation section name `%s\'"),
887 if (htab
->elf
.dynobj
== NULL
)
888 htab
->elf
.dynobj
= abfd
;
890 dynobj
= htab
->elf
.dynobj
;
892 sreloc
= bfd_get_section_by_name (dynobj
, name
);
897 flags
= (SEC_HAS_CONTENTS
| SEC_READONLY
898 | SEC_IN_MEMORY
| SEC_LINKER_CREATED
);
899 if ((sec
->flags
& SEC_ALLOC
) != 0)
900 flags
|= SEC_ALLOC
| SEC_LOAD
;
901 sreloc
= bfd_make_section_with_flags (dynobj
,
905 || ! bfd_set_section_alignment (dynobj
, sreloc
, 3))
908 elf_section_data (sec
)->sreloc
= sreloc
;
911 /* If this is a global symbol, we count the number of
912 relocations we need for this symbol. */
915 head
= &((struct elf64_x86_64_link_hash_entry
*) h
)->dyn_relocs
;
919 /* Track dynamic relocs needed for local syms too.
920 We really need local syms available to do this
924 s
= bfd_section_from_r_symndx (abfd
, &htab
->sym_sec
,
929 head
= ((struct elf64_x86_64_dyn_relocs
**)
930 &elf_section_data (s
)->local_dynrel
);
934 if (p
== NULL
|| p
->sec
!= sec
)
936 bfd_size_type amt
= sizeof *p
;
937 p
= ((struct elf64_x86_64_dyn_relocs
*)
938 bfd_alloc (htab
->elf
.dynobj
, amt
));
949 if (r_type
== R_X86_64_PC8
950 || r_type
== R_X86_64_PC16
951 || r_type
== R_X86_64_PC32
)
956 /* This relocation describes the C++ object vtable hierarchy.
957 Reconstruct it for later use during GC. */
958 case R_X86_64_GNU_VTINHERIT
:
959 if (!bfd_elf_gc_record_vtinherit (abfd
, sec
, h
, rel
->r_offset
))
963 /* This relocation describes which C++ vtable entries are actually
964 used. Record for later use during GC. */
965 case R_X86_64_GNU_VTENTRY
:
966 if (!bfd_elf_gc_record_vtentry (abfd
, sec
, h
, rel
->r_addend
))
978 /* Return the section that should be marked against GC for a given
982 elf64_x86_64_gc_mark_hook (asection
*sec
,
983 struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
984 Elf_Internal_Rela
*rel
,
985 struct elf_link_hash_entry
*h
,
986 Elf_Internal_Sym
*sym
)
990 switch (ELF64_R_TYPE (rel
->r_info
))
992 case R_X86_64_GNU_VTINHERIT
:
993 case R_X86_64_GNU_VTENTRY
:
997 switch (h
->root
.type
)
999 case bfd_link_hash_defined
:
1000 case bfd_link_hash_defweak
:
1001 return h
->root
.u
.def
.section
;
1003 case bfd_link_hash_common
:
1004 return h
->root
.u
.c
.p
->section
;
1012 return bfd_section_from_elf_index (sec
->owner
, sym
->st_shndx
);
1017 /* Update the got entry reference counts for the section being removed. */
1020 elf64_x86_64_gc_sweep_hook (bfd
*abfd
, struct bfd_link_info
*info
,
1021 asection
*sec
, const Elf_Internal_Rela
*relocs
)
1023 Elf_Internal_Shdr
*symtab_hdr
;
1024 struct elf_link_hash_entry
**sym_hashes
;
1025 bfd_signed_vma
*local_got_refcounts
;
1026 const Elf_Internal_Rela
*rel
, *relend
;
1028 elf_section_data (sec
)->local_dynrel
= NULL
;
1030 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
1031 sym_hashes
= elf_sym_hashes (abfd
);
1032 local_got_refcounts
= elf_local_got_refcounts (abfd
);
1034 relend
= relocs
+ sec
->reloc_count
;
1035 for (rel
= relocs
; rel
< relend
; rel
++)
1037 unsigned long r_symndx
;
1038 unsigned int r_type
;
1039 struct elf_link_hash_entry
*h
= NULL
;
1041 r_symndx
= ELF64_R_SYM (rel
->r_info
);
1042 if (r_symndx
>= symtab_hdr
->sh_info
)
1044 struct elf64_x86_64_link_hash_entry
*eh
;
1045 struct elf64_x86_64_dyn_relocs
**pp
;
1046 struct elf64_x86_64_dyn_relocs
*p
;
1048 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
1049 while (h
->root
.type
== bfd_link_hash_indirect
1050 || h
->root
.type
== bfd_link_hash_warning
)
1051 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
1052 eh
= (struct elf64_x86_64_link_hash_entry
*) h
;
1054 for (pp
= &eh
->dyn_relocs
; (p
= *pp
) != NULL
; pp
= &p
->next
)
1057 /* Everything must go for SEC. */
1063 r_type
= ELF64_R_TYPE (rel
->r_info
);
1064 r_type
= elf64_x86_64_tls_transition (info
, r_type
, h
!= NULL
);
1067 case R_X86_64_TLSLD
:
1068 if (elf64_x86_64_hash_table (info
)->tls_ld_got
.refcount
> 0)
1069 elf64_x86_64_hash_table (info
)->tls_ld_got
.refcount
-= 1;
1072 case R_X86_64_TLSGD
:
1073 case R_X86_64_GOTTPOFF
:
1074 case R_X86_64_GOT32
:
1075 case R_X86_64_GOTPCREL
:
1078 if (h
->got
.refcount
> 0)
1079 h
->got
.refcount
-= 1;
1081 else if (local_got_refcounts
!= NULL
)
1083 if (local_got_refcounts
[r_symndx
] > 0)
1084 local_got_refcounts
[r_symndx
] -= 1;
1100 case R_X86_64_PLT32
:
1103 if (h
->plt
.refcount
> 0)
1104 h
->plt
.refcount
-= 1;
1116 /* Adjust a symbol defined by a dynamic object and referenced by a
1117 regular object. The current definition is in some section of the
1118 dynamic object, but we're not including those sections. We have to
1119 change the definition to something the rest of the link can
1123 elf64_x86_64_adjust_dynamic_symbol (struct bfd_link_info
*info
,
1124 struct elf_link_hash_entry
*h
)
1126 struct elf64_x86_64_link_hash_table
*htab
;
1128 unsigned int power_of_two
;
1130 /* If this is a function, put it in the procedure linkage table. We
1131 will fill in the contents of the procedure linkage table later,
1132 when we know the address of the .got section. */
1133 if (h
->type
== STT_FUNC
1136 if (h
->plt
.refcount
<= 0
1137 || SYMBOL_CALLS_LOCAL (info
, h
)
1138 || (ELF_ST_VISIBILITY (h
->other
) != STV_DEFAULT
1139 && h
->root
.type
== bfd_link_hash_undefweak
))
1141 /* This case can occur if we saw a PLT32 reloc in an input
1142 file, but the symbol was never referred to by a dynamic
1143 object, or if all references were garbage collected. In
1144 such a case, we don't actually need to build a procedure
1145 linkage table, and we can just do a PC32 reloc instead. */
1146 h
->plt
.offset
= (bfd_vma
) -1;
1153 /* It's possible that we incorrectly decided a .plt reloc was
1154 needed for an R_X86_64_PC32 reloc to a non-function sym in
1155 check_relocs. We can't decide accurately between function and
1156 non-function syms in check-relocs; Objects loaded later in
1157 the link may change h->type. So fix it now. */
1158 h
->plt
.offset
= (bfd_vma
) -1;
1160 /* If this is a weak symbol, and there is a real definition, the
1161 processor independent code will have arranged for us to see the
1162 real definition first, and we can just use the same value. */
1163 if (h
->u
.weakdef
!= NULL
)
1165 BFD_ASSERT (h
->u
.weakdef
->root
.type
== bfd_link_hash_defined
1166 || h
->u
.weakdef
->root
.type
== bfd_link_hash_defweak
);
1167 h
->root
.u
.def
.section
= h
->u
.weakdef
->root
.u
.def
.section
;
1168 h
->root
.u
.def
.value
= h
->u
.weakdef
->root
.u
.def
.value
;
1169 if (ELIMINATE_COPY_RELOCS
|| info
->nocopyreloc
)
1170 h
->non_got_ref
= h
->u
.weakdef
->non_got_ref
;
1174 /* This is a reference to a symbol defined by a dynamic object which
1175 is not a function. */
1177 /* If we are creating a shared library, we must presume that the
1178 only references to the symbol are via the global offset table.
1179 For such cases we need not do anything here; the relocations will
1180 be handled correctly by relocate_section. */
1184 /* If there are no references to this symbol that do not use the
1185 GOT, we don't need to generate a copy reloc. */
1186 if (!h
->non_got_ref
)
1189 /* If -z nocopyreloc was given, we won't generate them either. */
1190 if (info
->nocopyreloc
)
1196 if (ELIMINATE_COPY_RELOCS
)
1198 struct elf64_x86_64_link_hash_entry
* eh
;
1199 struct elf64_x86_64_dyn_relocs
*p
;
1201 eh
= (struct elf64_x86_64_link_hash_entry
*) h
;
1202 for (p
= eh
->dyn_relocs
; p
!= NULL
; p
= p
->next
)
1204 s
= p
->sec
->output_section
;
1205 if (s
!= NULL
&& (s
->flags
& SEC_READONLY
) != 0)
1209 /* If we didn't find any dynamic relocs in read-only sections, then
1210 we'll be keeping the dynamic relocs and avoiding the copy reloc. */
1218 /* We must allocate the symbol in our .dynbss section, which will
1219 become part of the .bss section of the executable. There will be
1220 an entry for this symbol in the .dynsym section. The dynamic
1221 object will contain position independent code, so all references
1222 from the dynamic object to this symbol will go through the global
1223 offset table. The dynamic linker will use the .dynsym entry to
1224 determine the address it must put in the global offset table, so
1225 both the dynamic object and the regular object will refer to the
1226 same memory location for the variable. */
1228 htab
= elf64_x86_64_hash_table (info
);
1230 /* We must generate a R_X86_64_COPY reloc to tell the dynamic linker
1231 to copy the initial value out of the dynamic object and into the
1232 runtime process image. */
1233 if ((h
->root
.u
.def
.section
->flags
& SEC_ALLOC
) != 0)
1235 htab
->srelbss
->size
+= sizeof (Elf64_External_Rela
);
1239 /* We need to figure out the alignment required for this symbol. I
1240 have no idea how ELF linkers handle this. 16-bytes is the size
1241 of the largest type that requires hard alignment -- long double. */
1242 /* FIXME: This is VERY ugly. Should be fixed for all architectures using
1244 power_of_two
= bfd_log2 (h
->size
);
1245 if (power_of_two
> 4)
1248 /* Apply the required alignment. */
1250 s
->size
= BFD_ALIGN (s
->size
, (bfd_size_type
) (1 << power_of_two
));
1251 if (power_of_two
> bfd_get_section_alignment (htab
->elf
.dynobj
, s
))
1253 if (! bfd_set_section_alignment (htab
->elf
.dynobj
, s
, power_of_two
))
1257 /* Define the symbol as being at this point in the section. */
1258 h
->root
.u
.def
.section
= s
;
1259 h
->root
.u
.def
.value
= s
->size
;
1261 /* Increment the section size to make room for the symbol. */
1267 /* Allocate space in .plt, .got and associated reloc sections for
1271 allocate_dynrelocs (struct elf_link_hash_entry
*h
, void * inf
)
1273 struct bfd_link_info
*info
;
1274 struct elf64_x86_64_link_hash_table
*htab
;
1275 struct elf64_x86_64_link_hash_entry
*eh
;
1276 struct elf64_x86_64_dyn_relocs
*p
;
1278 if (h
->root
.type
== bfd_link_hash_indirect
)
1281 if (h
->root
.type
== bfd_link_hash_warning
)
1282 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
1284 info
= (struct bfd_link_info
*) inf
;
1285 htab
= elf64_x86_64_hash_table (info
);
1287 if (htab
->elf
.dynamic_sections_created
1288 && h
->plt
.refcount
> 0)
1290 /* Make sure this symbol is output as a dynamic symbol.
1291 Undefined weak syms won't yet be marked as dynamic. */
1292 if (h
->dynindx
== -1
1293 && !h
->forced_local
)
1295 if (! bfd_elf_link_record_dynamic_symbol (info
, h
))
1300 || WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, 0, h
))
1302 asection
*s
= htab
->splt
;
1304 /* If this is the first .plt entry, make room for the special
1307 s
->size
+= PLT_ENTRY_SIZE
;
1309 h
->plt
.offset
= s
->size
;
1311 /* If this symbol is not defined in a regular file, and we are
1312 not generating a shared library, then set the symbol to this
1313 location in the .plt. This is required to make function
1314 pointers compare as equal between the normal executable and
1315 the shared library. */
1319 h
->root
.u
.def
.section
= s
;
1320 h
->root
.u
.def
.value
= h
->plt
.offset
;
1323 /* Make room for this entry. */
1324 s
->size
+= PLT_ENTRY_SIZE
;
1326 /* We also need to make an entry in the .got.plt section, which
1327 will be placed in the .got section by the linker script. */
1328 htab
->sgotplt
->size
+= GOT_ENTRY_SIZE
;
1330 /* We also need to make an entry in the .rela.plt section. */
1331 htab
->srelplt
->size
+= sizeof (Elf64_External_Rela
);
1335 h
->plt
.offset
= (bfd_vma
) -1;
1341 h
->plt
.offset
= (bfd_vma
) -1;
1345 /* If R_X86_64_GOTTPOFF symbol is now local to the binary,
1346 make it a R_X86_64_TPOFF32 requiring no GOT entry. */
1347 if (h
->got
.refcount
> 0
1350 && elf64_x86_64_hash_entry (h
)->tls_type
== GOT_TLS_IE
)
1351 h
->got
.offset
= (bfd_vma
) -1;
1352 else if (h
->got
.refcount
> 0)
1356 int tls_type
= elf64_x86_64_hash_entry (h
)->tls_type
;
1358 /* Make sure this symbol is output as a dynamic symbol.
1359 Undefined weak syms won't yet be marked as dynamic. */
1360 if (h
->dynindx
== -1
1361 && !h
->forced_local
)
1363 if (! bfd_elf_link_record_dynamic_symbol (info
, h
))
1368 h
->got
.offset
= s
->size
;
1369 s
->size
+= GOT_ENTRY_SIZE
;
1370 /* R_X86_64_TLSGD needs 2 consecutive GOT slots. */
1371 if (tls_type
== GOT_TLS_GD
)
1372 s
->size
+= GOT_ENTRY_SIZE
;
1373 dyn
= htab
->elf
.dynamic_sections_created
;
1374 /* R_X86_64_TLSGD needs one dynamic relocation if local symbol
1376 R_X86_64_GOTTPOFF needs one dynamic relocation. */
1377 if ((tls_type
== GOT_TLS_GD
&& h
->dynindx
== -1)
1378 || tls_type
== GOT_TLS_IE
)
1379 htab
->srelgot
->size
+= sizeof (Elf64_External_Rela
);
1380 else if (tls_type
== GOT_TLS_GD
)
1381 htab
->srelgot
->size
+= 2 * sizeof (Elf64_External_Rela
);
1382 else if ((ELF_ST_VISIBILITY (h
->other
) == STV_DEFAULT
1383 || h
->root
.type
!= bfd_link_hash_undefweak
)
1385 || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn
, 0, h
)))
1386 htab
->srelgot
->size
+= sizeof (Elf64_External_Rela
);
1389 h
->got
.offset
= (bfd_vma
) -1;
1391 eh
= (struct elf64_x86_64_link_hash_entry
*) h
;
1392 if (eh
->dyn_relocs
== NULL
)
1395 /* In the shared -Bsymbolic case, discard space allocated for
1396 dynamic pc-relative relocs against symbols which turn out to be
1397 defined in regular objects. For the normal shared case, discard
1398 space for pc-relative relocs that have become local due to symbol
1399 visibility changes. */
1403 /* Relocs that use pc_count are those that appear on a call
1404 insn, or certain REL relocs that can generated via assembly.
1405 We want calls to protected symbols to resolve directly to the
1406 function rather than going via the plt. If people want
1407 function pointer comparisons to work as expected then they
1408 should avoid writing weird assembly. */
1409 if (SYMBOL_CALLS_LOCAL (info
, h
))
1411 struct elf64_x86_64_dyn_relocs
**pp
;
1413 for (pp
= &eh
->dyn_relocs
; (p
= *pp
) != NULL
; )
1415 p
->count
-= p
->pc_count
;
1424 /* Also discard relocs on undefined weak syms with non-default
1426 if (ELF_ST_VISIBILITY (h
->other
) != STV_DEFAULT
1427 && h
->root
.type
== bfd_link_hash_undefweak
)
1428 eh
->dyn_relocs
= NULL
;
1430 else if (ELIMINATE_COPY_RELOCS
)
1432 /* For the non-shared case, discard space for relocs against
1433 symbols which turn out to need copy relocs or are not
1439 || (htab
->elf
.dynamic_sections_created
1440 && (h
->root
.type
== bfd_link_hash_undefweak
1441 || h
->root
.type
== bfd_link_hash_undefined
))))
1443 /* Make sure this symbol is output as a dynamic symbol.
1444 Undefined weak syms won't yet be marked as dynamic. */
1445 if (h
->dynindx
== -1
1446 && !h
->forced_local
)
1448 if (! bfd_elf_link_record_dynamic_symbol (info
, h
))
1452 /* If that succeeded, we know we'll be keeping all the
1454 if (h
->dynindx
!= -1)
1458 eh
->dyn_relocs
= NULL
;
1463 /* Finally, allocate space. */
1464 for (p
= eh
->dyn_relocs
; p
!= NULL
; p
= p
->next
)
1466 asection
*sreloc
= elf_section_data (p
->sec
)->sreloc
;
1467 sreloc
->size
+= p
->count
* sizeof (Elf64_External_Rela
);
1473 /* Find any dynamic relocs that apply to read-only sections. */
1476 readonly_dynrelocs (struct elf_link_hash_entry
*h
, void * inf
)
1478 struct elf64_x86_64_link_hash_entry
*eh
;
1479 struct elf64_x86_64_dyn_relocs
*p
;
1481 if (h
->root
.type
== bfd_link_hash_warning
)
1482 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
1484 eh
= (struct elf64_x86_64_link_hash_entry
*) h
;
1485 for (p
= eh
->dyn_relocs
; p
!= NULL
; p
= p
->next
)
1487 asection
*s
= p
->sec
->output_section
;
1489 if (s
!= NULL
&& (s
->flags
& SEC_READONLY
) != 0)
1491 struct bfd_link_info
*info
= (struct bfd_link_info
*) inf
;
1493 info
->flags
|= DF_TEXTREL
;
1495 /* Not an error, just cut short the traversal. */
1502 /* Set the sizes of the dynamic sections. */
1505 elf64_x86_64_size_dynamic_sections (bfd
*output_bfd ATTRIBUTE_UNUSED
,
1506 struct bfd_link_info
*info
)
1508 struct elf64_x86_64_link_hash_table
*htab
;
1514 htab
= elf64_x86_64_hash_table (info
);
1515 dynobj
= htab
->elf
.dynobj
;
1519 if (htab
->elf
.dynamic_sections_created
)
1521 /* Set the contents of the .interp section to the interpreter. */
1522 if (info
->executable
)
1524 s
= bfd_get_section_by_name (dynobj
, ".interp");
1527 s
->size
= sizeof ELF_DYNAMIC_INTERPRETER
;
1528 s
->contents
= (unsigned char *) ELF_DYNAMIC_INTERPRETER
;
1532 /* Set up .got offsets for local syms, and space for local dynamic
1534 for (ibfd
= info
->input_bfds
; ibfd
!= NULL
; ibfd
= ibfd
->link_next
)
1536 bfd_signed_vma
*local_got
;
1537 bfd_signed_vma
*end_local_got
;
1538 char *local_tls_type
;
1539 bfd_size_type locsymcount
;
1540 Elf_Internal_Shdr
*symtab_hdr
;
1543 if (bfd_get_flavour (ibfd
) != bfd_target_elf_flavour
)
1546 for (s
= ibfd
->sections
; s
!= NULL
; s
= s
->next
)
1548 struct elf64_x86_64_dyn_relocs
*p
;
1550 for (p
= *((struct elf64_x86_64_dyn_relocs
**)
1551 &elf_section_data (s
)->local_dynrel
);
1555 if (!bfd_is_abs_section (p
->sec
)
1556 && bfd_is_abs_section (p
->sec
->output_section
))
1558 /* Input section has been discarded, either because
1559 it is a copy of a linkonce section or due to
1560 linker script /DISCARD/, so we'll be discarding
1563 else if (p
->count
!= 0)
1565 srel
= elf_section_data (p
->sec
)->sreloc
;
1566 srel
->size
+= p
->count
* sizeof (Elf64_External_Rela
);
1567 if ((p
->sec
->output_section
->flags
& SEC_READONLY
) != 0)
1568 info
->flags
|= DF_TEXTREL
;
1574 local_got
= elf_local_got_refcounts (ibfd
);
1578 symtab_hdr
= &elf_tdata (ibfd
)->symtab_hdr
;
1579 locsymcount
= symtab_hdr
->sh_info
;
1580 end_local_got
= local_got
+ locsymcount
;
1581 local_tls_type
= elf64_x86_64_local_got_tls_type (ibfd
);
1583 srel
= htab
->srelgot
;
1584 for (; local_got
< end_local_got
; ++local_got
, ++local_tls_type
)
1588 *local_got
= s
->size
;
1589 s
->size
+= GOT_ENTRY_SIZE
;
1590 if (*local_tls_type
== GOT_TLS_GD
)
1591 s
->size
+= GOT_ENTRY_SIZE
;
1593 || *local_tls_type
== GOT_TLS_GD
1594 || *local_tls_type
== GOT_TLS_IE
)
1595 srel
->size
+= sizeof (Elf64_External_Rela
);
1598 *local_got
= (bfd_vma
) -1;
1602 if (htab
->tls_ld_got
.refcount
> 0)
1604 /* Allocate 2 got entries and 1 dynamic reloc for R_X86_64_TLSLD
1606 htab
->tls_ld_got
.offset
= htab
->sgot
->size
;
1607 htab
->sgot
->size
+= 2 * GOT_ENTRY_SIZE
;
1608 htab
->srelgot
->size
+= sizeof (Elf64_External_Rela
);
1611 htab
->tls_ld_got
.offset
= -1;
1613 /* Allocate global sym .plt and .got entries, and space for global
1614 sym dynamic relocs. */
1615 elf_link_hash_traverse (&htab
->elf
, allocate_dynrelocs
, (PTR
) info
);
1617 /* We now have determined the sizes of the various dynamic sections.
1618 Allocate memory for them. */
1620 for (s
= dynobj
->sections
; s
!= NULL
; s
= s
->next
)
1622 if ((s
->flags
& SEC_LINKER_CREATED
) == 0)
1627 || s
== htab
->sgotplt
1628 || s
== htab
->sdynbss
)
1630 /* Strip this section if we don't need it; see the
1633 else if (strncmp (bfd_get_section_name (dynobj
, s
), ".rela", 5) == 0)
1635 if (s
->size
!= 0 && s
!= htab
->srelplt
)
1638 /* We use the reloc_count field as a counter if we need
1639 to copy relocs into the output file. */
1644 /* It's not one of our sections, so don't allocate space. */
1650 /* If we don't need this section, strip it from the
1651 output file. This is mostly to handle .rela.bss and
1652 .rela.plt. We must create both sections in
1653 create_dynamic_sections, because they must be created
1654 before the linker maps input sections to output
1655 sections. The linker does that before
1656 adjust_dynamic_symbol is called, and it is that
1657 function which decides whether anything needs to go
1658 into these sections. */
1660 s
->flags
|= SEC_EXCLUDE
;
1664 /* Allocate memory for the section contents. We use bfd_zalloc
1665 here in case unused entries are not reclaimed before the
1666 section's contents are written out. This should not happen,
1667 but this way if it does, we get a R_X86_64_NONE reloc instead
1669 s
->contents
= (bfd_byte
*) bfd_zalloc (dynobj
, s
->size
);
1670 if (s
->contents
== NULL
)
1674 if (htab
->elf
.dynamic_sections_created
)
1676 /* Add some entries to the .dynamic section. We fill in the
1677 values later, in elf64_x86_64_finish_dynamic_sections, but we
1678 must add the entries now so that we get the correct size for
1679 the .dynamic section. The DT_DEBUG entry is filled in by the
1680 dynamic linker and used by the debugger. */
1681 #define add_dynamic_entry(TAG, VAL) \
1682 _bfd_elf_add_dynamic_entry (info, TAG, VAL)
1684 if (info
->executable
)
1686 if (!add_dynamic_entry (DT_DEBUG
, 0))
1690 if (htab
->splt
->size
!= 0)
1692 if (!add_dynamic_entry (DT_PLTGOT
, 0)
1693 || !add_dynamic_entry (DT_PLTRELSZ
, 0)
1694 || !add_dynamic_entry (DT_PLTREL
, DT_RELA
)
1695 || !add_dynamic_entry (DT_JMPREL
, 0))
1701 if (!add_dynamic_entry (DT_RELA
, 0)
1702 || !add_dynamic_entry (DT_RELASZ
, 0)
1703 || !add_dynamic_entry (DT_RELAENT
, sizeof (Elf64_External_Rela
)))
1706 /* If any dynamic relocs apply to a read-only section,
1707 then we need a DT_TEXTREL entry. */
1708 if ((info
->flags
& DF_TEXTREL
) == 0)
1709 elf_link_hash_traverse (&htab
->elf
, readonly_dynrelocs
,
1712 if ((info
->flags
& DF_TEXTREL
) != 0)
1714 if (!add_dynamic_entry (DT_TEXTREL
, 0))
1719 #undef add_dynamic_entry
1724 /* Return the base VMA address which should be subtracted from real addresses
1725 when resolving @dtpoff relocation.
1726 This is PT_TLS segment p_vaddr. */
1729 dtpoff_base (struct bfd_link_info
*info
)
1731 /* If tls_sec is NULL, we should have signalled an error already. */
1732 if (elf_hash_table (info
)->tls_sec
== NULL
)
1734 return elf_hash_table (info
)->tls_sec
->vma
;
1737 /* Return the relocation value for @tpoff relocation
1738 if STT_TLS virtual address is ADDRESS. */
1741 tpoff (struct bfd_link_info
*info
, bfd_vma address
)
1743 struct elf_link_hash_table
*htab
= elf_hash_table (info
);
1745 /* If tls_segment is NULL, we should have signalled an error already. */
1746 if (htab
->tls_sec
== NULL
)
1748 return address
- htab
->tls_size
- htab
->tls_sec
->vma
;
1751 /* Is the instruction before OFFSET in CONTENTS a 32bit relative
1755 is_32bit_relative_branch (bfd_byte
*contents
, bfd_vma offset
)
1757 /* Opcode Instruction
1760 0x0f 0x8x conditional jump */
1762 && (contents
[offset
- 1] == 0xe8
1763 || contents
[offset
- 1] == 0xe9))
1765 && contents
[offset
- 2] == 0x0f
1766 && (contents
[offset
- 1] & 0xf0) == 0x80));
1769 /* Relocate an x86_64 ELF section. */
1772 elf64_x86_64_relocate_section (bfd
*output_bfd
, struct bfd_link_info
*info
,
1773 bfd
*input_bfd
, asection
*input_section
,
1774 bfd_byte
*contents
, Elf_Internal_Rela
*relocs
,
1775 Elf_Internal_Sym
*local_syms
,
1776 asection
**local_sections
)
1778 struct elf64_x86_64_link_hash_table
*htab
;
1779 Elf_Internal_Shdr
*symtab_hdr
;
1780 struct elf_link_hash_entry
**sym_hashes
;
1781 bfd_vma
*local_got_offsets
;
1782 Elf_Internal_Rela
*rel
;
1783 Elf_Internal_Rela
*relend
;
1785 if (info
->relocatable
)
1788 htab
= elf64_x86_64_hash_table (info
);
1789 symtab_hdr
= &elf_tdata (input_bfd
)->symtab_hdr
;
1790 sym_hashes
= elf_sym_hashes (input_bfd
);
1791 local_got_offsets
= elf_local_got_offsets (input_bfd
);
1794 relend
= relocs
+ input_section
->reloc_count
;
1795 for (; rel
< relend
; rel
++)
1797 unsigned int r_type
;
1798 reloc_howto_type
*howto
;
1799 unsigned long r_symndx
;
1800 struct elf_link_hash_entry
*h
;
1801 Elf_Internal_Sym
*sym
;
1805 bfd_boolean unresolved_reloc
;
1806 bfd_reloc_status_type r
;
1809 r_type
= ELF64_R_TYPE (rel
->r_info
);
1810 if (r_type
== (int) R_X86_64_GNU_VTINHERIT
1811 || r_type
== (int) R_X86_64_GNU_VTENTRY
)
1814 if (r_type
>= R_X86_64_max
)
1816 bfd_set_error (bfd_error_bad_value
);
1820 howto
= x86_64_elf_howto_table
+ r_type
;
1821 r_symndx
= ELF64_R_SYM (rel
->r_info
);
1825 unresolved_reloc
= FALSE
;
1826 if (r_symndx
< symtab_hdr
->sh_info
)
1828 sym
= local_syms
+ r_symndx
;
1829 sec
= local_sections
[r_symndx
];
1831 relocation
= _bfd_elf_rela_local_sym (output_bfd
, sym
, &sec
, rel
);
1837 RELOC_FOR_GLOBAL_SYMBOL (info
, input_bfd
, input_section
, rel
,
1838 r_symndx
, symtab_hdr
, sym_hashes
,
1840 unresolved_reloc
, warned
);
1842 /* When generating a shared object, the relocations handled here are
1843 copied into the output file to be resolved at run time. */
1846 case R_X86_64_GOT32
:
1847 /* Relocation is to the entry for this symbol in the global
1849 case R_X86_64_GOTPCREL
:
1850 /* Use global offset table as symbol value. */
1851 if (htab
->sgot
== NULL
)
1858 off
= h
->got
.offset
;
1859 dyn
= htab
->elf
.dynamic_sections_created
;
1861 if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn
, info
->shared
, h
)
1863 && SYMBOL_REFERENCES_LOCAL (info
, h
))
1864 || (ELF_ST_VISIBILITY (h
->other
)
1865 && h
->root
.type
== bfd_link_hash_undefweak
))
1867 /* This is actually a static link, or it is a -Bsymbolic
1868 link and the symbol is defined locally, or the symbol
1869 was forced to be local because of a version file. We
1870 must initialize this entry in the global offset table.
1871 Since the offset must always be a multiple of 8, we
1872 use the least significant bit to record whether we
1873 have initialized it already.
1875 When doing a dynamic link, we create a .rela.got
1876 relocation entry to initialize the value. This is
1877 done in the finish_dynamic_symbol routine. */
1882 bfd_put_64 (output_bfd
, relocation
,
1883 htab
->sgot
->contents
+ off
);
1888 unresolved_reloc
= FALSE
;
1892 if (local_got_offsets
== NULL
)
1895 off
= local_got_offsets
[r_symndx
];
1897 /* The offset must always be a multiple of 8. We use
1898 the least significant bit to record whether we have
1899 already generated the necessary reloc. */
1904 bfd_put_64 (output_bfd
, relocation
,
1905 htab
->sgot
->contents
+ off
);
1910 Elf_Internal_Rela outrel
;
1913 /* We need to generate a R_X86_64_RELATIVE reloc
1914 for the dynamic linker. */
1919 outrel
.r_offset
= (htab
->sgot
->output_section
->vma
1920 + htab
->sgot
->output_offset
1922 outrel
.r_info
= ELF64_R_INFO (0, R_X86_64_RELATIVE
);
1923 outrel
.r_addend
= relocation
;
1925 loc
+= s
->reloc_count
++ * sizeof (Elf64_External_Rela
);
1926 bfd_elf64_swap_reloca_out (output_bfd
, &outrel
, loc
);
1929 local_got_offsets
[r_symndx
] |= 1;
1933 if (off
>= (bfd_vma
) -2)
1936 relocation
= htab
->sgot
->output_section
->vma
1937 + htab
->sgot
->output_offset
+ off
;
1938 if (r_type
!= R_X86_64_GOTPCREL
)
1939 relocation
-= htab
->sgotplt
->output_section
->vma
1940 - htab
->sgotplt
->output_offset
;
1944 case R_X86_64_PLT32
:
1945 /* Relocation is to the entry for this symbol in the
1946 procedure linkage table. */
1948 /* Resolve a PLT32 reloc against a local symbol directly,
1949 without using the procedure linkage table. */
1953 if (h
->plt
.offset
== (bfd_vma
) -1
1954 || htab
->splt
== NULL
)
1956 /* We didn't make a PLT entry for this symbol. This
1957 happens when statically linking PIC code, or when
1958 using -Bsymbolic. */
1962 relocation
= (htab
->splt
->output_section
->vma
1963 + htab
->splt
->output_offset
1965 unresolved_reloc
= FALSE
;
1972 && !SYMBOL_REFERENCES_LOCAL (info
, h
)
1973 && (input_section
->flags
& SEC_ALLOC
) != 0
1974 && (input_section
->flags
& SEC_READONLY
) != 0
1976 || r_type
!= R_X86_64_PC32
1977 || h
->type
!= STT_FUNC
1978 || ELF_ST_VISIBILITY (h
->other
) != STV_PROTECTED
1979 || !is_32bit_relative_branch (contents
,
1983 && r_type
== R_X86_64_PC32
1984 && h
->type
== STT_FUNC
1985 && ELF_ST_VISIBILITY (h
->other
) == STV_PROTECTED
)
1986 (*_bfd_error_handler
)
1987 (_("%B: relocation R_X86_64_PC32 against protected function `%s' can not be used when making a shared object"),
1988 input_bfd
, h
->root
.root
.string
);
1990 (*_bfd_error_handler
)
1991 (_("%B: relocation %s against `%s' can not be used when making a shared object; recompile with -fPIC"),
1992 input_bfd
, x86_64_elf_howto_table
[r_type
].name
,
1993 h
->root
.root
.string
);
1994 bfd_set_error (bfd_error_bad_value
);
2003 /* FIXME: The ABI says the linker should make sure the value is
2004 the same when it's zeroextended to 64 bit. */
2006 /* r_symndx will be zero only for relocs against symbols
2007 from removed linkonce sections, or sections discarded by
2010 || (input_section
->flags
& SEC_ALLOC
) == 0)
2015 || ELF_ST_VISIBILITY (h
->other
) == STV_DEFAULT
2016 || h
->root
.type
!= bfd_link_hash_undefweak
)
2017 && ((r_type
!= R_X86_64_PC8
2018 && r_type
!= R_X86_64_PC16
2019 && r_type
!= R_X86_64_PC32
)
2020 || !SYMBOL_CALLS_LOCAL (info
, h
)))
2021 || (ELIMINATE_COPY_RELOCS
2028 || h
->root
.type
== bfd_link_hash_undefweak
2029 || h
->root
.type
== bfd_link_hash_undefined
)))
2031 Elf_Internal_Rela outrel
;
2033 bfd_boolean skip
, relocate
;
2036 /* When generating a shared object, these relocations
2037 are copied into the output file to be resolved at run
2043 _bfd_elf_section_offset (output_bfd
, info
, input_section
,
2045 if (outrel
.r_offset
== (bfd_vma
) -1)
2047 else if (outrel
.r_offset
== (bfd_vma
) -2)
2048 skip
= TRUE
, relocate
= TRUE
;
2050 outrel
.r_offset
+= (input_section
->output_section
->vma
2051 + input_section
->output_offset
);
2054 memset (&outrel
, 0, sizeof outrel
);
2056 /* h->dynindx may be -1 if this symbol was marked to
2060 && (r_type
== R_X86_64_PC8
2061 || r_type
== R_X86_64_PC16
2062 || r_type
== R_X86_64_PC32
2065 || !h
->def_regular
))
2067 outrel
.r_info
= ELF64_R_INFO (h
->dynindx
, r_type
);
2068 outrel
.r_addend
= rel
->r_addend
;
2072 /* This symbol is local, or marked to become local. */
2073 if (r_type
== R_X86_64_64
)
2076 outrel
.r_info
= ELF64_R_INFO (0, R_X86_64_RELATIVE
);
2077 outrel
.r_addend
= relocation
+ rel
->r_addend
;
2083 if (bfd_is_abs_section (sec
))
2085 else if (sec
== NULL
|| sec
->owner
== NULL
)
2087 bfd_set_error (bfd_error_bad_value
);
2094 osec
= sec
->output_section
;
2095 sindx
= elf_section_data (osec
)->dynindx
;
2096 BFD_ASSERT (sindx
> 0);
2099 outrel
.r_info
= ELF64_R_INFO (sindx
, r_type
);
2100 outrel
.r_addend
= relocation
+ rel
->r_addend
;
2104 sreloc
= elf_section_data (input_section
)->sreloc
;
2108 loc
= sreloc
->contents
;
2109 loc
+= sreloc
->reloc_count
++ * sizeof (Elf64_External_Rela
);
2110 bfd_elf64_swap_reloca_out (output_bfd
, &outrel
, loc
);
2112 /* If this reloc is against an external symbol, we do
2113 not want to fiddle with the addend. Otherwise, we
2114 need to include the symbol value so that it becomes
2115 an addend for the dynamic reloc. */
2122 case R_X86_64_TLSGD
:
2123 case R_X86_64_GOTTPOFF
:
2124 r_type
= elf64_x86_64_tls_transition (info
, r_type
, h
== NULL
);
2125 tls_type
= GOT_UNKNOWN
;
2126 if (h
== NULL
&& local_got_offsets
)
2127 tls_type
= elf64_x86_64_local_got_tls_type (input_bfd
) [r_symndx
];
2130 tls_type
= elf64_x86_64_hash_entry (h
)->tls_type
;
2131 if (!info
->shared
&& h
->dynindx
== -1 && tls_type
== GOT_TLS_IE
)
2132 r_type
= R_X86_64_TPOFF32
;
2134 if (r_type
== R_X86_64_TLSGD
)
2136 if (tls_type
== GOT_TLS_IE
)
2137 r_type
= R_X86_64_GOTTPOFF
;
2140 if (r_type
== R_X86_64_TPOFF32
)
2142 BFD_ASSERT (! unresolved_reloc
);
2143 if (ELF64_R_TYPE (rel
->r_info
) == R_X86_64_TLSGD
)
2146 static unsigned char tlsgd
[8]
2147 = { 0x66, 0x48, 0x8d, 0x3d, 0x66, 0x66, 0x48, 0xe8 };
2149 /* GD->LE transition.
2150 .byte 0x66; leaq foo@tlsgd(%rip), %rdi
2151 .word 0x6666; rex64; call __tls_get_addr@plt
2154 leaq foo@tpoff(%rax), %rax */
2155 BFD_ASSERT (rel
->r_offset
>= 4);
2156 for (i
= 0; i
< 4; i
++)
2157 BFD_ASSERT (bfd_get_8 (input_bfd
,
2158 contents
+ rel
->r_offset
- 4 + i
)
2160 BFD_ASSERT (rel
->r_offset
+ 12 <= input_section
->size
);
2161 for (i
= 0; i
< 4; i
++)
2162 BFD_ASSERT (bfd_get_8 (input_bfd
,
2163 contents
+ rel
->r_offset
+ 4 + i
)
2165 BFD_ASSERT (rel
+ 1 < relend
);
2166 BFD_ASSERT (ELF64_R_TYPE (rel
[1].r_info
) == R_X86_64_PLT32
);
2167 memcpy (contents
+ rel
->r_offset
- 4,
2168 "\x64\x48\x8b\x04\x25\0\0\0\0\x48\x8d\x80\0\0\0",
2170 bfd_put_32 (output_bfd
, tpoff (info
, relocation
),
2171 contents
+ rel
->r_offset
+ 8);
2172 /* Skip R_X86_64_PLT32. */
2178 unsigned int val
, type
, reg
;
2180 /* IE->LE transition:
2181 Originally it can be one of:
2182 movq foo@gottpoff(%rip), %reg
2183 addq foo@gottpoff(%rip), %reg
2186 leaq foo(%reg), %reg
2188 BFD_ASSERT (rel
->r_offset
>= 3);
2189 val
= bfd_get_8 (input_bfd
, contents
+ rel
->r_offset
- 3);
2190 BFD_ASSERT (val
== 0x48 || val
== 0x4c);
2191 type
= bfd_get_8 (input_bfd
, contents
+ rel
->r_offset
- 2);
2192 BFD_ASSERT (type
== 0x8b || type
== 0x03);
2193 reg
= bfd_get_8 (input_bfd
, contents
+ rel
->r_offset
- 1);
2194 BFD_ASSERT ((reg
& 0xc7) == 5);
2196 BFD_ASSERT (rel
->r_offset
+ 4 <= input_section
->size
);
2201 bfd_put_8 (output_bfd
, 0x49,
2202 contents
+ rel
->r_offset
- 3);
2203 bfd_put_8 (output_bfd
, 0xc7,
2204 contents
+ rel
->r_offset
- 2);
2205 bfd_put_8 (output_bfd
, 0xc0 | reg
,
2206 contents
+ rel
->r_offset
- 1);
2210 /* addq -> addq - addressing with %rsp/%r12 is
2213 bfd_put_8 (output_bfd
, 0x49,
2214 contents
+ rel
->r_offset
- 3);
2215 bfd_put_8 (output_bfd
, 0x81,
2216 contents
+ rel
->r_offset
- 2);
2217 bfd_put_8 (output_bfd
, 0xc0 | reg
,
2218 contents
+ rel
->r_offset
- 1);
2224 bfd_put_8 (output_bfd
, 0x4d,
2225 contents
+ rel
->r_offset
- 3);
2226 bfd_put_8 (output_bfd
, 0x8d,
2227 contents
+ rel
->r_offset
- 2);
2228 bfd_put_8 (output_bfd
, 0x80 | reg
| (reg
<< 3),
2229 contents
+ rel
->r_offset
- 1);
2231 bfd_put_32 (output_bfd
, tpoff (info
, relocation
),
2232 contents
+ rel
->r_offset
);
2237 if (htab
->sgot
== NULL
)
2241 off
= h
->got
.offset
;
2244 if (local_got_offsets
== NULL
)
2247 off
= local_got_offsets
[r_symndx
];
2254 Elf_Internal_Rela outrel
;
2258 if (htab
->srelgot
== NULL
)
2261 outrel
.r_offset
= (htab
->sgot
->output_section
->vma
2262 + htab
->sgot
->output_offset
+ off
);
2264 indx
= h
&& h
->dynindx
!= -1 ? h
->dynindx
: 0;
2265 if (r_type
== R_X86_64_TLSGD
)
2266 dr_type
= R_X86_64_DTPMOD64
;
2268 dr_type
= R_X86_64_TPOFF64
;
2270 bfd_put_64 (output_bfd
, 0, htab
->sgot
->contents
+ off
);
2271 outrel
.r_addend
= 0;
2272 if (dr_type
== R_X86_64_TPOFF64
&& indx
== 0)
2273 outrel
.r_addend
= relocation
- dtpoff_base (info
);
2274 outrel
.r_info
= ELF64_R_INFO (indx
, dr_type
);
2276 loc
= htab
->srelgot
->contents
;
2277 loc
+= htab
->srelgot
->reloc_count
++ * sizeof (Elf64_External_Rela
);
2278 bfd_elf64_swap_reloca_out (output_bfd
, &outrel
, loc
);
2280 if (r_type
== R_X86_64_TLSGD
)
2284 BFD_ASSERT (! unresolved_reloc
);
2285 bfd_put_64 (output_bfd
,
2286 relocation
- dtpoff_base (info
),
2287 htab
->sgot
->contents
+ off
+ GOT_ENTRY_SIZE
);
2291 bfd_put_64 (output_bfd
, 0,
2292 htab
->sgot
->contents
+ off
+ GOT_ENTRY_SIZE
);
2293 outrel
.r_info
= ELF64_R_INFO (indx
,
2295 outrel
.r_offset
+= GOT_ENTRY_SIZE
;
2296 htab
->srelgot
->reloc_count
++;
2297 loc
+= sizeof (Elf64_External_Rela
);
2298 bfd_elf64_swap_reloca_out (output_bfd
, &outrel
, loc
);
2305 local_got_offsets
[r_symndx
] |= 1;
2308 if (off
>= (bfd_vma
) -2)
2310 if (r_type
== ELF64_R_TYPE (rel
->r_info
))
2312 relocation
= htab
->sgot
->output_section
->vma
2313 + htab
->sgot
->output_offset
+ off
;
2314 unresolved_reloc
= FALSE
;
2319 static unsigned char tlsgd
[8]
2320 = { 0x66, 0x48, 0x8d, 0x3d, 0x66, 0x66, 0x48, 0xe8 };
2322 /* GD->IE transition.
2323 .byte 0x66; leaq foo@tlsgd(%rip), %rdi
2324 .word 0x6666; rex64; call __tls_get_addr@plt
2327 addq foo@gottpoff(%rip), %rax */
2328 BFD_ASSERT (rel
->r_offset
>= 4);
2329 for (i
= 0; i
< 4; i
++)
2330 BFD_ASSERT (bfd_get_8 (input_bfd
,
2331 contents
+ rel
->r_offset
- 4 + i
)
2333 BFD_ASSERT (rel
->r_offset
+ 12 <= input_section
->size
);
2334 for (i
= 0; i
< 4; i
++)
2335 BFD_ASSERT (bfd_get_8 (input_bfd
,
2336 contents
+ rel
->r_offset
+ 4 + i
)
2338 BFD_ASSERT (rel
+ 1 < relend
);
2339 BFD_ASSERT (ELF64_R_TYPE (rel
[1].r_info
) == R_X86_64_PLT32
);
2340 memcpy (contents
+ rel
->r_offset
- 4,
2341 "\x64\x48\x8b\x04\x25\0\0\0\0\x48\x03\x05\0\0\0",
2344 relocation
= (htab
->sgot
->output_section
->vma
2345 + htab
->sgot
->output_offset
+ off
2347 - input_section
->output_section
->vma
2348 - input_section
->output_offset
2350 bfd_put_32 (output_bfd
, relocation
,
2351 contents
+ rel
->r_offset
+ 8);
2352 /* Skip R_X86_64_PLT32. */
2358 case R_X86_64_TLSLD
:
2361 /* LD->LE transition:
2363 leaq foo@tlsld(%rip), %rdi; call __tls_get_addr@plt.
2365 .word 0x6666; .byte 0x66; movl %fs:0, %rax. */
2366 BFD_ASSERT (rel
->r_offset
>= 3);
2367 BFD_ASSERT (bfd_get_8 (input_bfd
, contents
+ rel
->r_offset
- 3)
2369 BFD_ASSERT (bfd_get_8 (input_bfd
, contents
+ rel
->r_offset
- 2)
2371 BFD_ASSERT (bfd_get_8 (input_bfd
, contents
+ rel
->r_offset
- 1)
2373 BFD_ASSERT (rel
->r_offset
+ 9 <= input_section
->size
);
2374 BFD_ASSERT (bfd_get_8 (input_bfd
, contents
+ rel
->r_offset
+ 4)
2376 BFD_ASSERT (rel
+ 1 < relend
);
2377 BFD_ASSERT (ELF64_R_TYPE (rel
[1].r_info
) == R_X86_64_PLT32
);
2378 memcpy (contents
+ rel
->r_offset
- 3,
2379 "\x66\x66\x66\x64\x48\x8b\x04\x25\0\0\0", 12);
2380 /* Skip R_X86_64_PLT32. */
2385 if (htab
->sgot
== NULL
)
2388 off
= htab
->tls_ld_got
.offset
;
2393 Elf_Internal_Rela outrel
;
2396 if (htab
->srelgot
== NULL
)
2399 outrel
.r_offset
= (htab
->sgot
->output_section
->vma
2400 + htab
->sgot
->output_offset
+ off
);
2402 bfd_put_64 (output_bfd
, 0,
2403 htab
->sgot
->contents
+ off
);
2404 bfd_put_64 (output_bfd
, 0,
2405 htab
->sgot
->contents
+ off
+ GOT_ENTRY_SIZE
);
2406 outrel
.r_info
= ELF64_R_INFO (0, R_X86_64_DTPMOD64
);
2407 outrel
.r_addend
= 0;
2408 loc
= htab
->srelgot
->contents
;
2409 loc
+= htab
->srelgot
->reloc_count
++ * sizeof (Elf64_External_Rela
);
2410 bfd_elf64_swap_reloca_out (output_bfd
, &outrel
, loc
);
2411 htab
->tls_ld_got
.offset
|= 1;
2413 relocation
= htab
->sgot
->output_section
->vma
2414 + htab
->sgot
->output_offset
+ off
;
2415 unresolved_reloc
= FALSE
;
2418 case R_X86_64_DTPOFF32
:
2419 if (info
->shared
|| (input_section
->flags
& SEC_CODE
) == 0)
2420 relocation
-= dtpoff_base (info
);
2422 relocation
= tpoff (info
, relocation
);
2425 case R_X86_64_TPOFF32
:
2426 BFD_ASSERT (! info
->shared
);
2427 relocation
= tpoff (info
, relocation
);
2434 /* Dynamic relocs are not propagated for SEC_DEBUGGING sections
2435 because such sections are not SEC_ALLOC and thus ld.so will
2436 not process them. */
2437 if (unresolved_reloc
2438 && !((input_section
->flags
& SEC_DEBUGGING
) != 0
2440 (*_bfd_error_handler
)
2441 (_("%B(%A+0x%lx): unresolvable relocation against symbol `%s'"),
2444 (long) rel
->r_offset
,
2445 h
->root
.root
.string
);
2447 r
= _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
2448 contents
, rel
->r_offset
,
2449 relocation
, rel
->r_addend
);
2451 if (r
!= bfd_reloc_ok
)
2456 name
= h
->root
.root
.string
;
2459 name
= bfd_elf_string_from_elf_section (input_bfd
,
2460 symtab_hdr
->sh_link
,
2465 name
= bfd_section_name (input_bfd
, sec
);
2468 if (r
== bfd_reloc_overflow
)
2471 && h
->root
.type
== bfd_link_hash_undefweak
2472 && howto
->pc_relative
)
2473 /* Ignore reloc overflow on branches to undefweak syms. */
2476 if (! ((*info
->callbacks
->reloc_overflow
)
2477 (info
, (h
? &h
->root
: NULL
), name
, howto
->name
,
2478 (bfd_vma
) 0, input_bfd
, input_section
,
2484 (*_bfd_error_handler
)
2485 (_("%B(%A+0x%lx): reloc against `%s': error %d"),
2486 input_bfd
, input_section
,
2487 (long) rel
->r_offset
, name
, (int) r
);
2496 /* Finish up dynamic symbol handling. We set the contents of various
2497 dynamic sections here. */
2500 elf64_x86_64_finish_dynamic_symbol (bfd
*output_bfd
,
2501 struct bfd_link_info
*info
,
2502 struct elf_link_hash_entry
*h
,
2503 Elf_Internal_Sym
*sym
)
2505 struct elf64_x86_64_link_hash_table
*htab
;
2507 htab
= elf64_x86_64_hash_table (info
);
2509 if (h
->plt
.offset
!= (bfd_vma
) -1)
2513 Elf_Internal_Rela rela
;
2516 /* This symbol has an entry in the procedure linkage table. Set
2518 if (h
->dynindx
== -1
2519 || htab
->splt
== NULL
2520 || htab
->sgotplt
== NULL
2521 || htab
->srelplt
== NULL
)
2524 /* Get the index in the procedure linkage table which
2525 corresponds to this symbol. This is the index of this symbol
2526 in all the symbols for which we are making plt entries. The
2527 first entry in the procedure linkage table is reserved. */
2528 plt_index
= h
->plt
.offset
/ PLT_ENTRY_SIZE
- 1;
2530 /* Get the offset into the .got table of the entry that
2531 corresponds to this function. Each .got entry is GOT_ENTRY_SIZE
2532 bytes. The first three are reserved for the dynamic linker. */
2533 got_offset
= (plt_index
+ 3) * GOT_ENTRY_SIZE
;
2535 /* Fill in the entry in the procedure linkage table. */
2536 memcpy (htab
->splt
->contents
+ h
->plt
.offset
, elf64_x86_64_plt_entry
,
2539 /* Insert the relocation positions of the plt section. The magic
2540 numbers at the end of the statements are the positions of the
2541 relocations in the plt section. */
2542 /* Put offset for jmp *name@GOTPCREL(%rip), since the
2543 instruction uses 6 bytes, subtract this value. */
2544 bfd_put_32 (output_bfd
,
2545 (htab
->sgotplt
->output_section
->vma
2546 + htab
->sgotplt
->output_offset
2548 - htab
->splt
->output_section
->vma
2549 - htab
->splt
->output_offset
2552 htab
->splt
->contents
+ h
->plt
.offset
+ 2);
2553 /* Put relocation index. */
2554 bfd_put_32 (output_bfd
, plt_index
,
2555 htab
->splt
->contents
+ h
->plt
.offset
+ 7);
2556 /* Put offset for jmp .PLT0. */
2557 bfd_put_32 (output_bfd
, - (h
->plt
.offset
+ PLT_ENTRY_SIZE
),
2558 htab
->splt
->contents
+ h
->plt
.offset
+ 12);
2560 /* Fill in the entry in the global offset table, initially this
2561 points to the pushq instruction in the PLT which is at offset 6. */
2562 bfd_put_64 (output_bfd
, (htab
->splt
->output_section
->vma
2563 + htab
->splt
->output_offset
2564 + h
->plt
.offset
+ 6),
2565 htab
->sgotplt
->contents
+ got_offset
);
2567 /* Fill in the entry in the .rela.plt section. */
2568 rela
.r_offset
= (htab
->sgotplt
->output_section
->vma
2569 + htab
->sgotplt
->output_offset
2571 rela
.r_info
= ELF64_R_INFO (h
->dynindx
, R_X86_64_JUMP_SLOT
);
2573 loc
= htab
->srelplt
->contents
+ plt_index
* sizeof (Elf64_External_Rela
);
2574 bfd_elf64_swap_reloca_out (output_bfd
, &rela
, loc
);
2576 if (!h
->def_regular
)
2578 /* Mark the symbol as undefined, rather than as defined in
2579 the .plt section. Leave the value if there were any
2580 relocations where pointer equality matters (this is a clue
2581 for the dynamic linker, to make function pointer
2582 comparisons work between an application and shared
2583 library), otherwise set it to zero. If a function is only
2584 called from a binary, there is no need to slow down
2585 shared libraries because of that. */
2586 sym
->st_shndx
= SHN_UNDEF
;
2587 if (!h
->pointer_equality_needed
)
2592 if (h
->got
.offset
!= (bfd_vma
) -1
2593 && elf64_x86_64_hash_entry (h
)->tls_type
!= GOT_TLS_GD
2594 && elf64_x86_64_hash_entry (h
)->tls_type
!= GOT_TLS_IE
)
2596 Elf_Internal_Rela rela
;
2599 /* This symbol has an entry in the global offset table. Set it
2601 if (htab
->sgot
== NULL
|| htab
->srelgot
== NULL
)
2604 rela
.r_offset
= (htab
->sgot
->output_section
->vma
2605 + htab
->sgot
->output_offset
2606 + (h
->got
.offset
&~ (bfd_vma
) 1));
2608 /* If this is a static link, or it is a -Bsymbolic link and the
2609 symbol is defined locally or was forced to be local because
2610 of a version file, we just want to emit a RELATIVE reloc.
2611 The entry in the global offset table will already have been
2612 initialized in the relocate_section function. */
2614 && SYMBOL_REFERENCES_LOCAL (info
, h
))
2616 BFD_ASSERT((h
->got
.offset
& 1) != 0);
2617 rela
.r_info
= ELF64_R_INFO (0, R_X86_64_RELATIVE
);
2618 rela
.r_addend
= (h
->root
.u
.def
.value
2619 + h
->root
.u
.def
.section
->output_section
->vma
2620 + h
->root
.u
.def
.section
->output_offset
);
2624 BFD_ASSERT((h
->got
.offset
& 1) == 0);
2625 bfd_put_64 (output_bfd
, (bfd_vma
) 0,
2626 htab
->sgot
->contents
+ h
->got
.offset
);
2627 rela
.r_info
= ELF64_R_INFO (h
->dynindx
, R_X86_64_GLOB_DAT
);
2631 loc
= htab
->srelgot
->contents
;
2632 loc
+= htab
->srelgot
->reloc_count
++ * sizeof (Elf64_External_Rela
);
2633 bfd_elf64_swap_reloca_out (output_bfd
, &rela
, loc
);
2638 Elf_Internal_Rela rela
;
2641 /* This symbol needs a copy reloc. Set it up. */
2643 if (h
->dynindx
== -1
2644 || (h
->root
.type
!= bfd_link_hash_defined
2645 && h
->root
.type
!= bfd_link_hash_defweak
)
2646 || htab
->srelbss
== NULL
)
2649 rela
.r_offset
= (h
->root
.u
.def
.value
2650 + h
->root
.u
.def
.section
->output_section
->vma
2651 + h
->root
.u
.def
.section
->output_offset
);
2652 rela
.r_info
= ELF64_R_INFO (h
->dynindx
, R_X86_64_COPY
);
2654 loc
= htab
->srelbss
->contents
;
2655 loc
+= htab
->srelbss
->reloc_count
++ * sizeof (Elf64_External_Rela
);
2656 bfd_elf64_swap_reloca_out (output_bfd
, &rela
, loc
);
2659 /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */
2660 if (strcmp (h
->root
.root
.string
, "_DYNAMIC") == 0
2661 || strcmp (h
->root
.root
.string
, "_GLOBAL_OFFSET_TABLE_") == 0)
2662 sym
->st_shndx
= SHN_ABS
;
2667 /* Used to decide how to sort relocs in an optimal manner for the
2668 dynamic linker, before writing them out. */
2670 static enum elf_reloc_type_class
2671 elf64_x86_64_reloc_type_class (const Elf_Internal_Rela
*rela
)
2673 switch ((int) ELF64_R_TYPE (rela
->r_info
))
2675 case R_X86_64_RELATIVE
:
2676 return reloc_class_relative
;
2677 case R_X86_64_JUMP_SLOT
:
2678 return reloc_class_plt
;
2680 return reloc_class_copy
;
2682 return reloc_class_normal
;
2686 /* Finish up the dynamic sections. */
2689 elf64_x86_64_finish_dynamic_sections (bfd
*output_bfd
, struct bfd_link_info
*info
)
2691 struct elf64_x86_64_link_hash_table
*htab
;
2695 htab
= elf64_x86_64_hash_table (info
);
2696 dynobj
= htab
->elf
.dynobj
;
2697 sdyn
= bfd_get_section_by_name (dynobj
, ".dynamic");
2699 if (htab
->elf
.dynamic_sections_created
)
2701 Elf64_External_Dyn
*dyncon
, *dynconend
;
2703 if (sdyn
== NULL
|| htab
->sgot
== NULL
)
2706 dyncon
= (Elf64_External_Dyn
*) sdyn
->contents
;
2707 dynconend
= (Elf64_External_Dyn
*) (sdyn
->contents
+ sdyn
->size
);
2708 for (; dyncon
< dynconend
; dyncon
++)
2710 Elf_Internal_Dyn dyn
;
2713 bfd_elf64_swap_dyn_in (dynobj
, dyncon
, &dyn
);
2722 dyn
.d_un
.d_ptr
= s
->output_section
->vma
+ s
->output_offset
;
2726 dyn
.d_un
.d_ptr
= htab
->srelplt
->output_section
->vma
;
2730 s
= htab
->srelplt
->output_section
;
2731 dyn
.d_un
.d_val
= s
->size
;
2735 /* The procedure linkage table relocs (DT_JMPREL) should
2736 not be included in the overall relocs (DT_RELA).
2737 Therefore, we override the DT_RELASZ entry here to
2738 make it not include the JMPREL relocs. Since the
2739 linker script arranges for .rela.plt to follow all
2740 other relocation sections, we don't have to worry
2741 about changing the DT_RELA entry. */
2742 if (htab
->srelplt
!= NULL
)
2744 s
= htab
->srelplt
->output_section
;
2745 dyn
.d_un
.d_val
-= s
->size
;
2750 bfd_elf64_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
2753 /* Fill in the special first entry in the procedure linkage table. */
2754 if (htab
->splt
&& htab
->splt
->size
> 0)
2756 /* Fill in the first entry in the procedure linkage table. */
2757 memcpy (htab
->splt
->contents
, elf64_x86_64_plt0_entry
,
2759 /* Add offset for pushq GOT+8(%rip), since the instruction
2760 uses 6 bytes subtract this value. */
2761 bfd_put_32 (output_bfd
,
2762 (htab
->sgotplt
->output_section
->vma
2763 + htab
->sgotplt
->output_offset
2765 - htab
->splt
->output_section
->vma
2766 - htab
->splt
->output_offset
2768 htab
->splt
->contents
+ 2);
2769 /* Add offset for jmp *GOT+16(%rip). The 12 is the offset to
2770 the end of the instruction. */
2771 bfd_put_32 (output_bfd
,
2772 (htab
->sgotplt
->output_section
->vma
2773 + htab
->sgotplt
->output_offset
2775 - htab
->splt
->output_section
->vma
2776 - htab
->splt
->output_offset
2778 htab
->splt
->contents
+ 8);
2780 elf_section_data (htab
->splt
->output_section
)->this_hdr
.sh_entsize
=
2787 /* Fill in the first three entries in the global offset table. */
2788 if (htab
->sgotplt
->size
> 0)
2790 /* Set the first entry in the global offset table to the address of
2791 the dynamic section. */
2793 bfd_put_64 (output_bfd
, (bfd_vma
) 0, htab
->sgotplt
->contents
);
2795 bfd_put_64 (output_bfd
,
2796 sdyn
->output_section
->vma
+ sdyn
->output_offset
,
2797 htab
->sgotplt
->contents
);
2798 /* Write GOT[1] and GOT[2], needed for the dynamic linker. */
2799 bfd_put_64 (output_bfd
, (bfd_vma
) 0, htab
->sgotplt
->contents
+ GOT_ENTRY_SIZE
);
2800 bfd_put_64 (output_bfd
, (bfd_vma
) 0, htab
->sgotplt
->contents
+ GOT_ENTRY_SIZE
*2);
2803 elf_section_data (htab
->sgotplt
->output_section
)->this_hdr
.sh_entsize
=
2807 if (htab
->sgot
&& htab
->sgot
->size
> 0)
2808 elf_section_data (htab
->sgot
->output_section
)->this_hdr
.sh_entsize
2814 /* Return address for Ith PLT stub in section PLT, for relocation REL
2815 or (bfd_vma) -1 if it should not be included. */
2818 elf64_x86_64_plt_sym_val (bfd_vma i
, const asection
*plt
,
2819 const arelent
*rel ATTRIBUTE_UNUSED
)
2821 return plt
->vma
+ (i
+ 1) * PLT_ENTRY_SIZE
;
2824 /* Handle an x86-64 specific section when reading an object file. This
2825 is called when elfcode.h finds a section with an unknown type. */
2828 elf64_x86_64_section_from_shdr (bfd
*abfd
,
2829 Elf_Internal_Shdr
*hdr
,
2833 if (hdr
->sh_type
!= SHT_X86_64_UNWIND
)
2836 if (! _bfd_elf_make_section_from_shdr (abfd
, hdr
, name
, shindex
))
2842 #define TARGET_LITTLE_SYM bfd_elf64_x86_64_vec
2843 #define TARGET_LITTLE_NAME "elf64-x86-64"
2844 #define ELF_ARCH bfd_arch_i386
2845 #define ELF_MACHINE_CODE EM_X86_64
2846 #define ELF_MAXPAGESIZE 0x100000
2848 #define elf_backend_can_gc_sections 1
2849 #define elf_backend_can_refcount 1
2850 #define elf_backend_want_got_plt 1
2851 #define elf_backend_plt_readonly 1
2852 #define elf_backend_want_plt_sym 0
2853 #define elf_backend_got_header_size (GOT_ENTRY_SIZE*3)
2854 #define elf_backend_rela_normal 1
2856 #define elf_info_to_howto elf64_x86_64_info_to_howto
2858 #define bfd_elf64_bfd_link_hash_table_create \
2859 elf64_x86_64_link_hash_table_create
2860 #define bfd_elf64_bfd_reloc_type_lookup elf64_x86_64_reloc_type_lookup
2862 #define elf_backend_adjust_dynamic_symbol elf64_x86_64_adjust_dynamic_symbol
2863 #define elf_backend_check_relocs elf64_x86_64_check_relocs
2864 #define elf_backend_copy_indirect_symbol elf64_x86_64_copy_indirect_symbol
2865 #define elf_backend_create_dynamic_sections elf64_x86_64_create_dynamic_sections
2866 #define elf_backend_finish_dynamic_sections elf64_x86_64_finish_dynamic_sections
2867 #define elf_backend_finish_dynamic_symbol elf64_x86_64_finish_dynamic_symbol
2868 #define elf_backend_gc_mark_hook elf64_x86_64_gc_mark_hook
2869 #define elf_backend_gc_sweep_hook elf64_x86_64_gc_sweep_hook
2870 #define elf_backend_grok_prstatus elf64_x86_64_grok_prstatus
2871 #define elf_backend_grok_psinfo elf64_x86_64_grok_psinfo
2872 #define elf_backend_reloc_type_class elf64_x86_64_reloc_type_class
2873 #define elf_backend_relocate_section elf64_x86_64_relocate_section
2874 #define elf_backend_size_dynamic_sections elf64_x86_64_size_dynamic_sections
2875 #define elf_backend_plt_sym_val elf64_x86_64_plt_sym_val
2876 #define elf_backend_object_p elf64_x86_64_elf_object_p
2877 #define bfd_elf64_mkobject elf64_x86_64_mkobject
2879 #define elf_backend_section_from_shdr \
2880 elf64_x86_64_section_from_shdr
2882 #include "elf64-target.h"