x86: Correct EVEX vector load/store optimization
[deliverable/binutils-gdb.git] / bfd / elfxx-x86.h
CommitLineData
0afcef53 1/* x86 specific support for ELF
82704155 2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
0afcef53
L
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"
0afcef53
L
26#include "hashtab.h"
27
aa595247
L
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
765e526c
L
33#define ABI_64_P(abfd) \
34 (get_elf_backend_data (abfd)->s->elfclass == ELFCLASS64)
35
0afcef53
L
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) \
1cf58434
AM
43 (is_elf_hash_table ((p)->hash) \
44 && elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) == (id) \
0afcef53
L
45 ? ((struct elf_x86_link_hash_table *) ((p)->hash)) : NULL)
46
6999821f
L
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
99180bcc
L
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). */
c5bce5c6 55#define UNDEFINED_WEAK_RESOLVED_TO_ZERO(INFO, EH) \
0afcef53 56 ((EH)->elf.root.type == bfd_link_hash_undefweak \
6999821f 57 && (SYMBOL_REFERENCES_LOCAL_P ((INFO), &(EH)->elf) \
0afcef53 58 || (bfd_link_executable (INFO) \
98b273dc 59 && (EH)->zero_undefweak > 0)))
0afcef53
L
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
daf1c414
L
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
451875b4
L
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.
daf1c414
L
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. */
451875b4
L
90#define NEED_DYNAMIC_RELOCATION_P(INFO, PCREL_PLT, H, SEC, R_TYPE, \
91 POINTER_TYPE) \
daf1c414
L
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 \
451875b4
L
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)))
daf1c414 114
aebcc8ff
L
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 \
aebcc8ff
L
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
e74399c4
L
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
2eba97c2
L
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
83924b38
L
164/* TRUE if this symbol isn't defined by a shared object. */
165#define SYMBOL_DEFINED_NON_SHARED_P(H) \
166 ((H)->def_regular \
167 || (H)->root.linker_def \
168 || (H)->root.ldscript_def \
169 || ELF_COMMON_DEF_P (H))
170
f70656b2
L
171/* TRUE if relative relocation should be generated. GOT reference to
172 global symbol in PIC will lead to dynamic symbol. It becomes a
173 problem when "time" or "times" is defined as a variable in an
174 executable, clashing with functions of the same name in libc. If a
175 symbol isn't undefined weak symbol, don't make it dynamic in PIC and
176 generate relative relocation. */
177#define GENERATE_RELATIVE_RELOC_P(INFO, H) \
178 ((H)->dynindx == -1 \
179 && !(H)->forced_local \
180 && (H)->root.type != bfd_link_hash_undefweak \
181 && bfd_link_pic (INFO))
182
cf1070f1
L
183/* TRUE if this is a pointer reference to a local IFUNC. */
184#define POINTER_LOCAL_IFUNC_P(INFO, H) \
185 ((H)->dynindx == -1 \
186 || (H)->forced_local \
187 || bfd_link_executable (INFO))
188
189/* TRUE if this is a PLT reference to a local IFUNC. */
190#define PLT_LOCAL_IFUNC_P(INFO, H) \
191 ((H)->dynindx == -1 \
192 || ((bfd_link_executable (INFO) \
193 || ELF_ST_VISIBILITY ((H)->other) != STV_DEFAULT) \
194 && (H)->def_regular \
195 && (H)->type == STT_GNU_IFUNC))
196
51537393
L
197/* TRUE if TLS IE->LE transition is OK. */
198#define TLS_TRANSITION_IE_TO_LE_P(INFO, H, TLS_TYPE) \
199 (bfd_link_executable (INFO) \
200 && (H) != NULL \
201 && (H)->dynindx == -1 \
202 && (TLS_TYPE & GOT_TLS_IE))
203
f3180fa9
L
204/* Verify that the symbol has an entry in the procedure linkage table. */
205#define VERIFY_PLT_ENTRY(INFO, H, PLT, GOTPLT, RELPLT, LOCAL_UNDEFWEAK) \
e0d8f431
L
206 do \
207 { \
208 if (((H)->dynindx == -1 \
209 && !LOCAL_UNDEFWEAK \
210 && !(((H)->forced_local || bfd_link_executable (INFO)) \
211 && (H)->def_regular \
212 && (H)->type == STT_GNU_IFUNC)) \
213 || (PLT) == NULL \
214 || (GOTPLT) == NULL \
215 || (RELPLT) == NULL) \
216 abort (); \
217 } \
218 while (0);
f3180fa9 219
ff38b4cc
L
220/* Verify that the symbol supports copy relocation. */
221#define VERIFY_COPY_RELOC(H, HTAB) \
e0d8f431
L
222 do \
223 { \
224 if ((H)->dynindx == -1 \
225 || ((H)->root.type != bfd_link_hash_defined \
226 && (H)->root.type != bfd_link_hash_defweak) \
227 || (HTAB)->elf.srelbss == NULL \
228 || (HTAB)->elf.sreldynrelro == NULL) \
229 abort (); \
230 } \
231 while (0);
ff38b4cc 232
0afcef53
L
233/* x86 ELF linker hash entry. */
234
235struct elf_x86_link_hash_entry
236{
237 struct elf_link_hash_entry elf;
238
239 /* Track dynamic relocs copied for this symbol. */
240 struct elf_dyn_relocs *dyn_relocs;
241
242 unsigned char tls_type;
243
98b273dc
L
244 /* Bit 0: Symbol has no GOT nor PLT relocations.
245 Bit 1: Symbol has non-GOT/non-PLT relocations in text sections.
246 zero_undefweak is initialized to 1 and undefined weak symbol
247 should be resolved to 0 if zero_undefweak > 0. */
248 unsigned int zero_undefweak : 2;
0afcef53
L
249
250 /* Don't call finish_dynamic_symbol on this symbol. */
251 unsigned int no_finish_dynamic_symbol : 1;
252
253 /* TRUE if symbol is __tls_get_addr. */
254 unsigned int tls_get_addr : 1;
255
256 /* TRUE if symbol is defined as a protected symbol. */
257 unsigned int def_protected : 1;
258
6999821f
L
259 /* 0: Symbol references are unknown.
260 1: Symbol references aren't local.
261 2: Symbol references are local.
262 */
263 unsigned int local_ref : 2;
264
0a27fed7
L
265 /* TRUE if symbol is defined by linker. */
266 unsigned int linker_def : 1;
267
f47432d4 268 /* TRUE if symbol is referenced by R_386_GOTOFF relocation. This is
c7df954f 269 only used by i386. */
0afcef53
L
270 unsigned int gotoff_ref : 1;
271
272 /* TRUE if a weak symbol with a real definition needs a copy reloc.
273 When there is a weak symbol with a real definition, the processor
274 independent code will have arranged for us to see the real
275 definition first. We need to copy the needs_copy bit from the
276 real definition and check it when allowing copy reloc in PIE. This
277 is only used by x86-64. */
278 unsigned int needs_copy : 1;
279
0afcef53
L
280 /* Information about the GOT PLT entry. Filled when there are both
281 GOT and PLT relocations against the same function. */
282 union gotplt_union plt_got;
283
284 /* Information about the second PLT entry. */
285 union gotplt_union plt_second;
286
287 /* Offset of the GOTPLT entry reserved for the TLS descriptor,
288 starting at the end of the jump table. */
289 bfd_vma tlsdesc_got;
290};
291
765e526c
L
292struct elf_x86_lazy_plt_layout
293{
92e68c1d 294 /* The first entry in a lazy procedure linkage table looks like this. */
765e526c 295 const bfd_byte *plt0_entry;
07d6d2b8 296 unsigned int plt0_entry_size; /* Size of PLT0 entry. */
765e526c 297
92e68c1d 298 /* Later entries in a lazy procedure linkage table look like this. */
765e526c 299 const bfd_byte *plt_entry;
07d6d2b8 300 unsigned int plt_entry_size; /* Size of each PLT entry. */
765e526c 301
92e68c1d
L
302 /* The TLSDESC entry in a lazy procedure linkage table looks like
303 this. This is for x86-64 only. */
304 const bfd_byte *plt_tlsdesc_entry;
305 unsigned int plt_tlsdesc_entry_size; /* Size of TLSDESC entry. */
306
307 /* Offsets into the TLSDESC entry that are to be replaced with
308 GOT+8 and GOT+TDG. These are for x86-64 only. */
309 unsigned int plt_tlsdesc_got1_offset;
310 unsigned int plt_tlsdesc_got2_offset;
311
312 /* Offset of the end of the PC-relative instructions containing
313 plt_tlsdesc_got1_offset and plt_tlsdesc_got2_offset. These
314 are for x86-64 only. */
315 unsigned int plt_tlsdesc_got1_insn_end;
316 unsigned int plt_tlsdesc_got2_insn_end;
317
765e526c
L
318 /* Offsets into plt0_entry that are to be replaced with GOT[1] and
319 GOT[2]. */
320 unsigned int plt0_got1_offset;
321 unsigned int plt0_got2_offset;
322
323 /* Offset of the end of the PC-relative instruction containing
324 plt0_got2_offset. This is for x86-64 only. */
325 unsigned int plt0_got2_insn_end;
326
327 /* Offsets into plt_entry that are to be replaced with... */
328 unsigned int plt_got_offset; /* ... address of this symbol in .got. */
329 unsigned int plt_reloc_offset; /* ... offset into relocation table. */
330 unsigned int plt_plt_offset; /* ... offset to start of .plt. */
331
332 /* Length of the PC-relative instruction containing plt_got_offset.
333 This is used for x86-64 only. */
334 unsigned int plt_got_insn_size;
335
336 /* Offset of the end of the PC-relative jump to plt0_entry. This is
337 used for x86-64 only. */
338 unsigned int plt_plt_insn_end;
339
340 /* Offset into plt_entry where the initial value of the GOT entry
341 points. */
342 unsigned int plt_lazy_offset;
343
344 /* The first entry in a PIC lazy procedure linkage table looks like
a6798bab 345 this. */
765e526c
L
346 const bfd_byte *pic_plt0_entry;
347
348 /* Subsequent entries in a PIC lazy procedure linkage table look
a6798bab 349 like this. */
765e526c
L
350 const bfd_byte *pic_plt_entry;
351
352 /* .eh_frame covering the lazy .plt section. */
353 const bfd_byte *eh_frame_plt;
354 unsigned int eh_frame_plt_size;
355};
356
357struct elf_x86_non_lazy_plt_layout
358{
92e68c1d 359 /* Entries in a non-lazy procedure linkage table look like this. */
765e526c 360 const bfd_byte *plt_entry;
92e68c1d
L
361 /* Entries in a PIC non-lazy procedure linkage table look like this.
362 This is only used for i386 where absolute PLT and PIC PLT are
363 different. */
765e526c
L
364 const bfd_byte *pic_plt_entry;
365
07d6d2b8 366 unsigned int plt_entry_size; /* Size of each PLT entry. */
765e526c
L
367
368 /* Offsets into plt_entry that are to be replaced with... */
369 unsigned int plt_got_offset; /* ... address of this symbol in .got. */
370
371 /* Length of the PC-relative instruction containing plt_got_offset.
372 This is used for x86-64 only. */
373 unsigned int plt_got_insn_size;
374
375 /* .eh_frame covering the non-lazy .plt section. */
376 const bfd_byte *eh_frame_plt;
377 unsigned int eh_frame_plt_size;
378};
379
380struct elf_x86_plt_layout
381{
92e68c1d 382 /* The first entry in a lazy procedure linkage table looks like this. */
765e526c
L
383 const bfd_byte *plt0_entry;
384 /* Entries in a procedure linkage table look like this. */
385 const bfd_byte *plt_entry;
07d6d2b8 386 unsigned int plt_entry_size; /* Size of each PLT entry. */
765e526c
L
387
388 /* 1 has PLT0. */
389 unsigned int has_plt0;
390
391 /* Offsets into plt_entry that are to be replaced with... */
392 unsigned int plt_got_offset; /* ... address of this symbol in .got. */
393
394 /* Length of the PC-relative instruction containing plt_got_offset.
395 This is only used for x86-64. */
396 unsigned int plt_got_insn_size;
397
b44ee3a8
L
398 /* Alignment of the .iplt section. */
399 unsigned int iplt_alignment;
400
765e526c
L
401 /* .eh_frame covering the .plt section. */
402 const bfd_byte *eh_frame_plt;
403 unsigned int eh_frame_plt_size;
404};
405
6b9553e2 406/* Values in tls_type of x86 ELF linker hash entry. */
0afcef53
L
407#define GOT_UNKNOWN 0
408#define GOT_NORMAL 1
409#define GOT_TLS_GD 2
6b9553e2
L
410#define GOT_TLS_IE 4
411#define GOT_TLS_IE_POS 5
412#define GOT_TLS_IE_NEG 6
413#define GOT_TLS_IE_BOTH 7
414#define GOT_TLS_GDESC 8
415#define GOT_TLS_GD_BOTH_P(type) \
416 ((type) == (GOT_TLS_GD | GOT_TLS_GDESC))
417#define GOT_TLS_GD_P(type) \
418 ((type) == GOT_TLS_GD || GOT_TLS_GD_BOTH_P (type))
419#define GOT_TLS_GDESC_P(type) \
420 ((type) == GOT_TLS_GDESC || GOT_TLS_GD_BOTH_P (type))
421#define GOT_TLS_GD_ANY_P(type) \
422 (GOT_TLS_GD_P (type) || GOT_TLS_GDESC_P (type))
0afcef53
L
423
424#define elf_x86_hash_entry(ent) \
425 ((struct elf_x86_link_hash_entry *)(ent))
426
851b6fa1
L
427enum elf_x86_target_os
428{
429 is_normal,
3b4c3844 430 is_solaris,
851b6fa1
L
431 is_vxworks,
432 is_nacl
433};
434
0afcef53
L
435/* x86 ELF linker hash table. */
436
437struct elf_x86_link_hash_table
438{
439 struct elf_link_hash_table elf;
440
441 /* Short-cuts to get to dynamic linker sections. */
442 asection *interp;
443 asection *plt_eh_frame;
444 asection *plt_second;
445 asection *plt_second_eh_frame;
446 asection *plt_got;
447 asection *plt_got_eh_frame;
448
765e526c
L
449 /* Parameters describing PLT generation, lazy or non-lazy. */
450 struct elf_x86_plt_layout plt;
451
452 /* Parameters describing lazy PLT generation. */
453 const struct elf_x86_lazy_plt_layout *lazy_plt;
454
455 /* Parameters describing non-lazy PLT generation. */
456 const struct elf_x86_non_lazy_plt_layout *non_lazy_plt;
457
0afcef53
L
458 union
459 {
460 bfd_signed_vma refcount;
461 bfd_vma offset;
462 } tls_ld_or_ldm_got;
463
464 /* The amount of space used by the jump slots in the GOT. */
465 bfd_vma sgotplt_jump_table_size;
466
467 /* Small local sym cache. */
468 struct sym_cache sym_cache;
469
470 /* _TLS_MODULE_BASE_ symbol. */
471 struct bfd_link_hash_entry *tls_module_base;
472
473 /* Used by local STT_GNU_IFUNC symbols. */
474 htab_t loc_hash_table;
475 void * loc_hash_memory;
476
0afcef53
L
477 /* The offset into sgot of the GOT entry used by the PLT entry
478 above. */
479 bfd_vma tlsdesc_got;
480
481 /* The index of the next R_X86_64_JUMP_SLOT entry in .rela.plt. */
482 bfd_vma next_jump_slot_index;
483 /* The index of the next R_X86_64_IRELATIVE entry in .rela.plt. */
484 bfd_vma next_irelative_index;
485
486 /* TRUE if there are dynamic relocs against IFUNC symbols that apply
487 to read-only sections. */
488 bfd_boolean readonly_dynrelocs_against_ifunc;
489
765e526c
L
490 /* The (unloaded but important) .rel.plt.unloaded section on VxWorks.
491 This is used for i386 only. */
492 asection *srelplt2;
493
494 /* The index of the next unused R_386_TLS_DESC slot in .rel.plt. This
2926eb2c 495 is only used for i386. */
765e526c
L
496 bfd_vma next_tls_desc_index;
497
2926eb2c
L
498 /* The offset into splt of the PLT entry for the TLS descriptor
499 resolver. Special values are 0, if not necessary (or not found
500 to be necessary yet), and -1 if needed but not determined
501 yet. This is only used for x86-64. */
502 bfd_vma tlsdesc_plt;
503
851b6fa1
L
504 /* Value used to fill the unused bytes of the first PLT entry. This
505 is only used for i386. */
506 bfd_byte plt0_pad_byte;
507
cd048363
L
508 /* TRUE if GOT is referenced. */
509 unsigned int got_referenced : 1;
510
451875b4
L
511 /* TRUE if PLT is PC-relative. PLT in PDE and PC-relative PLT in PIE
512 can be used as function address.
513
514 NB: i386 has non-PIC PLT and PIC PLT. Only non-PIC PLT in PDE can
515 be used as function address. PIC PLT in PIE can't be used as
516 function address. */
517 unsigned int pcrel_plt : 1;
518
0afcef53
L
519 bfd_vma (*r_info) (bfd_vma, bfd_vma);
520 bfd_vma (*r_sym) (bfd_vma);
5e2ac45d 521 bfd_boolean (*is_reloc_section) (const char *);
fe53b4a4 522 enum elf_target_id target_id;
851b6fa1 523 enum elf_x86_target_os target_os;
503294e7 524 unsigned int sizeof_reloc;
5e2ac45d
L
525 unsigned int dt_reloc;
526 unsigned int dt_reloc_sz;
527 unsigned int dt_reloc_ent;
9ff114ca 528 unsigned int got_entry_size;
0afcef53
L
529 unsigned int pointer_r_type;
530 int dynamic_interpreter_size;
531 const char *dynamic_interpreter;
532 const char *tls_get_addr;
533};
534
851b6fa1
L
535/* Architecture-specific backend data for x86. */
536
537struct elf_x86_backend_data
538{
539 /* Target system. */
540 enum elf_x86_target_os target_os;
541};
542
543#define get_elf_x86_backend_data(abfd) \
544 ((const struct elf_x86_backend_data *) \
545 get_elf_backend_data (abfd)->arch_data)
546
1de031c8 547struct elf_x86_init_table
a6798bab
L
548{
549 /* The lazy PLT layout. */
550 const struct elf_x86_lazy_plt_layout *lazy_plt;
551
552 /* The non-lazy PLT layout. */
553 const struct elf_x86_non_lazy_plt_layout *non_lazy_plt;
554
555 /* The lazy PLT layout for IBT. */
556 const struct elf_x86_lazy_plt_layout *lazy_ibt_plt;
557
558 /* The non-lazy PLT layout for IBT. */
559 const struct elf_x86_non_lazy_plt_layout *non_lazy_ibt_plt;
560
851b6fa1 561 bfd_byte plt0_pad_byte;
7a382c1c
L
562
563 bfd_vma (*r_info) (bfd_vma, bfd_vma);
564 bfd_vma (*r_sym) (bfd_vma);
a6798bab
L
565};
566
0afcef53
L
567struct elf_x86_obj_tdata
568{
569 struct elf_obj_tdata root;
570
571 /* tls_type for each local got entry. */
572 char *local_got_tls_type;
573
574 /* GOTPLT entries for TLS descriptors. */
575 bfd_vma *local_tlsdesc_gotent;
576};
577
f493882d
L
578enum elf_x86_plt_type
579{
580 plt_non_lazy = 0,
581 plt_lazy = 1 << 0,
582 plt_pic = 1 << 1,
583 plt_second = 1 << 2,
584 plt_unknown = -1
585};
586
587struct elf_x86_plt
588{
589 const char *name;
590 asection *sec;
591 bfd_byte *contents;
592 enum elf_x86_plt_type type;
593 unsigned int plt_got_offset;
594 unsigned int plt_entry_size;
595 unsigned int plt_got_insn_size; /* Only used for x86-64. */
596 long count;
597};
598
0afcef53
L
599#define elf_x86_tdata(abfd) \
600 ((struct elf_x86_obj_tdata *) (abfd)->tdata.any)
601
602#define elf_x86_local_got_tls_type(abfd) \
603 (elf_x86_tdata (abfd)->local_got_tls_type)
604
605#define elf_x86_local_tlsdesc_gotent(abfd) \
606 (elf_x86_tdata (abfd)->local_tlsdesc_gotent)
607
9ff114ca
L
608#define elf_x86_compute_jump_table_size(htab) \
609 ((htab)->elf.srelplt->reloc_count * (htab)->got_entry_size)
610
fe53b4a4
L
611#define is_x86_elf(bfd, htab) \
612 (bfd_get_flavour (bfd) == bfd_target_elf_flavour \
613 && elf_tdata (bfd) != NULL \
614 && elf_object_id (bfd) == (htab)->target_id)
615
39946cc2
L
616extern bfd_boolean _bfd_x86_elf_mkobject
617 (bfd *);
618
0afcef53
L
619extern void _bfd_x86_elf_set_tls_module_base
620 (struct bfd_link_info *);
621
622extern bfd_vma _bfd_x86_elf_dtpoff_base
623 (struct bfd_link_info *);
624
625extern bfd_boolean _bfd_x86_elf_readonly_dynrelocs
626 (struct elf_link_hash_entry *, void *);
627
628extern struct elf_link_hash_entry * _bfd_elf_x86_get_local_sym_hash
629 (struct elf_x86_link_hash_table *, bfd *, const Elf_Internal_Rela *,
630 bfd_boolean);
631
632extern hashval_t _bfd_x86_elf_local_htab_hash
633 (const void *);
634
635extern int _bfd_x86_elf_local_htab_eq
636 (const void *, const void *);
637
638extern struct bfd_hash_entry * _bfd_x86_elf_link_hash_newfunc
639 (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
640
765e526c 641extern struct bfd_link_hash_table * _bfd_x86_elf_link_hash_table_create
0afcef53
L
642 (bfd *);
643
644extern int _bfd_x86_elf_compare_relocs
645 (const void *, const void *);
646
647extern bfd_boolean _bfd_x86_elf_link_check_relocs
648 (bfd *, struct bfd_link_info *);
649
5e2ac45d
L
650extern bfd_boolean _bfd_x86_elf_size_dynamic_sections
651 (bfd *, struct bfd_link_info *);
652
9577f60b
L
653extern struct elf_x86_link_hash_table *_bfd_x86_elf_finish_dynamic_sections
654 (bfd *, struct bfd_link_info *);
655
0afcef53
L
656extern bfd_boolean _bfd_x86_elf_always_size_sections
657 (bfd *, struct bfd_link_info *);
658
659extern void _bfd_x86_elf_merge_symbol_attribute
660 (struct elf_link_hash_entry *, const Elf_Internal_Sym *,
661 bfd_boolean, bfd_boolean);
662
663extern void _bfd_x86_elf_copy_indirect_symbol
664 (struct bfd_link_info *, struct elf_link_hash_entry *,
665 struct elf_link_hash_entry *);
666
667extern bfd_boolean _bfd_x86_elf_fixup_symbol
668 (struct bfd_link_info *, struct elf_link_hash_entry *);
669
670extern bfd_boolean _bfd_x86_elf_hash_symbol
671 (struct elf_link_hash_entry *);
672
eeb2f20a
L
673extern bfd_boolean _bfd_x86_elf_adjust_dynamic_symbol
674 (struct bfd_link_info *, struct elf_link_hash_entry *);
675
9f857535
L
676extern void _bfd_x86_elf_hide_symbol
677 (struct bfd_link_info *, struct elf_link_hash_entry *, bfd_boolean);
678
6999821f
L
679extern bfd_boolean _bfd_x86_elf_link_symbol_references_local
680 (struct bfd_link_info *, struct elf_link_hash_entry *);
681
4f501a24
L
682extern asection * _bfd_x86_elf_gc_mark_hook
683 (asection *, struct bfd_link_info *, Elf_Internal_Rela *,
684 struct elf_link_hash_entry *, Elf_Internal_Sym *);
685
f493882d
L
686extern long _bfd_x86_elf_get_synthetic_symtab
687 (bfd *, long, long, bfd_vma, struct elf_x86_plt [], asymbol **,
688 asymbol **);
689
0afcef53
L
690extern enum elf_property_kind _bfd_x86_elf_parse_gnu_properties
691 (bfd *, unsigned int, bfd_byte *, unsigned int);
692
693extern bfd_boolean _bfd_x86_elf_merge_gnu_properties
694 (struct bfd_link_info *, bfd *, elf_property *, elf_property *);
695
bfb1e8c1
L
696extern void _bfd_x86_elf_link_fixup_gnu_properties
697 (struct bfd_link_info *, elf_property_list **);
698
a6798bab 699extern bfd * _bfd_x86_elf_link_setup_gnu_properties
1de031c8 700 (struct bfd_link_info *, struct elf_x86_init_table *);
a6798bab 701
4ec09950
L
702extern void _bfd_x86_elf_link_fixup_ifunc_symbol
703 (struct bfd_link_info *, struct elf_x86_link_hash_table *,
704 struct elf_link_hash_entry *, Elf_Internal_Sym *sym);
705
39946cc2
L
706#define bfd_elf64_mkobject \
707 _bfd_x86_elf_mkobject
708#define bfd_elf32_mkobject \
709 _bfd_x86_elf_mkobject
765e526c
L
710#define bfd_elf64_bfd_link_hash_table_create \
711 _bfd_x86_elf_link_hash_table_create
712#define bfd_elf32_bfd_link_hash_table_create \
713 _bfd_x86_elf_link_hash_table_create
0afcef53
L
714#define bfd_elf64_bfd_link_check_relocs \
715 _bfd_x86_elf_link_check_relocs
716#define bfd_elf32_bfd_link_check_relocs \
717 _bfd_x86_elf_link_check_relocs
718
5e2ac45d
L
719#define elf_backend_size_dynamic_sections \
720 _bfd_x86_elf_size_dynamic_sections
0afcef53
L
721#define elf_backend_always_size_sections \
722 _bfd_x86_elf_always_size_sections
723#define elf_backend_merge_symbol_attribute \
724 _bfd_x86_elf_merge_symbol_attribute
725#define elf_backend_copy_indirect_symbol \
726 _bfd_x86_elf_copy_indirect_symbol
727#define elf_backend_fixup_symbol \
728 _bfd_x86_elf_fixup_symbol
729#define elf_backend_hash_symbol \
730 _bfd_x86_elf_hash_symbol
eeb2f20a
L
731#define elf_backend_adjust_dynamic_symbol \
732 _bfd_x86_elf_adjust_dynamic_symbol
4f501a24
L
733#define elf_backend_gc_mark_hook \
734 _bfd_x86_elf_gc_mark_hook
0afcef53 735#define elf_backend_omit_section_dynsym \
d00dd7dc 736 _bfd_elf_omit_section_dynsym_all
0afcef53
L
737#define elf_backend_parse_gnu_properties \
738 _bfd_x86_elf_parse_gnu_properties
739#define elf_backend_merge_gnu_properties \
740 _bfd_x86_elf_merge_gnu_properties
bfb1e8c1
L
741#define elf_backend_fixup_gnu_properties \
742 _bfd_x86_elf_link_fixup_gnu_properties
This page took 0.248376 seconds and 4 git commands to generate.