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