Coverage Report

Created: 2026-03-10 08:46

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