x86: Add VERIFY_COPY_RELOC
[external/binutils.git] / bfd / elfxx-x86.h
1 /* x86 specific support for ELF
2    Copyright (C) 2017 Free Software Foundation, Inc.
3
4    This file is part of BFD, the Binary File Descriptor library.
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19    MA 02110-1301, USA.  */
20
21 #include "sysdep.h"
22 #include "bfd.h"
23 #include "bfdlink.h"
24 #include "libbfd.h"
25 #include "elf-bfd.h"
26 #include "bfd_stdint.h"
27 #include "hashtab.h"
28
29 #define PLT_CIE_LENGTH          20
30 #define PLT_FDE_LENGTH          36
31 #define PLT_FDE_START_OFFSET    4 + PLT_CIE_LENGTH + 8
32 #define PLT_FDE_LEN_OFFSET      4 + PLT_CIE_LENGTH + 12
33
34 #define ABI_64_P(abfd) \
35   (get_elf_backend_data (abfd)->s->elfclass == ELFCLASS64)
36
37 /* If ELIMINATE_COPY_RELOCS is non-zero, the linker will try to avoid
38    copying dynamic variables from a shared lib into an app's dynbss
39    section, and instead use a dynamic relocation to point into the
40    shared lib.  */
41 #define ELIMINATE_COPY_RELOCS 1
42
43 #define elf_x86_hash_table(p, id) \
44   (is_elf_hash_table ((p)->hash) \
45    && elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) == (id) \
46     ? ((struct elf_x86_link_hash_table *) ((p)->hash)) : NULL)
47
48 /* Will references to this symbol always be local in this object?  */
49 #define SYMBOL_REFERENCES_LOCAL_P(INFO, H) \
50   _bfd_x86_elf_link_symbol_references_local ((INFO), (H))
51
52 /* Is a undefined weak symbol which is resolved to 0.  Reference to an
53    undefined weak symbol is resolved to 0 when building executable if
54    it isn't dynamic and
55    1. Has non-GOT/non-PLT relocations in text section.  Or
56    2. Has no GOT/PLT relocation.
57    Local undefined weak symbol is always resolved to 0.
58  */
59 #define UNDEFINED_WEAK_RESOLVED_TO_ZERO(INFO, EH) \
60   ((EH)->elf.root.type == bfd_link_hash_undefweak                \
61    && (SYMBOL_REFERENCES_LOCAL_P ((INFO), &(EH)->elf)            \
62        || (bfd_link_executable (INFO)                            \
63            && (!(EH)->has_got_reloc                              \
64                || (EH)->has_non_got_reloc))))
65
66 /* Should copy relocation be generated for a symbol.  Don't generate
67    copy relocation against a protected symbol defined in a shared
68    object with GNU_PROPERTY_NO_COPY_ON_PROTECTED.  */
69 #define SYMBOL_NO_COPYRELOC(INFO, EH) \
70   ((EH)->def_protected \
71    && ((EH)->elf.root.type == bfd_link_hash_defined \
72        || (EH)->elf.root.type == bfd_link_hash_defweak) \
73    && elf_has_no_copy_on_protected ((EH)->elf.root.u.def.section->owner) \
74    && ((EH)->elf.root.u.def.section->owner->flags & DYNAMIC) != 0 \
75    && ((EH)->elf.root.u.def.section->flags & SEC_CODE) == 0)
76
77 /* TRUE if dynamic relocation is needed.  If we are creating a shared
78    library, and this is a reloc against a global symbol, or a non PC
79    relative reloc against a local symbol, then we need to copy the reloc
80    into the shared library.  However, if we are linking with -Bsymbolic,
81    we do not need to copy a reloc against a global symbol which is
82    defined in an object we are including in the link (i.e., DEF_REGULAR
83    is set).  At this point we have not seen all the input files, so it
84    is possible that DEF_REGULAR is not set now but will be set later (it
85    is never cleared).  In case of a weak definition, DEF_REGULAR may be
86    cleared later by a strong definition in a shared library.  We account
87    for that possibility below by storing information in the relocs_copied
88    field of the hash table entry.  A similar situation occurs when
89    creating shared libraries and symbol visibility changes render the
90    symbol local.
91
92    If on the other hand, we are creating an executable, we may need to
93    keep relocations for symbols satisfied by a dynamic library if we
94    manage to avoid copy relocs for the symbol.
95
96    We also need to generate dynamic pointer relocation against
97    STT_GNU_IFUNC symbol in the non-code section.  */
98 #define NEED_DYNAMIC_RELOCATION_P(INFO, H, SEC, R_TYPE, POINTER_TYPE) \
99   ((bfd_link_pic (INFO) \
100     && (! X86_PCREL_TYPE_P (R_TYPE) \
101         || ((H) != NULL \
102             && (! (bfd_link_pie (INFO) \
103                    || SYMBOLIC_BIND ((INFO), (H))) \
104                 || (H)->root.type == bfd_link_hash_defweak \
105                 || !(H)->def_regular)))) \
106                 || ((H) != NULL \
107                     && (H)->type == STT_GNU_IFUNC \
108                     && (R_TYPE) == POINTER_TYPE \
109                     && ((SEC)->flags & SEC_CODE) == 0) \
110                     || (ELIMINATE_COPY_RELOCS \
111                         && !bfd_link_pic (INFO) \
112                         && (H) != NULL \
113                         && ((H)->root.type == bfd_link_hash_defweak \
114                             || !(H)->def_regular)))
115
116 /* TRUE if dynamic relocation should be generated.  Don't copy a
117    pc-relative relocation into the output file if the symbol needs
118    copy reloc or the symbol is undefined when building executable.
119    Copy dynamic function pointer relocations.  Don't generate dynamic
120    relocations against resolved undefined weak symbols in PIE, except
121    when PC32_RELOC is TRUE.  Undefined weak symbol is bound locally
122    when PIC is false.  */
123 #define GENERATE_DYNAMIC_RELOCATION_P(INFO, EH, R_TYPE, \
124                                       NEED_COPY_RELOC_IN_PIE, \
125                                       RESOLVED_TO_ZERO, PC32_RELOC) \
126   ((bfd_link_pic (INFO) \
127     && !(NEED_COPY_RELOC_IN_PIE) \
128     && ((EH) == NULL \
129         || ((ELF_ST_VISIBILITY ((EH)->elf.other) == STV_DEFAULT \
130              && (!(RESOLVED_TO_ZERO) || PC32_RELOC)) \
131             || (EH)->elf.root.type != bfd_link_hash_undefweak)) \
132     && ((!X86_PCREL_TYPE_P (R_TYPE) \
133          && !X86_SIZE_TYPE_P (R_TYPE)) \
134          || ! SYMBOL_CALLS_LOCAL ((INFO), &(EH)->elf))) \
135    || (ELIMINATE_COPY_RELOCS \
136        && !bfd_link_pic (INFO) \
137        && (EH) != NULL \
138        && (EH)->elf.dynindx != -1 \
139        && (!(EH)->elf.non_got_ref \
140            || (EH)->func_pointer_refcount > 0 \
141            || ((EH)->elf.root.type == bfd_link_hash_undefweak \
142                && !(RESOLVED_TO_ZERO))) \
143                && (((EH)->elf.def_dynamic && !(EH)->elf.def_regular) \
144                    || (EH)->elf.root.type == bfd_link_hash_undefined)))
145
146 /* TRUE if this input relocation should be copied to output.  H->dynindx
147    may be -1 if this symbol was marked to become local.  */
148 #define COPY_INPUT_RELOC_P(INFO, H, R_TYPE) \
149   ((H) != NULL \
150    && (H)->dynindx != -1 \
151    && (X86_PCREL_TYPE_P (R_TYPE) \
152        || !(bfd_link_executable (INFO) || SYMBOLIC_BIND ((INFO), (H))) \
153        || !(H)->def_regular))
154
155 /* TRUE if this is actually a static link, or it is a -Bsymbolic link
156    and the symbol is defined locally, or the symbol was forced to be
157    local because of a version file.  */
158 #define RESOLVED_LOCALLY_P(INFO, H, HTAB) \
159   (!WILL_CALL_FINISH_DYNAMIC_SYMBOL ((HTAB)->elf.dynamic_sections_created, \
160                                      bfd_link_pic (INFO), (H)) \
161    || (bfd_link_pic (INFO) \
162        && SYMBOL_REFERENCES_LOCAL_P ((INFO), (H))) \
163        || (ELF_ST_VISIBILITY ((H)->other) \
164            && (H)->root.type == bfd_link_hash_undefweak))
165
166 /* TRUE if relative relocation should be generated.  GOT reference to
167    global symbol in PIC will lead to dynamic symbol.  It becomes a
168    problem when "time" or "times" is defined as a variable in an
169    executable, clashing with functions of the same name in libc.  If a
170    symbol isn't undefined weak symbol, don't make it dynamic in PIC and
171    generate relative relocation.  */
172 #define GENERATE_RELATIVE_RELOC_P(INFO, H) \
173   ((H)->dynindx == -1 \
174    && !(H)->forced_local \
175    && (H)->root.type != bfd_link_hash_undefweak \
176    && bfd_link_pic (INFO))
177
178 /* TRUE if this is a pointer reference to a local IFUNC.  */
179 #define POINTER_LOCAL_IFUNC_P(INFO, H) \
180   ((H)->dynindx == -1 \
181    || (H)->forced_local \
182    || bfd_link_executable (INFO))
183
184 /* TRUE if this is a PLT reference to a local IFUNC.  */
185 #define PLT_LOCAL_IFUNC_P(INFO, H) \
186   ((H)->dynindx == -1 \
187    || ((bfd_link_executable (INFO) \
188         || ELF_ST_VISIBILITY ((H)->other) != STV_DEFAULT) \
189         && (H)->def_regular \
190         && (H)->type == STT_GNU_IFUNC))
191
192 /* TRUE if TLS IE->LE transition is OK.  */
193 #define TLS_TRANSITION_IE_TO_LE_P(INFO, H, TLS_TYPE) \
194   (bfd_link_executable (INFO) \
195    && (H) != NULL \
196    && (H)->dynindx == -1 \
197    && (TLS_TYPE & GOT_TLS_IE))
198
199 /* Verify that the symbol has an entry in the procedure linkage table.  */
200 #define VERIFY_PLT_ENTRY(INFO, H, PLT, GOTPLT, RELPLT, LOCAL_UNDEFWEAK) \
201   if (((H)->dynindx == -1 \
202        && !LOCAL_UNDEFWEAK \
203        && !(((H)->forced_local || bfd_link_executable (INFO)) \
204             && (H)->def_regular \
205             && (H)->type == STT_GNU_IFUNC)) \
206       || (PLT) == NULL \
207       || (GOTPLT) == NULL \
208       || (RELPLT) == NULL) \
209     abort ();
210
211 /* Verify that the symbol supports copy relocation.  */
212 #define VERIFY_COPY_RELOC(H, HTAB) \
213   if ((H)->dynindx == -1 \
214       || ((H)->root.type != bfd_link_hash_defined \
215           && (H)->root.type != bfd_link_hash_defweak) \
216       || (HTAB)->elf.srelbss == NULL \
217       || (HTAB)->elf.sreldynrelro == NULL) \
218     abort ();
219
220 /* x86 ELF linker hash entry.  */
221
222 struct elf_x86_link_hash_entry
223 {
224   struct elf_link_hash_entry elf;
225
226   /* Track dynamic relocs copied for this symbol.  */
227   struct elf_dyn_relocs *dyn_relocs;
228
229   unsigned char tls_type;
230
231   /* TRUE if symbol has GOT or PLT relocations.  */
232   unsigned int has_got_reloc : 1;
233
234   /* TRUE if symbol has non-GOT/non-PLT relocations in text sections.  */
235   unsigned int has_non_got_reloc : 1;
236
237   /* Don't call finish_dynamic_symbol on this symbol.  */
238   unsigned int no_finish_dynamic_symbol : 1;
239
240   /* TRUE if symbol is __tls_get_addr.  */
241   unsigned int tls_get_addr : 1;
242
243   /* TRUE if symbol is defined as a protected symbol.  */
244   unsigned int def_protected : 1;
245
246   /* 0: Symbol references are unknown.
247      1: Symbol references aren't local.
248      2: Symbol references are local.
249    */
250   unsigned int local_ref : 2;
251
252   /* TRUE if symbol is defined by linker.  */
253   unsigned int linker_def : 1;
254
255   /* TRUE if symbol is referenced by R_386_GOTOFF relocation.  This is
256      only used by i386.  */
257   unsigned int gotoff_ref : 1;
258
259   /* TRUE if a weak symbol with a real definition needs a copy reloc.
260      When there is a weak symbol with a real definition, the processor
261      independent code will have arranged for us to see the real
262      definition first.  We need to copy the needs_copy bit from the
263      real definition and check it when allowing copy reloc in PIE.  This
264      is only used by x86-64.  */
265   unsigned int needs_copy : 1;
266
267   /* Reference count of C/C++ function pointer relocations in read-write
268      section which can be resolved at run-time.  */
269   bfd_signed_vma func_pointer_refcount;
270
271   /* Information about the GOT PLT entry. Filled when there are both
272      GOT and PLT relocations against the same function.  */
273   union gotplt_union plt_got;
274
275   /* Information about the second PLT entry.   */
276   union gotplt_union plt_second;
277
278   /* Offset of the GOTPLT entry reserved for the TLS descriptor,
279      starting at the end of the jump table.  */
280   bfd_vma tlsdesc_got;
281 };
282
283 struct elf_x86_lazy_plt_layout
284 {
285   /* The first entry in an absolute lazy procedure linkage table looks
286      like this.  */
287   const bfd_byte *plt0_entry;
288   unsigned int plt0_entry_size;          /* Size of PLT0 entry.  */
289
290   /* Later entries in an absolute lazy procedure linkage table look
291      like this.  */
292   const bfd_byte *plt_entry;
293   unsigned int plt_entry_size;          /* Size of each PLT entry.  */
294
295   /* Offsets into plt0_entry that are to be replaced with GOT[1] and
296      GOT[2].  */
297   unsigned int plt0_got1_offset;
298   unsigned int plt0_got2_offset;
299
300   /* Offset of the end of the PC-relative instruction containing
301      plt0_got2_offset.  This is for x86-64 only.  */
302   unsigned int plt0_got2_insn_end;
303
304   /* Offsets into plt_entry that are to be replaced with...  */
305   unsigned int plt_got_offset;    /* ... address of this symbol in .got. */
306   unsigned int plt_reloc_offset;  /* ... offset into relocation table. */
307   unsigned int plt_plt_offset;    /* ... offset to start of .plt. */
308
309   /* Length of the PC-relative instruction containing plt_got_offset.
310      This is used for x86-64 only.  */
311   unsigned int plt_got_insn_size;
312
313   /* Offset of the end of the PC-relative jump to plt0_entry.  This is
314      used for x86-64 only.  */
315   unsigned int plt_plt_insn_end;
316
317   /* Offset into plt_entry where the initial value of the GOT entry
318      points.  */
319   unsigned int plt_lazy_offset;
320
321   /* The first entry in a PIC lazy procedure linkage table looks like
322      this.  */
323   const bfd_byte *pic_plt0_entry;
324
325   /* Subsequent entries in a PIC lazy procedure linkage table look
326      like this.  */
327   const bfd_byte *pic_plt_entry;
328
329   /* .eh_frame covering the lazy .plt section.  */
330   const bfd_byte *eh_frame_plt;
331   unsigned int eh_frame_plt_size;
332 };
333
334 struct elf_x86_non_lazy_plt_layout
335 {
336   /* Entries in an absolute non-lazy procedure linkage table look like
337      this.  */
338   const bfd_byte *plt_entry;
339   /* Entries in a PIC non-lazy procedure linkage table look like this.  */
340   const bfd_byte *pic_plt_entry;
341
342   unsigned int plt_entry_size;          /* Size of each PLT entry.  */
343
344   /* Offsets into plt_entry that are to be replaced with...  */
345   unsigned int plt_got_offset;    /* ... address of this symbol in .got. */
346
347   /* Length of the PC-relative instruction containing plt_got_offset.
348      This is used for x86-64 only.  */
349   unsigned int plt_got_insn_size;
350
351   /* .eh_frame covering the non-lazy .plt section.  */
352   const bfd_byte *eh_frame_plt;
353   unsigned int eh_frame_plt_size;
354 };
355
356 struct elf_x86_plt_layout
357 {
358   /* The first entry in a lazy procedure linkage table looks like this.
359      This is only used for i386 where absolute PLT0 and PIC PLT0 are
360      different.  */
361   const bfd_byte *plt0_entry;
362   /* Entries in a procedure linkage table look like this.  */
363   const bfd_byte *plt_entry;
364   unsigned int plt_entry_size;          /* Size of each PLT entry.  */
365
366   /* 1 has PLT0.  */
367   unsigned int has_plt0;
368
369   /* Offsets into plt_entry that are to be replaced with...  */
370   unsigned int plt_got_offset;    /* ... address of this symbol in .got. */
371
372   /* Length of the PC-relative instruction containing plt_got_offset.
373      This is only used for x86-64.  */
374   unsigned int plt_got_insn_size;
375
376   /* .eh_frame covering the .plt section.  */
377   const bfd_byte *eh_frame_plt;
378   unsigned int eh_frame_plt_size;
379 };
380
381 /* Values in tls_type of x86 ELF linker hash entry.  */
382 #define GOT_UNKNOWN     0
383 #define GOT_NORMAL      1
384 #define GOT_TLS_GD      2
385 #define GOT_TLS_IE      4
386 #define GOT_TLS_IE_POS  5
387 #define GOT_TLS_IE_NEG  6
388 #define GOT_TLS_IE_BOTH 7
389 #define GOT_TLS_GDESC   8
390 #define GOT_TLS_GD_BOTH_P(type) \
391   ((type) == (GOT_TLS_GD | GOT_TLS_GDESC))
392 #define GOT_TLS_GD_P(type) \
393   ((type) == GOT_TLS_GD || GOT_TLS_GD_BOTH_P (type))
394 #define GOT_TLS_GDESC_P(type) \
395   ((type) == GOT_TLS_GDESC || GOT_TLS_GD_BOTH_P (type))
396 #define GOT_TLS_GD_ANY_P(type) \
397   (GOT_TLS_GD_P (type) || GOT_TLS_GDESC_P (type))
398
399 #define elf_x86_hash_entry(ent) \
400   ((struct elf_x86_link_hash_entry *)(ent))
401
402 /* x86 ELF linker hash table.  */
403
404 struct elf_x86_link_hash_table
405 {
406   struct elf_link_hash_table elf;
407
408   /* Short-cuts to get to dynamic linker sections.  */
409   asection *interp;
410   asection *plt_eh_frame;
411   asection *plt_second;
412   asection *plt_second_eh_frame;
413   asection *plt_got;
414   asection *plt_got_eh_frame;
415
416   /* Parameters describing PLT generation, lazy or non-lazy.  */
417   struct elf_x86_plt_layout plt;
418
419   /* Parameters describing lazy PLT generation.  */
420   const struct elf_x86_lazy_plt_layout *lazy_plt;
421
422   /* Parameters describing non-lazy PLT generation.  */
423   const struct elf_x86_non_lazy_plt_layout *non_lazy_plt;
424
425   union
426   {
427     bfd_signed_vma refcount;
428     bfd_vma offset;
429   } tls_ld_or_ldm_got;
430
431   /* The amount of space used by the jump slots in the GOT.  */
432   bfd_vma sgotplt_jump_table_size;
433
434   /* Small local sym cache.  */
435   struct sym_cache sym_cache;
436
437   /* _TLS_MODULE_BASE_ symbol.  */
438   struct bfd_link_hash_entry *tls_module_base;
439
440   /* Used by local STT_GNU_IFUNC symbols.  */
441   htab_t loc_hash_table;
442   void * loc_hash_memory;
443
444   /* The offset into sgot of the GOT entry used by the PLT entry
445      above.  */
446   bfd_vma tlsdesc_got;
447
448   /* The index of the next R_X86_64_JUMP_SLOT entry in .rela.plt.  */
449   bfd_vma next_jump_slot_index;
450   /* The index of the next R_X86_64_IRELATIVE entry in .rela.plt.  */
451   bfd_vma next_irelative_index;
452
453   /* TRUE if there are dynamic relocs against IFUNC symbols that apply
454      to read-only sections.  */
455   bfd_boolean readonly_dynrelocs_against_ifunc;
456
457   /* TRUE if this is a VxWorks x86 target.  This is only used for
458      i386.  */
459   bfd_boolean is_vxworks;
460
461   /* The (unloaded but important) .rel.plt.unloaded section on VxWorks.
462      This is used for i386 only.  */
463   asection *srelplt2;
464
465   /* The index of the next unused R_386_TLS_DESC slot in .rel.plt.  This
466      is only used for i386.  */
467   bfd_vma next_tls_desc_index;
468
469   /* The offset into splt of the PLT entry for the TLS descriptor
470      resolver.  Special values are 0, if not necessary (or not found
471      to be necessary yet), and -1 if needed but not determined
472      yet.  This is only used for x86-64.  */
473   bfd_vma tlsdesc_plt;
474
475   bfd_vma (*r_info) (bfd_vma, bfd_vma);
476   bfd_vma (*r_sym) (bfd_vma);
477   bfd_boolean (*is_reloc_section) (const char *);
478   enum elf_target_id target_id;
479   unsigned int sizeof_reloc;
480   unsigned int dt_reloc;
481   unsigned int dt_reloc_sz;
482   unsigned int dt_reloc_ent;
483   unsigned int got_entry_size;
484   unsigned int pointer_r_type;
485   int dynamic_interpreter_size;
486   const char *dynamic_interpreter;
487   const char *tls_get_addr;
488 };
489
490 struct elf_x86_init_table
491 {
492   /* The lazy PLT layout.  */
493   const struct elf_x86_lazy_plt_layout *lazy_plt;
494
495   /* The non-lazy PLT layout.  */
496   const struct elf_x86_non_lazy_plt_layout *non_lazy_plt;
497
498   /* The lazy PLT layout for IBT.  */
499   const struct elf_x86_lazy_plt_layout *lazy_ibt_plt;
500
501   /* The non-lazy PLT layout for IBT.  */
502   const struct elf_x86_non_lazy_plt_layout *non_lazy_ibt_plt;
503
504   /* TRUE if this is a normal x86 target.  */
505   bfd_boolean normal_target;
506
507   /* TRUE if this is a VxWorks x86 target.  */
508   bfd_boolean is_vxworks;
509
510   bfd_vma (*r_info) (bfd_vma, bfd_vma);
511   bfd_vma (*r_sym) (bfd_vma);
512 };
513
514 struct elf_x86_obj_tdata
515 {
516   struct elf_obj_tdata root;
517
518   /* tls_type for each local got entry.  */
519   char *local_got_tls_type;
520
521   /* GOTPLT entries for TLS descriptors.  */
522   bfd_vma *local_tlsdesc_gotent;
523 };
524
525 enum elf_x86_plt_type
526 {
527   plt_non_lazy = 0,
528   plt_lazy = 1 << 0,
529   plt_pic = 1 << 1,
530   plt_second = 1 << 2,
531   plt_unknown = -1
532 };
533
534 struct elf_x86_plt
535 {
536   const char *name;
537   asection *sec;
538   bfd_byte *contents;
539   enum elf_x86_plt_type type;
540   unsigned int plt_got_offset;
541   unsigned int plt_entry_size;
542   unsigned int plt_got_insn_size;       /* Only used for x86-64.  */
543   long count;
544 };
545
546 #define elf_x86_tdata(abfd) \
547   ((struct elf_x86_obj_tdata *) (abfd)->tdata.any)
548
549 #define elf_x86_local_got_tls_type(abfd) \
550   (elf_x86_tdata (abfd)->local_got_tls_type)
551
552 #define elf_x86_local_tlsdesc_gotent(abfd) \
553   (elf_x86_tdata (abfd)->local_tlsdesc_gotent)
554
555 #define elf_x86_compute_jump_table_size(htab) \
556   ((htab)->elf.srelplt->reloc_count * (htab)->got_entry_size)
557
558 #define is_x86_elf(bfd, htab)                           \
559   (bfd_get_flavour (bfd) == bfd_target_elf_flavour      \
560    && elf_tdata (bfd) != NULL                           \
561    && elf_object_id (bfd) == (htab)->target_id)
562
563 extern bfd_boolean _bfd_x86_elf_mkobject
564   (bfd *);
565
566 extern void _bfd_x86_elf_set_tls_module_base
567   (struct bfd_link_info *);
568
569 extern bfd_vma _bfd_x86_elf_dtpoff_base
570   (struct bfd_link_info *);
571
572 extern bfd_boolean _bfd_x86_elf_readonly_dynrelocs
573   (struct elf_link_hash_entry *, void *);
574
575 extern struct elf_link_hash_entry * _bfd_elf_x86_get_local_sym_hash
576   (struct elf_x86_link_hash_table *, bfd *, const Elf_Internal_Rela *,
577    bfd_boolean);
578
579 extern hashval_t _bfd_x86_elf_local_htab_hash
580   (const void *);
581
582 extern int _bfd_x86_elf_local_htab_eq
583   (const void *, const void *);
584
585 extern struct bfd_hash_entry * _bfd_x86_elf_link_hash_newfunc
586   (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
587
588 extern struct bfd_link_hash_table * _bfd_x86_elf_link_hash_table_create
589   (bfd *);
590
591 extern int _bfd_x86_elf_compare_relocs
592   (const void *, const void *);
593
594 extern bfd_boolean _bfd_x86_elf_link_check_relocs
595   (bfd *, struct bfd_link_info *);
596
597 extern bfd_boolean _bfd_x86_elf_size_dynamic_sections
598   (bfd *, struct bfd_link_info *);
599
600 extern bfd_boolean _bfd_x86_elf_always_size_sections
601   (bfd *, struct bfd_link_info *);
602
603 extern void _bfd_x86_elf_merge_symbol_attribute
604   (struct elf_link_hash_entry *, const Elf_Internal_Sym *,
605    bfd_boolean, bfd_boolean);
606
607 extern void _bfd_x86_elf_copy_indirect_symbol
608   (struct bfd_link_info *, struct elf_link_hash_entry *,
609    struct elf_link_hash_entry *);
610
611 extern bfd_boolean _bfd_x86_elf_fixup_symbol
612   (struct bfd_link_info *, struct elf_link_hash_entry *);
613
614 extern bfd_boolean _bfd_x86_elf_hash_symbol
615   (struct elf_link_hash_entry *);
616
617 extern bfd_boolean _bfd_x86_elf_adjust_dynamic_symbol
618   (struct bfd_link_info *, struct elf_link_hash_entry *);
619
620 extern bfd_boolean _bfd_x86_elf_link_symbol_references_local
621   (struct bfd_link_info *, struct elf_link_hash_entry *);
622
623 extern asection * _bfd_x86_elf_gc_mark_hook
624   (asection *, struct bfd_link_info *, Elf_Internal_Rela *,
625    struct elf_link_hash_entry *, Elf_Internal_Sym *);
626
627 extern long _bfd_x86_elf_get_synthetic_symtab
628   (bfd *, long, long, bfd_vma, struct elf_x86_plt [], asymbol **,
629    asymbol **);
630
631 extern enum elf_property_kind _bfd_x86_elf_parse_gnu_properties
632   (bfd *, unsigned int, bfd_byte *, unsigned int);
633
634 extern bfd_boolean _bfd_x86_elf_merge_gnu_properties
635   (struct bfd_link_info *, bfd *, elf_property *, elf_property *);
636
637 extern bfd * _bfd_x86_elf_link_setup_gnu_properties
638   (struct bfd_link_info *, struct elf_x86_init_table *);
639
640 #define bfd_elf64_mkobject \
641   _bfd_x86_elf_mkobject
642 #define bfd_elf32_mkobject \
643   _bfd_x86_elf_mkobject
644 #define bfd_elf64_bfd_link_hash_table_create \
645   _bfd_x86_elf_link_hash_table_create
646 #define bfd_elf32_bfd_link_hash_table_create \
647   _bfd_x86_elf_link_hash_table_create
648 #define bfd_elf64_bfd_link_check_relocs \
649   _bfd_x86_elf_link_check_relocs
650 #define bfd_elf32_bfd_link_check_relocs \
651   _bfd_x86_elf_link_check_relocs
652
653 #define elf_backend_size_dynamic_sections \
654   _bfd_x86_elf_size_dynamic_sections
655 #define elf_backend_always_size_sections \
656   _bfd_x86_elf_always_size_sections
657 #define elf_backend_merge_symbol_attribute \
658   _bfd_x86_elf_merge_symbol_attribute
659 #define elf_backend_copy_indirect_symbol \
660   _bfd_x86_elf_copy_indirect_symbol
661 #define elf_backend_fixup_symbol \
662   _bfd_x86_elf_fixup_symbol
663 #define elf_backend_hash_symbol \
664   _bfd_x86_elf_hash_symbol
665 #define elf_backend_adjust_dynamic_symbol \
666   _bfd_x86_elf_adjust_dynamic_symbol
667 #define elf_backend_gc_mark_hook \
668   _bfd_x86_elf_gc_mark_hook
669 #define elf_backend_omit_section_dynsym \
670   ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true)
671 #define elf_backend_parse_gnu_properties \
672   _bfd_x86_elf_parse_gnu_properties
673 #define elf_backend_merge_gnu_properties \
674   _bfd_x86_elf_merge_gnu_properties