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