1 /* x86 specific support for ELF
2 Copyright (C) 2017-2022 Free Software Foundation, Inc.
4 This file is part of BFD, the Binary File Descriptor library.
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.
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.
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. */
21 /* Don't generate unused section symbols. */
22 #define TARGET_KEEP_UNUSED_SECTION_SYMBOLS false
30 #include "elf-linker-x86.h"
32 #include "elf/x86-64.h"
34 #define X86_64_PCREL_TYPE_P(TYPE) \
35 ((TYPE) == R_X86_64_PC8 \
36 || (TYPE) == R_X86_64_PC16 \
37 || (TYPE) == R_X86_64_PC32 \
38 || (TYPE) == R_X86_64_PC32_BND \
39 || (TYPE) == R_X86_64_PC64)
40 #define I386_PCREL_TYPE_P(TYPE) ((TYPE) == R_386_PC32)
41 #define X86_PCREL_TYPE_P(IS_X86_64, TYPE) \
42 ((IS_X86_64) ? X86_64_PCREL_TYPE_P (TYPE) : I386_PCREL_TYPE_P (TYPE))
44 #define X86_64_SIZE_TYPE_P(TYPE) \
45 ((TYPE) == R_X86_64_SIZE32 || (TYPE) == R_X86_64_SIZE64)
46 #define I386_SIZE_TYPE_P(TYPE) ((TYPE) == R_386_SIZE32)
47 #define X86_SIZE_TYPE_P(IS_X86_64, TYPE) \
48 ((IS_X86_64) ? X86_64_SIZE_TYPE_P(TYPE) : I386_SIZE_TYPE_P (TYPE))
50 #define PLT_CIE_LENGTH 20
51 #define PLT_FDE_LENGTH 36
52 #define PLT_FDE_START_OFFSET 4 + PLT_CIE_LENGTH + 8
53 #define PLT_FDE_LEN_OFFSET 4 + PLT_CIE_LENGTH + 12
55 #define ABI_64_P(abfd) \
56 (get_elf_backend_data (abfd)->s->elfclass == ELFCLASS64)
58 /* If ELIMINATE_COPY_RELOCS is non-zero, the linker will try to avoid
59 copying dynamic variables from a shared lib into an app's dynbss
60 section, and instead use a dynamic relocation to point into the
62 #define ELIMINATE_COPY_RELOCS 1
64 #define elf_x86_hash_table(p, id) \
65 (is_elf_hash_table ((p)->hash) \
66 && elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) == (id) \
67 ? ((struct elf_x86_link_hash_table *) ((p)->hash)) : NULL)
69 /* Will references to this symbol always be local in this object? */
70 #define SYMBOL_REFERENCES_LOCAL_P(INFO, H) \
71 _bfd_x86_elf_link_symbol_references_local ((INFO), (H))
73 /* TRUE if an undefined weak symbol should be resolved to 0. Local
74 undefined weak symbol is always resolved to 0. Reference to an
75 undefined weak symbol is resolved to 0 in executable if undefined
76 weak symbol should be resolved to 0 (zero_undefweak > 0). */
77 #define UNDEFINED_WEAK_RESOLVED_TO_ZERO(INFO, EH) \
78 ((EH)->elf.root.type == bfd_link_hash_undefweak \
79 && (SYMBOL_REFERENCES_LOCAL_P ((INFO), &(EH)->elf) \
80 || (bfd_link_executable (INFO) \
81 && (EH)->zero_undefweak > 0)))
83 /* Should copy relocation be generated for a symbol. Don't generate
84 copy relocation against a protected symbol defined in a shared
85 object with GNU_PROPERTY_NO_COPY_ON_PROTECTED. */
86 #define SYMBOL_NO_COPYRELOC(INFO, EH) \
87 ((EH)->def_protected \
88 && ((EH)->elf.root.type == bfd_link_hash_defined \
89 || (EH)->elf.root.type == bfd_link_hash_defweak) \
90 && elf_has_no_copy_on_protected ((EH)->elf.root.u.def.section->owner) \
91 && ((EH)->elf.root.u.def.section->owner->flags & DYNAMIC) != 0 \
92 && ((EH)->elf.root.u.def.section->flags & SEC_CODE) == 0)
94 /* TRUE if dynamic relocation is needed. If we are creating a shared
95 library, and this is a reloc against a global symbol, or a non PC
96 relative reloc against a local symbol, then we need to copy the reloc
97 into the shared library. However, if we are linking with -Bsymbolic,
98 we do not need to copy a reloc against a global symbol which is
99 defined in an object we are including in the link (i.e., DEF_REGULAR
102 If PCREL_PLT is true, don't generate dynamic relocation in PIE for
103 PC-relative relocation against a dynamic function definition in data
104 section when PLT address can be used.
106 If on the other hand, we are creating an executable, we may need to
107 keep relocations for symbols satisfied by a dynamic library if we
108 manage to avoid copy relocs for the symbol.
110 We also need to generate dynamic pointer relocation against
111 STT_GNU_IFUNC symbol in the non-code section. */
112 #define NEED_DYNAMIC_RELOCATION_P(IS_X86_64, INFO, PCREL_PLT, H, SEC, \
113 R_TYPE, POINTER_TYPE) \
114 ((bfd_link_pic (INFO) \
115 && (! X86_PCREL_TYPE_P (IS_X86_64, R_TYPE) \
117 && (! (bfd_link_pie (INFO) \
118 || SYMBOLIC_BIND ((INFO), (H))) \
119 || (H)->root.type == bfd_link_hash_defweak \
120 || (!(bfd_link_pie (INFO) \
122 && (H)->plt.refcount > 0 \
123 && ((SEC)->flags & SEC_CODE) == 0 \
124 && (H)->type == STT_FUNC \
125 && (H)->def_dynamic) \
126 && !(H)->def_regular))))) \
128 && (H)->type == STT_GNU_IFUNC \
129 && (R_TYPE) == POINTER_TYPE \
130 && ((SEC)->flags & SEC_CODE) == 0) \
131 || (ELIMINATE_COPY_RELOCS \
132 && !bfd_link_pic (INFO) \
134 && ((H)->root.type == bfd_link_hash_defweak \
135 || !(H)->def_regular)))
137 /* TRUE if dynamic relocation should be generated. Don't copy a
138 pc-relative relocation into the output file if the symbol needs
139 copy reloc or the symbol is undefined when building executable.
140 Copy dynamic function pointer relocations. Don't generate dynamic
141 relocations against resolved undefined weak symbols in PIE, except
142 when PC32_RELOC is TRUE. Undefined weak symbol is bound locally
143 when PIC is false. Don't generate dynamic relocations against
144 non-preemptible absolute symbol. */
145 #define GENERATE_DYNAMIC_RELOCATION_P(IS_X86_64, INFO, EH, R_TYPE, \
146 SEC, NEED_COPY_RELOC_IN_PIE, \
147 RESOLVED_TO_ZERO, PC32_RELOC) \
148 ((bfd_link_pic (INFO) \
149 && !(bfd_is_abs_section (SEC) \
151 || SYMBOL_REFERENCES_LOCAL (INFO, &(EH)->elf))) \
152 && !(NEED_COPY_RELOC_IN_PIE) \
154 || ((ELF_ST_VISIBILITY ((EH)->elf.other) == STV_DEFAULT \
155 && (!(RESOLVED_TO_ZERO) || PC32_RELOC)) \
156 || (EH)->elf.root.type != bfd_link_hash_undefweak)) \
157 && ((!X86_PCREL_TYPE_P (IS_X86_64, R_TYPE) \
158 && !X86_SIZE_TYPE_P (IS_X86_64, R_TYPE)) \
159 || ! SYMBOL_CALLS_LOCAL ((INFO), \
160 (struct elf_link_hash_entry *) (EH)))) \
161 || (ELIMINATE_COPY_RELOCS \
162 && !bfd_link_pic (INFO) \
164 && (EH)->elf.dynindx != -1 \
165 && (!(EH)->elf.non_got_ref \
166 || ((EH)->elf.root.type == bfd_link_hash_undefweak \
167 && !(RESOLVED_TO_ZERO))) \
168 && (((EH)->elf.def_dynamic && !(EH)->elf.def_regular) \
169 || (EH)->elf.root.type == bfd_link_hash_undefined)))
171 /* TRUE if this input relocation should be copied to output. H->dynindx
172 may be -1 if this symbol was marked to become local. */
173 #define COPY_INPUT_RELOC_P(IS_X86_64, INFO, H, R_TYPE) \
175 && (H)->dynindx != -1 \
176 && (X86_PCREL_TYPE_P (IS_X86_64, R_TYPE) \
177 || !(bfd_link_executable (INFO) || SYMBOLIC_BIND ((INFO), (H))) \
178 || !(H)->def_regular))
180 /* TRUE if this is actually a static link, or it is a -Bsymbolic link
181 and the symbol is defined locally, or the symbol was forced to be
182 local because of a version file. */
183 #define RESOLVED_LOCALLY_P(INFO, H, HTAB) \
184 (!WILL_CALL_FINISH_DYNAMIC_SYMBOL ((HTAB)->elf.dynamic_sections_created, \
185 bfd_link_pic (INFO), (H)) \
186 || (bfd_link_pic (INFO) \
187 && SYMBOL_REFERENCES_LOCAL_P ((INFO), (H))) \
188 || (ELF_ST_VISIBILITY ((H)->other) \
189 && (H)->root.type == bfd_link_hash_undefweak))
191 /* TRUE if this symbol isn't defined by a shared object. */
192 #define SYMBOL_DEFINED_NON_SHARED_P(H) \
194 || (H)->root.linker_def \
195 || (H)->root.ldscript_def \
196 || ((struct elf_x86_link_hash_entry *) (H))->linker_def \
197 || ELF_COMMON_DEF_P (H))
199 /* Return TRUE if the symbol described by a linker hash entry H is
200 going to be absolute. Similar to bfd_is_abs_symbol, but excluding
201 all linker-script defined symbols. */
202 #define ABS_SYMBOL_P(H) \
203 (bfd_is_abs_symbol (&(H)->root) && !(H)->root.ldscript_def)
205 /* TRUE if relative relocation should be generated. GOT reference to
206 global symbol in PIC will lead to dynamic symbol. It becomes a
207 problem when "time" or "times" is defined as a variable in an
208 executable, clashing with functions of the same name in libc. If a
209 symbol isn't undefined weak symbol, don't make it dynamic in PIC and
210 generate relative relocation. Don't generate relative relocation
211 against non-preemptible absolute symbol. */
212 #define GENERATE_RELATIVE_RELOC_P(INFO, H) \
213 ((H)->dynindx == -1 \
214 && !(H)->forced_local \
215 && (H)->root.type != bfd_link_hash_undefweak \
216 && bfd_link_pic (INFO) \
217 && !ABS_SYMBOL_P (H))
219 /* TRUE if this is a pointer reference to a local IFUNC. */
220 #define POINTER_LOCAL_IFUNC_P(INFO, H) \
221 ((H)->dynindx == -1 \
222 || (H)->forced_local \
223 || bfd_link_executable (INFO))
225 /* TRUE if this is a PLT reference to a local IFUNC. */
226 #define PLT_LOCAL_IFUNC_P(INFO, H) \
227 ((H)->dynindx == -1 \
228 || ((bfd_link_executable (INFO) \
229 || ELF_ST_VISIBILITY ((H)->other) != STV_DEFAULT) \
230 && (H)->def_regular \
231 && (H)->type == STT_GNU_IFUNC))
233 /* TRUE if TLS IE->LE transition is OK. */
234 #define TLS_TRANSITION_IE_TO_LE_P(INFO, H, TLS_TYPE) \
235 (bfd_link_executable (INFO) \
237 && (H)->dynindx == -1 \
238 && (TLS_TYPE & GOT_TLS_IE))
240 /* Verify that the symbol has an entry in the procedure linkage table. */
241 #define VERIFY_PLT_ENTRY(INFO, H, PLT, GOTPLT, RELPLT, LOCAL_UNDEFWEAK) \
244 if (((H)->dynindx == -1 \
245 && !LOCAL_UNDEFWEAK \
246 && !(((H)->forced_local || bfd_link_executable (INFO)) \
247 && (H)->def_regular \
248 && (H)->type == STT_GNU_IFUNC)) \
250 || (GOTPLT) == NULL \
251 || (RELPLT) == NULL) \
256 /* Verify that the symbol supports copy relocation. */
257 #define VERIFY_COPY_RELOC(H, HTAB) \
260 if ((H)->dynindx == -1 \
261 || ((H)->root.type != bfd_link_hash_defined \
262 && (H)->root.type != bfd_link_hash_defweak) \
263 || (HTAB)->elf.srelbss == NULL \
264 || (HTAB)->elf.sreldynrelro == NULL) \
269 /* x86 ELF linker hash entry. */
271 struct elf_x86_link_hash_entry
273 struct elf_link_hash_entry elf
;
275 unsigned char tls_type
;
277 /* Bit 0: Symbol has no GOT nor PLT relocations.
278 Bit 1: Symbol has non-GOT/non-PLT relocations in text sections.
279 zero_undefweak is initialized to 1 and undefined weak symbol
280 should be resolved to 0 if zero_undefweak > 0. */
281 unsigned int zero_undefweak
: 2;
283 /* Don't call finish_dynamic_symbol on this symbol. */
284 unsigned int no_finish_dynamic_symbol
: 1;
286 /* TRUE if symbol is __tls_get_addr. */
287 unsigned int tls_get_addr
: 1;
289 /* TRUE if symbol is defined as a protected symbol. */
290 unsigned int def_protected
: 1;
292 /* 0: Symbol references are unknown.
293 1: Symbol references aren't local.
294 2: Symbol references are local.
296 unsigned int local_ref
: 2;
298 /* TRUE if symbol is defined by linker. */
299 unsigned int linker_def
: 1;
301 /* TRUE if symbol is referenced by a non-GOT/non-PLT relocation in a
302 relocatable object file without indirect external access marker. */
303 unsigned int non_got_ref_without_indirect_extern_access
: 1;
305 /* TRUE if symbol is referenced by R_386_GOTOFF relocation. This is
306 only used by i386. */
307 unsigned int gotoff_ref
: 1;
309 /* TRUE if a weak symbol with a real definition needs a copy reloc.
310 When there is a weak symbol with a real definition, the processor
311 independent code will have arranged for us to see the real
312 definition first. We need to copy the needs_copy bit from the
313 real definition and check it when allowing copy reloc in PIE. This
314 is only used by x86-64. */
315 unsigned int needs_copy
: 1;
317 /* Information about the GOT PLT entry. Filled when there are both
318 GOT and PLT relocations against the same function. */
319 union gotplt_union plt_got
;
321 /* Information about the second PLT entry. */
322 union gotplt_union plt_second
;
324 /* Offset of the GOTPLT entry reserved for the TLS descriptor,
325 starting at the end of the jump table. */
329 struct elf_x86_lazy_plt_layout
331 /* The first entry in a lazy procedure linkage table looks like this. */
332 const bfd_byte
*plt0_entry
;
333 unsigned int plt0_entry_size
; /* Size of PLT0 entry. */
335 /* Later entries in a lazy procedure linkage table look like this. */
336 const bfd_byte
*plt_entry
;
337 unsigned int plt_entry_size
; /* Size of each PLT entry. */
339 /* The TLSDESC entry in a lazy procedure linkage table looks like
340 this. This is for x86-64 only. */
341 const bfd_byte
*plt_tlsdesc_entry
;
342 unsigned int plt_tlsdesc_entry_size
; /* Size of TLSDESC entry. */
344 /* Offsets into the TLSDESC entry that are to be replaced with
345 GOT+8 and GOT+TDG. These are for x86-64 only. */
346 unsigned int plt_tlsdesc_got1_offset
;
347 unsigned int plt_tlsdesc_got2_offset
;
349 /* Offset of the end of the PC-relative instructions containing
350 plt_tlsdesc_got1_offset and plt_tlsdesc_got2_offset. These
351 are for x86-64 only. */
352 unsigned int plt_tlsdesc_got1_insn_end
;
353 unsigned int plt_tlsdesc_got2_insn_end
;
355 /* Offsets into plt0_entry that are to be replaced with GOT[1] and
357 unsigned int plt0_got1_offset
;
358 unsigned int plt0_got2_offset
;
360 /* Offset of the end of the PC-relative instruction containing
361 plt0_got2_offset. This is for x86-64 only. */
362 unsigned int plt0_got2_insn_end
;
364 /* Offsets into plt_entry that are to be replaced with... */
365 unsigned int plt_got_offset
; /* ... address of this symbol in .got. */
366 unsigned int plt_reloc_offset
; /* ... offset into relocation table. */
367 unsigned int plt_plt_offset
; /* ... offset to start of .plt. */
369 /* Length of the PC-relative instruction containing plt_got_offset.
370 This is used for x86-64 only. */
371 unsigned int plt_got_insn_size
;
373 /* Offset of the end of the PC-relative jump to plt0_entry. This is
374 used for x86-64 only. */
375 unsigned int plt_plt_insn_end
;
377 /* Offset into plt_entry where the initial value of the GOT entry
379 unsigned int plt_lazy_offset
;
381 /* The first entry in a PIC lazy procedure linkage table looks like
383 const bfd_byte
*pic_plt0_entry
;
385 /* Subsequent entries in a PIC lazy procedure linkage table look
387 const bfd_byte
*pic_plt_entry
;
389 /* .eh_frame covering the lazy .plt section. */
390 const bfd_byte
*eh_frame_plt
;
391 unsigned int eh_frame_plt_size
;
394 struct elf_x86_non_lazy_plt_layout
396 /* Entries in a non-lazy procedure linkage table look like this. */
397 const bfd_byte
*plt_entry
;
398 /* Entries in a PIC non-lazy procedure linkage table look like this.
399 This is only used for i386 where absolute PLT and PIC PLT are
401 const bfd_byte
*pic_plt_entry
;
403 unsigned int plt_entry_size
; /* Size of each PLT entry. */
405 /* Offsets into plt_entry that are to be replaced with... */
406 unsigned int plt_got_offset
; /* ... address of this symbol in .got. */
408 /* Length of the PC-relative instruction containing plt_got_offset.
409 This is used for x86-64 only. */
410 unsigned int plt_got_insn_size
;
412 /* .eh_frame covering the non-lazy .plt section. */
413 const bfd_byte
*eh_frame_plt
;
414 unsigned int eh_frame_plt_size
;
417 struct elf_x86_plt_layout
419 /* The first entry in a lazy procedure linkage table looks like this. */
420 const bfd_byte
*plt0_entry
;
421 /* Entries in a procedure linkage table look like this. */
422 const bfd_byte
*plt_entry
;
423 unsigned int plt_entry_size
; /* Size of each PLT entry. */
426 unsigned int has_plt0
;
428 /* Offsets into plt_entry that are to be replaced with... */
429 unsigned int plt_got_offset
; /* ... address of this symbol in .got. */
431 /* Length of the PC-relative instruction containing plt_got_offset.
432 This is only used for x86-64. */
433 unsigned int plt_got_insn_size
;
435 /* Alignment of the .iplt section. */
436 unsigned int iplt_alignment
;
438 /* .eh_frame covering the .plt section. */
439 const bfd_byte
*eh_frame_plt
;
440 unsigned int eh_frame_plt_size
;
443 /* Values in tls_type of x86 ELF linker hash entry. */
444 #define GOT_UNKNOWN 0
448 #define GOT_TLS_IE_POS 5
449 #define GOT_TLS_IE_NEG 6
450 #define GOT_TLS_IE_BOTH 7
451 #define GOT_TLS_GDESC 8
453 #define GOT_TLS_GD_BOTH_P(type) \
454 ((type) == (GOT_TLS_GD | GOT_TLS_GDESC))
455 #define GOT_TLS_GD_P(type) \
456 ((type) == GOT_TLS_GD || GOT_TLS_GD_BOTH_P (type))
457 #define GOT_TLS_GDESC_P(type) \
458 ((type) == GOT_TLS_GDESC || GOT_TLS_GD_BOTH_P (type))
459 #define GOT_TLS_GD_ANY_P(type) \
460 (GOT_TLS_GD_P (type) || GOT_TLS_GDESC_P (type))
462 #define elf_x86_hash_entry(ent) \
463 ((struct elf_x86_link_hash_entry *)(ent))
465 /* x86 ELF linker hash table. */
467 struct elf_x86_link_hash_table
469 struct elf_link_hash_table elf
;
471 /* Short-cuts to get to dynamic linker sections. */
473 asection
*plt_eh_frame
;
474 asection
*plt_second
;
475 asection
*plt_second_eh_frame
;
477 asection
*plt_got_eh_frame
;
479 /* Parameters describing PLT generation, lazy or non-lazy. */
480 struct elf_x86_plt_layout plt
;
482 /* Parameters describing lazy PLT generation. */
483 const struct elf_x86_lazy_plt_layout
*lazy_plt
;
485 /* Parameters describing non-lazy PLT generation. */
486 const struct elf_x86_non_lazy_plt_layout
*non_lazy_plt
;
490 bfd_signed_vma refcount
;
494 /* The amount of space used by the jump slots in the GOT. */
495 bfd_vma sgotplt_jump_table_size
;
497 /* _TLS_MODULE_BASE_ symbol. */
498 struct bfd_link_hash_entry
*tls_module_base
;
500 /* Used by local STT_GNU_IFUNC symbols. */
501 htab_t loc_hash_table
;
502 void * loc_hash_memory
;
504 /* The index of the next R_X86_64_JUMP_SLOT entry in .rela.plt. */
505 bfd_vma next_jump_slot_index
;
506 /* The index of the next R_X86_64_IRELATIVE entry in .rela.plt. */
507 bfd_vma next_irelative_index
;
509 /* The (unloaded but important) .rel.plt.unloaded section on VxWorks.
510 This is used for i386 only. */
513 /* The index of the next unused R_386_TLS_DESC slot in .rel.plt. This
514 is only used for i386. */
515 bfd_vma next_tls_desc_index
;
517 /* Value used to fill the unused bytes of the first PLT entry. This
518 is only used for i386. */
519 bfd_byte plt0_pad_byte
;
521 /* TRUE if GOT is referenced. */
522 unsigned int got_referenced
: 1;
524 /* TRUE if PLT is PC-relative. PLT in PDE and PC-relative PLT in PIE
525 can be used as function address.
527 NB: i386 has non-PIC PLT and PIC PLT. Only non-PIC PLT in PDE can
528 be used as function address. PIC PLT in PIE can't be used as
530 unsigned int pcrel_plt
: 1;
532 bfd_vma (*r_info
) (bfd_vma
, bfd_vma
);
533 bfd_vma (*r_sym
) (bfd_vma
);
534 bool (*is_reloc_section
) (const char *);
535 unsigned int sizeof_reloc
;
536 unsigned int got_entry_size
;
537 unsigned int pointer_r_type
;
538 int dynamic_interpreter_size
;
539 const char *dynamic_interpreter
;
540 const char *tls_get_addr
;
542 /* Options passed from the linker. */
543 struct elf_linker_x86_params
*params
;
546 struct elf_x86_init_table
548 /* The lazy PLT layout. */
549 const struct elf_x86_lazy_plt_layout
*lazy_plt
;
551 /* The non-lazy PLT layout. */
552 const struct elf_x86_non_lazy_plt_layout
*non_lazy_plt
;
554 /* The lazy PLT layout for IBT. */
555 const struct elf_x86_lazy_plt_layout
*lazy_ibt_plt
;
557 /* The non-lazy PLT layout for IBT. */
558 const struct elf_x86_non_lazy_plt_layout
*non_lazy_ibt_plt
;
560 bfd_byte plt0_pad_byte
;
562 bfd_vma (*r_info
) (bfd_vma
, bfd_vma
);
563 bfd_vma (*r_sym
) (bfd_vma
);
566 struct elf_x86_obj_tdata
568 struct elf_obj_tdata root
;
570 /* tls_type for each local got entry. */
571 char *local_got_tls_type
;
573 /* GOTPLT entries for TLS descriptors. */
574 bfd_vma
*local_tlsdesc_gotent
;
577 enum elf_x86_plt_type
591 enum elf_x86_plt_type type
;
592 unsigned int plt_got_offset
;
593 unsigned int plt_entry_size
;
594 unsigned int plt_got_insn_size
; /* Only used for x86-64. */
598 /* Set if a relocation is converted from a GOTPCREL relocation. */
599 #define R_X86_64_converted_reloc_bit (1 << 7)
601 #define elf_x86_tdata(abfd) \
602 ((struct elf_x86_obj_tdata *) (abfd)->tdata.any)
604 #define elf_x86_local_got_tls_type(abfd) \
605 (elf_x86_tdata (abfd)->local_got_tls_type)
607 #define elf_x86_local_tlsdesc_gotent(abfd) \
608 (elf_x86_tdata (abfd)->local_tlsdesc_gotent)
610 #define elf_x86_compute_jump_table_size(htab) \
611 ((htab)->elf.srelplt->reloc_count * (htab)->got_entry_size)
613 #define is_x86_elf(bfd, htab) \
614 (bfd_get_flavour (bfd) == bfd_target_elf_flavour \
615 && elf_tdata (bfd) != NULL \
616 && elf_object_id (bfd) == (htab)->elf.hash_table_id)
618 /* Rename some of the generic section flags to better document how they
620 #define check_relocs_failed sec_flg0
622 extern bool _bfd_x86_elf_mkobject
625 extern void _bfd_x86_elf_set_tls_module_base
626 (struct bfd_link_info
*);
628 extern bfd_vma _bfd_x86_elf_dtpoff_base
629 (struct bfd_link_info
*);
631 extern bool _bfd_x86_elf_readonly_dynrelocs
632 (struct elf_link_hash_entry
*, void *);
634 extern struct elf_link_hash_entry
* _bfd_elf_x86_get_local_sym_hash
635 (struct elf_x86_link_hash_table
*, bfd
*, const Elf_Internal_Rela
*,
638 extern hashval_t _bfd_x86_elf_local_htab_hash
641 extern int _bfd_x86_elf_local_htab_eq
642 (const void *, const void *);
644 extern struct bfd_hash_entry
* _bfd_x86_elf_link_hash_newfunc
645 (struct bfd_hash_entry
*, struct bfd_hash_table
*, const char *);
647 extern struct bfd_link_hash_table
* _bfd_x86_elf_link_hash_table_create
650 extern int _bfd_x86_elf_compare_relocs
651 (const void *, const void *);
653 extern bool _bfd_x86_elf_link_check_relocs
654 (bfd
*, struct bfd_link_info
*);
656 extern bool _bfd_elf_x86_valid_reloc_p
657 (asection
*, struct bfd_link_info
*, struct elf_x86_link_hash_table
*,
658 const Elf_Internal_Rela
*, struct elf_link_hash_entry
*,
659 Elf_Internal_Sym
*, Elf_Internal_Shdr
*, bool *);
661 extern bool _bfd_x86_elf_size_dynamic_sections
662 (bfd
*, struct bfd_link_info
*);
664 extern struct elf_x86_link_hash_table
*_bfd_x86_elf_finish_dynamic_sections
665 (bfd
*, struct bfd_link_info
*);
667 extern bool _bfd_x86_elf_always_size_sections
668 (bfd
*, struct bfd_link_info
*);
670 extern void _bfd_x86_elf_merge_symbol_attribute
671 (struct elf_link_hash_entry
*, unsigned int, bool, bool);
673 extern void _bfd_x86_elf_copy_indirect_symbol
674 (struct bfd_link_info
*, struct elf_link_hash_entry
*,
675 struct elf_link_hash_entry
*);
677 extern bool _bfd_x86_elf_fixup_symbol
678 (struct bfd_link_info
*, struct elf_link_hash_entry
*);
680 extern bool _bfd_x86_elf_hash_symbol
681 (struct elf_link_hash_entry
*);
683 extern bool _bfd_x86_elf_adjust_dynamic_symbol
684 (struct bfd_link_info
*, struct elf_link_hash_entry
*);
686 extern void _bfd_x86_elf_hide_symbol
687 (struct bfd_link_info
*, struct elf_link_hash_entry
*, bool);
689 extern bool _bfd_x86_elf_link_symbol_references_local
690 (struct bfd_link_info
*, struct elf_link_hash_entry
*);
692 extern asection
* _bfd_x86_elf_gc_mark_hook
693 (asection
*, struct bfd_link_info
*, Elf_Internal_Rela
*,
694 struct elf_link_hash_entry
*, Elf_Internal_Sym
*);
696 extern long _bfd_x86_elf_get_synthetic_symtab
697 (bfd
*, long, long, bfd_vma
, struct elf_x86_plt
[], asymbol
**,
700 extern enum elf_property_kind _bfd_x86_elf_parse_gnu_properties
701 (bfd
*, unsigned int, bfd_byte
*, unsigned int);
703 extern bool _bfd_x86_elf_merge_gnu_properties
704 (struct bfd_link_info
*, bfd
*, bfd
*, elf_property
*, elf_property
*);
706 extern void _bfd_x86_elf_link_fixup_gnu_properties
707 (struct bfd_link_info
*, elf_property_list
**);
709 extern bfd
* _bfd_x86_elf_link_setup_gnu_properties
710 (struct bfd_link_info
*, struct elf_x86_init_table
*);
712 extern void _bfd_x86_elf_link_fixup_ifunc_symbol
713 (struct bfd_link_info
*, struct elf_x86_link_hash_table
*,
714 struct elf_link_hash_entry
*, Elf_Internal_Sym
*sym
);
716 extern void _bfd_x86_elf_link_report_relative_reloc
717 (struct bfd_link_info
*, asection
*, struct elf_link_hash_entry
*,
718 Elf_Internal_Sym
*, const char *, const void *);
720 #define bfd_elf64_mkobject \
721 _bfd_x86_elf_mkobject
722 #define bfd_elf32_mkobject \
723 _bfd_x86_elf_mkobject
724 #define bfd_elf64_bfd_link_hash_table_create \
725 _bfd_x86_elf_link_hash_table_create
726 #define bfd_elf32_bfd_link_hash_table_create \
727 _bfd_x86_elf_link_hash_table_create
728 #define bfd_elf64_bfd_link_check_relocs \
729 _bfd_x86_elf_link_check_relocs
730 #define bfd_elf32_bfd_link_check_relocs \
731 _bfd_x86_elf_link_check_relocs
733 #define elf_backend_size_dynamic_sections \
734 _bfd_x86_elf_size_dynamic_sections
735 #define elf_backend_always_size_sections \
736 _bfd_x86_elf_always_size_sections
737 #define elf_backend_merge_symbol_attribute \
738 _bfd_x86_elf_merge_symbol_attribute
739 #define elf_backend_copy_indirect_symbol \
740 _bfd_x86_elf_copy_indirect_symbol
741 #define elf_backend_fixup_symbol \
742 _bfd_x86_elf_fixup_symbol
743 #define elf_backend_hash_symbol \
744 _bfd_x86_elf_hash_symbol
745 #define elf_backend_adjust_dynamic_symbol \
746 _bfd_x86_elf_adjust_dynamic_symbol
747 #define elf_backend_gc_mark_hook \
748 _bfd_x86_elf_gc_mark_hook
749 #define elf_backend_omit_section_dynsym \
750 _bfd_elf_omit_section_dynsym_all
751 #define elf_backend_parse_gnu_properties \
752 _bfd_x86_elf_parse_gnu_properties
753 #define elf_backend_merge_gnu_properties \
754 _bfd_x86_elf_merge_gnu_properties
755 #define elf_backend_fixup_gnu_properties \
756 _bfd_x86_elf_link_fixup_gnu_properties
758 /* Return true if H is a __start_SECNAME/__stop_SECNAME symbol for the
759 SECNAME section which has been garbage collected by --gc-sections
763 elf_x86_start_stop_gc_p (struct bfd_link_info
*link_info
,
764 struct elf_link_hash_entry
*h
)
767 && link_info
->gc_sections
768 && link_info
->start_stop_gc
)
770 asection
*s
= h
->root
.u
.def
.section
;
774 /* Return false if any SECNAME section is kept. */
777 s
= bfd_get_next_section_by_name (s
->owner
, s
);
781 /* Return true only if all SECNAME sections have been garbage
786 /* Return false if H isn't a __start_SECNAME/__stop_SECNAME symbol or
787 --gc-sections or -z start-stop-gc isn't used. */