1 /* X86-64 specific support for 64-bit ELF
2 Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
3 Contributed by Jan Hubicka <jh@suse.cz>.
5 This file is part of BFD, the Binary File Descriptor library.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
27 #include "elf/x86-64.h"
29 /* We use only the RELA entries. */
32 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value. */
33 #define MINUS_ONE (~ (bfd_vma) 0)
35 /* The relocation "howto" table. Order of fields:
36 type, size, bitsize, pc_relative, complain_on_overflow,
37 special_function, name, partial_inplace, src_mask, dst_pack, pcrel_offset. */
38 static reloc_howto_type x86_64_elf_howto_table[] =
40 HOWTO(R_X86_64_NONE, 0, 0, 0, false, 0, complain_overflow_dont,
41 bfd_elf_generic_reloc, "R_X86_64_NONE", false, 0x00000000, 0x00000000,
43 HOWTO(R_X86_64_64, 0, 4, 64, false, 0, complain_overflow_bitfield,
44 bfd_elf_generic_reloc, "R_X86_64_64", false, MINUS_ONE, MINUS_ONE,
46 HOWTO(R_X86_64_PC32, 0, 4, 32, true, 0, complain_overflow_signed,
47 bfd_elf_generic_reloc, "R_X86_64_PC32", false, 0xffffffff, 0xffffffff,
49 HOWTO(R_X86_64_GOT32, 0, 4, 32, false, 0, complain_overflow_signed,
50 bfd_elf_generic_reloc, "R_X86_64_GOT32", false, 0xffffffff, 0xffffffff,
52 HOWTO(R_X86_64_PLT32, 0, 4, 32, true, 0, complain_overflow_signed,
53 bfd_elf_generic_reloc, "R_X86_64_PLT32", false, 0xffffffff, 0xffffffff,
55 HOWTO(R_X86_64_COPY, 0, 4, 32, false, 0, complain_overflow_bitfield,
56 bfd_elf_generic_reloc, "R_X86_64_COPY", false, 0xffffffff, 0xffffffff,
58 HOWTO(R_X86_64_GLOB_DAT, 0, 4, 64, false, 0, complain_overflow_bitfield,
59 bfd_elf_generic_reloc, "R_X86_64_GLOB_DAT", false, MINUS_ONE,
61 HOWTO(R_X86_64_JUMP_SLOT, 0, 4, 64, false, 0, complain_overflow_bitfield,
62 bfd_elf_generic_reloc, "R_X86_64_JUMP_SLOT", false, MINUS_ONE,
64 HOWTO(R_X86_64_RELATIVE, 0, 4, 64, false, 0, complain_overflow_bitfield,
65 bfd_elf_generic_reloc, "R_X86_64_RELATIVE", false, MINUS_ONE,
67 HOWTO(R_X86_64_GOTPCREL, 0, 4, 32, true,0 , complain_overflow_signed,
68 bfd_elf_generic_reloc, "R_X86_64_GOTPCREL", false, 0xffffffff,
70 HOWTO(R_X86_64_32, 0, 4, 32, false, 0, complain_overflow_unsigned,
71 bfd_elf_generic_reloc, "R_X86_64_32", false, 0xffffffff, 0xffffffff,
73 HOWTO(R_X86_64_32S, 0, 4, 32, false, 0, complain_overflow_signed,
74 bfd_elf_generic_reloc, "R_X86_64_32S", false, 0xffffffff, 0xffffffff,
76 HOWTO(R_X86_64_16, 0, 1, 16, false, 0, complain_overflow_bitfield,
77 bfd_elf_generic_reloc, "R_X86_64_16", false, 0xffff, 0xffff, false),
78 HOWTO(R_X86_64_PC16,0, 1, 16, true, 0, complain_overflow_bitfield,
79 bfd_elf_generic_reloc, "R_X86_64_PC16", false, 0xffff, 0xffff, true),
80 HOWTO(R_X86_64_8, 0, 0, 8, false, 0, complain_overflow_signed,
81 bfd_elf_generic_reloc, "R_X86_64_8", false, 0xff, 0xff, false),
82 HOWTO(R_X86_64_PC8, 0, 0, 8, true, 0, complain_overflow_signed,
83 bfd_elf_generic_reloc, "R_X86_64_PC8", false, 0xff, 0xff, true),
85 /* GNU extension to record C++ vtable hierarchy. */
86 HOWTO (R_X86_64_GNU_VTINHERIT, 0, 4, 0, false, 0, complain_overflow_dont,
87 NULL, "R_X86_64_GNU_VTINHERIT", false, 0, 0, false),
89 /* GNU extension to record C++ vtable member usage. */
90 HOWTO (R_X86_64_GNU_VTENTRY, 0, 4, 0, false, 0, complain_overflow_dont,
91 _bfd_elf_rel_vtable_reloc_fn, "R_X86_64_GNU_VTENTRY", false, 0, 0,
95 /* Map BFD relocs to the x86_64 elf relocs. */
98 bfd_reloc_code_real_type bfd_reloc_val;
99 unsigned char elf_reloc_val;
102 static const struct elf_reloc_map x86_64_reloc_map[] =
104 { BFD_RELOC_NONE, R_X86_64_NONE, },
105 { BFD_RELOC_64, R_X86_64_64, },
106 { BFD_RELOC_32_PCREL, R_X86_64_PC32, },
107 { BFD_RELOC_X86_64_GOT32, R_X86_64_GOT32,},
108 { BFD_RELOC_X86_64_PLT32, R_X86_64_PLT32,},
109 { BFD_RELOC_X86_64_COPY, R_X86_64_COPY, },
110 { BFD_RELOC_X86_64_GLOB_DAT, R_X86_64_GLOB_DAT, },
111 { BFD_RELOC_X86_64_JUMP_SLOT, R_X86_64_JUMP_SLOT, },
112 { BFD_RELOC_X86_64_RELATIVE, R_X86_64_RELATIVE, },
113 { BFD_RELOC_X86_64_GOTPCREL, R_X86_64_GOTPCREL, },
114 { BFD_RELOC_32, R_X86_64_32, },
115 { BFD_RELOC_X86_64_32S, R_X86_64_32S, },
116 { BFD_RELOC_16, R_X86_64_16, },
117 { BFD_RELOC_16_PCREL, R_X86_64_PC16, },
118 { BFD_RELOC_8, R_X86_64_8, },
119 { BFD_RELOC_8_PCREL, R_X86_64_PC8, },
120 { BFD_RELOC_VTABLE_INHERIT, R_X86_64_GNU_VTINHERIT, },
121 { BFD_RELOC_VTABLE_ENTRY, R_X86_64_GNU_VTENTRY, },
124 static reloc_howto_type *elf64_x86_64_reloc_type_lookup
125 PARAMS ((bfd *, bfd_reloc_code_real_type));
126 static void elf64_x86_64_info_to_howto
127 PARAMS ((bfd *, arelent *, Elf64_Internal_Rela *));
128 static boolean elf64_x86_64_grok_prstatus
129 PARAMS ((bfd *, Elf_Internal_Note *));
130 static boolean elf64_x86_64_grok_psinfo
131 PARAMS ((bfd *, Elf_Internal_Note *));
132 static struct bfd_link_hash_table *elf64_x86_64_link_hash_table_create
134 static boolean elf64_x86_64_elf_object_p PARAMS ((bfd *abfd));
135 static boolean create_got_section
136 PARAMS((bfd *, struct bfd_link_info *));
137 static boolean elf64_x86_64_create_dynamic_sections
138 PARAMS((bfd *, struct bfd_link_info *));
139 static void elf64_x86_64_copy_indirect_symbol
140 PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *));
141 static boolean elf64_x86_64_check_relocs
142 PARAMS ((bfd *, struct bfd_link_info *, asection *sec,
143 const Elf_Internal_Rela *));
144 static asection *elf64_x86_64_gc_mark_hook
145 PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *,
146 struct elf_link_hash_entry *, Elf_Internal_Sym *));
148 static boolean elf64_x86_64_gc_sweep_hook
149 PARAMS ((bfd *, struct bfd_link_info *, asection *,
150 const Elf_Internal_Rela *));
152 static struct bfd_hash_entry *link_hash_newfunc
153 PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
154 static boolean elf64_x86_64_adjust_dynamic_symbol
155 PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
157 static boolean allocate_dynrelocs
158 PARAMS ((struct elf_link_hash_entry *, PTR));
159 static boolean readonly_dynrelocs
160 PARAMS ((struct elf_link_hash_entry *, PTR));
161 static boolean elf64_x86_64_size_dynamic_sections
162 PARAMS ((bfd *, struct bfd_link_info *));
163 static boolean elf64_x86_64_relocate_section
164 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
165 Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
166 static boolean elf64_x86_64_finish_dynamic_symbol
167 PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
168 Elf_Internal_Sym *sym));
169 static boolean elf64_x86_64_finish_dynamic_sections
170 PARAMS ((bfd *, struct bfd_link_info *));
171 static enum elf_reloc_type_class elf64_x86_64_reloc_type_class
172 PARAMS ((const Elf_Internal_Rela *));
174 /* Given a BFD reloc type, return a HOWTO structure. */
175 static reloc_howto_type *
176 elf64_x86_64_reloc_type_lookup (abfd, code)
177 bfd *abfd ATTRIBUTE_UNUSED;
178 bfd_reloc_code_real_type code;
181 for (i = 0; i < sizeof (x86_64_reloc_map) / sizeof (struct elf_reloc_map);
184 if (x86_64_reloc_map[i].bfd_reloc_val == code)
185 return &x86_64_elf_howto_table[i];
190 /* Given an x86_64 ELF reloc type, fill in an arelent structure. */
193 elf64_x86_64_info_to_howto (abfd, cache_ptr, dst)
194 bfd *abfd ATTRIBUTE_UNUSED;
196 Elf64_Internal_Rela *dst;
200 r_type = ELF64_R_TYPE (dst->r_info);
201 if (r_type < (unsigned int) R_X86_64_GNU_VTINHERIT)
203 BFD_ASSERT (r_type <= (unsigned int) R_X86_64_PC8);
208 BFD_ASSERT (r_type < (unsigned int) R_X86_64_max);
209 i = r_type - ((unsigned int) R_X86_64_GNU_VTINHERIT - R_X86_64_PC8 - 1);
211 cache_ptr->howto = &x86_64_elf_howto_table[i];
212 BFD_ASSERT (r_type == cache_ptr->howto->type);
215 /* Support for core dump NOTE sections. */
217 elf64_x86_64_grok_prstatus (abfd, note)
219 Elf_Internal_Note *note;
224 switch (note->descsz)
229 case 336: /* sizeof(istruct elf_prstatus) on Linux/x86_64 */
231 elf_tdata (abfd)->core_signal
232 = bfd_get_16 (abfd, note->descdata + 12);
235 elf_tdata (abfd)->core_pid
236 = bfd_get_32 (abfd, note->descdata + 32);
245 /* Make a ".reg/999" section. */
246 return _bfd_elfcore_make_pseudosection (abfd, ".reg",
247 raw_size, note->descpos + offset);
251 elf64_x86_64_grok_psinfo (abfd, note)
253 Elf_Internal_Note *note;
255 switch (note->descsz)
260 case 136: /* sizeof(struct elf_prpsinfo) on Linux/x86_64 */
261 elf_tdata (abfd)->core_program
262 = _bfd_elfcore_strndup (abfd, note->descdata + 40, 16);
263 elf_tdata (abfd)->core_command
264 = _bfd_elfcore_strndup (abfd, note->descdata + 56, 80);
267 /* Note that for some reason, a spurious space is tacked
268 onto the end of the args in some (at least one anyway)
269 implementations, so strip it off if it exists. */
272 char *command = elf_tdata (abfd)->core_command;
273 int n = strlen (command);
275 if (0 < n && command[n - 1] == ' ')
276 command[n - 1] = '\0';
282 /* Functions for the x86-64 ELF linker. */
284 /* The name of the dynamic interpreter. This is put in the .interp
287 #define ELF_DYNAMIC_INTERPRETER "/lib/ld64.so.1"
289 /* The size in bytes of an entry in the global offset table. */
291 #define GOT_ENTRY_SIZE 8
293 /* The size in bytes of an entry in the procedure linkage table. */
295 #define PLT_ENTRY_SIZE 16
297 /* The first entry in a procedure linkage table looks like this. See the
298 SVR4 ABI i386 supplement and the x86-64 ABI to see how this works. */
300 static const bfd_byte elf64_x86_64_plt0_entry[PLT_ENTRY_SIZE] =
302 0xff, 0x35, 8, 0, 0, 0, /* pushq GOT+8(%rip) */
303 0xff, 0x25, 16, 0, 0, 0, /* jmpq *GOT+16(%rip) */
304 0x90, 0x90, 0x90, 0x90 /* pad out to 16 bytes with nops. */
307 /* Subsequent entries in a procedure linkage table look like this. */
309 static const bfd_byte elf64_x86_64_plt_entry[PLT_ENTRY_SIZE] =
311 0xff, 0x25, /* jmpq *name@GOTPC(%rip) */
312 0, 0, 0, 0, /* replaced with offset to this symbol in .got. */
313 0x68, /* pushq immediate */
314 0, 0, 0, 0, /* replaced with index into relocation table. */
315 0xe9, /* jmp relative */
316 0, 0, 0, 0 /* replaced with offset to start of .plt0. */
319 /* The x86-64 linker needs to keep track of the number of relocs that
320 it decides to copy as dynamic relocs in check_relocs for each symbol.
321 This is so that it can later discard them if they are found to be
322 unnecessary. We store the information in a field extending the
323 regular ELF linker hash table. */
325 struct elf64_x86_64_dyn_relocs
328 struct elf64_x86_64_dyn_relocs *next;
330 /* The input section of the reloc. */
333 /* Total number of relocs copied for the input section. */
336 /* Number of pc-relative relocs copied for the input section. */
337 bfd_size_type pc_count;
340 /* x86-64 ELF linker hash entry. */
342 struct elf64_x86_64_link_hash_entry
344 struct elf_link_hash_entry elf;
346 /* Track dynamic relocs copied for this symbol. */
347 struct elf64_x86_64_dyn_relocs *dyn_relocs;
350 /* x86-64 ELF linker hash table. */
352 struct elf64_x86_64_link_hash_table
354 struct elf_link_hash_table elf;
356 /* Short-cuts to get to dynamic linker sections. */
365 /* Small local sym to section mapping cache. */
366 struct sym_sec_cache sym_sec;
369 /* Get the x86-64 ELF linker hash table from a link_info structure. */
371 #define elf64_x86_64_hash_table(p) \
372 ((struct elf64_x86_64_link_hash_table *) ((p)->hash))
374 /* Create an entry in an x86-64 ELF linker hash table. */
376 static struct bfd_hash_entry *
377 link_hash_newfunc (entry, table, string)
378 struct bfd_hash_entry *entry;
379 struct bfd_hash_table *table;
382 /* Allocate the structure if it has not already been allocated by a
386 entry = bfd_hash_allocate (table,
387 sizeof (struct elf64_x86_64_link_hash_entry));
392 /* Call the allocation method of the superclass. */
393 entry = _bfd_elf_link_hash_newfunc (entry, table, string);
396 struct elf64_x86_64_link_hash_entry *eh;
398 eh = (struct elf64_x86_64_link_hash_entry *) entry;
399 eh->dyn_relocs = NULL;
405 /* Create an X86-64 ELF linker hash table. */
407 static struct bfd_link_hash_table *
408 elf64_x86_64_link_hash_table_create (abfd)
411 struct elf64_x86_64_link_hash_table *ret;
412 bfd_size_type amt = sizeof (struct elf64_x86_64_link_hash_table);
414 ret = (struct elf64_x86_64_link_hash_table *) bfd_malloc (amt);
418 if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc))
431 ret->sym_sec.abfd = NULL;
433 return &ret->elf.root;
436 /* Create .got, .gotplt, and .rela.got sections in DYNOBJ, and set up
437 shortcuts to them in our hash table. */
440 create_got_section (dynobj, info)
442 struct bfd_link_info *info;
444 struct elf64_x86_64_link_hash_table *htab;
446 if (! _bfd_elf_create_got_section (dynobj, info))
449 htab = elf64_x86_64_hash_table (info);
450 htab->sgot = bfd_get_section_by_name (dynobj, ".got");
451 htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
452 if (!htab->sgot || !htab->sgotplt)
455 htab->srelgot = bfd_make_section (dynobj, ".rela.got");
456 if (htab->srelgot == NULL
457 || ! bfd_set_section_flags (dynobj, htab->srelgot,
458 (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
459 | SEC_IN_MEMORY | SEC_LINKER_CREATED
461 || ! bfd_set_section_alignment (dynobj, htab->srelgot, 3))
466 /* Create .plt, .rela.plt, .got, .got.plt, .rela.got, .dynbss, and
467 .rela.bss sections in DYNOBJ, and set up shortcuts to them in our
471 elf64_x86_64_create_dynamic_sections (dynobj, info)
473 struct bfd_link_info *info;
475 struct elf64_x86_64_link_hash_table *htab;
477 htab = elf64_x86_64_hash_table (info);
478 if (!htab->sgot && !create_got_section (dynobj, info))
481 if (!_bfd_elf_create_dynamic_sections (dynobj, info))
484 htab->splt = bfd_get_section_by_name (dynobj, ".plt");
485 htab->srelplt = bfd_get_section_by_name (dynobj, ".rela.plt");
486 htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss");
488 htab->srelbss = bfd_get_section_by_name (dynobj, ".rela.bss");
490 if (!htab->splt || !htab->srelplt || !htab->sdynbss
491 || (!info->shared && !htab->srelbss))
497 /* Copy the extra info we tack onto an elf_link_hash_entry. */
500 elf64_x86_64_copy_indirect_symbol (dir, ind)
501 struct elf_link_hash_entry *dir, *ind;
503 struct elf64_x86_64_link_hash_entry *edir, *eind;
505 edir = (struct elf64_x86_64_link_hash_entry *) dir;
506 eind = (struct elf64_x86_64_link_hash_entry *) ind;
508 if (eind->dyn_relocs != NULL)
510 if (edir->dyn_relocs != NULL)
512 struct elf64_x86_64_dyn_relocs **pp;
513 struct elf64_x86_64_dyn_relocs *p;
515 if (ind->root.type == bfd_link_hash_indirect)
518 /* Add reloc counts against the weak sym to the strong sym
519 list. Merge any entries against the same section. */
520 for (pp = &eind->dyn_relocs; (p = *pp) != NULL; )
522 struct elf64_x86_64_dyn_relocs *q;
524 for (q = edir->dyn_relocs; q != NULL; q = q->next)
525 if (q->sec == p->sec)
527 q->pc_count += p->pc_count;
528 q->count += p->count;
535 *pp = edir->dyn_relocs;
538 edir->dyn_relocs = eind->dyn_relocs;
539 eind->dyn_relocs = NULL;
542 _bfd_elf_link_hash_copy_indirect (dir, ind);
546 elf64_x86_64_elf_object_p (abfd)
549 /* Set the right machine number for an x86-64 elf64 file. */
550 bfd_default_set_arch_mach (abfd, bfd_arch_i386, bfd_mach_x86_64);
554 /* Look through the relocs for a section during the first phase, and
555 calculate needed space in the global offset table, procedure
556 linkage table, and dynamic reloc sections. */
559 elf64_x86_64_check_relocs (abfd, info, sec, relocs)
561 struct bfd_link_info *info;
563 const Elf_Internal_Rela *relocs;
565 struct elf64_x86_64_link_hash_table *htab;
566 Elf_Internal_Shdr *symtab_hdr;
567 struct elf_link_hash_entry **sym_hashes;
568 const Elf_Internal_Rela *rel;
569 const Elf_Internal_Rela *rel_end;
572 if (info->relocateable)
575 htab = elf64_x86_64_hash_table (info);
576 symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
577 sym_hashes = elf_sym_hashes (abfd);
581 rel_end = relocs + sec->reloc_count;
582 for (rel = relocs; rel < rel_end; rel++)
584 unsigned long r_symndx;
585 struct elf_link_hash_entry *h;
587 r_symndx = ELF64_R_SYM (rel->r_info);
589 if (r_symndx >= NUM_SHDR_ENTRIES (symtab_hdr))
591 (*_bfd_error_handler) (_("%s: bad symbol index: %d"),
592 bfd_archive_filename (abfd),
597 if (r_symndx < symtab_hdr->sh_info)
600 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
602 switch (ELF64_R_TYPE (rel->r_info))
605 case R_X86_64_GOTPCREL:
606 /* This symbol requires a global offset table entry. */
609 h->got.refcount += 1;
613 bfd_signed_vma *local_got_refcounts;
615 /* This is a global offset table entry for a local symbol. */
616 local_got_refcounts = elf_local_got_refcounts (abfd);
617 if (local_got_refcounts == NULL)
621 size = symtab_hdr->sh_info;
622 size *= sizeof (bfd_signed_vma);
623 local_got_refcounts = ((bfd_signed_vma *)
624 bfd_zalloc (abfd, size));
625 if (local_got_refcounts == NULL)
627 elf_local_got_refcounts (abfd) = local_got_refcounts;
629 local_got_refcounts[r_symndx] += 1;
633 //case R_X86_64_GOTPCREL:
634 if (htab->sgot == NULL)
636 if (htab->elf.dynobj == NULL)
637 htab->elf.dynobj = abfd;
638 if (!create_got_section (htab->elf.dynobj, info))
644 /* This symbol requires a procedure linkage table entry. We
645 actually build the entry in adjust_dynamic_symbol,
646 because this might be a case of linking PIC code which is
647 never referenced by a dynamic object, in which case we
648 don't need to generate a procedure linkage table entry
651 /* If this is a local symbol, we resolve it directly without
652 creating a procedure linkage table entry. */
656 h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
657 h->plt.refcount += 1;
668 if (h != NULL && !info->shared)
670 /* If this reloc is in a read-only section, we might
671 need a copy reloc. We can't check reliably at this
672 stage whether the section is read-only, as input
673 sections have not yet been mapped to output sections.
674 Tentatively set the flag for now, and correct in
675 adjust_dynamic_symbol. */
676 h->elf_link_hash_flags |= ELF_LINK_NON_GOT_REF;
678 /* We may need a .plt entry if the function this reloc
679 refers to is in a shared lib. */
680 h->plt.refcount += 1;
683 /* If we are creating a shared library, and this is a reloc
684 against a global symbol, or a non PC relative reloc
685 against a local symbol, then we need to copy the reloc
686 into the shared library. However, if we are linking with
687 -Bsymbolic, we do not need to copy a reloc against a
688 global symbol which is defined in an object we are
689 including in the link (i.e., DEF_REGULAR is set). At
690 this point we have not seen all the input files, so it is
691 possible that DEF_REGULAR is not set now but will be set
692 later (it is never cleared). In case of a weak definition,
693 DEF_REGULAR may be cleared later by a strong definition in
694 a shared library. We account for that possibility below by
695 storing information in the relocs_copied field of the hash
696 table entry. A similar situation occurs when creating
697 shared libraries and symbol visibility changes render the
700 If on the other hand, we are creating an executable, we
701 may need to keep relocations for symbols satisfied by a
702 dynamic library if we manage to avoid copy relocs for the
705 && (sec->flags & SEC_ALLOC) != 0
706 && (((ELF64_R_TYPE (rel->r_info) != R_X86_64_PC8)
707 && (ELF64_R_TYPE (rel->r_info) != R_X86_64_PC16)
708 && (ELF64_R_TYPE (rel->r_info) != R_X86_64_PC32))
711 || h->root.type == bfd_link_hash_defweak
712 || (h->elf_link_hash_flags
713 & ELF_LINK_HASH_DEF_REGULAR) == 0))))
715 && (sec->flags & SEC_ALLOC) != 0
717 && (h->root.type == bfd_link_hash_defweak
718 || (h->elf_link_hash_flags
719 & ELF_LINK_HASH_DEF_REGULAR) == 0)))
721 struct elf64_x86_64_dyn_relocs *p;
722 struct elf64_x86_64_dyn_relocs **head;
724 /* We must copy these reloc types into the output file.
725 Create a reloc section in dynobj and make room for
732 name = (bfd_elf_string_from_elf_section
734 elf_elfheader (abfd)->e_shstrndx,
735 elf_section_data (sec)->rel_hdr.sh_name));
739 if (strncmp (name, ".rela", 5) != 0
740 || strcmp (bfd_get_section_name (abfd, sec),
743 (*_bfd_error_handler)
744 (_("%s: bad relocation section name `%s\'"),
745 bfd_archive_filename (abfd), name);
748 if (htab->elf.dynobj == NULL)
749 htab->elf.dynobj = abfd;
751 dynobj = htab->elf.dynobj;
753 sreloc = bfd_get_section_by_name (dynobj, name);
758 sreloc = bfd_make_section (dynobj, name);
759 flags = (SEC_HAS_CONTENTS | SEC_READONLY
760 | SEC_IN_MEMORY | SEC_LINKER_CREATED);
761 if ((sec->flags & SEC_ALLOC) != 0)
762 flags |= SEC_ALLOC | SEC_LOAD;
764 || ! bfd_set_section_flags (dynobj, sreloc, flags)
765 || ! bfd_set_section_alignment (dynobj, sreloc, 3))
768 elf_section_data (sec)->sreloc = sreloc;
771 /* If this is a global symbol, we count the number of
772 relocations we need for this symbol. */
775 head = &((struct elf64_x86_64_link_hash_entry *) h)->dyn_relocs;
779 /* Track dynamic relocs needed for local syms too.
780 We really need local syms available to do this
784 s = bfd_section_from_r_symndx (abfd, &htab->sym_sec,
789 head = ((struct elf64_x86_64_dyn_relocs **)
790 &elf_section_data (s)->local_dynrel);
794 if (p == NULL || p->sec != sec)
796 bfd_size_type amt = sizeof *p;
797 p = ((struct elf64_x86_64_dyn_relocs *)
798 bfd_alloc (htab->elf.dynobj, amt));
809 if (ELF64_R_TYPE (rel->r_info) == R_X86_64_PC8
810 || ELF64_R_TYPE (rel->r_info) == R_X86_64_PC16
811 || ELF64_R_TYPE (rel->r_info) == R_X86_64_PC32)
816 /* This relocation describes the C++ object vtable hierarchy.
817 Reconstruct it for later use during GC. */
818 case R_X86_64_GNU_VTINHERIT:
819 if (!_bfd_elf64_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
823 /* This relocation describes which C++ vtable entries are actually
824 used. Record for later use during GC. */
825 case R_X86_64_GNU_VTENTRY:
826 if (!_bfd_elf64_gc_record_vtentry (abfd, sec, h, rel->r_addend))
838 /* Return the section that should be marked against GC for a given
842 elf64_x86_64_gc_mark_hook (abfd, info, rel, h, sym)
844 struct bfd_link_info *info ATTRIBUTE_UNUSED;
845 Elf_Internal_Rela *rel;
846 struct elf_link_hash_entry *h;
847 Elf_Internal_Sym *sym;
851 switch (ELF64_R_TYPE (rel->r_info))
853 case R_X86_64_GNU_VTINHERIT:
854 case R_X86_64_GNU_VTENTRY:
858 switch (h->root.type)
860 case bfd_link_hash_defined:
861 case bfd_link_hash_defweak:
862 return h->root.u.def.section;
864 case bfd_link_hash_common:
865 return h->root.u.c.p->section;
874 return bfd_section_from_elf_index (abfd, sym->st_shndx);
880 /* Update the got entry reference counts for the section being removed. */
883 elf64_x86_64_gc_sweep_hook (abfd, info, sec, relocs)
885 struct bfd_link_info *info;
887 const Elf_Internal_Rela *relocs;
889 Elf_Internal_Shdr *symtab_hdr;
890 struct elf_link_hash_entry **sym_hashes;
891 bfd_signed_vma *local_got_refcounts;
892 const Elf_Internal_Rela *rel, *relend;
893 unsigned long r_symndx;
894 struct elf_link_hash_entry *h;
896 elf_section_data (sec)->local_dynrel = NULL;
898 symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
899 sym_hashes = elf_sym_hashes (abfd);
900 local_got_refcounts = elf_local_got_refcounts (abfd);
902 relend = relocs + sec->reloc_count;
903 for (rel = relocs; rel < relend; rel++)
904 switch (ELF64_R_TYPE (rel->r_info))
907 case R_X86_64_GOTPCREL:
908 r_symndx = ELF64_R_SYM (rel->r_info);
909 if (r_symndx >= symtab_hdr->sh_info)
911 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
912 if (h->got.refcount > 0)
913 h->got.refcount -= 1;
915 else if (local_got_refcounts != NULL)
917 if (local_got_refcounts[r_symndx] > 0)
918 local_got_refcounts[r_symndx] -= 1;
930 r_symndx = ELF64_R_SYM (rel->r_info);
931 if (r_symndx >= symtab_hdr->sh_info)
933 struct elf64_x86_64_link_hash_entry *eh;
934 struct elf64_x86_64_dyn_relocs **pp;
935 struct elf64_x86_64_dyn_relocs *p;
937 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
939 if (!info->shared && h->plt.refcount > 0)
940 h->plt.refcount -= 1;
942 eh = (struct elf64_x86_64_link_hash_entry *) h;
944 for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
947 if (ELF64_R_TYPE (rel->r_info) == R_X86_64_PC8
948 || ELF64_R_TYPE (rel->r_info) == R_X86_64_PC16
949 || ELF64_R_TYPE (rel->r_info) == R_X86_64_PC32)
961 r_symndx = ELF64_R_SYM (rel->r_info);
962 if (r_symndx >= symtab_hdr->sh_info)
964 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
965 if (h->plt.refcount > 0)
966 h->plt.refcount -= 1;
977 /* Adjust a symbol defined by a dynamic object and referenced by a
978 regular object. The current definition is in some section of the
979 dynamic object, but we're not including those sections. We have to
980 change the definition to something the rest of the link can
984 elf64_x86_64_adjust_dynamic_symbol (info, h)
985 struct bfd_link_info *info;
986 struct elf_link_hash_entry *h;
988 struct elf64_x86_64_link_hash_table *htab;
989 struct elf64_x86_64_link_hash_entry * eh;
990 struct elf64_x86_64_dyn_relocs *p;
992 unsigned int power_of_two;
994 /* If this is a function, put it in the procedure linkage table. We
995 will fill in the contents of the procedure linkage table later,
996 when we know the address of the .got section. */
997 if (h->type == STT_FUNC
998 || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
1000 if (h->plt.refcount <= 0
1002 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0
1003 && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) == 0
1004 && h->root.type != bfd_link_hash_undefweak
1005 && h->root.type != bfd_link_hash_undefined))
1007 /* This case can occur if we saw a PLT32 reloc in an input
1008 file, but the symbol was never referred to by a dynamic
1009 object, or if all references were garbage collected. In
1010 such a case, we don't actually need to build a procedure
1011 linkage table, and we can just do a PC32 reloc instead. */
1012 h->plt.offset = (bfd_vma) -1;
1013 h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
1019 /* It's possible that we incorrectly decided a .plt reloc was
1020 needed for an R_X86_64_PC32 reloc to a non-function sym in
1021 check_relocs. We can't decide accurately between function and
1022 non-function syms in check-relocs; Objects loaded later in
1023 the link may change h->type. So fix it now. */
1024 h->plt.offset = (bfd_vma) -1;
1026 /* If this is a weak symbol, and there is a real definition, the
1027 processor independent code will have arranged for us to see the
1028 real definition first, and we can just use the same value. */
1029 if (h->weakdef != NULL)
1031 BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined
1032 || h->weakdef->root.type == bfd_link_hash_defweak);
1033 h->root.u.def.section = h->weakdef->root.u.def.section;
1034 h->root.u.def.value = h->weakdef->root.u.def.value;
1038 /* This is a reference to a symbol defined by a dynamic object which
1039 is not a function. */
1041 /* If we are creating a shared library, we must presume that the
1042 only references to the symbol are via the global offset table.
1043 For such cases we need not do anything here; the relocations will
1044 be handled correctly by relocate_section. */
1048 /* If there are no references to this symbol that do not use the
1049 GOT, we don't need to generate a copy reloc. */
1050 if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0)
1053 /* If -z nocopyreloc was given, we won't generate them either. */
1054 if (info->nocopyreloc)
1056 h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF;
1060 eh = (struct elf64_x86_64_link_hash_entry *) h;
1061 for (p = eh->dyn_relocs; p != NULL; p = p->next)
1063 s = p->sec->output_section;
1064 if (s != NULL && (s->flags & SEC_READONLY) != 0)
1068 /* If we didn't find any dynamic relocs in read-only sections, then
1069 we'll be keeping the dynamic relocs and avoiding the copy reloc. */
1072 h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF;
1076 /* We must allocate the symbol in our .dynbss section, which will
1077 become part of the .bss section of the executable. There will be
1078 an entry for this symbol in the .dynsym section. The dynamic
1079 object will contain position independent code, so all references
1080 from the dynamic object to this symbol will go through the global
1081 offset table. The dynamic linker will use the .dynsym entry to
1082 determine the address it must put in the global offset table, so
1083 both the dynamic object and the regular object will refer to the
1084 same memory location for the variable. */
1086 htab = elf64_x86_64_hash_table (info);
1088 /* We must generate a R_X86_64_COPY reloc to tell the dynamic linker
1089 to copy the initial value out of the dynamic object and into the
1090 runtime process image. */
1091 if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
1093 htab->srelbss->_raw_size += sizeof (Elf64_External_Rela);
1094 h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY;
1097 /* We need to figure out the alignment required for this symbol. I
1098 have no idea how ELF linkers handle this. 16-bytes is the size
1099 of the largest type that requires hard alignment -- long double. */
1100 /* FIXME: This is VERY ugly. Should be fixed for all architectures using
1102 power_of_two = bfd_log2 (h->size);
1103 if (power_of_two > 4)
1106 /* Apply the required alignment. */
1108 s->_raw_size = BFD_ALIGN (s->_raw_size, (bfd_size_type) (1 << power_of_two));
1109 if (power_of_two > bfd_get_section_alignment (htab->elf.dynobj, s))
1111 if (! bfd_set_section_alignment (htab->elf.dynobj, s, power_of_two))
1115 /* Define the symbol as being at this point in the section. */
1116 h->root.u.def.section = s;
1117 h->root.u.def.value = s->_raw_size;
1119 /* Increment the section size to make room for the symbol. */
1120 s->_raw_size += h->size;
1125 /* This is the condition under which elf64_x86_64_finish_dynamic_symbol
1126 will be called from elflink.h. If elflink.h doesn't call our
1127 finish_dynamic_symbol routine, we'll need to do something about
1128 initializing any .plt and .got entries in elf64_x86_64_relocate_section. */
1129 #define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, INFO, H) \
1131 && ((INFO)->shared \
1132 || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0) \
1133 && ((H)->dynindx != -1 \
1134 || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0))
1136 /* Allocate space in .plt, .got and associated reloc sections for
1140 allocate_dynrelocs (h, inf)
1141 struct elf_link_hash_entry *h;
1144 struct bfd_link_info *info;
1145 struct elf64_x86_64_link_hash_table *htab;
1146 struct elf64_x86_64_link_hash_entry *eh;
1147 struct elf64_x86_64_dyn_relocs *p;
1149 if (h->root.type == bfd_link_hash_indirect)
1152 if (h->root.type == bfd_link_hash_warning)
1153 h = (struct elf_link_hash_entry *) h->root.u.i.link;
1155 info = (struct bfd_link_info *) inf;
1156 htab = elf64_x86_64_hash_table (info);
1158 if (htab->elf.dynamic_sections_created
1159 && h->plt.refcount > 0)
1161 /* Make sure this symbol is output as a dynamic symbol.
1162 Undefined weak syms won't yet be marked as dynamic. */
1163 if (h->dynindx == -1
1164 && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
1166 if (! bfd_elf64_link_record_dynamic_symbol (info, h))
1170 if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info, h))
1172 asection *s = htab->splt;
1174 /* If this is the first .plt entry, make room for the special
1176 if (s->_raw_size == 0)
1177 s->_raw_size += PLT_ENTRY_SIZE;
1179 h->plt.offset = s->_raw_size;
1181 /* If this symbol is not defined in a regular file, and we are
1182 not generating a shared library, then set the symbol to this
1183 location in the .plt. This is required to make function
1184 pointers compare as equal between the normal executable and
1185 the shared library. */
1187 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
1189 h->root.u.def.section = s;
1190 h->root.u.def.value = h->plt.offset;
1193 /* Make room for this entry. */
1194 s->_raw_size += PLT_ENTRY_SIZE;
1196 /* We also need to make an entry in the .got.plt section, which
1197 will be placed in the .got section by the linker script. */
1198 htab->sgotplt->_raw_size += GOT_ENTRY_SIZE;
1200 /* We also need to make an entry in the .rela.plt section. */
1201 htab->srelplt->_raw_size += sizeof (Elf64_External_Rela);
1205 h->plt.offset = (bfd_vma) -1;
1206 h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
1211 h->plt.offset = (bfd_vma) -1;
1212 h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
1215 if (h->got.refcount > 0)
1220 /* Make sure this symbol is output as a dynamic symbol.
1221 Undefined weak syms won't yet be marked as dynamic. */
1222 if (h->dynindx == -1
1223 && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
1225 if (! bfd_elf64_link_record_dynamic_symbol (info, h))
1230 h->got.offset = s->_raw_size;
1231 s->_raw_size += GOT_ENTRY_SIZE;
1232 dyn = htab->elf.dynamic_sections_created;
1233 if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h))
1234 htab->srelgot->_raw_size += sizeof (Elf64_External_Rela);
1237 h->got.offset = (bfd_vma) -1;
1239 eh = (struct elf64_x86_64_link_hash_entry *) h;
1240 if (eh->dyn_relocs == NULL)
1243 /* In the shared -Bsymbolic case, discard space allocated for
1244 dynamic pc-relative relocs against symbols which turn out to be
1245 defined in regular objects. For the normal shared case, discard
1246 space for pc-relative relocs that have become local due to symbol
1247 visibility changes. */
1251 if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0
1252 && ((h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0
1255 struct elf64_x86_64_dyn_relocs **pp;
1257 for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
1259 p->count -= p->pc_count;
1270 /* For the non-shared case, discard space for relocs against
1271 symbols which turn out to need copy relocs or are not
1274 if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0
1275 && (((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
1276 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
1277 || (htab->elf.dynamic_sections_created
1278 && (h->root.type == bfd_link_hash_undefweak
1279 || h->root.type == bfd_link_hash_undefined))))
1281 /* Make sure this symbol is output as a dynamic symbol.
1282 Undefined weak syms won't yet be marked as dynamic. */
1283 if (h->dynindx == -1
1284 && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
1286 if (! bfd_elf64_link_record_dynamic_symbol (info, h))
1290 /* If that succeeded, we know we'll be keeping all the
1292 if (h->dynindx != -1)
1296 eh->dyn_relocs = NULL;
1301 /* Finally, allocate space. */
1302 for (p = eh->dyn_relocs; p != NULL; p = p->next)
1304 asection *sreloc = elf_section_data (p->sec)->sreloc;
1305 sreloc->_raw_size += p->count * sizeof (Elf64_External_Rela);
1311 /* Find any dynamic relocs that apply to read-only sections. */
1314 readonly_dynrelocs (h, inf)
1315 struct elf_link_hash_entry *h;
1318 struct elf64_x86_64_link_hash_entry *eh;
1319 struct elf64_x86_64_dyn_relocs *p;
1321 if (h->root.type == bfd_link_hash_warning)
1322 h = (struct elf_link_hash_entry *) h->root.u.i.link;
1324 eh = (struct elf64_x86_64_link_hash_entry *) h;
1325 for (p = eh->dyn_relocs; p != NULL; p = p->next)
1327 asection *s = p->sec->output_section;
1329 if (s != NULL && (s->flags & SEC_READONLY) != 0)
1331 struct bfd_link_info *info = (struct bfd_link_info *) inf;
1333 info->flags |= DF_TEXTREL;
1335 /* Not an error, just cut short the traversal. */
1342 /* Set the sizes of the dynamic sections. */
1345 elf64_x86_64_size_dynamic_sections (output_bfd, info)
1346 bfd *output_bfd ATTRIBUTE_UNUSED;
1347 struct bfd_link_info *info;
1349 struct elf64_x86_64_link_hash_table *htab;
1355 htab = elf64_x86_64_hash_table (info);
1356 dynobj = htab->elf.dynobj;
1360 if (htab->elf.dynamic_sections_created)
1362 /* Set the contents of the .interp section to the interpreter. */
1365 s = bfd_get_section_by_name (dynobj, ".interp");
1368 s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;
1369 s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
1373 /* Set up .got offsets for local syms, and space for local dynamic
1375 for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
1377 bfd_signed_vma *local_got;
1378 bfd_signed_vma *end_local_got;
1379 bfd_size_type locsymcount;
1380 Elf_Internal_Shdr *symtab_hdr;
1383 if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour)
1386 for (s = ibfd->sections; s != NULL; s = s->next)
1388 struct elf64_x86_64_dyn_relocs *p;
1390 for (p = *((struct elf64_x86_64_dyn_relocs **)
1391 &elf_section_data (s)->local_dynrel);
1395 if (!bfd_is_abs_section (p->sec)
1396 && bfd_is_abs_section (p->sec->output_section))
1398 /* Input section has been discarded, either because
1399 it is a copy of a linkonce section or due to
1400 linker script /DISCARD/, so we'll be discarding
1403 else if (p->count != 0)
1405 srel = elf_section_data (p->sec)->sreloc;
1406 srel->_raw_size += p->count * sizeof (Elf64_External_Rela);
1407 if ((p->sec->output_section->flags & SEC_READONLY) != 0)
1408 info->flags |= DF_TEXTREL;
1414 local_got = elf_local_got_refcounts (ibfd);
1418 symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
1419 locsymcount = symtab_hdr->sh_info;
1420 end_local_got = local_got + locsymcount;
1422 srel = htab->srelgot;
1423 for (; local_got < end_local_got; ++local_got)
1427 *local_got = s->_raw_size;
1428 s->_raw_size += GOT_ENTRY_SIZE;
1430 srel->_raw_size += sizeof (Elf64_External_Rela);
1433 *local_got = (bfd_vma) -1;
1437 /* Allocate global sym .plt and .got entries, and space for global
1438 sym dynamic relocs. */
1439 elf_link_hash_traverse (&htab->elf, allocate_dynrelocs, (PTR) info);
1441 /* We now have determined the sizes of the various dynamic sections.
1442 Allocate memory for them. */
1444 for (s = dynobj->sections; s != NULL; s = s->next)
1446 if ((s->flags & SEC_LINKER_CREATED) == 0)
1451 || s == htab->sgotplt)
1453 /* Strip this section if we don't need it; see the
1456 else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0)
1458 if (s->_raw_size != 0 && s != htab->srelplt)
1461 /* We use the reloc_count field as a counter if we need
1462 to copy relocs into the output file. */
1467 /* It's not one of our sections, so don't allocate space. */
1471 if (s->_raw_size == 0)
1473 /* If we don't need this section, strip it from the
1474 output file. This is mostly to handle .rela.bss and
1475 .rela.plt. We must create both sections in
1476 create_dynamic_sections, because they must be created
1477 before the linker maps input sections to output
1478 sections. The linker does that before
1479 adjust_dynamic_symbol is called, and it is that
1480 function which decides whether anything needs to go
1481 into these sections. */
1483 _bfd_strip_section_from_output (info, s);
1487 /* Allocate memory for the section contents. We use bfd_zalloc
1488 here in case unused entries are not reclaimed before the
1489 section's contents are written out. This should not happen,
1490 but this way if it does, we get a R_X86_64_NONE reloc instead
1492 s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);
1493 if (s->contents == NULL)
1497 if (htab->elf.dynamic_sections_created)
1499 /* Add some entries to the .dynamic section. We fill in the
1500 values later, in elf64_x86_64_finish_dynamic_sections, but we
1501 must add the entries now so that we get the correct size for
1502 the .dynamic section. The DT_DEBUG entry is filled in by the
1503 dynamic linker and used by the debugger. */
1504 #define add_dynamic_entry(TAG, VAL) \
1505 bfd_elf64_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
1509 if (!add_dynamic_entry (DT_DEBUG, 0))
1513 if (htab->splt->_raw_size != 0)
1515 if (!add_dynamic_entry (DT_PLTGOT, 0)
1516 || !add_dynamic_entry (DT_PLTRELSZ, 0)
1517 || !add_dynamic_entry (DT_PLTREL, DT_RELA)
1518 || !add_dynamic_entry (DT_JMPREL, 0))
1524 if (!add_dynamic_entry (DT_RELA, 0)
1525 || !add_dynamic_entry (DT_RELASZ, 0)
1526 || !add_dynamic_entry (DT_RELAENT, sizeof (Elf64_External_Rela)))
1529 /* If any dynamic relocs apply to a read-only section,
1530 then we need a DT_TEXTREL entry. */
1531 if ((info->flags & DF_TEXTREL) == 0)
1532 elf_link_hash_traverse (&htab->elf, readonly_dynrelocs,
1535 if ((info->flags & DF_TEXTREL) != 0)
1537 if (!add_dynamic_entry (DT_TEXTREL, 0))
1542 #undef add_dynamic_entry
1547 /* Relocate an x86_64 ELF section. */
1550 elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section,
1551 contents, relocs, local_syms, local_sections)
1553 struct bfd_link_info *info;
1555 asection *input_section;
1557 Elf_Internal_Rela *relocs;
1558 Elf_Internal_Sym *local_syms;
1559 asection **local_sections;
1561 struct elf64_x86_64_link_hash_table *htab;
1562 Elf_Internal_Shdr *symtab_hdr;
1563 struct elf_link_hash_entry **sym_hashes;
1564 bfd_vma *local_got_offsets;
1565 Elf_Internal_Rela *rel;
1566 Elf_Internal_Rela *relend;
1568 if (info->relocateable)
1571 htab = elf64_x86_64_hash_table (info);
1572 symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
1573 sym_hashes = elf_sym_hashes (input_bfd);
1574 local_got_offsets = elf_local_got_offsets (input_bfd);
1577 relend = relocs + input_section->reloc_count;
1578 for (; rel < relend; rel++)
1581 reloc_howto_type *howto;
1582 unsigned long r_symndx;
1583 struct elf_link_hash_entry *h;
1584 Elf_Internal_Sym *sym;
1588 boolean unresolved_reloc;
1589 bfd_reloc_status_type r;
1591 r_type = ELF64_R_TYPE (rel->r_info);
1592 if (r_type == (int) R_X86_64_GNU_VTINHERIT
1593 || r_type == (int) R_X86_64_GNU_VTENTRY)
1596 if (r_type < 0 || r_type >= R_X86_64_max)
1598 bfd_set_error (bfd_error_bad_value);
1602 howto = x86_64_elf_howto_table + r_type;
1603 r_symndx = ELF64_R_SYM (rel->r_info);
1607 unresolved_reloc = false;
1608 if (r_symndx < symtab_hdr->sh_info)
1610 sym = local_syms + r_symndx;
1611 sec = local_sections[r_symndx];
1613 relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
1617 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
1618 while (h->root.type == bfd_link_hash_indirect
1619 || h->root.type == bfd_link_hash_warning)
1620 h = (struct elf_link_hash_entry *) h->root.u.i.link;
1622 if (h->root.type == bfd_link_hash_defined
1623 || h->root.type == bfd_link_hash_defweak)
1625 sec = h->root.u.def.section;
1626 if (sec->output_section == NULL)
1628 /* Set a flag that will be cleared later if we find a
1629 relocation value for this symbol. output_section
1630 is typically NULL for symbols satisfied by a shared
1632 unresolved_reloc = true;
1636 relocation = (h->root.u.def.value
1637 + sec->output_section->vma
1638 + sec->output_offset);
1640 else if (h->root.type == bfd_link_hash_undefweak)
1642 else if (info->shared
1643 && (!info->symbolic || info->allow_shlib_undefined)
1644 && !info->no_undefined
1645 && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
1649 if (! ((*info->callbacks->undefined_symbol)
1650 (info, h->root.root.string, input_bfd,
1651 input_section, rel->r_offset,
1652 (!info->shared || info->no_undefined
1653 || ELF_ST_VISIBILITY (h->other)))))
1658 /* When generating a shared object, the relocations handled here are
1659 copied into the output file to be resolved at run time. */
1662 case R_X86_64_GOT32:
1663 /* Relocation is to the entry for this symbol in the global
1665 case R_X86_64_GOTPCREL:
1666 /* Use global offset table as symbol value. */
1667 if (htab->sgot == NULL)
1674 off = h->got.offset;
1675 dyn = htab->elf.dynamic_sections_created;
1677 if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h)
1681 || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL))
1682 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
1684 /* This is actually a static link, or it is a -Bsymbolic
1685 link and the symbol is defined locally, or the symbol
1686 was forced to be local because of a version file. We
1687 must initialize this entry in the global offset table.
1688 Since the offset must always be a multiple of 8, we
1689 use the least significant bit to record whether we
1690 have initialized it already.
1692 When doing a dynamic link, we create a .rela.got
1693 relocation entry to initialize the value. This is
1694 done in the finish_dynamic_symbol routine. */
1699 bfd_put_64 (output_bfd, relocation,
1700 htab->sgot->contents + off);
1705 unresolved_reloc = false;
1709 if (local_got_offsets == NULL)
1712 off = local_got_offsets[r_symndx];
1714 /* The offset must always be a multiple of 8. We use
1715 the least significant bit to record whether we have
1716 already generated the necessary reloc. */
1721 bfd_put_64 (output_bfd, relocation,
1722 htab->sgot->contents + off);
1727 Elf_Internal_Rela outrel;
1728 Elf64_External_Rela *loc;
1730 /* We need to generate a R_X86_64_RELATIVE reloc
1731 for the dynamic linker. */
1732 srelgot = htab->srelgot;
1733 if (srelgot == NULL)
1736 outrel.r_offset = (htab->sgot->output_section->vma
1737 + htab->sgot->output_offset
1739 outrel.r_info = ELF64_R_INFO (0, R_X86_64_RELATIVE);
1740 outrel.r_addend = relocation;
1741 loc = (Elf64_External_Rela *) srelgot->contents;
1742 loc += srelgot->reloc_count++;
1743 bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
1746 local_got_offsets[r_symndx] |= 1;
1750 if (off >= (bfd_vma) -2)
1753 relocation = htab->sgot->output_offset + off;
1754 if (r_type == R_X86_64_GOTPCREL)
1755 relocation += htab->sgot->output_section->vma;
1759 case R_X86_64_PLT32:
1760 /* Relocation is to the entry for this symbol in the
1761 procedure linkage table. */
1763 /* Resolve a PLT32 reloc against a local symbol directly,
1764 without using the procedure linkage table. */
1768 if (h->plt.offset == (bfd_vma) -1
1769 || htab->splt == NULL)
1771 /* We didn't make a PLT entry for this symbol. This
1772 happens when statically linking PIC code, or when
1773 using -Bsymbolic. */
1777 relocation = (htab->splt->output_section->vma
1778 + htab->splt->output_offset
1780 unresolved_reloc = false;
1790 /* FIXME: The ABI says the linker should make sure the value is
1791 the same when it's zeroextended to 64 bit. */
1793 /* r_symndx will be zero only for relocs against symbols
1794 from removed linkonce sections, or sections discarded by
1797 || (input_section->flags & SEC_ALLOC) == 0)
1801 && ((r_type != R_X86_64_PC8
1802 && r_type != R_X86_64_PC16
1803 && r_type != R_X86_64_PC32)
1806 && (! info->symbolic
1807 || (h->elf_link_hash_flags
1808 & ELF_LINK_HASH_DEF_REGULAR) == 0))))
1812 && (h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0
1813 && (((h->elf_link_hash_flags
1814 & ELF_LINK_HASH_DEF_DYNAMIC) != 0
1815 && (h->elf_link_hash_flags
1816 & ELF_LINK_HASH_DEF_REGULAR) == 0)
1817 || h->root.type == bfd_link_hash_undefweak
1818 || h->root.type == bfd_link_hash_undefined)))
1820 Elf_Internal_Rela outrel;
1821 boolean skip, relocate;
1823 Elf64_External_Rela *loc;
1825 /* When generating a shared object, these relocations
1826 are copied into the output file to be resolved at run
1833 _bfd_elf_section_offset (output_bfd, info, input_section,
1835 if (outrel.r_offset == (bfd_vma) -1)
1837 else if (outrel.r_offset == (bfd_vma) -2)
1838 skip = true, relocate = true;
1840 outrel.r_offset += (input_section->output_section->vma
1841 + input_section->output_offset);
1844 memset (&outrel, 0, sizeof outrel);
1846 /* h->dynindx may be -1 if this symbol was marked to
1850 && (r_type == R_X86_64_PC8
1851 || r_type == R_X86_64_PC16
1852 || r_type == R_X86_64_PC32
1855 || (h->elf_link_hash_flags
1856 & ELF_LINK_HASH_DEF_REGULAR) == 0))
1858 outrel.r_info = ELF64_R_INFO (h->dynindx, r_type);
1859 outrel.r_addend = rel->r_addend;
1863 /* This symbol is local, or marked to become local. */
1865 outrel.r_info = ELF64_R_INFO (0, R_X86_64_RELATIVE);
1866 outrel.r_addend = relocation + rel->r_addend;
1869 sreloc = elf_section_data (input_section)->sreloc;
1873 loc = (Elf64_External_Rela *) sreloc->contents;
1874 loc += sreloc->reloc_count++;
1875 bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
1877 /* If this reloc is against an external symbol, we do
1878 not want to fiddle with the addend. Otherwise, we
1879 need to include the symbol value so that it becomes
1880 an addend for the dynamic reloc. */
1891 /* FIXME: Why do we allow debugging sections to escape this error?
1892 More importantly, why do we not emit dynamic relocs for
1893 R_386_32 above in debugging sections (which are ! SEC_ALLOC)?
1894 If we had emitted the dynamic reloc, we could remove the
1896 if (unresolved_reloc
1898 && (input_section->flags & SEC_DEBUGGING) != 0
1899 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0))
1900 (*_bfd_error_handler)
1901 (_("%s(%s+0x%lx): unresolvable relocation against symbol `%s'"),
1902 bfd_archive_filename (input_bfd),
1903 bfd_get_section_name (input_bfd, input_section),
1904 (long) rel->r_offset,
1905 h->root.root.string);
1907 r = _bfd_final_link_relocate (howto, input_bfd, input_section,
1908 contents, rel->r_offset,
1909 relocation, rel->r_addend);
1911 if (r != bfd_reloc_ok)
1916 name = h->root.root.string;
1919 name = bfd_elf_string_from_elf_section (input_bfd,
1920 symtab_hdr->sh_link,
1925 name = bfd_section_name (input_bfd, sec);
1928 if (r == bfd_reloc_overflow)
1931 if (! ((*info->callbacks->reloc_overflow)
1932 (info, name, howto->name, (bfd_vma) 0,
1933 input_bfd, input_section, rel->r_offset)))
1938 (*_bfd_error_handler)
1939 (_("%s(%s+0x%lx): reloc against `%s': error %d"),
1940 bfd_archive_filename (input_bfd),
1941 bfd_get_section_name (input_bfd, input_section),
1942 (long) rel->r_offset, name, (int) r);
1951 /* Finish up dynamic symbol handling. We set the contents of various
1952 dynamic sections here. */
1955 elf64_x86_64_finish_dynamic_symbol (output_bfd, info, h, sym)
1957 struct bfd_link_info *info;
1958 struct elf_link_hash_entry *h;
1959 Elf_Internal_Sym *sym;
1961 struct elf64_x86_64_link_hash_table *htab;
1963 htab = elf64_x86_64_hash_table (info);
1965 if (h->plt.offset != (bfd_vma) -1)
1969 Elf_Internal_Rela rela;
1970 Elf64_External_Rela *loc;
1972 /* This symbol has an entry in the procedure linkage table. Set
1975 if (h->dynindx == -1
1976 || htab->splt == NULL
1977 || htab->sgotplt == NULL
1978 || htab->srelplt == NULL)
1981 /* Get the index in the procedure linkage table which
1982 corresponds to this symbol. This is the index of this symbol
1983 in all the symbols for which we are making plt entries. The
1984 first entry in the procedure linkage table is reserved. */
1985 plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1;
1987 /* Get the offset into the .got table of the entry that
1988 corresponds to this function. Each .got entry is GOT_ENTRY_SIZE
1989 bytes. The first three are reserved for the dynamic linker. */
1990 got_offset = (plt_index + 3) * GOT_ENTRY_SIZE;
1992 /* Fill in the entry in the procedure linkage table. */
1993 memcpy (htab->splt->contents + h->plt.offset, elf64_x86_64_plt_entry,
1996 /* Insert the relocation positions of the plt section. The magic
1997 numbers at the end of the statements are the positions of the
1998 relocations in the plt section. */
1999 /* Put offset for jmp *name@GOTPCREL(%rip), since the
2000 instruction uses 6 bytes, subtract this value. */
2001 bfd_put_32 (output_bfd,
2002 (htab->sgotplt->output_section->vma
2003 + htab->sgotplt->output_offset
2005 - htab->splt->output_section->vma
2006 - htab->splt->output_offset
2009 htab->splt->contents + h->plt.offset + 2);
2010 /* Put relocation index. */
2011 bfd_put_32 (output_bfd, plt_index,
2012 htab->splt->contents + h->plt.offset + 7);
2013 /* Put offset for jmp .PLT0. */
2014 bfd_put_32 (output_bfd, - (h->plt.offset + PLT_ENTRY_SIZE),
2015 htab->splt->contents + h->plt.offset + 12);
2017 /* Fill in the entry in the global offset table, initially this
2018 points to the pushq instruction in the PLT which is at offset 6. */
2019 bfd_put_64 (output_bfd, (htab->splt->output_section->vma
2020 + htab->splt->output_offset
2021 + h->plt.offset + 6),
2022 htab->sgotplt->contents + got_offset);
2024 /* Fill in the entry in the .rela.plt section. */
2025 rela.r_offset = (htab->sgotplt->output_section->vma
2026 + htab->sgotplt->output_offset
2028 rela.r_info = ELF64_R_INFO (h->dynindx, R_X86_64_JUMP_SLOT);
2030 loc = (Elf64_External_Rela *) htab->srelplt->contents + plt_index;
2031 bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
2033 if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
2035 /* Mark the symbol as undefined, rather than as defined in
2036 the .plt section. Leave the value alone. This is a clue
2037 for the dynamic linker, to make function pointer
2038 comparisons work between an application and shared
2040 sym->st_shndx = SHN_UNDEF;
2044 if (h->got.offset != (bfd_vma) -1)
2046 Elf_Internal_Rela rela;
2047 Elf64_External_Rela *loc;
2049 /* This symbol has an entry in the global offset table. Set it
2052 if (htab->sgot == NULL || htab->srelgot == NULL)
2055 rela.r_offset = (htab->sgot->output_section->vma
2056 + htab->sgot->output_offset
2057 + (h->got.offset &~ (bfd_vma) 1));
2059 /* If this is a static link, or it is a -Bsymbolic link and the
2060 symbol is defined locally or was forced to be local because
2061 of a version file, we just want to emit a RELATIVE reloc.
2062 The entry in the global offset table will already have been
2063 initialized in the relocate_section function. */
2067 || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL))
2068 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
2070 BFD_ASSERT((h->got.offset & 1) != 0);
2071 rela.r_info = ELF64_R_INFO (0, R_X86_64_RELATIVE);
2072 rela.r_addend = (h->root.u.def.value
2073 + h->root.u.def.section->output_section->vma
2074 + h->root.u.def.section->output_offset);
2078 BFD_ASSERT((h->got.offset & 1) == 0);
2079 bfd_put_64 (output_bfd, (bfd_vma) 0,
2080 htab->sgot->contents + h->got.offset);
2081 rela.r_info = ELF64_R_INFO (h->dynindx, R_X86_64_GLOB_DAT);
2085 loc = (Elf64_External_Rela *) htab->srelgot->contents;
2086 loc += htab->srelgot->reloc_count++;
2087 bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
2090 if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
2092 Elf_Internal_Rela rela;
2093 Elf64_External_Rela *loc;
2095 /* This symbol needs a copy reloc. Set it up. */
2097 if (h->dynindx == -1
2098 || (h->root.type != bfd_link_hash_defined
2099 && h->root.type != bfd_link_hash_defweak)
2100 || htab->srelbss == NULL)
2103 rela.r_offset = (h->root.u.def.value
2104 + h->root.u.def.section->output_section->vma
2105 + h->root.u.def.section->output_offset);
2106 rela.r_info = ELF64_R_INFO (h->dynindx, R_X86_64_COPY);
2108 loc = (Elf64_External_Rela *) htab->srelbss->contents;
2109 loc += htab->srelbss->reloc_count++;
2110 bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
2113 /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */
2114 if (strcmp (h->root.root.string, "_DYNAMIC") == 0
2115 || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
2116 sym->st_shndx = SHN_ABS;
2121 /* Used to decide how to sort relocs in an optimal manner for the
2122 dynamic linker, before writing them out. */
2124 static enum elf_reloc_type_class
2125 elf64_x86_64_reloc_type_class (rela)
2126 const Elf_Internal_Rela *rela;
2128 switch ((int) ELF64_R_TYPE (rela->r_info))
2130 case R_X86_64_RELATIVE:
2131 return reloc_class_relative;
2132 case R_X86_64_JUMP_SLOT:
2133 return reloc_class_plt;
2135 return reloc_class_copy;
2137 return reloc_class_normal;
2141 /* Finish up the dynamic sections. */
2144 elf64_x86_64_finish_dynamic_sections (output_bfd, info)
2146 struct bfd_link_info *info;
2148 struct elf64_x86_64_link_hash_table *htab;
2152 htab = elf64_x86_64_hash_table (info);
2153 dynobj = htab->elf.dynobj;
2154 sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
2156 if (htab->elf.dynamic_sections_created)
2158 Elf64_External_Dyn *dyncon, *dynconend;
2160 if (sdyn == NULL || htab->sgot == NULL)
2163 dyncon = (Elf64_External_Dyn *) sdyn->contents;
2164 dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->_raw_size);
2165 for (; dyncon < dynconend; dyncon++)
2167 Elf_Internal_Dyn dyn;
2170 bfd_elf64_swap_dyn_in (dynobj, dyncon, &dyn);
2178 dyn.d_un.d_ptr = htab->sgot->output_section->vma;
2182 dyn.d_un.d_ptr = htab->srelplt->output_section->vma;
2186 s = htab->srelplt->output_section;
2187 if (s->_cooked_size != 0)
2188 dyn.d_un.d_val = s->_cooked_size;
2190 dyn.d_un.d_val = s->_raw_size;
2194 /* The procedure linkage table relocs (DT_JMPREL) should
2195 not be included in the overall relocs (DT_RELA).
2196 Therefore, we override the DT_RELASZ entry here to
2197 make it not include the JMPREL relocs. Since the
2198 linker script arranges for .rela.plt to follow all
2199 other relocation sections, we don't have to worry
2200 about changing the DT_RELA entry. */
2201 if (htab->srelplt != NULL)
2203 s = htab->srelplt->output_section;
2204 if (s->_cooked_size != 0)
2205 dyn.d_un.d_val -= s->_cooked_size;
2207 dyn.d_un.d_val -= s->_raw_size;
2212 bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
2215 /* Fill in the special first entry in the procedure linkage table. */
2216 if (htab->splt && htab->splt->_raw_size > 0)
2218 /* Fill in the first entry in the procedure linkage table. */
2219 memcpy (htab->splt->contents, elf64_x86_64_plt0_entry,
2221 /* Add offset for pushq GOT+8(%rip), since the instruction
2222 uses 6 bytes subtract this value. */
2223 bfd_put_32 (output_bfd,
2224 (htab->sgotplt->output_section->vma
2225 + htab->sgotplt->output_offset
2227 - htab->splt->output_section->vma
2228 - htab->splt->output_offset
2230 htab->splt->contents + 2);
2231 /* Add offset for jmp *GOT+16(%rip). The 12 is the offset to
2232 the end of the instruction. */
2233 bfd_put_32 (output_bfd,
2234 (htab->sgotplt->output_section->vma
2235 + htab->sgotplt->output_offset
2237 - htab->splt->output_section->vma
2238 - htab->splt->output_offset
2240 htab->splt->contents + 8);
2242 elf_section_data (htab->splt->output_section)->this_hdr.sh_entsize =
2249 /* Fill in the first three entries in the global offset table. */
2250 if (htab->sgotplt->_raw_size > 0)
2252 /* Set the first entry in the global offset table to the address of
2253 the dynamic section. */
2255 bfd_put_64 (output_bfd, (bfd_vma) 0, htab->sgotplt->contents);
2257 bfd_put_64 (output_bfd,
2258 sdyn->output_section->vma + sdyn->output_offset,
2259 htab->sgotplt->contents);
2260 /* Write GOT[1] and GOT[2], needed for the dynamic linker. */
2261 bfd_put_64 (output_bfd, (bfd_vma) 0, htab->sgotplt->contents + GOT_ENTRY_SIZE);
2262 bfd_put_64 (output_bfd, (bfd_vma) 0, htab->sgotplt->contents + GOT_ENTRY_SIZE*2);
2265 elf_section_data (htab->sgotplt->output_section)->this_hdr.sh_entsize =
2273 #define TARGET_LITTLE_SYM bfd_elf64_x86_64_vec
2274 #define TARGET_LITTLE_NAME "elf64-x86-64"
2275 #define ELF_ARCH bfd_arch_i386
2276 #define ELF_MACHINE_CODE EM_X86_64
2277 #define ELF_MAXPAGESIZE 0x100000
2279 #define elf_backend_can_gc_sections 1
2280 #define elf_backend_can_refcount 1
2281 #define elf_backend_want_got_plt 1
2282 #define elf_backend_plt_readonly 1
2283 #define elf_backend_want_plt_sym 0
2284 #define elf_backend_got_header_size (GOT_ENTRY_SIZE*3)
2285 #define elf_backend_plt_header_size PLT_ENTRY_SIZE
2286 #define elf_backend_rela_normal 1
2288 #define elf_info_to_howto elf64_x86_64_info_to_howto
2290 #define bfd_elf64_bfd_link_hash_table_create \
2291 elf64_x86_64_link_hash_table_create
2292 #define bfd_elf64_bfd_reloc_type_lookup elf64_x86_64_reloc_type_lookup
2294 #define elf_backend_adjust_dynamic_symbol elf64_x86_64_adjust_dynamic_symbol
2295 #define elf_backend_check_relocs elf64_x86_64_check_relocs
2296 #define elf_backend_copy_indirect_symbol elf64_x86_64_copy_indirect_symbol
2297 #define elf_backend_create_dynamic_sections elf64_x86_64_create_dynamic_sections
2298 #define elf_backend_finish_dynamic_sections elf64_x86_64_finish_dynamic_sections
2299 #define elf_backend_finish_dynamic_symbol elf64_x86_64_finish_dynamic_symbol
2300 #define elf_backend_gc_mark_hook elf64_x86_64_gc_mark_hook
2301 #define elf_backend_gc_sweep_hook elf64_x86_64_gc_sweep_hook
2302 #define elf_backend_grok_prstatus elf64_x86_64_grok_prstatus
2303 #define elf_backend_grok_psinfo elf64_x86_64_grok_psinfo
2304 #define elf_backend_reloc_type_class elf64_x86_64_reloc_type_class
2305 #define elf_backend_relocate_section elf64_x86_64_relocate_section
2306 #define elf_backend_size_dynamic_sections elf64_x86_64_size_dynamic_sections
2307 #define elf_backend_object_p elf64_x86_64_elf_object_p
2309 #include "elf64-target.h"