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