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_backend_data *, struct elf_link_hash_entry *,
141 struct elf_link_hash_entry *));
142 static boolean elf64_x86_64_check_relocs
143 PARAMS ((bfd *, struct bfd_link_info *, asection *sec,
144 const Elf_Internal_Rela *));
145 static asection *elf64_x86_64_gc_mark_hook
146 PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *,
147 struct elf_link_hash_entry *, Elf_Internal_Sym *));
149 static boolean elf64_x86_64_gc_sweep_hook
150 PARAMS ((bfd *, struct bfd_link_info *, asection *,
151 const Elf_Internal_Rela *));
153 static struct bfd_hash_entry *link_hash_newfunc
154 PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
155 static boolean elf64_x86_64_adjust_dynamic_symbol
156 PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
158 static boolean allocate_dynrelocs
159 PARAMS ((struct elf_link_hash_entry *, PTR));
160 static boolean readonly_dynrelocs
161 PARAMS ((struct elf_link_hash_entry *, PTR));
162 static boolean elf64_x86_64_size_dynamic_sections
163 PARAMS ((bfd *, struct bfd_link_info *));
164 static boolean elf64_x86_64_relocate_section
165 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
166 Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
167 static boolean elf64_x86_64_finish_dynamic_symbol
168 PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
169 Elf_Internal_Sym *sym));
170 static boolean elf64_x86_64_finish_dynamic_sections
171 PARAMS ((bfd *, struct bfd_link_info *));
172 static enum elf_reloc_type_class elf64_x86_64_reloc_type_class
173 PARAMS ((const Elf_Internal_Rela *));
175 /* Given a BFD reloc type, return a HOWTO structure. */
176 static reloc_howto_type *
177 elf64_x86_64_reloc_type_lookup (abfd, code)
178 bfd *abfd ATTRIBUTE_UNUSED;
179 bfd_reloc_code_real_type code;
182 for (i = 0; i < sizeof (x86_64_reloc_map) / sizeof (struct elf_reloc_map);
185 if (x86_64_reloc_map[i].bfd_reloc_val == code)
186 return &x86_64_elf_howto_table[i];
191 /* Given an x86_64 ELF reloc type, fill in an arelent structure. */
194 elf64_x86_64_info_to_howto (abfd, cache_ptr, dst)
195 bfd *abfd ATTRIBUTE_UNUSED;
197 Elf64_Internal_Rela *dst;
201 r_type = ELF64_R_TYPE (dst->r_info);
202 if (r_type < (unsigned int) R_X86_64_GNU_VTINHERIT)
204 BFD_ASSERT (r_type <= (unsigned int) R_X86_64_PC8);
209 BFD_ASSERT (r_type < (unsigned int) R_X86_64_max);
210 i = r_type - ((unsigned int) R_X86_64_GNU_VTINHERIT - R_X86_64_PC8 - 1);
212 cache_ptr->howto = &x86_64_elf_howto_table[i];
213 BFD_ASSERT (r_type == cache_ptr->howto->type);
216 /* Support for core dump NOTE sections. */
218 elf64_x86_64_grok_prstatus (abfd, note)
220 Elf_Internal_Note *note;
225 switch (note->descsz)
230 case 336: /* sizeof(istruct elf_prstatus) on Linux/x86_64 */
232 elf_tdata (abfd)->core_signal
233 = bfd_get_16 (abfd, note->descdata + 12);
236 elf_tdata (abfd)->core_pid
237 = bfd_get_32 (abfd, note->descdata + 32);
246 /* Make a ".reg/999" section. */
247 return _bfd_elfcore_make_pseudosection (abfd, ".reg",
248 raw_size, note->descpos + offset);
252 elf64_x86_64_grok_psinfo (abfd, note)
254 Elf_Internal_Note *note;
256 switch (note->descsz)
261 case 136: /* sizeof(struct elf_prpsinfo) on Linux/x86_64 */
262 elf_tdata (abfd)->core_program
263 = _bfd_elfcore_strndup (abfd, note->descdata + 40, 16);
264 elf_tdata (abfd)->core_command
265 = _bfd_elfcore_strndup (abfd, note->descdata + 56, 80);
268 /* Note that for some reason, a spurious space is tacked
269 onto the end of the args in some (at least one anyway)
270 implementations, so strip it off if it exists. */
273 char *command = elf_tdata (abfd)->core_command;
274 int n = strlen (command);
276 if (0 < n && command[n - 1] == ' ')
277 command[n - 1] = '\0';
283 /* Functions for the x86-64 ELF linker. */
285 /* The name of the dynamic interpreter. This is put in the .interp
288 #define ELF_DYNAMIC_INTERPRETER "/lib/ld64.so.1"
290 /* The size in bytes of an entry in the global offset table. */
292 #define GOT_ENTRY_SIZE 8
294 /* The size in bytes of an entry in the procedure linkage table. */
296 #define PLT_ENTRY_SIZE 16
298 /* The first entry in a procedure linkage table looks like this. See the
299 SVR4 ABI i386 supplement and the x86-64 ABI to see how this works. */
301 static const bfd_byte elf64_x86_64_plt0_entry[PLT_ENTRY_SIZE] =
303 0xff, 0x35, 8, 0, 0, 0, /* pushq GOT+8(%rip) */
304 0xff, 0x25, 16, 0, 0, 0, /* jmpq *GOT+16(%rip) */
305 0x90, 0x90, 0x90, 0x90 /* pad out to 16 bytes with nops. */
308 /* Subsequent entries in a procedure linkage table look like this. */
310 static const bfd_byte elf64_x86_64_plt_entry[PLT_ENTRY_SIZE] =
312 0xff, 0x25, /* jmpq *name@GOTPC(%rip) */
313 0, 0, 0, 0, /* replaced with offset to this symbol in .got. */
314 0x68, /* pushq immediate */
315 0, 0, 0, 0, /* replaced with index into relocation table. */
316 0xe9, /* jmp relative */
317 0, 0, 0, 0 /* replaced with offset to start of .plt0. */
320 /* The x86-64 linker needs to keep track of the number of relocs that
321 it decides to copy as dynamic relocs in check_relocs for each symbol.
322 This is so that it can later discard them if they are found to be
323 unnecessary. We store the information in a field extending the
324 regular ELF linker hash table. */
326 struct elf64_x86_64_dyn_relocs
329 struct elf64_x86_64_dyn_relocs *next;
331 /* The input section of the reloc. */
334 /* Total number of relocs copied for the input section. */
337 /* Number of pc-relative relocs copied for the input section. */
338 bfd_size_type pc_count;
341 /* x86-64 ELF linker hash entry. */
343 struct elf64_x86_64_link_hash_entry
345 struct elf_link_hash_entry elf;
347 /* Track dynamic relocs copied for this symbol. */
348 struct elf64_x86_64_dyn_relocs *dyn_relocs;
351 /* x86-64 ELF linker hash table. */
353 struct elf64_x86_64_link_hash_table
355 struct elf_link_hash_table elf;
357 /* Short-cuts to get to dynamic linker sections. */
366 /* Small local sym to section mapping cache. */
367 struct sym_sec_cache sym_sec;
370 /* Get the x86-64 ELF linker hash table from a link_info structure. */
372 #define elf64_x86_64_hash_table(p) \
373 ((struct elf64_x86_64_link_hash_table *) ((p)->hash))
375 /* Create an entry in an x86-64 ELF linker hash table. */
377 static struct bfd_hash_entry *
378 link_hash_newfunc (entry, table, string)
379 struct bfd_hash_entry *entry;
380 struct bfd_hash_table *table;
383 /* Allocate the structure if it has not already been allocated by a
387 entry = bfd_hash_allocate (table,
388 sizeof (struct elf64_x86_64_link_hash_entry));
393 /* Call the allocation method of the superclass. */
394 entry = _bfd_elf_link_hash_newfunc (entry, table, string);
397 struct elf64_x86_64_link_hash_entry *eh;
399 eh = (struct elf64_x86_64_link_hash_entry *) entry;
400 eh->dyn_relocs = NULL;
406 /* Create an X86-64 ELF linker hash table. */
408 static struct bfd_link_hash_table *
409 elf64_x86_64_link_hash_table_create (abfd)
412 struct elf64_x86_64_link_hash_table *ret;
413 bfd_size_type amt = sizeof (struct elf64_x86_64_link_hash_table);
415 ret = (struct elf64_x86_64_link_hash_table *) bfd_malloc (amt);
419 if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc))
432 ret->sym_sec.abfd = NULL;
434 return &ret->elf.root;
437 /* Create .got, .gotplt, and .rela.got sections in DYNOBJ, and set up
438 shortcuts to them in our hash table. */
441 create_got_section (dynobj, info)
443 struct bfd_link_info *info;
445 struct elf64_x86_64_link_hash_table *htab;
447 if (! _bfd_elf_create_got_section (dynobj, info))
450 htab = elf64_x86_64_hash_table (info);
451 htab->sgot = bfd_get_section_by_name (dynobj, ".got");
452 htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
453 if (!htab->sgot || !htab->sgotplt)
456 htab->srelgot = bfd_make_section (dynobj, ".rela.got");
457 if (htab->srelgot == NULL
458 || ! bfd_set_section_flags (dynobj, htab->srelgot,
459 (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
460 | SEC_IN_MEMORY | SEC_LINKER_CREATED
462 || ! bfd_set_section_alignment (dynobj, htab->srelgot, 3))
467 /* Create .plt, .rela.plt, .got, .got.plt, .rela.got, .dynbss, and
468 .rela.bss sections in DYNOBJ, and set up shortcuts to them in our
472 elf64_x86_64_create_dynamic_sections (dynobj, info)
474 struct bfd_link_info *info;
476 struct elf64_x86_64_link_hash_table *htab;
478 htab = elf64_x86_64_hash_table (info);
479 if (!htab->sgot && !create_got_section (dynobj, info))
482 if (!_bfd_elf_create_dynamic_sections (dynobj, info))
485 htab->splt = bfd_get_section_by_name (dynobj, ".plt");
486 htab->srelplt = bfd_get_section_by_name (dynobj, ".rela.plt");
487 htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss");
489 htab->srelbss = bfd_get_section_by_name (dynobj, ".rela.bss");
491 if (!htab->splt || !htab->srelplt || !htab->sdynbss
492 || (!info->shared && !htab->srelbss))
498 /* Copy the extra info we tack onto an elf_link_hash_entry. */
501 elf64_x86_64_copy_indirect_symbol (bed, dir, ind)
502 struct elf_backend_data *bed;
503 struct elf_link_hash_entry *dir, *ind;
505 struct elf64_x86_64_link_hash_entry *edir, *eind;
507 edir = (struct elf64_x86_64_link_hash_entry *) dir;
508 eind = (struct elf64_x86_64_link_hash_entry *) ind;
510 if (eind->dyn_relocs != NULL)
512 if (edir->dyn_relocs != NULL)
514 struct elf64_x86_64_dyn_relocs **pp;
515 struct elf64_x86_64_dyn_relocs *p;
517 if (ind->root.type == bfd_link_hash_indirect)
520 /* Add reloc counts against the weak sym to the strong sym
521 list. Merge any entries against the same section. */
522 for (pp = &eind->dyn_relocs; (p = *pp) != NULL; )
524 struct elf64_x86_64_dyn_relocs *q;
526 for (q = edir->dyn_relocs; q != NULL; q = q->next)
527 if (q->sec == p->sec)
529 q->pc_count += p->pc_count;
530 q->count += p->count;
537 *pp = edir->dyn_relocs;
540 edir->dyn_relocs = eind->dyn_relocs;
541 eind->dyn_relocs = NULL;
544 _bfd_elf_link_hash_copy_indirect (bed, dir, ind);
548 elf64_x86_64_elf_object_p (abfd)
551 /* Set the right machine number for an x86-64 elf64 file. */
552 bfd_default_set_arch_mach (abfd, bfd_arch_i386, bfd_mach_x86_64);
556 /* Look through the relocs for a section during the first phase, and
557 calculate needed space in the global offset table, procedure
558 linkage table, and dynamic reloc sections. */
561 elf64_x86_64_check_relocs (abfd, info, sec, relocs)
563 struct bfd_link_info *info;
565 const Elf_Internal_Rela *relocs;
567 struct elf64_x86_64_link_hash_table *htab;
568 Elf_Internal_Shdr *symtab_hdr;
569 struct elf_link_hash_entry **sym_hashes;
570 const Elf_Internal_Rela *rel;
571 const Elf_Internal_Rela *rel_end;
574 if (info->relocateable)
577 htab = elf64_x86_64_hash_table (info);
578 symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
579 sym_hashes = elf_sym_hashes (abfd);
583 rel_end = relocs + sec->reloc_count;
584 for (rel = relocs; rel < rel_end; rel++)
586 unsigned long r_symndx;
587 struct elf_link_hash_entry *h;
589 r_symndx = ELF64_R_SYM (rel->r_info);
591 if (r_symndx >= NUM_SHDR_ENTRIES (symtab_hdr))
593 (*_bfd_error_handler) (_("%s: bad symbol index: %d"),
594 bfd_archive_filename (abfd),
599 if (r_symndx < symtab_hdr->sh_info)
602 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
604 switch (ELF64_R_TYPE (rel->r_info))
607 case R_X86_64_GOTPCREL:
608 /* This symbol requires a global offset table entry. */
611 h->got.refcount += 1;
615 bfd_signed_vma *local_got_refcounts;
617 /* This is a global offset table entry for a local symbol. */
618 local_got_refcounts = elf_local_got_refcounts (abfd);
619 if (local_got_refcounts == NULL)
623 size = symtab_hdr->sh_info;
624 size *= sizeof (bfd_signed_vma);
625 local_got_refcounts = ((bfd_signed_vma *)
626 bfd_zalloc (abfd, size));
627 if (local_got_refcounts == NULL)
629 elf_local_got_refcounts (abfd) = local_got_refcounts;
631 local_got_refcounts[r_symndx] += 1;
635 //case R_X86_64_GOTPCREL:
636 if (htab->sgot == NULL)
638 if (htab->elf.dynobj == NULL)
639 htab->elf.dynobj = abfd;
640 if (!create_got_section (htab->elf.dynobj, info))
646 /* This symbol requires a procedure linkage table entry. We
647 actually build the entry in adjust_dynamic_symbol,
648 because this might be a case of linking PIC code which is
649 never referenced by a dynamic object, in which case we
650 don't need to generate a procedure linkage table entry
653 /* If this is a local symbol, we resolve it directly without
654 creating a procedure linkage table entry. */
658 h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
659 h->plt.refcount += 1;
666 /* Let's help debug shared library creation. These relocs
667 cannot be used in shared libs. Don't error out for
668 sections we don't care about, such as debug sections or
669 non-constant sections. */
671 && (sec->flags & SEC_ALLOC) != 0
672 && (sec->flags & SEC_READONLY) != 0)
674 (*_bfd_error_handler)
675 (_("%s: relocation %s can not be used when making a shared object; recompile with -fPIC"),
676 bfd_archive_filename (abfd),
677 x86_64_elf_howto_table[ELF64_R_TYPE (rel->r_info)].name);
678 bfd_set_error (bfd_error_bad_value);
687 if (h != NULL && !info->shared)
689 /* If this reloc is in a read-only section, we might
690 need a copy reloc. We can't check reliably at this
691 stage whether the section is read-only, as input
692 sections have not yet been mapped to output sections.
693 Tentatively set the flag for now, and correct in
694 adjust_dynamic_symbol. */
695 h->elf_link_hash_flags |= ELF_LINK_NON_GOT_REF;
697 /* We may need a .plt entry if the function this reloc
698 refers to is in a shared lib. */
699 h->plt.refcount += 1;
702 /* If we are creating a shared library, and this is a reloc
703 against a global symbol, or a non PC relative reloc
704 against a local symbol, then we need to copy the reloc
705 into the shared library. However, if we are linking with
706 -Bsymbolic, we do not need to copy a reloc against a
707 global symbol which is defined in an object we are
708 including in the link (i.e., DEF_REGULAR is set). At
709 this point we have not seen all the input files, so it is
710 possible that DEF_REGULAR is not set now but will be set
711 later (it is never cleared). In case of a weak definition,
712 DEF_REGULAR may be cleared later by a strong definition in
713 a shared library. We account for that possibility below by
714 storing information in the relocs_copied field of the hash
715 table entry. A similar situation occurs when creating
716 shared libraries and symbol visibility changes render the
719 If on the other hand, we are creating an executable, we
720 may need to keep relocations for symbols satisfied by a
721 dynamic library if we manage to avoid copy relocs for the
724 && (sec->flags & SEC_ALLOC) != 0
725 && (((ELF64_R_TYPE (rel->r_info) != R_X86_64_PC8)
726 && (ELF64_R_TYPE (rel->r_info) != R_X86_64_PC16)
727 && (ELF64_R_TYPE (rel->r_info) != R_X86_64_PC32))
730 || h->root.type == bfd_link_hash_defweak
731 || (h->elf_link_hash_flags
732 & ELF_LINK_HASH_DEF_REGULAR) == 0))))
734 && (sec->flags & SEC_ALLOC) != 0
736 && (h->root.type == bfd_link_hash_defweak
737 || (h->elf_link_hash_flags
738 & ELF_LINK_HASH_DEF_REGULAR) == 0)))
740 struct elf64_x86_64_dyn_relocs *p;
741 struct elf64_x86_64_dyn_relocs **head;
743 /* We must copy these reloc types into the output file.
744 Create a reloc section in dynobj and make room for
751 name = (bfd_elf_string_from_elf_section
753 elf_elfheader (abfd)->e_shstrndx,
754 elf_section_data (sec)->rel_hdr.sh_name));
758 if (strncmp (name, ".rela", 5) != 0
759 || strcmp (bfd_get_section_name (abfd, sec),
762 (*_bfd_error_handler)
763 (_("%s: bad relocation section name `%s\'"),
764 bfd_archive_filename (abfd), name);
767 if (htab->elf.dynobj == NULL)
768 htab->elf.dynobj = abfd;
770 dynobj = htab->elf.dynobj;
772 sreloc = bfd_get_section_by_name (dynobj, name);
777 sreloc = bfd_make_section (dynobj, name);
778 flags = (SEC_HAS_CONTENTS | SEC_READONLY
779 | SEC_IN_MEMORY | SEC_LINKER_CREATED);
780 if ((sec->flags & SEC_ALLOC) != 0)
781 flags |= SEC_ALLOC | SEC_LOAD;
783 || ! bfd_set_section_flags (dynobj, sreloc, flags)
784 || ! bfd_set_section_alignment (dynobj, sreloc, 3))
787 elf_section_data (sec)->sreloc = sreloc;
790 /* If this is a global symbol, we count the number of
791 relocations we need for this symbol. */
794 head = &((struct elf64_x86_64_link_hash_entry *) h)->dyn_relocs;
798 /* Track dynamic relocs needed for local syms too.
799 We really need local syms available to do this
803 s = bfd_section_from_r_symndx (abfd, &htab->sym_sec,
808 head = ((struct elf64_x86_64_dyn_relocs **)
809 &elf_section_data (s)->local_dynrel);
813 if (p == NULL || p->sec != sec)
815 bfd_size_type amt = sizeof *p;
816 p = ((struct elf64_x86_64_dyn_relocs *)
817 bfd_alloc (htab->elf.dynobj, amt));
828 if (ELF64_R_TYPE (rel->r_info) == R_X86_64_PC8
829 || ELF64_R_TYPE (rel->r_info) == R_X86_64_PC16
830 || ELF64_R_TYPE (rel->r_info) == R_X86_64_PC32)
835 /* This relocation describes the C++ object vtable hierarchy.
836 Reconstruct it for later use during GC. */
837 case R_X86_64_GNU_VTINHERIT:
838 if (!_bfd_elf64_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
842 /* This relocation describes which C++ vtable entries are actually
843 used. Record for later use during GC. */
844 case R_X86_64_GNU_VTENTRY:
845 if (!_bfd_elf64_gc_record_vtentry (abfd, sec, h, rel->r_addend))
857 /* Return the section that should be marked against GC for a given
861 elf64_x86_64_gc_mark_hook (sec, info, rel, h, sym)
863 struct bfd_link_info *info ATTRIBUTE_UNUSED;
864 Elf_Internal_Rela *rel;
865 struct elf_link_hash_entry *h;
866 Elf_Internal_Sym *sym;
870 switch (ELF64_R_TYPE (rel->r_info))
872 case R_X86_64_GNU_VTINHERIT:
873 case R_X86_64_GNU_VTENTRY:
877 switch (h->root.type)
879 case bfd_link_hash_defined:
880 case bfd_link_hash_defweak:
881 return h->root.u.def.section;
883 case bfd_link_hash_common:
884 return h->root.u.c.p->section;
892 return bfd_section_from_elf_index (sec->owner, sym->st_shndx);
897 /* Update the got entry reference counts for the section being removed. */
900 elf64_x86_64_gc_sweep_hook (abfd, info, sec, relocs)
902 struct bfd_link_info *info;
904 const Elf_Internal_Rela *relocs;
906 Elf_Internal_Shdr *symtab_hdr;
907 struct elf_link_hash_entry **sym_hashes;
908 bfd_signed_vma *local_got_refcounts;
909 const Elf_Internal_Rela *rel, *relend;
910 unsigned long r_symndx;
911 struct elf_link_hash_entry *h;
913 elf_section_data (sec)->local_dynrel = NULL;
915 symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
916 sym_hashes = elf_sym_hashes (abfd);
917 local_got_refcounts = elf_local_got_refcounts (abfd);
919 relend = relocs + sec->reloc_count;
920 for (rel = relocs; rel < relend; rel++)
921 switch (ELF64_R_TYPE (rel->r_info))
924 case R_X86_64_GOTPCREL:
925 r_symndx = ELF64_R_SYM (rel->r_info);
926 if (r_symndx >= symtab_hdr->sh_info)
928 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
929 if (h->got.refcount > 0)
930 h->got.refcount -= 1;
932 else if (local_got_refcounts != NULL)
934 if (local_got_refcounts[r_symndx] > 0)
935 local_got_refcounts[r_symndx] -= 1;
947 r_symndx = ELF64_R_SYM (rel->r_info);
948 if (r_symndx >= symtab_hdr->sh_info)
950 struct elf64_x86_64_link_hash_entry *eh;
951 struct elf64_x86_64_dyn_relocs **pp;
952 struct elf64_x86_64_dyn_relocs *p;
954 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
956 if (!info->shared && h->plt.refcount > 0)
957 h->plt.refcount -= 1;
959 eh = (struct elf64_x86_64_link_hash_entry *) h;
961 for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
964 if (ELF64_R_TYPE (rel->r_info) == R_X86_64_PC8
965 || ELF64_R_TYPE (rel->r_info) == R_X86_64_PC16
966 || ELF64_R_TYPE (rel->r_info) == R_X86_64_PC32)
978 r_symndx = ELF64_R_SYM (rel->r_info);
979 if (r_symndx >= symtab_hdr->sh_info)
981 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
982 if (h->plt.refcount > 0)
983 h->plt.refcount -= 1;
994 /* Adjust a symbol defined by a dynamic object and referenced by a
995 regular object. The current definition is in some section of the
996 dynamic object, but we're not including those sections. We have to
997 change the definition to something the rest of the link can
1001 elf64_x86_64_adjust_dynamic_symbol (info, h)
1002 struct bfd_link_info *info;
1003 struct elf_link_hash_entry *h;
1005 struct elf64_x86_64_link_hash_table *htab;
1006 struct elf64_x86_64_link_hash_entry * eh;
1007 struct elf64_x86_64_dyn_relocs *p;
1009 unsigned int power_of_two;
1011 /* If this is a function, put it in the procedure linkage table. We
1012 will fill in the contents of the procedure linkage table later,
1013 when we know the address of the .got section. */
1014 if (h->type == STT_FUNC
1015 || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
1017 if (h->plt.refcount <= 0
1019 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0
1020 && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) == 0
1021 && h->root.type != bfd_link_hash_undefweak
1022 && h->root.type != bfd_link_hash_undefined))
1024 /* This case can occur if we saw a PLT32 reloc in an input
1025 file, but the symbol was never referred to by a dynamic
1026 object, or if all references were garbage collected. In
1027 such a case, we don't actually need to build a procedure
1028 linkage table, and we can just do a PC32 reloc instead. */
1029 h->plt.offset = (bfd_vma) -1;
1030 h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
1036 /* It's possible that we incorrectly decided a .plt reloc was
1037 needed for an R_X86_64_PC32 reloc to a non-function sym in
1038 check_relocs. We can't decide accurately between function and
1039 non-function syms in check-relocs; Objects loaded later in
1040 the link may change h->type. So fix it now. */
1041 h->plt.offset = (bfd_vma) -1;
1043 /* If this is a weak symbol, and there is a real definition, the
1044 processor independent code will have arranged for us to see the
1045 real definition first, and we can just use the same value. */
1046 if (h->weakdef != NULL)
1048 BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined
1049 || h->weakdef->root.type == bfd_link_hash_defweak);
1050 h->root.u.def.section = h->weakdef->root.u.def.section;
1051 h->root.u.def.value = h->weakdef->root.u.def.value;
1055 /* This is a reference to a symbol defined by a dynamic object which
1056 is not a function. */
1058 /* If we are creating a shared library, we must presume that the
1059 only references to the symbol are via the global offset table.
1060 For such cases we need not do anything here; the relocations will
1061 be handled correctly by relocate_section. */
1065 /* If there are no references to this symbol that do not use the
1066 GOT, we don't need to generate a copy reloc. */
1067 if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0)
1070 /* If -z nocopyreloc was given, we won't generate them either. */
1071 if (info->nocopyreloc)
1073 h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF;
1077 eh = (struct elf64_x86_64_link_hash_entry *) h;
1078 for (p = eh->dyn_relocs; p != NULL; p = p->next)
1080 s = p->sec->output_section;
1081 if (s != NULL && (s->flags & SEC_READONLY) != 0)
1085 /* If we didn't find any dynamic relocs in read-only sections, then
1086 we'll be keeping the dynamic relocs and avoiding the copy reloc. */
1089 h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF;
1093 /* We must allocate the symbol in our .dynbss section, which will
1094 become part of the .bss section of the executable. There will be
1095 an entry for this symbol in the .dynsym section. The dynamic
1096 object will contain position independent code, so all references
1097 from the dynamic object to this symbol will go through the global
1098 offset table. The dynamic linker will use the .dynsym entry to
1099 determine the address it must put in the global offset table, so
1100 both the dynamic object and the regular object will refer to the
1101 same memory location for the variable. */
1103 htab = elf64_x86_64_hash_table (info);
1105 /* We must generate a R_X86_64_COPY reloc to tell the dynamic linker
1106 to copy the initial value out of the dynamic object and into the
1107 runtime process image. */
1108 if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
1110 htab->srelbss->_raw_size += sizeof (Elf64_External_Rela);
1111 h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY;
1114 /* We need to figure out the alignment required for this symbol. I
1115 have no idea how ELF linkers handle this. 16-bytes is the size
1116 of the largest type that requires hard alignment -- long double. */
1117 /* FIXME: This is VERY ugly. Should be fixed for all architectures using
1119 power_of_two = bfd_log2 (h->size);
1120 if (power_of_two > 4)
1123 /* Apply the required alignment. */
1125 s->_raw_size = BFD_ALIGN (s->_raw_size, (bfd_size_type) (1 << power_of_two));
1126 if (power_of_two > bfd_get_section_alignment (htab->elf.dynobj, s))
1128 if (! bfd_set_section_alignment (htab->elf.dynobj, s, power_of_two))
1132 /* Define the symbol as being at this point in the section. */
1133 h->root.u.def.section = s;
1134 h->root.u.def.value = s->_raw_size;
1136 /* Increment the section size to make room for the symbol. */
1137 s->_raw_size += h->size;
1142 /* This is the condition under which elf64_x86_64_finish_dynamic_symbol
1143 will be called from elflink.h. If elflink.h doesn't call our
1144 finish_dynamic_symbol routine, we'll need to do something about
1145 initializing any .plt and .got entries in elf64_x86_64_relocate_section. */
1146 #define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, INFO, H) \
1148 && ((INFO)->shared \
1149 || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0) \
1150 && ((H)->dynindx != -1 \
1151 || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0))
1153 /* Allocate space in .plt, .got and associated reloc sections for
1157 allocate_dynrelocs (h, inf)
1158 struct elf_link_hash_entry *h;
1161 struct bfd_link_info *info;
1162 struct elf64_x86_64_link_hash_table *htab;
1163 struct elf64_x86_64_link_hash_entry *eh;
1164 struct elf64_x86_64_dyn_relocs *p;
1166 if (h->root.type == bfd_link_hash_indirect)
1169 if (h->root.type == bfd_link_hash_warning)
1170 h = (struct elf_link_hash_entry *) h->root.u.i.link;
1172 info = (struct bfd_link_info *) inf;
1173 htab = elf64_x86_64_hash_table (info);
1175 if (htab->elf.dynamic_sections_created
1176 && h->plt.refcount > 0)
1178 /* Make sure this symbol is output as a dynamic symbol.
1179 Undefined weak syms won't yet be marked as dynamic. */
1180 if (h->dynindx == -1
1181 && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
1183 if (! bfd_elf64_link_record_dynamic_symbol (info, h))
1187 if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info, h))
1189 asection *s = htab->splt;
1191 /* If this is the first .plt entry, make room for the special
1193 if (s->_raw_size == 0)
1194 s->_raw_size += PLT_ENTRY_SIZE;
1196 h->plt.offset = s->_raw_size;
1198 /* If this symbol is not defined in a regular file, and we are
1199 not generating a shared library, then set the symbol to this
1200 location in the .plt. This is required to make function
1201 pointers compare as equal between the normal executable and
1202 the shared library. */
1204 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
1206 h->root.u.def.section = s;
1207 h->root.u.def.value = h->plt.offset;
1210 /* Make room for this entry. */
1211 s->_raw_size += PLT_ENTRY_SIZE;
1213 /* We also need to make an entry in the .got.plt section, which
1214 will be placed in the .got section by the linker script. */
1215 htab->sgotplt->_raw_size += GOT_ENTRY_SIZE;
1217 /* We also need to make an entry in the .rela.plt section. */
1218 htab->srelplt->_raw_size += sizeof (Elf64_External_Rela);
1222 h->plt.offset = (bfd_vma) -1;
1223 h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
1228 h->plt.offset = (bfd_vma) -1;
1229 h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
1232 if (h->got.refcount > 0)
1237 /* Make sure this symbol is output as a dynamic symbol.
1238 Undefined weak syms won't yet be marked as dynamic. */
1239 if (h->dynindx == -1
1240 && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
1242 if (! bfd_elf64_link_record_dynamic_symbol (info, h))
1247 h->got.offset = s->_raw_size;
1248 s->_raw_size += GOT_ENTRY_SIZE;
1249 dyn = htab->elf.dynamic_sections_created;
1250 if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h))
1251 htab->srelgot->_raw_size += sizeof (Elf64_External_Rela);
1254 h->got.offset = (bfd_vma) -1;
1256 eh = (struct elf64_x86_64_link_hash_entry *) h;
1257 if (eh->dyn_relocs == NULL)
1260 /* In the shared -Bsymbolic case, discard space allocated for
1261 dynamic pc-relative relocs against symbols which turn out to be
1262 defined in regular objects. For the normal shared case, discard
1263 space for pc-relative relocs that have become local due to symbol
1264 visibility changes. */
1268 if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0
1269 && ((h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0
1272 struct elf64_x86_64_dyn_relocs **pp;
1274 for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
1276 p->count -= p->pc_count;
1287 /* For the non-shared case, discard space for relocs against
1288 symbols which turn out to need copy relocs or are not
1291 if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0
1292 && (((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
1293 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
1294 || (htab->elf.dynamic_sections_created
1295 && (h->root.type == bfd_link_hash_undefweak
1296 || h->root.type == bfd_link_hash_undefined))))
1298 /* Make sure this symbol is output as a dynamic symbol.
1299 Undefined weak syms won't yet be marked as dynamic. */
1300 if (h->dynindx == -1
1301 && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
1303 if (! bfd_elf64_link_record_dynamic_symbol (info, h))
1307 /* If that succeeded, we know we'll be keeping all the
1309 if (h->dynindx != -1)
1313 eh->dyn_relocs = NULL;
1318 /* Finally, allocate space. */
1319 for (p = eh->dyn_relocs; p != NULL; p = p->next)
1321 asection *sreloc = elf_section_data (p->sec)->sreloc;
1322 sreloc->_raw_size += p->count * sizeof (Elf64_External_Rela);
1328 /* Find any dynamic relocs that apply to read-only sections. */
1331 readonly_dynrelocs (h, inf)
1332 struct elf_link_hash_entry *h;
1335 struct elf64_x86_64_link_hash_entry *eh;
1336 struct elf64_x86_64_dyn_relocs *p;
1338 if (h->root.type == bfd_link_hash_warning)
1339 h = (struct elf_link_hash_entry *) h->root.u.i.link;
1341 eh = (struct elf64_x86_64_link_hash_entry *) h;
1342 for (p = eh->dyn_relocs; p != NULL; p = p->next)
1344 asection *s = p->sec->output_section;
1346 if (s != NULL && (s->flags & SEC_READONLY) != 0)
1348 struct bfd_link_info *info = (struct bfd_link_info *) inf;
1350 info->flags |= DF_TEXTREL;
1352 /* Not an error, just cut short the traversal. */
1359 /* Set the sizes of the dynamic sections. */
1362 elf64_x86_64_size_dynamic_sections (output_bfd, info)
1363 bfd *output_bfd ATTRIBUTE_UNUSED;
1364 struct bfd_link_info *info;
1366 struct elf64_x86_64_link_hash_table *htab;
1372 htab = elf64_x86_64_hash_table (info);
1373 dynobj = htab->elf.dynobj;
1377 if (htab->elf.dynamic_sections_created)
1379 /* Set the contents of the .interp section to the interpreter. */
1382 s = bfd_get_section_by_name (dynobj, ".interp");
1385 s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;
1386 s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
1390 /* Set up .got offsets for local syms, and space for local dynamic
1392 for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
1394 bfd_signed_vma *local_got;
1395 bfd_signed_vma *end_local_got;
1396 bfd_size_type locsymcount;
1397 Elf_Internal_Shdr *symtab_hdr;
1400 if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour)
1403 for (s = ibfd->sections; s != NULL; s = s->next)
1405 struct elf64_x86_64_dyn_relocs *p;
1407 for (p = *((struct elf64_x86_64_dyn_relocs **)
1408 &elf_section_data (s)->local_dynrel);
1412 if (!bfd_is_abs_section (p->sec)
1413 && bfd_is_abs_section (p->sec->output_section))
1415 /* Input section has been discarded, either because
1416 it is a copy of a linkonce section or due to
1417 linker script /DISCARD/, so we'll be discarding
1420 else if (p->count != 0)
1422 srel = elf_section_data (p->sec)->sreloc;
1423 srel->_raw_size += p->count * sizeof (Elf64_External_Rela);
1424 if ((p->sec->output_section->flags & SEC_READONLY) != 0)
1425 info->flags |= DF_TEXTREL;
1431 local_got = elf_local_got_refcounts (ibfd);
1435 symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
1436 locsymcount = symtab_hdr->sh_info;
1437 end_local_got = local_got + locsymcount;
1439 srel = htab->srelgot;
1440 for (; local_got < end_local_got; ++local_got)
1444 *local_got = s->_raw_size;
1445 s->_raw_size += GOT_ENTRY_SIZE;
1447 srel->_raw_size += sizeof (Elf64_External_Rela);
1450 *local_got = (bfd_vma) -1;
1454 /* Allocate global sym .plt and .got entries, and space for global
1455 sym dynamic relocs. */
1456 elf_link_hash_traverse (&htab->elf, allocate_dynrelocs, (PTR) info);
1458 /* We now have determined the sizes of the various dynamic sections.
1459 Allocate memory for them. */
1461 for (s = dynobj->sections; s != NULL; s = s->next)
1463 if ((s->flags & SEC_LINKER_CREATED) == 0)
1468 || s == htab->sgotplt)
1470 /* Strip this section if we don't need it; see the
1473 else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0)
1475 if (s->_raw_size != 0 && s != htab->srelplt)
1478 /* We use the reloc_count field as a counter if we need
1479 to copy relocs into the output file. */
1484 /* It's not one of our sections, so don't allocate space. */
1488 if (s->_raw_size == 0)
1490 /* If we don't need this section, strip it from the
1491 output file. This is mostly to handle .rela.bss and
1492 .rela.plt. We must create both sections in
1493 create_dynamic_sections, because they must be created
1494 before the linker maps input sections to output
1495 sections. The linker does that before
1496 adjust_dynamic_symbol is called, and it is that
1497 function which decides whether anything needs to go
1498 into these sections. */
1500 _bfd_strip_section_from_output (info, s);
1504 /* Allocate memory for the section contents. We use bfd_zalloc
1505 here in case unused entries are not reclaimed before the
1506 section's contents are written out. This should not happen,
1507 but this way if it does, we get a R_X86_64_NONE reloc instead
1509 s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);
1510 if (s->contents == NULL)
1514 if (htab->elf.dynamic_sections_created)
1516 /* Add some entries to the .dynamic section. We fill in the
1517 values later, in elf64_x86_64_finish_dynamic_sections, but we
1518 must add the entries now so that we get the correct size for
1519 the .dynamic section. The DT_DEBUG entry is filled in by the
1520 dynamic linker and used by the debugger. */
1521 #define add_dynamic_entry(TAG, VAL) \
1522 bfd_elf64_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
1526 if (!add_dynamic_entry (DT_DEBUG, 0))
1530 if (htab->splt->_raw_size != 0)
1532 if (!add_dynamic_entry (DT_PLTGOT, 0)
1533 || !add_dynamic_entry (DT_PLTRELSZ, 0)
1534 || !add_dynamic_entry (DT_PLTREL, DT_RELA)
1535 || !add_dynamic_entry (DT_JMPREL, 0))
1541 if (!add_dynamic_entry (DT_RELA, 0)
1542 || !add_dynamic_entry (DT_RELASZ, 0)
1543 || !add_dynamic_entry (DT_RELAENT, sizeof (Elf64_External_Rela)))
1546 /* If any dynamic relocs apply to a read-only section,
1547 then we need a DT_TEXTREL entry. */
1548 if ((info->flags & DF_TEXTREL) == 0)
1549 elf_link_hash_traverse (&htab->elf, readonly_dynrelocs,
1552 if ((info->flags & DF_TEXTREL) != 0)
1554 if (!add_dynamic_entry (DT_TEXTREL, 0))
1559 #undef add_dynamic_entry
1564 /* Relocate an x86_64 ELF section. */
1567 elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section,
1568 contents, relocs, local_syms, local_sections)
1570 struct bfd_link_info *info;
1572 asection *input_section;
1574 Elf_Internal_Rela *relocs;
1575 Elf_Internal_Sym *local_syms;
1576 asection **local_sections;
1578 struct elf64_x86_64_link_hash_table *htab;
1579 Elf_Internal_Shdr *symtab_hdr;
1580 struct elf_link_hash_entry **sym_hashes;
1581 bfd_vma *local_got_offsets;
1582 Elf_Internal_Rela *rel;
1583 Elf_Internal_Rela *relend;
1585 if (info->relocateable)
1588 htab = elf64_x86_64_hash_table (info);
1589 symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
1590 sym_hashes = elf_sym_hashes (input_bfd);
1591 local_got_offsets = elf_local_got_offsets (input_bfd);
1594 relend = relocs + input_section->reloc_count;
1595 for (; rel < relend; rel++)
1598 reloc_howto_type *howto;
1599 unsigned long r_symndx;
1600 struct elf_link_hash_entry *h;
1601 Elf_Internal_Sym *sym;
1605 boolean unresolved_reloc;
1606 bfd_reloc_status_type r;
1608 r_type = ELF64_R_TYPE (rel->r_info);
1609 if (r_type == (int) R_X86_64_GNU_VTINHERIT
1610 || r_type == (int) R_X86_64_GNU_VTENTRY)
1613 if (r_type < 0 || r_type >= R_X86_64_max)
1615 bfd_set_error (bfd_error_bad_value);
1619 howto = x86_64_elf_howto_table + r_type;
1620 r_symndx = ELF64_R_SYM (rel->r_info);
1624 unresolved_reloc = false;
1625 if (r_symndx < symtab_hdr->sh_info)
1627 sym = local_syms + r_symndx;
1628 sec = local_sections[r_symndx];
1630 relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
1634 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
1635 while (h->root.type == bfd_link_hash_indirect
1636 || h->root.type == bfd_link_hash_warning)
1637 h = (struct elf_link_hash_entry *) h->root.u.i.link;
1639 if (h->root.type == bfd_link_hash_defined
1640 || h->root.type == bfd_link_hash_defweak)
1642 sec = h->root.u.def.section;
1643 if (sec->output_section == NULL)
1645 /* Set a flag that will be cleared later if we find a
1646 relocation value for this symbol. output_section
1647 is typically NULL for symbols satisfied by a shared
1649 unresolved_reloc = true;
1653 relocation = (h->root.u.def.value
1654 + sec->output_section->vma
1655 + sec->output_offset);
1657 else if (h->root.type == bfd_link_hash_undefweak)
1659 else if (info->shared
1660 && (!info->symbolic || info->allow_shlib_undefined)
1661 && !info->no_undefined
1662 && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
1666 if (! ((*info->callbacks->undefined_symbol)
1667 (info, h->root.root.string, input_bfd,
1668 input_section, rel->r_offset,
1669 (!info->shared || info->no_undefined
1670 || ELF_ST_VISIBILITY (h->other)))))
1675 /* When generating a shared object, the relocations handled here are
1676 copied into the output file to be resolved at run time. */
1679 case R_X86_64_GOT32:
1680 /* Relocation is to the entry for this symbol in the global
1682 case R_X86_64_GOTPCREL:
1683 /* Use global offset table as symbol value. */
1684 if (htab->sgot == NULL)
1691 off = h->got.offset;
1692 dyn = htab->elf.dynamic_sections_created;
1694 if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h)
1698 || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL))
1699 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
1701 /* This is actually a static link, or it is a -Bsymbolic
1702 link and the symbol is defined locally, or the symbol
1703 was forced to be local because of a version file. We
1704 must initialize this entry in the global offset table.
1705 Since the offset must always be a multiple of 8, we
1706 use the least significant bit to record whether we
1707 have initialized it already.
1709 When doing a dynamic link, we create a .rela.got
1710 relocation entry to initialize the value. This is
1711 done in the finish_dynamic_symbol routine. */
1716 bfd_put_64 (output_bfd, relocation,
1717 htab->sgot->contents + off);
1722 unresolved_reloc = false;
1726 if (local_got_offsets == NULL)
1729 off = local_got_offsets[r_symndx];
1731 /* The offset must always be a multiple of 8. We use
1732 the least significant bit to record whether we have
1733 already generated the necessary reloc. */
1738 bfd_put_64 (output_bfd, relocation,
1739 htab->sgot->contents + off);
1744 Elf_Internal_Rela outrel;
1745 Elf64_External_Rela *loc;
1747 /* We need to generate a R_X86_64_RELATIVE reloc
1748 for the dynamic linker. */
1749 srelgot = htab->srelgot;
1750 if (srelgot == NULL)
1753 outrel.r_offset = (htab->sgot->output_section->vma
1754 + htab->sgot->output_offset
1756 outrel.r_info = ELF64_R_INFO (0, R_X86_64_RELATIVE);
1757 outrel.r_addend = relocation;
1758 loc = (Elf64_External_Rela *) srelgot->contents;
1759 loc += srelgot->reloc_count++;
1760 bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
1763 local_got_offsets[r_symndx] |= 1;
1767 if (off >= (bfd_vma) -2)
1770 relocation = htab->sgot->output_offset + off;
1771 if (r_type == R_X86_64_GOTPCREL)
1772 relocation += htab->sgot->output_section->vma;
1776 case R_X86_64_PLT32:
1777 /* Relocation is to the entry for this symbol in the
1778 procedure linkage table. */
1780 /* Resolve a PLT32 reloc against a local symbol directly,
1781 without using the procedure linkage table. */
1785 if (h->plt.offset == (bfd_vma) -1
1786 || htab->splt == NULL)
1788 /* We didn't make a PLT entry for this symbol. This
1789 happens when statically linking PIC code, or when
1790 using -Bsymbolic. */
1794 relocation = (htab->splt->output_section->vma
1795 + htab->splt->output_offset
1797 unresolved_reloc = false;
1807 /* FIXME: The ABI says the linker should make sure the value is
1808 the same when it's zeroextended to 64 bit. */
1810 /* r_symndx will be zero only for relocs against symbols
1811 from removed linkonce sections, or sections discarded by
1814 || (input_section->flags & SEC_ALLOC) == 0)
1818 && ((r_type != R_X86_64_PC8
1819 && r_type != R_X86_64_PC16
1820 && r_type != R_X86_64_PC32)
1823 && (! info->symbolic
1824 || (h->elf_link_hash_flags
1825 & ELF_LINK_HASH_DEF_REGULAR) == 0))))
1829 && (h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0
1830 && (((h->elf_link_hash_flags
1831 & ELF_LINK_HASH_DEF_DYNAMIC) != 0
1832 && (h->elf_link_hash_flags
1833 & ELF_LINK_HASH_DEF_REGULAR) == 0)
1834 || h->root.type == bfd_link_hash_undefweak
1835 || h->root.type == bfd_link_hash_undefined)))
1837 Elf_Internal_Rela outrel;
1838 boolean skip, relocate;
1840 Elf64_External_Rela *loc;
1842 /* When generating a shared object, these relocations
1843 are copied into the output file to be resolved at run
1850 _bfd_elf_section_offset (output_bfd, info, input_section,
1852 if (outrel.r_offset == (bfd_vma) -1)
1854 else if (outrel.r_offset == (bfd_vma) -2)
1855 skip = true, relocate = true;
1857 outrel.r_offset += (input_section->output_section->vma
1858 + input_section->output_offset);
1861 memset (&outrel, 0, sizeof outrel);
1863 /* h->dynindx may be -1 if this symbol was marked to
1867 && (r_type == R_X86_64_PC8
1868 || r_type == R_X86_64_PC16
1869 || r_type == R_X86_64_PC32
1872 || (h->elf_link_hash_flags
1873 & ELF_LINK_HASH_DEF_REGULAR) == 0))
1875 outrel.r_info = ELF64_R_INFO (h->dynindx, r_type);
1876 outrel.r_addend = rel->r_addend;
1880 /* This symbol is local, or marked to become local. */
1881 if (r_type == R_X86_64_64)
1884 outrel.r_info = ELF64_R_INFO (0, R_X86_64_RELATIVE);
1885 outrel.r_addend = relocation + rel->r_addend;
1892 sec = local_sections[r_symndx];
1895 BFD_ASSERT (h->root.type == bfd_link_hash_defined
1897 == bfd_link_hash_defweak));
1898 sec = h->root.u.def.section;
1900 if (sec != NULL && bfd_is_abs_section (sec))
1902 else if (sec == NULL || sec->owner == NULL)
1904 bfd_set_error (bfd_error_bad_value);
1911 osec = sec->output_section;
1912 sindx = elf_section_data (osec)->dynindx;
1913 BFD_ASSERT (sindx > 0);
1916 outrel.r_info = ELF64_R_INFO (sindx, r_type);
1917 outrel.r_addend = relocation + rel->r_addend;
1921 sreloc = elf_section_data (input_section)->sreloc;
1925 loc = (Elf64_External_Rela *) sreloc->contents;
1926 loc += sreloc->reloc_count++;
1927 bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
1929 /* If this reloc is against an external symbol, we do
1930 not want to fiddle with the addend. Otherwise, we
1931 need to include the symbol value so that it becomes
1932 an addend for the dynamic reloc. */
1943 /* Dynamic relocs are not propagated for SEC_DEBUGGING sections
1944 because such sections are not SEC_ALLOC and thus ld.so will
1945 not process them. */
1946 if (unresolved_reloc
1947 && !((input_section->flags & SEC_DEBUGGING) != 0
1948 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0))
1949 (*_bfd_error_handler)
1950 (_("%s(%s+0x%lx): unresolvable relocation against symbol `%s'"),
1951 bfd_archive_filename (input_bfd),
1952 bfd_get_section_name (input_bfd, input_section),
1953 (long) rel->r_offset,
1954 h->root.root.string);
1956 r = _bfd_final_link_relocate (howto, input_bfd, input_section,
1957 contents, rel->r_offset,
1958 relocation, rel->r_addend);
1960 if (r != bfd_reloc_ok)
1965 name = h->root.root.string;
1968 name = bfd_elf_string_from_elf_section (input_bfd,
1969 symtab_hdr->sh_link,
1974 name = bfd_section_name (input_bfd, sec);
1977 if (r == bfd_reloc_overflow)
1980 if (! ((*info->callbacks->reloc_overflow)
1981 (info, name, howto->name, (bfd_vma) 0,
1982 input_bfd, input_section, rel->r_offset)))
1987 (*_bfd_error_handler)
1988 (_("%s(%s+0x%lx): reloc against `%s': error %d"),
1989 bfd_archive_filename (input_bfd),
1990 bfd_get_section_name (input_bfd, input_section),
1991 (long) rel->r_offset, name, (int) r);
2000 /* Finish up dynamic symbol handling. We set the contents of various
2001 dynamic sections here. */
2004 elf64_x86_64_finish_dynamic_symbol (output_bfd, info, h, sym)
2006 struct bfd_link_info *info;
2007 struct elf_link_hash_entry *h;
2008 Elf_Internal_Sym *sym;
2010 struct elf64_x86_64_link_hash_table *htab;
2012 htab = elf64_x86_64_hash_table (info);
2014 if (h->plt.offset != (bfd_vma) -1)
2018 Elf_Internal_Rela rela;
2019 Elf64_External_Rela *loc;
2021 /* This symbol has an entry in the procedure linkage table. Set
2024 if (h->dynindx == -1
2025 || htab->splt == NULL
2026 || htab->sgotplt == NULL
2027 || htab->srelplt == NULL)
2030 /* Get the index in the procedure linkage table which
2031 corresponds to this symbol. This is the index of this symbol
2032 in all the symbols for which we are making plt entries. The
2033 first entry in the procedure linkage table is reserved. */
2034 plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1;
2036 /* Get the offset into the .got table of the entry that
2037 corresponds to this function. Each .got entry is GOT_ENTRY_SIZE
2038 bytes. The first three are reserved for the dynamic linker. */
2039 got_offset = (plt_index + 3) * GOT_ENTRY_SIZE;
2041 /* Fill in the entry in the procedure linkage table. */
2042 memcpy (htab->splt->contents + h->plt.offset, elf64_x86_64_plt_entry,
2045 /* Insert the relocation positions of the plt section. The magic
2046 numbers at the end of the statements are the positions of the
2047 relocations in the plt section. */
2048 /* Put offset for jmp *name@GOTPCREL(%rip), since the
2049 instruction uses 6 bytes, subtract this value. */
2050 bfd_put_32 (output_bfd,
2051 (htab->sgotplt->output_section->vma
2052 + htab->sgotplt->output_offset
2054 - htab->splt->output_section->vma
2055 - htab->splt->output_offset
2058 htab->splt->contents + h->plt.offset + 2);
2059 /* Put relocation index. */
2060 bfd_put_32 (output_bfd, plt_index,
2061 htab->splt->contents + h->plt.offset + 7);
2062 /* Put offset for jmp .PLT0. */
2063 bfd_put_32 (output_bfd, - (h->plt.offset + PLT_ENTRY_SIZE),
2064 htab->splt->contents + h->plt.offset + 12);
2066 /* Fill in the entry in the global offset table, initially this
2067 points to the pushq instruction in the PLT which is at offset 6. */
2068 bfd_put_64 (output_bfd, (htab->splt->output_section->vma
2069 + htab->splt->output_offset
2070 + h->plt.offset + 6),
2071 htab->sgotplt->contents + got_offset);
2073 /* Fill in the entry in the .rela.plt section. */
2074 rela.r_offset = (htab->sgotplt->output_section->vma
2075 + htab->sgotplt->output_offset
2077 rela.r_info = ELF64_R_INFO (h->dynindx, R_X86_64_JUMP_SLOT);
2079 loc = (Elf64_External_Rela *) htab->srelplt->contents + plt_index;
2080 bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
2082 if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
2084 /* Mark the symbol as undefined, rather than as defined in
2085 the .plt section. Leave the value alone. This is a clue
2086 for the dynamic linker, to make function pointer
2087 comparisons work between an application and shared
2089 sym->st_shndx = SHN_UNDEF;
2093 if (h->got.offset != (bfd_vma) -1)
2095 Elf_Internal_Rela rela;
2096 Elf64_External_Rela *loc;
2098 /* This symbol has an entry in the global offset table. Set it
2101 if (htab->sgot == NULL || htab->srelgot == NULL)
2104 rela.r_offset = (htab->sgot->output_section->vma
2105 + htab->sgot->output_offset
2106 + (h->got.offset &~ (bfd_vma) 1));
2108 /* If this is a static link, or it is a -Bsymbolic link and the
2109 symbol is defined locally or was forced to be local because
2110 of a version file, we just want to emit a RELATIVE reloc.
2111 The entry in the global offset table will already have been
2112 initialized in the relocate_section function. */
2116 || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL))
2117 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
2119 BFD_ASSERT((h->got.offset & 1) != 0);
2120 rela.r_info = ELF64_R_INFO (0, R_X86_64_RELATIVE);
2121 rela.r_addend = (h->root.u.def.value
2122 + h->root.u.def.section->output_section->vma
2123 + h->root.u.def.section->output_offset);
2127 BFD_ASSERT((h->got.offset & 1) == 0);
2128 bfd_put_64 (output_bfd, (bfd_vma) 0,
2129 htab->sgot->contents + h->got.offset);
2130 rela.r_info = ELF64_R_INFO (h->dynindx, R_X86_64_GLOB_DAT);
2134 loc = (Elf64_External_Rela *) htab->srelgot->contents;
2135 loc += htab->srelgot->reloc_count++;
2136 bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
2139 if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
2141 Elf_Internal_Rela rela;
2142 Elf64_External_Rela *loc;
2144 /* This symbol needs a copy reloc. Set it up. */
2146 if (h->dynindx == -1
2147 || (h->root.type != bfd_link_hash_defined
2148 && h->root.type != bfd_link_hash_defweak)
2149 || htab->srelbss == NULL)
2152 rela.r_offset = (h->root.u.def.value
2153 + h->root.u.def.section->output_section->vma
2154 + h->root.u.def.section->output_offset);
2155 rela.r_info = ELF64_R_INFO (h->dynindx, R_X86_64_COPY);
2157 loc = (Elf64_External_Rela *) htab->srelbss->contents;
2158 loc += htab->srelbss->reloc_count++;
2159 bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
2162 /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */
2163 if (strcmp (h->root.root.string, "_DYNAMIC") == 0
2164 || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
2165 sym->st_shndx = SHN_ABS;
2170 /* Used to decide how to sort relocs in an optimal manner for the
2171 dynamic linker, before writing them out. */
2173 static enum elf_reloc_type_class
2174 elf64_x86_64_reloc_type_class (rela)
2175 const Elf_Internal_Rela *rela;
2177 switch ((int) ELF64_R_TYPE (rela->r_info))
2179 case R_X86_64_RELATIVE:
2180 return reloc_class_relative;
2181 case R_X86_64_JUMP_SLOT:
2182 return reloc_class_plt;
2184 return reloc_class_copy;
2186 return reloc_class_normal;
2190 /* Finish up the dynamic sections. */
2193 elf64_x86_64_finish_dynamic_sections (output_bfd, info)
2195 struct bfd_link_info *info;
2197 struct elf64_x86_64_link_hash_table *htab;
2201 htab = elf64_x86_64_hash_table (info);
2202 dynobj = htab->elf.dynobj;
2203 sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
2205 if (htab->elf.dynamic_sections_created)
2207 Elf64_External_Dyn *dyncon, *dynconend;
2209 if (sdyn == NULL || htab->sgot == NULL)
2212 dyncon = (Elf64_External_Dyn *) sdyn->contents;
2213 dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->_raw_size);
2214 for (; dyncon < dynconend; dyncon++)
2216 Elf_Internal_Dyn dyn;
2219 bfd_elf64_swap_dyn_in (dynobj, dyncon, &dyn);
2227 dyn.d_un.d_ptr = htab->sgot->output_section->vma;
2231 dyn.d_un.d_ptr = htab->srelplt->output_section->vma;
2235 s = htab->srelplt->output_section;
2236 if (s->_cooked_size != 0)
2237 dyn.d_un.d_val = s->_cooked_size;
2239 dyn.d_un.d_val = s->_raw_size;
2243 /* The procedure linkage table relocs (DT_JMPREL) should
2244 not be included in the overall relocs (DT_RELA).
2245 Therefore, we override the DT_RELASZ entry here to
2246 make it not include the JMPREL relocs. Since the
2247 linker script arranges for .rela.plt to follow all
2248 other relocation sections, we don't have to worry
2249 about changing the DT_RELA entry. */
2250 if (htab->srelplt != NULL)
2252 s = htab->srelplt->output_section;
2253 if (s->_cooked_size != 0)
2254 dyn.d_un.d_val -= s->_cooked_size;
2256 dyn.d_un.d_val -= s->_raw_size;
2261 bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
2264 /* Fill in the special first entry in the procedure linkage table. */
2265 if (htab->splt && htab->splt->_raw_size > 0)
2267 /* Fill in the first entry in the procedure linkage table. */
2268 memcpy (htab->splt->contents, elf64_x86_64_plt0_entry,
2270 /* Add offset for pushq GOT+8(%rip), since the instruction
2271 uses 6 bytes subtract this value. */
2272 bfd_put_32 (output_bfd,
2273 (htab->sgotplt->output_section->vma
2274 + htab->sgotplt->output_offset
2276 - htab->splt->output_section->vma
2277 - htab->splt->output_offset
2279 htab->splt->contents + 2);
2280 /* Add offset for jmp *GOT+16(%rip). The 12 is the offset to
2281 the end of the instruction. */
2282 bfd_put_32 (output_bfd,
2283 (htab->sgotplt->output_section->vma
2284 + htab->sgotplt->output_offset
2286 - htab->splt->output_section->vma
2287 - htab->splt->output_offset
2289 htab->splt->contents + 8);
2291 elf_section_data (htab->splt->output_section)->this_hdr.sh_entsize =
2298 /* Fill in the first three entries in the global offset table. */
2299 if (htab->sgotplt->_raw_size > 0)
2301 /* Set the first entry in the global offset table to the address of
2302 the dynamic section. */
2304 bfd_put_64 (output_bfd, (bfd_vma) 0, htab->sgotplt->contents);
2306 bfd_put_64 (output_bfd,
2307 sdyn->output_section->vma + sdyn->output_offset,
2308 htab->sgotplt->contents);
2309 /* Write GOT[1] and GOT[2], needed for the dynamic linker. */
2310 bfd_put_64 (output_bfd, (bfd_vma) 0, htab->sgotplt->contents + GOT_ENTRY_SIZE);
2311 bfd_put_64 (output_bfd, (bfd_vma) 0, htab->sgotplt->contents + GOT_ENTRY_SIZE*2);
2314 elf_section_data (htab->sgotplt->output_section)->this_hdr.sh_entsize =
2322 #define TARGET_LITTLE_SYM bfd_elf64_x86_64_vec
2323 #define TARGET_LITTLE_NAME "elf64-x86-64"
2324 #define ELF_ARCH bfd_arch_i386
2325 #define ELF_MACHINE_CODE EM_X86_64
2326 #define ELF_MAXPAGESIZE 0x100000
2328 #define elf_backend_can_gc_sections 1
2329 #define elf_backend_can_refcount 1
2330 #define elf_backend_want_got_plt 1
2331 #define elf_backend_plt_readonly 1
2332 #define elf_backend_want_plt_sym 0
2333 #define elf_backend_got_header_size (GOT_ENTRY_SIZE*3)
2334 #define elf_backend_plt_header_size PLT_ENTRY_SIZE
2335 #define elf_backend_rela_normal 1
2337 #define elf_info_to_howto elf64_x86_64_info_to_howto
2339 #define bfd_elf64_bfd_link_hash_table_create \
2340 elf64_x86_64_link_hash_table_create
2341 #define bfd_elf64_bfd_reloc_type_lookup elf64_x86_64_reloc_type_lookup
2343 #define elf_backend_adjust_dynamic_symbol elf64_x86_64_adjust_dynamic_symbol
2344 #define elf_backend_check_relocs elf64_x86_64_check_relocs
2345 #define elf_backend_copy_indirect_symbol elf64_x86_64_copy_indirect_symbol
2346 #define elf_backend_create_dynamic_sections elf64_x86_64_create_dynamic_sections
2347 #define elf_backend_finish_dynamic_sections elf64_x86_64_finish_dynamic_sections
2348 #define elf_backend_finish_dynamic_symbol elf64_x86_64_finish_dynamic_symbol
2349 #define elf_backend_gc_mark_hook elf64_x86_64_gc_mark_hook
2350 #define elf_backend_gc_sweep_hook elf64_x86_64_gc_sweep_hook
2351 #define elf_backend_grok_prstatus elf64_x86_64_grok_prstatus
2352 #define elf_backend_grok_psinfo elf64_x86_64_grok_psinfo
2353 #define elf_backend_reloc_type_class elf64_x86_64_reloc_type_class
2354 #define elf_backend_relocate_section elf64_x86_64_relocate_section
2355 #define elf_backend_size_dynamic_sections elf64_x86_64_size_dynamic_sections
2356 #define elf_backend_object_p elf64_x86_64_elf_object_p
2358 #include "elf64-target.h"