/src/binutils-gdb/bfd/elfxx-x86.h
Line | Count | Source |
1 | | /* x86 specific support for ELF |
2 | | Copyright (C) 2017-2026 Free Software Foundation, Inc. |
3 | | |
4 | | This file is part of BFD, the Binary File Descriptor library. |
5 | | |
6 | | This program is free software; you can redistribute it and/or modify |
7 | | it under the terms of the GNU General Public License as published by |
8 | | the Free Software Foundation; either version 3 of the License, or |
9 | | (at your option) any later version. |
10 | | |
11 | | This program is distributed in the hope that it will be useful, |
12 | | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | | GNU General Public License for more details. |
15 | | |
16 | | You should have received a copy of the GNU General Public License |
17 | | along with this program; if not, write to the Free Software |
18 | | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
19 | | MA 02110-1301, USA. */ |
20 | | |
21 | | /* Don't generate unused section symbols. */ |
22 | | #define TARGET_KEEP_UNUSED_SECTION_SYMBOLS false |
23 | | |
24 | | #include "sysdep.h" |
25 | | #include "bfd.h" |
26 | | #include "bfdlink.h" |
27 | | #include "libbfd.h" |
28 | | #include "elf-bfd.h" |
29 | | #include "hashtab.h" |
30 | | #include "elf-linker-x86.h" |
31 | | #include "elf/i386.h" |
32 | | #include "elf/x86-64.h" |
33 | | #include "sframe-api.h" |
34 | | |
35 | | #define X86_64_PCREL_TYPE_P(TYPE) \ |
36 | 0 | ((TYPE) == R_X86_64_PC8 \ |
37 | 0 | || (TYPE) == R_X86_64_PC16 \ |
38 | 0 | || (TYPE) == R_X86_64_PC32 \ |
39 | 0 | || (TYPE) == R_X86_64_PC64) |
40 | 0 | #define I386_PCREL_TYPE_P(TYPE) ((TYPE) == R_386_PC32) |
41 | | #define X86_PCREL_TYPE_P(IS_X86_64, TYPE) \ |
42 | 0 | ((IS_X86_64) ? X86_64_PCREL_TYPE_P (TYPE) : I386_PCREL_TYPE_P (TYPE)) |
43 | | |
44 | | #define X86_64_SIZE_TYPE_P(TYPE) \ |
45 | 0 | ((TYPE) == R_X86_64_SIZE32 || (TYPE) == R_X86_64_SIZE64) |
46 | 0 | #define I386_SIZE_TYPE_P(TYPE) ((TYPE) == R_386_SIZE32) |
47 | | #define X86_SIZE_TYPE_P(IS_X86_64, TYPE) \ |
48 | 0 | ((IS_X86_64) ? X86_64_SIZE_TYPE_P(TYPE) : I386_SIZE_TYPE_P (TYPE)) |
49 | | |
50 | | #define X86_64_GOT_TYPE_P(TYPE) \ |
51 | 0 | ((TYPE) == R_X86_64_GOTPCREL \ |
52 | 0 | || (TYPE) == R_X86_64_GOTPCRELX \ |
53 | 0 | || (TYPE) == R_X86_64_REX_GOTPCRELX \ |
54 | 0 | || (TYPE) == R_X86_64_GOT32 \ |
55 | 0 | || (TYPE) == R_X86_64_GOT64 \ |
56 | 0 | || (TYPE) == R_X86_64_GOTPCREL64 \ |
57 | 0 | || (TYPE) == R_X86_64_GOTPLT64) |
58 | | #define I386_GOT_TYPE_P(TYPE) \ |
59 | 0 | ((TYPE) == R_386_GOT32 || (TYPE) == R_386_GOT32X) |
60 | | #define X86_GOT_TYPE_P(IS_X86_64, TYPE) \ |
61 | 0 | ((IS_X86_64) ? X86_64_GOT_TYPE_P (TYPE) : I386_GOT_TYPE_P (TYPE)) |
62 | | |
63 | | #define X86_64_RELATIVE_RELOC_TYPE_P(TYPE) \ |
64 | 0 | (X86_64_PCREL_TYPE_P (TYPE) \ |
65 | 0 | || (TYPE) == R_X86_64_8 \ |
66 | 0 | || (TYPE) == R_X86_64_16 \ |
67 | 0 | || (TYPE) == R_X86_64_32 \ |
68 | 0 | || (TYPE) == R_X86_64_32S \ |
69 | 0 | || (TYPE) == R_X86_64_64) |
70 | | #define I386_RELATIVE_RELOC_TYPE_P(TYPE) \ |
71 | 0 | ((TYPE) == R_386_32 || (TYPE) == R_386_PC32) |
72 | | #define X86_RELATIVE_RELOC_TYPE_P(IS_X86_64, TYPE) \ |
73 | 0 | ((IS_X86_64) \ |
74 | 0 | ? X86_64_RELATIVE_RELOC_TYPE_P (TYPE) \ |
75 | 0 | : I386_RELATIVE_RELOC_TYPE_P(TYPE)) |
76 | | |
77 | | #define X86_64_NEED_DYNAMIC_RELOC_TYPE_P(TYPE) \ |
78 | 0 | (X86_64_SIZE_TYPE_P (TYPE) \ |
79 | 0 | || X86_64_RELATIVE_RELOC_TYPE_P (TYPE)) |
80 | | #define I386_NEED_DYNAMIC_RELOC_TYPE_P(TYPE) \ |
81 | 0 | (I386_SIZE_TYPE_P (TYPE) \ |
82 | 0 | || I386_RELATIVE_RELOC_TYPE_P (TYPE) \ |
83 | 0 | || (TYPE) == R_386_TLS_IE \ |
84 | 0 | || (TYPE) == R_386_TLS_LE \ |
85 | 0 | || (TYPE) == R_386_TLS_LE_32) |
86 | | #define X86_NEED_DYNAMIC_RELOC_TYPE_P(IS_X86_64, TYPE) \ |
87 | 0 | ((IS_X86_64) \ |
88 | 0 | ? X86_64_NEED_DYNAMIC_RELOC_TYPE_P (TYPE) \ |
89 | 0 | : I386_NEED_DYNAMIC_RELOC_TYPE_P (TYPE)) |
90 | | |
91 | | #define X86_LOCAL_GOT_RELATIVE_RELOC_P(IS_X86_64, INFO, SYM) \ |
92 | 0 | (bfd_link_pic (INFO) \ |
93 | 0 | && (!(IS_X86_64) || ((SYM) != NULL && (SYM)->st_shndx != SHN_ABS))) |
94 | | |
95 | 0 | #define PLT_CIE_LENGTH 20 |
96 | | #define PLT_FDE_LENGTH 36 |
97 | 0 | #define PLT_FDE_START_OFFSET 4 + PLT_CIE_LENGTH + 8 |
98 | | #define PLT_FDE_LEN_OFFSET 4 + PLT_CIE_LENGTH + 12 |
99 | | |
100 | | /* This must be the same as sframe_get_hdr_size (sfh). For x86-64, this value |
101 | | is the same as sizeof (sframe_header) because there is no SFrame auxilliary |
102 | | header. */ |
103 | 0 | #define PLT_SFRAME_FDE_START_OFFSET sizeof (sframe_header) |
104 | | |
105 | | /* If ELIMINATE_COPY_RELOCS is non-zero, the linker will try to avoid |
106 | | copying dynamic variables from a shared lib into an app's dynbss |
107 | | section, and instead use a dynamic relocation to point into the |
108 | | shared lib. */ |
109 | 0 | #define ELIMINATE_COPY_RELOCS 1 |
110 | | |
111 | | /* Return true if ID names an x86 ELF backend, so that struct |
112 | | elf_x86_link_hash_table is the correct layout of the link hash table. |
113 | | ID is the target id of the output backend, which a linker script can |
114 | | retarget with OUTPUT_FORMAT, so it need not name an x86 backend. */ |
115 | | |
116 | | static inline bool |
117 | | elf_x86_target_id_p (enum elf_target_id id) |
118 | 0 | { |
119 | 0 | return id == X86_64_ELF_DATA || id == I386_ELF_DATA; |
120 | 0 | } Unexecuted instantiation: elf64-x86-64.c:elf_x86_target_id_p Unexecuted instantiation: elfxx-x86.c:elf_x86_target_id_p Unexecuted instantiation: elf32-i386.c:elf_x86_target_id_p |
121 | | |
122 | | #define elf_x86_hash_table(p, id) \ |
123 | 0 | (is_elf_hash_table ((p)->hash) \ |
124 | 0 | && elf_x86_target_id_p (id) \ |
125 | 0 | && elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) == (id) \ |
126 | 0 | ? ((struct elf_x86_link_hash_table *) ((p)->hash)) : NULL) |
127 | | |
128 | | /* Will references to this symbol always be local in this object? */ |
129 | | #define SYMBOL_REFERENCES_LOCAL_P(INFO, H) \ |
130 | 0 | _bfd_x86_elf_link_symbol_references_local ((INFO), (H)) |
131 | | |
132 | | /* TRUE if an undefined weak symbol should be resolved to 0. Local |
133 | | undefined weak symbol is always resolved to 0. Reference to an |
134 | | undefined weak symbol is resolved to 0 in executable if undefined |
135 | | weak symbol should be resolved to 0 (zero_undefweak > 0). */ |
136 | | #define UNDEFINED_WEAK_RESOLVED_TO_ZERO(INFO, EH) \ |
137 | 0 | ((EH)->elf.root.type == bfd_link_hash_undefweak \ |
138 | 0 | && (SYMBOL_REFERENCES_LOCAL_P ((INFO), &(EH)->elf) \ |
139 | 0 | || (bfd_link_executable (INFO) \ |
140 | 0 | && (EH)->zero_undefweak > 0))) |
141 | | |
142 | | /* Should copy relocation be generated for a symbol. Don't generate |
143 | | copy relocation against a protected symbol defined in a shared |
144 | | object. */ |
145 | | #define SYMBOL_NO_COPYRELOC(INFO, EH) \ |
146 | 0 | ((EH)->def_protected \ |
147 | 0 | && ((EH)->elf.root.type == bfd_link_hash_defined \ |
148 | 0 | || (EH)->elf.root.type == bfd_link_hash_defweak) \ |
149 | 0 | && ((EH)->elf.root.u.def.section->owner->flags & DYNAMIC) != 0 \ |
150 | 0 | && ((EH)->elf.root.u.def.section->flags & SEC_CODE) == 0) |
151 | | |
152 | | /* TRUE if dynamic relocation is needed. If we are creating a shared |
153 | | library, and this is a reloc against a global symbol, or a non PC |
154 | | relative reloc against a local symbol, then we need to copy the reloc |
155 | | into the shared library. However, if we are linking with -Bsymbolic, |
156 | | we do not need to copy a reloc against a global symbol which is |
157 | | defined in an object we are including in the link (i.e., DEF_REGULAR |
158 | | is set). |
159 | | |
160 | | If PCREL_PLT is true, don't generate dynamic relocation in PIE for |
161 | | PC-relative relocation against a dynamic function definition in data |
162 | | section when PLT address can be used. |
163 | | |
164 | | If on the other hand, we are creating an executable, we may need to |
165 | | keep relocations for symbols satisfied by a dynamic library if we |
166 | | manage to avoid copy relocs for the symbol. |
167 | | |
168 | | We also need to generate dynamic pointer relocation against |
169 | | STT_GNU_IFUNC symbol in the non-code section. */ |
170 | | #define NEED_DYNAMIC_RELOCATION_P(IS_X86_64, INFO, PCREL_PLT, H, SEC, \ |
171 | | R_TYPE, POINTER_TYPE) \ |
172 | 0 | ((bfd_link_pic (INFO) \ |
173 | 0 | && (! X86_PCREL_TYPE_P (IS_X86_64, R_TYPE) \ |
174 | 0 | || ((H) != NULL \ |
175 | 0 | && (! (bfd_link_pie (INFO) \ |
176 | 0 | || SYMBOLIC_BIND ((INFO), (H))) \ |
177 | 0 | || (H)->root.type == bfd_link_hash_defweak \ |
178 | 0 | || (!(bfd_link_pie (INFO) \ |
179 | 0 | && (PCREL_PLT) \ |
180 | 0 | && (H)->plt.refcount > 0 \ |
181 | 0 | && ((SEC)->flags & SEC_CODE) == 0 \ |
182 | 0 | && (H)->type == STT_FUNC \ |
183 | 0 | && (H)->def_dynamic) \ |
184 | 0 | && !(H)->def_regular))))) \ |
185 | 0 | || ((H) != NULL \ |
186 | 0 | && (H)->type == STT_GNU_IFUNC \ |
187 | 0 | && (R_TYPE) == POINTER_TYPE \ |
188 | 0 | && ((SEC)->flags & SEC_CODE) == 0) \ |
189 | 0 | || (ELIMINATE_COPY_RELOCS \ |
190 | 0 | && !bfd_link_pic (INFO) \ |
191 | 0 | && (H) != NULL \ |
192 | 0 | && ((H)->root.type == bfd_link_hash_defweak \ |
193 | 0 | || !(H)->def_regular))) |
194 | | |
195 | | /* TRUE if dynamic relocation should be generated. Don't copy a |
196 | | pc-relative relocation into the output file if the symbol needs |
197 | | copy reloc or the symbol is undefined when building executable. |
198 | | Copy dynamic function pointer relocations. Don't generate dynamic |
199 | | relocations against resolved undefined weak symbols in PIE, except |
200 | | when PC32_RELOC is TRUE. Undefined weak symbol is bound locally |
201 | | when PIC is false. Don't generate dynamic relocations against |
202 | | non-preemptible absolute symbol. NB: rel_from_abs is set on symbols |
203 | | defined by linker scripts from "dot" (also SEGMENT_START or ORIGIN) |
204 | | outside of an output section statement, which will be converted from |
205 | | absolute to section-relative in set_sym_sections called from |
206 | | ldexp_finalize_syms after ldemul_finish. */ |
207 | | #define GENERATE_DYNAMIC_RELOCATION_P(IS_X86_64, INFO, EH, R_TYPE, \ |
208 | | SEC, NEED_COPY_RELOC_IN_PIE, \ |
209 | | RESOLVED_TO_ZERO, PC32_RELOC) \ |
210 | 0 | ((bfd_link_pic (INFO) \ |
211 | 0 | && !(bfd_is_abs_section (SEC) \ |
212 | 0 | && ((EH) == NULL \ |
213 | 0 | || (EH)->elf.root.rel_from_abs == 0) \ |
214 | 0 | && ((EH) == NULL \ |
215 | 0 | || SYMBOL_REFERENCES_LOCAL (INFO, &(EH)->elf))) \ |
216 | 0 | && !(NEED_COPY_RELOC_IN_PIE) \ |
217 | 0 | && ((EH) == NULL \ |
218 | 0 | || ((ELF_ST_VISIBILITY ((EH)->elf.other) == STV_DEFAULT \ |
219 | 0 | && (!(RESOLVED_TO_ZERO) || PC32_RELOC)) \ |
220 | 0 | || (EH)->elf.root.type != bfd_link_hash_undefweak)) \ |
221 | 0 | && ((!X86_PCREL_TYPE_P (IS_X86_64, R_TYPE) \ |
222 | 0 | && !X86_SIZE_TYPE_P (IS_X86_64, R_TYPE)) \ |
223 | 0 | || ! SYMBOL_CALLS_LOCAL ((INFO), \ |
224 | 0 | (struct elf_link_hash_entry *) (EH)))) \ |
225 | 0 | || (ELIMINATE_COPY_RELOCS \ |
226 | 0 | && !bfd_link_pic (INFO) \ |
227 | 0 | && (EH) != NULL \ |
228 | 0 | && (EH)->elf.dynindx != -1 \ |
229 | 0 | && (!(EH)->elf.non_got_ref \ |
230 | 0 | || ((EH)->elf.root.type == bfd_link_hash_undefweak \ |
231 | 0 | && !(RESOLVED_TO_ZERO))) \ |
232 | 0 | && (((EH)->elf.def_dynamic && !(EH)->elf.def_regular) \ |
233 | 0 | || (EH)->elf.root.type == bfd_link_hash_undefined))) |
234 | | |
235 | | /* TRUE if this input relocation should be copied to output. H->dynindx |
236 | | may be -1 if this symbol was marked to become local. STV_PROTECTED |
237 | | symbols are local. */ |
238 | | #define COPY_INPUT_RELOC_P(IS_X86_64, INFO, H, R_TYPE) \ |
239 | 0 | ((H) != NULL \ |
240 | 0 | && (H)->dynindx != -1 \ |
241 | 0 | && (X86_PCREL_TYPE_P (IS_X86_64, R_TYPE) \ |
242 | 0 | || !(bfd_link_executable (INFO) \ |
243 | 0 | || SYMBOLIC_BIND ((INFO), (H)) \ |
244 | 0 | || ELF_ST_VISIBILITY ((H)->other) == STV_PROTECTED) \ |
245 | 0 | || !(H)->def_regular)) |
246 | | |
247 | | /* TRUE if this is actually a static link, or it is a -Bsymbolic link |
248 | | and the symbol is defined locally, or the symbol was forced to be |
249 | | local because of a version file. */ |
250 | | #define RESOLVED_LOCALLY_P(INFO, H, HTAB) \ |
251 | 0 | (!WILL_CALL_FINISH_DYNAMIC_SYMBOL ((HTAB)->elf.dynamic_sections_created, \ |
252 | 0 | bfd_link_pic (INFO), (H)) \ |
253 | 0 | || (bfd_link_pic (INFO) \ |
254 | 0 | && SYMBOL_REFERENCES_LOCAL_P ((INFO), (H))) \ |
255 | 0 | || (ELF_ST_VISIBILITY ((H)->other) \ |
256 | 0 | && (H)->root.type == bfd_link_hash_undefweak)) |
257 | | |
258 | | /* TRUE if this symbol isn't defined by a shared object. */ |
259 | | #define SYMBOL_DEFINED_NON_SHARED_P(H) \ |
260 | 0 | ((H)->def_regular \ |
261 | 0 | || (H)->root.linker_def \ |
262 | 0 | || (H)->root.ldscript_def \ |
263 | 0 | || ((struct elf_x86_link_hash_entry *) (H))->linker_def \ |
264 | 0 | || ELF_COMMON_DEF_P (H)) |
265 | | |
266 | | /* Return TRUE if the symbol described by a linker hash entry H is |
267 | | going to be absolute. Similar to bfd_is_abs_symbol, but excluding |
268 | | all linker-script defined symbols. */ |
269 | | #define ABS_SYMBOL_P(H) \ |
270 | 0 | (bfd_is_abs_symbol (&(H)->root) && !(H)->root.ldscript_def) |
271 | | |
272 | | /* TRUE if relative relocation should be generated. GOT reference to |
273 | | global symbol in PIC will lead to dynamic symbol. It becomes a |
274 | | problem when "time" or "times" is defined as a variable in an |
275 | | executable, clashing with functions of the same name in libc. If a |
276 | | symbol isn't undefined weak symbol, don't make it dynamic in PIC and |
277 | | generate relative relocation. Don't generate relative relocation |
278 | | against non-preemptible absolute symbol. */ |
279 | | #define GENERATE_RELATIVE_RELOC_P(INFO, H) \ |
280 | 0 | ((H)->dynindx == -1 \ |
281 | 0 | && !(H)->forced_local \ |
282 | 0 | && (H)->root.type != bfd_link_hash_undefweak \ |
283 | 0 | && bfd_link_pic (INFO) \ |
284 | 0 | && !ABS_SYMBOL_P (H)) |
285 | | |
286 | | /* TRUE if this is a pointer reference to a local IFUNC. */ |
287 | | #define POINTER_LOCAL_IFUNC_P(INFO, H) \ |
288 | 0 | ((H)->dynindx == -1 \ |
289 | 0 | || (H)->forced_local \ |
290 | 0 | || bfd_link_executable (INFO)) |
291 | | |
292 | | /* TRUE if this is a PLT reference to a local IFUNC. */ |
293 | | #define PLT_LOCAL_IFUNC_P(INFO, H) \ |
294 | 0 | ((H)->dynindx == -1 \ |
295 | 0 | || ((bfd_link_executable (INFO) \ |
296 | 0 | || ELF_ST_VISIBILITY ((H)->other) != STV_DEFAULT) \ |
297 | 0 | && (H)->def_regular \ |
298 | 0 | && (H)->type == STT_GNU_IFUNC)) |
299 | | |
300 | | /* TRUE if TLS IE->LE transition is OK. */ |
301 | | #define TLS_TRANSITION_IE_TO_LE_P(INFO, H, TLS_TYPE) \ |
302 | 0 | (bfd_link_executable (INFO) \ |
303 | 0 | && (H) != NULL \ |
304 | 0 | && (H)->dynindx == -1 \ |
305 | 0 | && (TLS_TYPE & GOT_TLS_IE)) |
306 | | |
307 | | /* Verify that the symbol has an entry in the procedure linkage table. */ |
308 | | #define VERIFY_PLT_ENTRY(INFO, H, PLT, GOTPLT, RELPLT, LOCAL_UNDEFWEAK) \ |
309 | 0 | do \ |
310 | 0 | { \ |
311 | 0 | if (((H)->dynindx == -1 \ |
312 | 0 | && !LOCAL_UNDEFWEAK \ |
313 | 0 | && !(((H)->forced_local || bfd_link_executable (INFO)) \ |
314 | 0 | && (H)->def_regular \ |
315 | 0 | && (H)->type == STT_GNU_IFUNC)) \ |
316 | 0 | || (PLT) == NULL \ |
317 | 0 | || (GOTPLT) == NULL \ |
318 | 0 | || (RELPLT) == NULL) \ |
319 | 0 | abort (); \ |
320 | 0 | } \ |
321 | 0 | while (0); |
322 | | |
323 | | /* Verify that the symbol supports copy relocation. */ |
324 | | #define VERIFY_COPY_RELOC(H, HTAB) \ |
325 | 0 | do \ |
326 | 0 | { \ |
327 | 0 | if ((H)->dynindx == -1 \ |
328 | 0 | || ((H)->root.type != bfd_link_hash_defined \ |
329 | 0 | && (H)->root.type != bfd_link_hash_defweak) \ |
330 | 0 | || (HTAB)->elf.srelbss == NULL \ |
331 | 0 | || (HTAB)->elf.sreldynrelro == NULL) \ |
332 | 0 | abort (); \ |
333 | 0 | } \ |
334 | 0 | while (0); |
335 | | |
336 | | /* x86 ELF linker hash entry. */ |
337 | | |
338 | | struct elf_x86_link_hash_entry |
339 | | { |
340 | | struct elf_link_hash_entry elf; |
341 | | |
342 | | unsigned char tls_type; |
343 | | |
344 | | /* Bit 0: Symbol has no GOT nor PLT relocations. |
345 | | Bit 1: Symbol has non-GOT/non-PLT relocations in text sections. |
346 | | zero_undefweak is initialized to 1 and undefined weak symbol |
347 | | should be resolved to 0 if zero_undefweak > 0. */ |
348 | | unsigned int zero_undefweak : 2; |
349 | | |
350 | | /* Don't call finish_dynamic_symbol on this symbol. */ |
351 | | unsigned int no_finish_dynamic_symbol : 1; |
352 | | |
353 | | /* R_*_RELATIVE relocation in GOT for this symbol has been |
354 | | processed. */ |
355 | | unsigned int got_relative_reloc_done : 1; |
356 | | |
357 | | /* TRUE if symbol is __tls_get_addr. */ |
358 | | unsigned int tls_get_addr : 1; |
359 | | |
360 | | /* TRUE if symbol is defined as a protected symbol. */ |
361 | | unsigned int def_protected : 1; |
362 | | |
363 | | /* 0: Symbol references are unknown. |
364 | | 1: Symbol references aren't local. |
365 | | 2: Symbol references are local. |
366 | | */ |
367 | | unsigned int local_ref : 2; |
368 | | |
369 | | /* TRUE if symbol is defined by linker. */ |
370 | | unsigned int linker_def : 1; |
371 | | |
372 | | /* TRUE if symbol is referenced by a non-GOT/non-PLT relocation in a |
373 | | relocatable object file without indirect external access marker. */ |
374 | | unsigned int non_got_ref_without_indirect_extern_access : 1; |
375 | | |
376 | | /* TRUE if symbol is referenced by R_386_GOTOFF relocation. This is |
377 | | only used by i386. */ |
378 | | unsigned int gotoff_ref : 1; |
379 | | |
380 | | /* TRUE if a weak symbol with a real definition needs a copy reloc. |
381 | | When there is a weak symbol with a real definition, the processor |
382 | | independent code will have arranged for us to see the real |
383 | | definition first. We need to copy the needs_copy bit from the |
384 | | real definition and check it when allowing copy reloc in PIE. This |
385 | | is only used by x86-64. */ |
386 | | unsigned int needs_copy : 1; |
387 | | |
388 | | /* Information about the GOT PLT entry. Filled when there are both |
389 | | GOT and PLT relocations against the same function. */ |
390 | | union gotplt_union plt_got; |
391 | | |
392 | | /* Information about the second PLT entry. */ |
393 | | union gotplt_union plt_second; |
394 | | |
395 | | /* Offset of the GOTPLT entry reserved for the TLS descriptor, |
396 | | starting at the end of the jump table. */ |
397 | | bfd_vma tlsdesc_got; |
398 | | }; |
399 | | |
400 | | #define SFRAME_PLT0_MAX_NUM_FRES 2 |
401 | | #define SFRAME_PLTN_MAX_NUM_FRES 2 |
402 | | |
403 | | struct elf_x86_sframe_plt |
404 | | { |
405 | | unsigned int plt0_entry_size; |
406 | | unsigned int plt0_num_fres; |
407 | | const sframe_frame_row_entry *plt0_fres[SFRAME_PLT0_MAX_NUM_FRES]; |
408 | | |
409 | | unsigned int pltn_entry_size; |
410 | | unsigned int pltn_num_fres; |
411 | | const sframe_frame_row_entry *pltn_fres[SFRAME_PLTN_MAX_NUM_FRES]; |
412 | | |
413 | | unsigned int sec_pltn_entry_size; |
414 | | unsigned int sec_pltn_num_fres; |
415 | | const sframe_frame_row_entry *sec_pltn_fres[SFRAME_PLTN_MAX_NUM_FRES]; |
416 | | |
417 | | unsigned int plt_got_entry_size; |
418 | | unsigned int plt_got_num_fres; |
419 | | const sframe_frame_row_entry *plt_got_fres[SFRAME_PLTN_MAX_NUM_FRES]; |
420 | | }; |
421 | | |
422 | | struct elf_x86_lazy_plt_layout |
423 | | { |
424 | | /* The first entry in a lazy procedure linkage table looks like this. */ |
425 | | const bfd_byte *plt0_entry; |
426 | | unsigned int plt0_entry_size; /* Size of PLT0 entry. */ |
427 | | |
428 | | /* Later entries in a lazy procedure linkage table look like this. */ |
429 | | const bfd_byte *plt_entry; |
430 | | unsigned int plt_entry_size; /* Size of each PLT entry. */ |
431 | | |
432 | | /* The TLSDESC entry in a lazy procedure linkage table looks like |
433 | | this. This is for x86-64 only. */ |
434 | | const bfd_byte *plt_tlsdesc_entry; |
435 | | unsigned int plt_tlsdesc_entry_size; /* Size of TLSDESC entry. */ |
436 | | |
437 | | /* Offsets into the TLSDESC entry that are to be replaced with |
438 | | GOT+8 and GOT+TDG. These are for x86-64 only. */ |
439 | | unsigned int plt_tlsdesc_got1_offset; |
440 | | unsigned int plt_tlsdesc_got2_offset; |
441 | | |
442 | | /* Offset of the end of the PC-relative instructions containing |
443 | | plt_tlsdesc_got1_offset and plt_tlsdesc_got2_offset. These |
444 | | are for x86-64 only. */ |
445 | | unsigned int plt_tlsdesc_got1_insn_end; |
446 | | unsigned int plt_tlsdesc_got2_insn_end; |
447 | | |
448 | | /* Offsets into plt0_entry that are to be replaced with GOT[1] and |
449 | | GOT[2]. */ |
450 | | unsigned int plt0_got1_offset; |
451 | | unsigned int plt0_got2_offset; |
452 | | |
453 | | /* Offset of the end of the PC-relative instruction containing |
454 | | plt0_got2_offset. This is for x86-64 only. */ |
455 | | unsigned int plt0_got2_insn_end; |
456 | | |
457 | | /* Offsets into plt_entry that are to be replaced with... */ |
458 | | unsigned int plt_got_offset; /* ... address of this symbol in .got. */ |
459 | | unsigned int plt_reloc_offset; /* ... offset into relocation table. */ |
460 | | unsigned int plt_plt_offset; /* ... offset to start of .plt. */ |
461 | | |
462 | | /* Length of the PC-relative instruction containing plt_got_offset. |
463 | | This is used for x86-64 only. */ |
464 | | unsigned int plt_got_insn_size; |
465 | | |
466 | | /* Offset of the end of the PC-relative jump to plt0_entry. This is |
467 | | used for x86-64 only. */ |
468 | | unsigned int plt_plt_insn_end; |
469 | | |
470 | | /* Offset into plt_entry where the initial value of the GOT entry |
471 | | points. */ |
472 | | unsigned int plt_lazy_offset; |
473 | | |
474 | | /* The first entry in a PIC lazy procedure linkage table looks like |
475 | | this. */ |
476 | | const bfd_byte *pic_plt0_entry; |
477 | | |
478 | | /* Subsequent entries in a PIC lazy procedure linkage table look |
479 | | like this. */ |
480 | | const bfd_byte *pic_plt_entry; |
481 | | |
482 | | /* .eh_frame covering the lazy .plt section. */ |
483 | | const bfd_byte *eh_frame_plt; |
484 | | unsigned int eh_frame_plt_size; |
485 | | }; |
486 | | |
487 | | struct elf_x86_non_lazy_plt_layout |
488 | | { |
489 | | /* Entries in a non-lazy procedure linkage table look like this. */ |
490 | | const bfd_byte *plt_entry; |
491 | | /* Entries in a PIC non-lazy procedure linkage table look like this. |
492 | | This is only used for i386 where absolute PLT and PIC PLT are |
493 | | different. */ |
494 | | const bfd_byte *pic_plt_entry; |
495 | | |
496 | | unsigned int plt_entry_size; /* Size of each PLT entry. */ |
497 | | |
498 | | /* Offsets into plt_entry that are to be replaced with... */ |
499 | | unsigned int plt_got_offset; /* ... address of this symbol in .got. */ |
500 | | |
501 | | /* Length of the PC-relative instruction containing plt_got_offset. |
502 | | This is used for x86-64 only. */ |
503 | | unsigned int plt_got_insn_size; |
504 | | |
505 | | /* .eh_frame covering the non-lazy .plt section. */ |
506 | | const bfd_byte *eh_frame_plt; |
507 | | unsigned int eh_frame_plt_size; |
508 | | }; |
509 | | |
510 | | struct elf_x86_plt_layout |
511 | | { |
512 | | /* The first entry in a lazy procedure linkage table looks like this. */ |
513 | | const bfd_byte *plt0_entry; |
514 | | /* Entries in a procedure linkage table look like this. */ |
515 | | const bfd_byte *plt_entry; |
516 | | unsigned int plt_entry_size; /* Size of each PLT entry. */ |
517 | | |
518 | | /* 1 has PLT0. */ |
519 | | unsigned int has_plt0; |
520 | | |
521 | | /* Offset of indirect branch in plt_entry. */ |
522 | | unsigned int plt_indirect_branch_offset; |
523 | | |
524 | | /* Offsets into plt_entry that are to be replaced with... */ |
525 | | unsigned int plt_got_offset; /* ... address of this symbol in .got. */ |
526 | | |
527 | | /* Length of the PC-relative instruction containing plt_got_offset. |
528 | | This is only used for x86-64. */ |
529 | | unsigned int plt_got_insn_size; |
530 | | |
531 | | /* Alignment of the .iplt section. */ |
532 | | unsigned int iplt_alignment; |
533 | | |
534 | | /* .eh_frame covering the .plt section. */ |
535 | | const bfd_byte *eh_frame_plt; |
536 | | unsigned int eh_frame_plt_size; |
537 | | }; |
538 | | |
539 | | /* Values in tls_type of x86 ELF linker hash entry. */ |
540 | 0 | #define GOT_UNKNOWN 0 |
541 | 0 | #define GOT_NORMAL 1 |
542 | 0 | #define GOT_TLS_GD 2 |
543 | 0 | #define GOT_TLS_IE 4 |
544 | 0 | #define GOT_TLS_IE_POS 5 |
545 | 0 | #define GOT_TLS_IE_NEG 6 |
546 | 0 | #define GOT_TLS_IE_BOTH 7 |
547 | 0 | #define GOT_TLS_GDESC 8 |
548 | 0 | #define GOT_ABS 9 |
549 | | #define GOT_TLS_GD_BOTH_P(type) \ |
550 | 0 | ((type) == (GOT_TLS_GD | GOT_TLS_GDESC)) |
551 | | #define GOT_TLS_GD_P(type) \ |
552 | 0 | ((type) == GOT_TLS_GD || GOT_TLS_GD_BOTH_P (type)) |
553 | | #define GOT_TLS_GDESC_P(type) \ |
554 | 0 | ((type) == GOT_TLS_GDESC || GOT_TLS_GD_BOTH_P (type)) |
555 | | #define GOT_TLS_GD_ANY_P(type) \ |
556 | 0 | (GOT_TLS_GD_P (type) || GOT_TLS_GDESC_P (type)) |
557 | | |
558 | | #define elf_x86_hash_entry(ent) \ |
559 | 0 | ((struct elf_x86_link_hash_entry *)(ent)) |
560 | | |
561 | | /* Information of an input relocation used to compute its contribution |
562 | | to the DT_RELR section size. */ |
563 | | |
564 | | struct elf_x86_relative_reloc_record |
565 | | { |
566 | | /* The original relocation info. */ |
567 | | Elf_Internal_Rela rel; |
568 | | /* The input or the GOT section where the relocation is applied. */ |
569 | | asection *sec; |
570 | | /* Local symbol info. NULL for global symbol. */ |
571 | | Elf_Internal_Sym *sym; |
572 | | union |
573 | | { |
574 | | /* Section where the local symbol is defined. */ |
575 | | asection *sym_sec; |
576 | | /* Global symbol hash. */ |
577 | | struct elf_link_hash_entry *h; |
578 | | } u; |
579 | | /* The offset into the output section where the relative relocation |
580 | | will be applied at run-time. */ |
581 | | bfd_vma offset; |
582 | | /* The run-time address. */ |
583 | | bfd_vma address; |
584 | | }; |
585 | | |
586 | | struct elf_x86_relative_reloc_data |
587 | | { |
588 | | bfd_size_type count; |
589 | | bfd_size_type size; |
590 | | struct elf_x86_relative_reloc_record *data; |
591 | | }; |
592 | | |
593 | | /* DT_RELR bitmap. */ |
594 | | struct elf_dt_relr_bitmap |
595 | | { |
596 | | bfd_size_type count; |
597 | | bfd_size_type size; |
598 | | union |
599 | | { |
600 | | /* 32-bit bitmap. */ |
601 | | uint32_t *elf32; |
602 | | /* 64-bit bitmap. */ |
603 | | uint64_t *elf64; |
604 | | } u; |
605 | | }; |
606 | | |
607 | | /* x86 ELF linker hash table. */ |
608 | | |
609 | | struct elf_x86_link_hash_table |
610 | | { |
611 | | struct elf_link_hash_table elf; |
612 | | |
613 | | /* Short-cuts to get to dynamic linker sections. */ |
614 | | asection *plt_eh_frame; |
615 | | asection *plt_second; |
616 | | asection *plt_second_eh_frame; |
617 | | asection *plt_got; |
618 | | asection *plt_got_eh_frame; |
619 | | |
620 | | sframe_encoder_ctx *plt_cfe_ctx; |
621 | | asection *plt_sframe; |
622 | | sframe_encoder_ctx *plt_second_cfe_ctx; |
623 | | asection *plt_second_sframe; |
624 | | sframe_encoder_ctx *plt_got_cfe_ctx; |
625 | | asection *plt_got_sframe; |
626 | | |
627 | | /* Parameters describing PLT generation, lazy or non-lazy. */ |
628 | | struct elf_x86_plt_layout plt; |
629 | | |
630 | | /* Parameters describing lazy PLT generation. */ |
631 | | const struct elf_x86_lazy_plt_layout *lazy_plt; |
632 | | |
633 | | /* Parameters describing non-lazy PLT generation. */ |
634 | | const struct elf_x86_non_lazy_plt_layout *non_lazy_plt; |
635 | | |
636 | | /* The .sframe helper object for .plt section. |
637 | | This is used for x86-64 only. */ |
638 | | const struct elf_x86_sframe_plt *sframe_plt; |
639 | | |
640 | | union |
641 | | { |
642 | | bfd_signed_vma refcount; |
643 | | bfd_vma offset; |
644 | | } tls_ld_or_ldm_got; |
645 | | |
646 | | /* The amount of space used by the jump slots in the GOT. */ |
647 | | bfd_vma sgotplt_jump_table_size; |
648 | | |
649 | | /* _TLS_MODULE_BASE_ symbol. */ |
650 | | struct bfd_link_hash_entry *tls_module_base; |
651 | | |
652 | | /* Used by local STT_GNU_IFUNC symbols. */ |
653 | | htab_t loc_hash_table; |
654 | | void * loc_hash_memory; |
655 | | |
656 | | /* The index of the next R_X86_64_JUMP_SLOT entry in .rela.plt. */ |
657 | | bfd_vma next_jump_slot_index; |
658 | | /* The index of the next R_X86_64_IRELATIVE entry in .rela.plt. */ |
659 | | bfd_vma next_irelative_index; |
660 | | |
661 | | /* The .rela.tls/.rel.tls section for R_386_TLS_DESC or R_X86_64_TLSDESC |
662 | | relocation. */ |
663 | | asection *rel_tls_desc; |
664 | | |
665 | | /* The (unloaded but important) .rel.plt.unloaded section on VxWorks. |
666 | | This is used for i386 only. */ |
667 | | asection *srelplt2; |
668 | | |
669 | | /* DT_RELR bitmap. */ |
670 | | struct elf_dt_relr_bitmap dt_relr_bitmap; |
671 | | |
672 | | /* Relative relocation data. */ |
673 | | struct elf_x86_relative_reloc_data relative_reloc; |
674 | | |
675 | | /* Unaligned relative relocation data. */ |
676 | | struct elf_x86_relative_reloc_data unaligned_relative_reloc; |
677 | | |
678 | | /* Number of relative reloc generation pass. */ |
679 | | unsigned int generate_relative_reloc_pass; |
680 | | |
681 | | /* TRUE if inputs have R_386_TLS_DESC_CALL or R_X86_64_TLSDESC_CALL |
682 | | relocation. */ |
683 | | unsigned int has_tls_desc_call : 1; |
684 | | |
685 | | /* TRUE if inputs call ___tls_get_addr. This is only used for i386. */ |
686 | | unsigned int has_tls_get_addr_call : 1; |
687 | | |
688 | | /* TRUE if loc_hash_table is used. */ |
689 | | unsigned int has_loc_hash_table : 1; |
690 | | |
691 | | /* TRUE if GOT is referenced. */ |
692 | | unsigned int got_referenced : 1; |
693 | | |
694 | | /* TRUE if PLT is PC-relative. PLT in PDE and PC-relative PLT in PIE |
695 | | can be used as function address. |
696 | | |
697 | | NB: i386 has non-PIC PLT and PIC PLT. Only non-PIC PLT in PDE can |
698 | | be used as function address. PIC PLT in PIE can't be used as |
699 | | function address. */ |
700 | | unsigned int pcrel_plt : 1; |
701 | | |
702 | | /* Value used to fill the unused bytes of the first PLT entry. This |
703 | | is only used for i386. */ |
704 | | bfd_byte plt0_pad_byte; |
705 | | |
706 | | bfd_vma (*r_info) (bfd_vma, bfd_vma); |
707 | | bfd_vma (*r_sym) (bfd_vma); |
708 | | bool (*is_reloc_section) (const char *); |
709 | | unsigned int sizeof_reloc; |
710 | | unsigned int got_entry_size; |
711 | | unsigned int pointer_r_type; |
712 | | unsigned int relative_r_type; |
713 | | int dynamic_interpreter_size; |
714 | | const char *dynamic_interpreter; |
715 | | const char *tls_get_addr; |
716 | | const char *relative_r_name; |
717 | | const char *ax_register; |
718 | | void (*elf_append_reloc) (bfd *, asection *, Elf_Internal_Rela *); |
719 | | void (*elf_write_addend) (bfd *, uint64_t, void *); |
720 | | void (*elf_write_addend_in_got) (bfd *, uint64_t, void *); |
721 | | |
722 | | /* Options passed from the linker. */ |
723 | | struct elf_linker_x86_params *params; |
724 | | }; |
725 | | |
726 | | struct elf_x86_init_table |
727 | | { |
728 | | /* The lazy PLT layout. */ |
729 | | const struct elf_x86_lazy_plt_layout *lazy_plt; |
730 | | |
731 | | /* The non-lazy PLT layout. */ |
732 | | const struct elf_x86_non_lazy_plt_layout *non_lazy_plt; |
733 | | |
734 | | /* The lazy PLT layout for IBT. */ |
735 | | const struct elf_x86_lazy_plt_layout *lazy_ibt_plt; |
736 | | |
737 | | /* The non-lazy PLT layout for IBT. */ |
738 | | const struct elf_x86_non_lazy_plt_layout *non_lazy_ibt_plt; |
739 | | |
740 | | /* The .sframe helper object for lazy .plt section. |
741 | | This is used for x86-64 only. */ |
742 | | const struct elf_x86_sframe_plt *sframe_lazy_plt; |
743 | | |
744 | | /* The .sframe helper object for non-lazy .plt section. |
745 | | This is used for x86-64 only. */ |
746 | | const struct elf_x86_sframe_plt *sframe_non_lazy_plt; |
747 | | |
748 | | /* The .sframe helper object for lazy IBT .plt section. |
749 | | This is used for x86-64 only. */ |
750 | | const struct elf_x86_sframe_plt *sframe_lazy_ibt_plt; |
751 | | |
752 | | /* The .sframe helper object for non-lazy IBT .plt section. |
753 | | This is used for x86-64 only. */ |
754 | | const struct elf_x86_sframe_plt *sframe_non_lazy_ibt_plt; |
755 | | |
756 | | bfd_byte plt0_pad_byte; |
757 | | |
758 | | bfd_vma (*r_info) (bfd_vma, bfd_vma); |
759 | | bfd_vma (*r_sym) (bfd_vma); |
760 | | }; |
761 | | |
762 | | struct elf_x86_obj_tdata |
763 | | { |
764 | | struct elf_obj_tdata root; |
765 | | |
766 | | /* tls_type for each local got entry. */ |
767 | | char *local_got_tls_type; |
768 | | |
769 | | /* GOTPLT entries for TLS descriptors. */ |
770 | | bfd_vma *local_tlsdesc_gotent; |
771 | | |
772 | | /* R_*_RELATIVE relocation in GOT for this local symbol has been |
773 | | processed. */ |
774 | | char *relative_reloc_done; |
775 | | }; |
776 | | |
777 | | enum elf_x86_plt_type |
778 | | { |
779 | | plt_non_lazy = 0, |
780 | | plt_lazy = 1 << 0, |
781 | | plt_pic = 1 << 1, |
782 | | plt_second = 1 << 2, |
783 | | plt_unknown = -1 |
784 | | }; |
785 | | |
786 | | struct elf_x86_plt |
787 | | { |
788 | | const char *name; |
789 | | asection *sec; |
790 | | bfd_byte *contents; |
791 | | enum elf_x86_plt_type type; |
792 | | unsigned int plt_got_offset; |
793 | | unsigned int plt_entry_size; |
794 | | unsigned int plt_got_insn_size; /* Only used for x86-64. */ |
795 | | long count; |
796 | | }; |
797 | | |
798 | | enum elf_x86_tls_error_type |
799 | | { |
800 | | elf_x86_tls_error_none, |
801 | | elf_x86_tls_error_add_mov, |
802 | | elf_x86_tls_error_add_movrs, |
803 | | elf_x86_tls_error_add_sub_mov, |
804 | | elf_x86_tls_error_indirect_call, |
805 | | elf_x86_tls_error_lea, |
806 | | elf_x86_tls_error_yes |
807 | | }; |
808 | | |
809 | | enum elf_x86_error_type |
810 | | { |
811 | | elf_x86_error_tls, |
812 | | elf_x86_error_non_alloc |
813 | | }; |
814 | | |
815 | | /* Set if a relocation is converted from a GOTPCREL relocation. */ |
816 | 0 | #define R_X86_64_converted_reloc_bit (1 << 7) |
817 | | |
818 | | #define elf_x86_tdata(abfd) \ |
819 | 0 | ((struct elf_x86_obj_tdata *) (abfd)->tdata.any) |
820 | | |
821 | | #define elf_x86_local_got_tls_type(abfd) \ |
822 | 0 | (elf_x86_tdata (abfd)->local_got_tls_type) |
823 | | |
824 | | #define elf_x86_local_tlsdesc_gotent(abfd) \ |
825 | 0 | (elf_x86_tdata (abfd)->local_tlsdesc_gotent) |
826 | | |
827 | | #define elf_x86_relative_reloc_done(abfd) \ |
828 | 0 | (elf_x86_tdata (abfd)->relative_reloc_done) |
829 | | |
830 | | #define elf_x86_compute_jump_table_size(htab) \ |
831 | 0 | ((htab)->elf.srelplt->reloc_count * (htab)->got_entry_size) |
832 | | |
833 | | #define is_x86_elf(bfd, htab) \ |
834 | 0 | (bfd_get_flavour (bfd) == bfd_target_elf_flavour \ |
835 | 0 | && elf_tdata (bfd) != NULL \ |
836 | 0 | && elf_object_id (bfd) == (htab)->elf.hash_table_id) |
837 | | |
838 | | /* Rename some of the generic section flags to better document how they |
839 | | are used here. */ |
840 | 0 | #define check_relocs_failed sec_flg0 |
841 | 0 | #define relative_reloc_packed sec_flg1 |
842 | | |
843 | | extern bool _bfd_x86_elf_mkobject |
844 | | (bfd *) ATTRIBUTE_HIDDEN; |
845 | | |
846 | | extern void _bfd_x86_elf_set_tls_module_base |
847 | | (struct bfd_link_info *) ATTRIBUTE_HIDDEN; |
848 | | |
849 | | extern bfd_vma _bfd_x86_elf_dtpoff_base |
850 | | (struct bfd_link_info *) ATTRIBUTE_HIDDEN; |
851 | | |
852 | | extern bool _bfd_x86_elf_readonly_dynrelocs |
853 | | (struct elf_link_hash_entry *, void *) ATTRIBUTE_HIDDEN; |
854 | | |
855 | | extern struct elf_link_hash_entry * _bfd_elf_x86_get_local_sym_hash |
856 | | (struct elf_x86_link_hash_table *, bfd *, const Elf_Internal_Rela *, |
857 | | bool) ATTRIBUTE_HIDDEN; |
858 | | |
859 | | extern hashval_t _bfd_x86_elf_local_htab_hash |
860 | | (const void *) ATTRIBUTE_HIDDEN; |
861 | | |
862 | | extern int _bfd_x86_elf_local_htab_eq |
863 | | (const void *, const void *) ATTRIBUTE_HIDDEN; |
864 | | |
865 | | extern struct bfd_hash_entry * _bfd_x86_elf_link_hash_newfunc |
866 | | (struct bfd_hash_entry *, struct bfd_hash_table *, const char *) |
867 | | ATTRIBUTE_HIDDEN; |
868 | | |
869 | | extern struct bfd_link_hash_table * _bfd_x86_elf_link_hash_table_create |
870 | | (bfd *) ATTRIBUTE_HIDDEN; |
871 | | |
872 | | extern int _bfd_x86_elf_compare_relocs |
873 | | (const void *, const void *) ATTRIBUTE_HIDDEN; |
874 | | |
875 | | extern bool _bfd_x86_elf_link_check_relocs |
876 | | (bfd *, struct bfd_link_info *) ATTRIBUTE_HIDDEN; |
877 | | |
878 | | extern bool _bfd_x86_elf_check_relocs |
879 | | (bfd *, struct bfd_link_info *, asection *, |
880 | | const Elf_Internal_Rela *) ATTRIBUTE_HIDDEN; |
881 | | |
882 | | extern bool _bfd_x86_elf_link_relax_section |
883 | | (bfd *, asection *, struct bfd_link_info *, bool *) ATTRIBUTE_HIDDEN; |
884 | | |
885 | | extern bool _bfd_elf_x86_size_relative_relocs |
886 | | (struct bfd_link_info *, bool *) ATTRIBUTE_HIDDEN; |
887 | | |
888 | | extern bool _bfd_elf_x86_finish_relative_relocs |
889 | | (struct bfd_link_info *) ATTRIBUTE_HIDDEN; |
890 | | |
891 | | extern asection * _bfd_elf_x86_get_reloc_section |
892 | | (bfd *, const char *) ATTRIBUTE_HIDDEN; |
893 | | |
894 | | extern void _bfd_elf32_write_addend |
895 | | (bfd *, uint64_t, void *) ATTRIBUTE_HIDDEN; |
896 | | extern void _bfd_elf64_write_addend |
897 | | (bfd *, uint64_t, void *) ATTRIBUTE_HIDDEN; |
898 | | |
899 | | extern bool _bfd_elf_x86_valid_reloc_p |
900 | | (asection *, struct bfd_link_info *, struct elf_x86_link_hash_table *, |
901 | | const Elf_Internal_Rela *, struct elf_link_hash_entry *, |
902 | | const Elf_Internal_Sym *, Elf_Internal_Shdr *, bool *) ATTRIBUTE_HIDDEN; |
903 | | |
904 | | extern bool _bfd_x86_elf_late_size_sections |
905 | | (struct bfd_link_info *) ATTRIBUTE_HIDDEN; |
906 | | |
907 | | extern struct elf_x86_link_hash_table *_bfd_x86_elf_finish_dynamic_sections |
908 | | (struct bfd_link_info *, bfd_byte *) ATTRIBUTE_HIDDEN; |
909 | | |
910 | | extern bool _bfd_x86_elf_early_size_sections |
911 | | (struct bfd_link_info *) ATTRIBUTE_HIDDEN; |
912 | | |
913 | | extern void _bfd_x86_elf_merge_symbol_attribute |
914 | | (struct elf_link_hash_entry *, unsigned int, bool, bool) |
915 | | ATTRIBUTE_HIDDEN; |
916 | | |
917 | | extern void _bfd_x86_elf_copy_indirect_symbol |
918 | | (struct bfd_link_info *, struct elf_link_hash_entry *, |
919 | | struct elf_link_hash_entry *) ATTRIBUTE_HIDDEN; |
920 | | |
921 | | extern bool _bfd_x86_elf_fixup_symbol |
922 | | (struct bfd_link_info *, struct elf_link_hash_entry *) ATTRIBUTE_HIDDEN; |
923 | | |
924 | | extern bool _bfd_x86_elf_hash_symbol |
925 | | (struct elf_link_hash_entry *) ATTRIBUTE_HIDDEN; |
926 | | |
927 | | extern bool _bfd_x86_elf_adjust_dynamic_symbol |
928 | | (struct bfd_link_info *, struct elf_link_hash_entry *) ATTRIBUTE_HIDDEN; |
929 | | |
930 | | extern void _bfd_x86_elf_hide_symbol |
931 | | (struct bfd_link_info *, struct elf_link_hash_entry *, |
932 | | bool) ATTRIBUTE_HIDDEN; |
933 | | |
934 | | extern bool _bfd_x86_elf_link_symbol_references_local |
935 | | (struct bfd_link_info *, struct elf_link_hash_entry *) ATTRIBUTE_HIDDEN; |
936 | | |
937 | | extern asection * _bfd_x86_elf_gc_mark_hook |
938 | | (asection *, struct bfd_link_info *, struct elf_reloc_cookie *, |
939 | | struct elf_link_hash_entry *, unsigned int) ATTRIBUTE_HIDDEN; |
940 | | |
941 | | extern long _bfd_x86_elf_get_synthetic_symtab |
942 | | (bfd *, long, long, bfd_vma, struct elf_x86_plt [], asymbol **, |
943 | | asymbol **) ATTRIBUTE_HIDDEN; |
944 | | |
945 | | extern enum elf_property_kind _bfd_x86_elf_parse_gnu_properties |
946 | | (bfd *, unsigned int, bfd_byte *, unsigned int) ATTRIBUTE_HIDDEN; |
947 | | |
948 | | extern bool _bfd_x86_elf_merge_gnu_properties |
949 | | (struct bfd_link_info *, bfd *, bfd *, elf_property *, elf_property *) |
950 | | ATTRIBUTE_HIDDEN; |
951 | | |
952 | | extern void _bfd_x86_elf_link_fixup_gnu_properties |
953 | | (struct bfd_link_info *, elf_property_list **) ATTRIBUTE_HIDDEN; |
954 | | |
955 | | extern bfd * _bfd_x86_elf_link_setup_gnu_properties |
956 | | (struct bfd_link_info *, struct elf_x86_init_table *) ATTRIBUTE_HIDDEN; |
957 | | |
958 | | extern void _bfd_x86_elf_link_fixup_ifunc_symbol |
959 | | (struct bfd_link_info *, struct elf_x86_link_hash_table *, |
960 | | struct elf_link_hash_entry *, Elf_Internal_Sym *sym) ATTRIBUTE_HIDDEN; |
961 | | |
962 | | extern void _bfd_x86_elf_link_report_relative_reloc |
963 | | (struct bfd_link_info *, asection *, struct elf_link_hash_entry *, |
964 | | const Elf_Internal_Sym *, const char *, const void *) ATTRIBUTE_HIDDEN; |
965 | | |
966 | | extern void _bfd_x86_elf_link_report_tls_transition_error |
967 | | (struct bfd_link_info *, bfd *, asection *, Elf_Internal_Shdr *, |
968 | | struct elf_link_hash_entry *, const Elf_Internal_Sym *, |
969 | | const Elf_Internal_Rela *, const char *, const char *, |
970 | | enum elf_x86_tls_error_type) ATTRIBUTE_HIDDEN; |
971 | | |
972 | | extern void _bfd_x86_elf_link_report_error |
973 | | (bfd *, asection *, Elf_Internal_Shdr *, struct elf_link_hash_entry *, |
974 | | const Elf_Internal_Sym *, reloc_howto_type *, |
975 | | enum elf_x86_error_type) ATTRIBUTE_HIDDEN; |
976 | | |
977 | | extern void _bfd_x86_elf_link_report_relocation_error |
978 | | (bfd *, asection *, const char *, Elf_Internal_Rela *, |
979 | | reloc_howto_type *, bfd_reloc_status_type) ATTRIBUTE_HIDDEN; |
980 | | |
981 | | extern bool |
982 | | _bfd_elf_x86_copy_special_section_fields |
983 | | (const bfd *, bfd *, const Elf_Internal_Shdr *, |
984 | | Elf_Internal_Shdr *) ATTRIBUTE_HIDDEN; |
985 | | |
986 | | #define bfd_elf64_mkobject \ |
987 | | _bfd_x86_elf_mkobject |
988 | | #define bfd_elf32_mkobject \ |
989 | | _bfd_x86_elf_mkobject |
990 | | #define bfd_elf64_bfd_link_hash_table_create \ |
991 | | _bfd_x86_elf_link_hash_table_create |
992 | | #define bfd_elf32_bfd_link_hash_table_create \ |
993 | | _bfd_x86_elf_link_hash_table_create |
994 | | #define bfd_elf64_bfd_link_check_relocs \ |
995 | | _bfd_x86_elf_link_check_relocs |
996 | | #define bfd_elf32_bfd_link_check_relocs \ |
997 | | _bfd_x86_elf_link_check_relocs |
998 | | #define bfd_elf32_bfd_relax_section \ |
999 | | _bfd_x86_elf_link_relax_section |
1000 | | #define bfd_elf64_bfd_relax_section \ |
1001 | | _bfd_x86_elf_link_relax_section |
1002 | | |
1003 | | #define elf_backend_check_relocs \ |
1004 | | _bfd_x86_elf_check_relocs |
1005 | | #define elf_backend_late_size_sections \ |
1006 | | _bfd_x86_elf_late_size_sections |
1007 | | #define elf_backend_merge_symbol_attribute \ |
1008 | | _bfd_x86_elf_merge_symbol_attribute |
1009 | | #define elf_backend_copy_indirect_symbol \ |
1010 | | _bfd_x86_elf_copy_indirect_symbol |
1011 | | #define elf_backend_fixup_symbol \ |
1012 | | _bfd_x86_elf_fixup_symbol |
1013 | | #define elf_backend_hash_symbol \ |
1014 | | _bfd_x86_elf_hash_symbol |
1015 | | #define elf_backend_adjust_dynamic_symbol \ |
1016 | | _bfd_x86_elf_adjust_dynamic_symbol |
1017 | | #define elf_backend_gc_mark_hook \ |
1018 | | _bfd_x86_elf_gc_mark_hook |
1019 | | #define elf_backend_omit_section_dynsym \ |
1020 | | _bfd_elf_omit_section_dynsym_all |
1021 | | #define elf_backend_parse_gnu_properties \ |
1022 | | _bfd_x86_elf_parse_gnu_properties |
1023 | | #define elf_backend_merge_gnu_properties \ |
1024 | | _bfd_x86_elf_merge_gnu_properties |
1025 | | #define elf_backend_fixup_gnu_properties \ |
1026 | | _bfd_x86_elf_link_fixup_gnu_properties |
1027 | | #define elf_backend_size_relative_relocs \ |
1028 | | _bfd_elf_x86_size_relative_relocs |
1029 | | #define elf_backend_finish_relative_relocs \ |
1030 | | _bfd_elf_x86_finish_relative_relocs |
1031 | | #define elf_backend_get_reloc_section \ |
1032 | | _bfd_elf_x86_get_reloc_section |
1033 | | #define elf_backend_copy_special_section_fields \ |
1034 | | _bfd_elf_x86_copy_special_section_fields |
1035 | | #define elf_backend_use_mmap true |
1036 | | |
1037 | | #define ELF_P_ALIGN ELF_MINPAGESIZE |
1038 | | |
1039 | | /* Allocate x86 GOT info for local symbols. */ |
1040 | | |
1041 | | static inline bool |
1042 | | elf_x86_allocate_local_got_info (bfd *abfd, bfd_size_type count) |
1043 | 0 | { |
1044 | 0 | bfd_signed_vma *local_got_refcounts = elf_local_got_refcounts (abfd); |
1045 | 0 | if (local_got_refcounts == NULL) |
1046 | 0 | { |
1047 | 0 | bfd_size_type size = count * (sizeof (bfd_signed_vma) |
1048 | 0 | + sizeof (bfd_vma) |
1049 | 0 | + 2 * sizeof(char)); |
1050 | 0 | local_got_refcounts = (bfd_signed_vma *) bfd_zalloc (abfd, size); |
1051 | 0 | if (local_got_refcounts == NULL) |
1052 | 0 | return false; |
1053 | 0 | elf_local_got_refcounts (abfd) = local_got_refcounts; |
1054 | 0 | elf_x86_local_tlsdesc_gotent (abfd) = |
1055 | 0 | (bfd_vma *) (local_got_refcounts + count); |
1056 | 0 | elf_x86_local_got_tls_type (abfd) = |
1057 | 0 | (char *) (local_got_refcounts + 2 * count); |
1058 | 0 | elf_x86_relative_reloc_done (abfd) = |
1059 | 0 | ((char *) (local_got_refcounts + 2 * count)) + count; |
1060 | 0 | } |
1061 | 0 | return true; |
1062 | 0 | } Unexecuted instantiation: elf64-x86-64.c:elf_x86_allocate_local_got_info Unexecuted instantiation: elfxx-x86.c:elf_x86_allocate_local_got_info Unexecuted instantiation: elf32-i386.c:elf_x86_allocate_local_got_info |