Coverage Report

Created: 2026-03-10 08:46

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/binutils-gdb/bfd/coff-aarch64.c
Line
Count
Source
1
/* BFD back-end for AArch64 COFF files.
2
   Copyright (C) 2021-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
#ifndef COFF_WITH_PE
22
#error non-PE COFF unsupported
23
#endif
24
25
#include "sysdep.h"
26
#include "bfd.h"
27
#include "libbfd.h"
28
#include "coff/aarch64.h"
29
#include "coff/internal.h"
30
#include "coff/pe.h"
31
#include "libcoff.h"
32
#include "libiberty.h"
33
34
/* For these howto special functions,
35
   output_bfd == NULL => final link, or objdump -W and other calls to
36
   bfd_simple_get_relocated_section_contents
37
   output_bfd != NULL && output_bfd != abfd => ld -r
38
   output_bfd != NULL && output_bfd == abfd => gas.
39
   FIXME: ld -r is punted to bfd_perform_relocation.  This won't be
40
   correct for cases where the addend needs to be adjusted, eg. for
41
   relocations against section symbols, and the field is split because
42
   bfd_perform_relocation can't write addends to split relocation fields.  */
43
44
static bfd_reloc_status_type
45
coff_aarch64_rel21_reloc (bfd *abfd,
46
        arelent *reloc_entry,
47
        asymbol *symbol,
48
        void *data,
49
        asection *input_section,
50
        bfd *output_bfd,
51
        char **error_message ATTRIBUTE_UNUSED)
52
0
{
53
0
  if (output_bfd != NULL && output_bfd != abfd)
54
0
    return bfd_reloc_continue;
55
56
0
  if (!bfd_reloc_offset_in_range (reloc_entry->howto, abfd,
57
0
          input_section, reloc_entry->address))
58
0
    return bfd_reloc_outofrange;
59
60
0
  uint32_t op = bfd_getl32 (data + reloc_entry->address);
61
0
  bfd_vma relocation = reloc_entry->addend;
62
0
  bfd_reloc_status_type ret = bfd_reloc_ok;
63
0
  if (output_bfd == NULL)
64
0
    {
65
0
      if (bfd_is_und_section (symbol->section))
66
0
  {
67
0
    if ((symbol->flags & BSF_WEAK) == 0)
68
0
      ret = bfd_reloc_undefined;
69
0
  }
70
0
      else if (!bfd_is_com_section (symbol->section))
71
0
  relocation += (symbol->value
72
0
           + symbol->section->output_offset
73
0
           + symbol->section->output_section->vma);
74
0
      bfd_vma addend = ((op >> 3) & 0x1ffffc) | ((op >> 29) & 0x3);
75
0
      addend = (addend ^ 0x100000) - 0x100000;
76
0
      relocation += addend;
77
0
      relocation -= (reloc_entry->address
78
0
         + input_section->output_offset
79
0
         + input_section->output_section->vma);
80
0
      relocation = (bfd_signed_vma) relocation >> reloc_entry->howto->rightshift;
81
0
    }
82
0
  if (relocation + 0x100000 > 0x1fffff)
83
0
    ret = bfd_reloc_overflow;
84
85
0
  op &= 0x9f00001f;
86
0
  op |= (relocation & 0x1ffffc) << 3;
87
0
  op |= (relocation & 0x3) << 29;
88
89
0
  bfd_putl32 (op, data + reloc_entry->address);
90
91
0
  return ret;
92
0
}
Unexecuted instantiation: pe-aarch64.c:coff_aarch64_rel21_reloc
Unexecuted instantiation: pei-aarch64.c:coff_aarch64_rel21_reloc
93
94
static bfd_reloc_status_type
95
coff_aarch64_po12l_reloc (bfd *abfd,
96
        arelent *reloc_entry,
97
        asymbol *symbol ATTRIBUTE_UNUSED,
98
        void *data,
99
        asection *input_section,
100
        bfd *output_bfd,
101
        char **error_message ATTRIBUTE_UNUSED)
102
0
{
103
0
  if (output_bfd != NULL && output_bfd != abfd)
104
0
    return bfd_reloc_continue;
105
106
0
  if (!bfd_reloc_offset_in_range (reloc_entry->howto, abfd,
107
0
          input_section, reloc_entry->address))
108
0
    return bfd_reloc_outofrange;
109
110
0
  uint32_t op = bfd_getl32 (data + reloc_entry->address);
111
0
  bfd_vma relocation = reloc_entry->addend & 0xfff;
112
0
  int shift;
113
114
0
  if ((op & 0xff800000) == 0x3d800000)
115
0
    {
116
      /* LDR / STR with q register */
117
0
      shift = 4;
118
0
    }
119
0
  else
120
0
    {
121
      /* top two bits represent how much addend should be shifted */
122
0
      shift = op >> 30;
123
0
    }
124
125
0
  bfd_reloc_status_type ret = bfd_reloc_ok;
126
0
  if (output_bfd == NULL)
127
0
    {
128
0
      if (bfd_is_und_section (symbol->section))
129
0
  {
130
0
    if ((symbol->flags & BSF_WEAK) == 0)
131
0
      ret = bfd_reloc_undefined;
132
0
  }
133
0
      else if (!bfd_is_com_section (symbol->section))
134
0
  relocation += (symbol->value
135
0
           + symbol->section->output_offset
136
0
           + symbol->section->output_section->vma);
137
0
      bfd_vma addend = (op >> 10) & 0xfff;
138
0
      addend <<= shift;
139
0
      relocation += addend;
140
0
    }
141
142
0
  if (relocation & ((1 << shift) - 1))
143
0
    ret = bfd_reloc_overflow;
144
145
0
  op &= 0xffc003ff;
146
0
  op |= (relocation >> shift << 10) & 0x3ffc00;
147
148
0
  bfd_putl32 (op, data + reloc_entry->address);
149
150
0
  return ret;
151
0
}
Unexecuted instantiation: pe-aarch64.c:coff_aarch64_po12l_reloc
Unexecuted instantiation: pei-aarch64.c:coff_aarch64_po12l_reloc
152
153
static bfd_reloc_status_type
154
coff_aarch64_addr32nb_reloc (bfd *abfd,
155
           arelent *reloc_entry,
156
           asymbol *symbol ATTRIBUTE_UNUSED,
157
           void *data,
158
           asection *input_section,
159
           bfd *output_bfd,
160
           char **error_message)
161
0
{
162
0
  if (output_bfd != NULL && output_bfd != abfd)
163
0
    return bfd_reloc_continue;
164
165
0
  if (!bfd_reloc_offset_in_range (reloc_entry->howto, abfd,
166
0
          input_section, reloc_entry->address))
167
0
    return bfd_reloc_outofrange;
168
169
0
  bfd_vma relocation = reloc_entry->addend;
170
0
  bfd_reloc_status_type ret = bfd_reloc_ok;
171
0
  if (output_bfd == NULL)
172
0
    {
173
0
      if (bfd_is_und_section (symbol->section))
174
0
  {
175
0
    if ((symbol->flags & BSF_WEAK) == 0)
176
0
      ret = bfd_reloc_undefined;
177
0
  }
178
0
      else if (!bfd_is_com_section (symbol->section))
179
0
  relocation += (symbol->value
180
0
           + symbol->section->output_offset
181
0
           + symbol->section->output_section->vma);
182
0
      bfd_vma addend = bfd_getl_signed_32 (data + reloc_entry->address);
183
0
      relocation += addend;
184
0
      bfd *obfd = input_section->output_section->owner;
185
0
      if (bfd_get_flavour (obfd) == bfd_target_coff_flavour
186
0
    && obj_pe (obfd))
187
0
  relocation -= pe_data (obfd)->pe_opthdr.ImageBase;
188
0
      else
189
0
  {
190
0
    *error_message = "unsupported";
191
0
    return bfd_reloc_dangerous;
192
0
  }
193
0
    }
194
195
0
  if (relocation + 0x80000000 > 0xffffffff)
196
0
    ret = bfd_reloc_overflow;
197
198
0
  bfd_putl32 (relocation, data + reloc_entry->address);
199
200
0
  return ret;
201
0
}
Unexecuted instantiation: pe-aarch64.c:coff_aarch64_addr32nb_reloc
Unexecuted instantiation: pei-aarch64.c:coff_aarch64_addr32nb_reloc
202
203
static bfd_reloc_status_type
204
coff_aarch64_secrel_reloc (bfd *abfd,
205
         arelent *reloc_entry,
206
         asymbol *symbol ATTRIBUTE_UNUSED,
207
         void *data,
208
         asection *input_section,
209
         bfd *output_bfd,
210
         char **error_message ATTRIBUTE_UNUSED)
211
0
{
212
0
  if (output_bfd != NULL && output_bfd != abfd)
213
0
    return bfd_reloc_continue;
214
215
0
  if (!bfd_reloc_offset_in_range (reloc_entry->howto, abfd,
216
0
          input_section, reloc_entry->address))
217
0
    return bfd_reloc_outofrange;
218
219
0
  bfd_vma relocation = reloc_entry->addend;
220
0
  bfd_reloc_status_type ret = bfd_reloc_ok;
221
0
  if (output_bfd == NULL)
222
0
    {
223
0
      if (bfd_is_und_section (symbol->section))
224
0
  {
225
0
    if ((symbol->flags & BSF_WEAK) == 0)
226
0
      ret = bfd_reloc_undefined;
227
0
  }
228
0
      else if (!bfd_is_com_section (symbol->section))
229
0
  relocation += (symbol->value
230
0
           + symbol->section->output_offset);
231
0
      bfd_vma addend = bfd_getl_signed_32 (data + reloc_entry->address);
232
0
      relocation += addend;
233
0
    }
234
0
  if (relocation > 0xffffffff)
235
0
    ret = bfd_reloc_overflow;
236
237
0
  bfd_putl32 (relocation, data + reloc_entry->address);
238
239
0
  return ret;
240
0
}
Unexecuted instantiation: pe-aarch64.c:coff_aarch64_secrel_reloc
Unexecuted instantiation: pei-aarch64.c:coff_aarch64_secrel_reloc
241
242
#define coff_aarch64_NULL NULL
243
#undef HOWTO_INSTALL_ADDEND
244
#define HOWTO_INSTALL_ADDEND 1
245
#define HOW(type, right, size, bits, pcrel, left, ovf, func, mask) \
246
  HOWTO (type, right, size, bits, pcrel, left, complain_overflow_##ovf, \
247
   coff_aarch64_##func, #type, true, mask, mask, false)
248
249
static const reloc_howto_type arm64_reloc_howto_abs
250
= HOW (IMAGE_REL_ARM64_ABSOLUTE,
251
       0, 0, 0, false, 0, dont, NULL, 0);
252
253
static const reloc_howto_type arm64_reloc_howto_64
254
= HOW (IMAGE_REL_ARM64_ADDR64,
255
       0, 8, 64, false, 0, dont, NULL, UINT64_C (-1));
256
257
static const reloc_howto_type arm64_reloc_howto_32
258
= HOW (IMAGE_REL_ARM64_ADDR32,
259
       0, 4, 32, false, 0, signed, NULL, 0xffffffff);
260
261
static const reloc_howto_type arm64_reloc_howto_32_pcrel
262
= HOW (IMAGE_REL_ARM64_REL32,
263
       0, 4, 32, true, 0, signed, NULL, 0xffffffff);
264
265
static const reloc_howto_type arm64_reloc_howto_branch26
266
= HOW (IMAGE_REL_ARM64_BRANCH26,
267
       2, 4, 26, true, 0, signed, NULL, 0x3ffffff);
268
269
static const reloc_howto_type arm64_reloc_howto_page21
270
= HOW (IMAGE_REL_ARM64_PAGEBASE_REL21,
271
       12, 4, 21, true, 0, signed, rel21_reloc, 0x1fffff);
272
273
static const reloc_howto_type arm64_reloc_howto_lo21
274
= HOW (IMAGE_REL_ARM64_REL21,
275
       0, 4, 21, true, 0, signed, rel21_reloc, 0x1fffff);
276
277
static const reloc_howto_type arm64_reloc_howto_pgoff12l
278
= HOW (IMAGE_REL_ARM64_PAGEOFFSET_12L,
279
       0, 4, 12, true, 10, signed, po12l_reloc, 0x3ffc00);
280
281
static const reloc_howto_type arm64_reloc_howto_branch19
282
= HOW (IMAGE_REL_ARM64_BRANCH19,
283
       2, 4, 19, true, 5, signed, NULL, 0xffffe0);
284
285
static const reloc_howto_type arm64_reloc_howto_branch14
286
= HOW (IMAGE_REL_ARM64_BRANCH14,
287
       2, 4, 14, true, 5, signed, NULL, 0x7ffe0);
288
289
static const reloc_howto_type arm64_reloc_howto_pgoff12a
290
= HOW (IMAGE_REL_ARM64_PAGEOFFSET_12A,
291
       0, 4, 12, true, 10, dont, NULL, 0x3ffc00);
292
293
static const reloc_howto_type arm64_reloc_howto_32nb
294
= HOW (IMAGE_REL_ARM64_ADDR32NB,
295
       0, 4, 32, false, 0, signed, addr32nb_reloc, 0xffffffff);
296
297
static const reloc_howto_type arm64_reloc_howto_secrel
298
= HOW (IMAGE_REL_ARM64_SECREL,
299
       0, 4, 32, false, 0, dont, secrel_reloc, 0xffffffff);
300
301
static const reloc_howto_type arm64_reloc_howto_secidx
302
= HOW (IMAGE_REL_ARM64_SECTION,
303
       0, 2, 16, false, 0, dont, NULL, 0xffff);
304
305
static const reloc_howto_type* const arm64_howto_table[] = {
306
     &arm64_reloc_howto_abs,
307
     &arm64_reloc_howto_64,
308
     &arm64_reloc_howto_32,
309
     &arm64_reloc_howto_32_pcrel,
310
     &arm64_reloc_howto_branch26,
311
     &arm64_reloc_howto_page21,
312
     &arm64_reloc_howto_lo21,
313
     &arm64_reloc_howto_pgoff12l,
314
     &arm64_reloc_howto_branch19,
315
     &arm64_reloc_howto_branch14,
316
     &arm64_reloc_howto_pgoff12a,
317
     &arm64_reloc_howto_32nb,
318
     &arm64_reloc_howto_secrel,
319
     &arm64_reloc_howto_secidx
320
};
321
322
/* No adjustment to addends should be needed.  The actual relocation
323
   addend is in the section contents.  Unfortunately this means actual
324
   addends are not shown by objdump -r, but that's true for most
325
   COFF/PE targets where arelent.addend is an adjustment.  */
326
#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr)    \
327
313
  cache_ptr->addend = 0;
328
329
#ifndef NUM_ELEM
330
0
#define NUM_ELEM(a) ((sizeof (a)) / sizeof ((a)[0]))
331
#endif
332
333
0
#define NUM_RELOCS NUM_ELEM (arm64_howto_table)
334
335
#define coff_bfd_reloc_type_lookup    coff_aarch64_reloc_type_lookup
336
#define coff_bfd_reloc_name_lookup    coff_aarch64_reloc_name_lookup
337
338
static reloc_howto_type *
339
coff_aarch64_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED, bfd_reloc_code_real_type code)
340
187
{
341
187
  switch (code)
342
187
  {
343
0
  case BFD_RELOC_64:
344
0
    return &arm64_reloc_howto_64;
345
51
  case BFD_RELOC_32:
346
51
    return &arm64_reloc_howto_32;
347
0
  case BFD_RELOC_32_PCREL:
348
0
    return &arm64_reloc_howto_32_pcrel;
349
0
  case BFD_RELOC_AARCH64_CALL26:
350
0
  case BFD_RELOC_AARCH64_JUMP26:
351
0
    return &arm64_reloc_howto_branch26;
352
0
  case BFD_RELOC_AARCH64_ADR_HI21_PCREL:
353
0
  case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL:
354
0
  case BFD_RELOC_AARCH64_ADR_GOT_PAGE:
355
0
    return &arm64_reloc_howto_page21;
356
0
  case BFD_RELOC_AARCH64_TSTBR14:
357
0
    return &arm64_reloc_howto_branch14;
358
0
  case BFD_RELOC_AARCH64_ADR_LO21_PCREL:
359
0
    return &arm64_reloc_howto_lo21;
360
0
  case BFD_RELOC_AARCH64_ADD_LO12:
361
0
    return &arm64_reloc_howto_pgoff12a;
362
0
  case BFD_RELOC_AARCH64_LDST8_LO12:
363
0
  case BFD_RELOC_AARCH64_LDST16_LO12:
364
0
  case BFD_RELOC_AARCH64_LDST32_LO12:
365
0
  case BFD_RELOC_AARCH64_LDST64_LO12:
366
0
  case BFD_RELOC_AARCH64_LDST128_LO12:
367
0
  case BFD_RELOC_AARCH64_LD64_GOT_LO12_NC:
368
0
    return &arm64_reloc_howto_pgoff12l;
369
0
  case BFD_RELOC_AARCH64_BRANCH19:
370
0
    return &arm64_reloc_howto_branch19;
371
136
  case BFD_RELOC_RVA:
372
136
    return &arm64_reloc_howto_32nb;
373
0
  case BFD_RELOC_32_SECREL:
374
0
    return &arm64_reloc_howto_secrel;
375
0
  case BFD_RELOC_16_SECIDX:
376
0
    return &arm64_reloc_howto_secidx;
377
0
  default:
378
0
    BFD_FAIL ();
379
0
    return NULL;
380
187
  }
381
382
0
  return NULL;
383
187
}
Unexecuted instantiation: pe-aarch64.c:coff_aarch64_reloc_type_lookup
pei-aarch64.c:coff_aarch64_reloc_type_lookup
Line
Count
Source
340
187
{
341
187
  switch (code)
342
187
  {
343
0
  case BFD_RELOC_64:
344
0
    return &arm64_reloc_howto_64;
345
51
  case BFD_RELOC_32:
346
51
    return &arm64_reloc_howto_32;
347
0
  case BFD_RELOC_32_PCREL:
348
0
    return &arm64_reloc_howto_32_pcrel;
349
0
  case BFD_RELOC_AARCH64_CALL26:
350
0
  case BFD_RELOC_AARCH64_JUMP26:
351
0
    return &arm64_reloc_howto_branch26;
352
0
  case BFD_RELOC_AARCH64_ADR_HI21_PCREL:
353
0
  case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL:
354
0
  case BFD_RELOC_AARCH64_ADR_GOT_PAGE:
355
0
    return &arm64_reloc_howto_page21;
356
0
  case BFD_RELOC_AARCH64_TSTBR14:
357
0
    return &arm64_reloc_howto_branch14;
358
0
  case BFD_RELOC_AARCH64_ADR_LO21_PCREL:
359
0
    return &arm64_reloc_howto_lo21;
360
0
  case BFD_RELOC_AARCH64_ADD_LO12:
361
0
    return &arm64_reloc_howto_pgoff12a;
362
0
  case BFD_RELOC_AARCH64_LDST8_LO12:
363
0
  case BFD_RELOC_AARCH64_LDST16_LO12:
364
0
  case BFD_RELOC_AARCH64_LDST32_LO12:
365
0
  case BFD_RELOC_AARCH64_LDST64_LO12:
366
0
  case BFD_RELOC_AARCH64_LDST128_LO12:
367
0
  case BFD_RELOC_AARCH64_LD64_GOT_LO12_NC:
368
0
    return &arm64_reloc_howto_pgoff12l;
369
0
  case BFD_RELOC_AARCH64_BRANCH19:
370
0
    return &arm64_reloc_howto_branch19;
371
136
  case BFD_RELOC_RVA:
372
136
    return &arm64_reloc_howto_32nb;
373
0
  case BFD_RELOC_32_SECREL:
374
0
    return &arm64_reloc_howto_secrel;
375
0
  case BFD_RELOC_16_SECIDX:
376
0
    return &arm64_reloc_howto_secidx;
377
0
  default:
378
0
    BFD_FAIL ();
379
0
    return NULL;
380
187
  }
381
382
0
  return NULL;
383
187
}
384
385
static reloc_howto_type *
386
coff_aarch64_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
387
          const char *r_name)
388
0
{
389
0
  unsigned int i;
390
391
0
  for (i = 0; i < NUM_RELOCS; i++)
392
0
    if (arm64_howto_table[i]->name != NULL
393
0
      && strcasecmp (arm64_howto_table[i]->name, r_name) == 0)
394
0
      return arm64_howto_table[i];
395
396
0
  return NULL;
397
0
}
Unexecuted instantiation: pe-aarch64.c:coff_aarch64_reloc_name_lookup
Unexecuted instantiation: pei-aarch64.c:coff_aarch64_reloc_name_lookup
398
399
196k
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER  2
400
226
#define COFF_PAGE_SIZE            0x1000
401
402
static reloc_howto_type *
403
coff_aarch64_rtype_lookup (unsigned int code)
404
313
{
405
313
  switch (code)
406
313
  {
407
264
    case IMAGE_REL_ARM64_ABSOLUTE:
408
264
      return &arm64_reloc_howto_abs;
409
0
    case IMAGE_REL_ARM64_ADDR64:
410
0
      return &arm64_reloc_howto_64;
411
2
    case IMAGE_REL_ARM64_ADDR32:
412
2
      return &arm64_reloc_howto_32;
413
0
    case IMAGE_REL_ARM64_REL32:
414
0
      return &arm64_reloc_howto_32_pcrel;
415
0
    case IMAGE_REL_ARM64_BRANCH26:
416
0
      return &arm64_reloc_howto_branch26;
417
0
    case IMAGE_REL_ARM64_PAGEBASE_REL21:
418
0
      return &arm64_reloc_howto_page21;
419
0
    case IMAGE_REL_ARM64_REL21:
420
0
      return &arm64_reloc_howto_lo21;
421
1
    case IMAGE_REL_ARM64_PAGEOFFSET_12L:
422
1
      return &arm64_reloc_howto_pgoff12l;
423
1
    case IMAGE_REL_ARM64_BRANCH19:
424
1
      return &arm64_reloc_howto_branch19;
425
3
    case IMAGE_REL_ARM64_BRANCH14:
426
3
      return &arm64_reloc_howto_branch14;
427
0
    case IMAGE_REL_ARM64_PAGEOFFSET_12A:
428
0
      return &arm64_reloc_howto_pgoff12a;
429
0
    case IMAGE_REL_ARM64_ADDR32NB:
430
0
      return &arm64_reloc_howto_32nb;
431
0
    case IMAGE_REL_ARM64_SECREL:
432
0
      return &arm64_reloc_howto_secrel;
433
2
    case IMAGE_REL_ARM64_SECTION:
434
2
      return &arm64_reloc_howto_secidx;
435
40
    default:
436
40
      return NULL;
437
313
  }
438
439
0
  return NULL;
440
313
}
pe-aarch64.c:coff_aarch64_rtype_lookup
Line
Count
Source
404
313
{
405
313
  switch (code)
406
313
  {
407
264
    case IMAGE_REL_ARM64_ABSOLUTE:
408
264
      return &arm64_reloc_howto_abs;
409
0
    case IMAGE_REL_ARM64_ADDR64:
410
0
      return &arm64_reloc_howto_64;
411
2
    case IMAGE_REL_ARM64_ADDR32:
412
2
      return &arm64_reloc_howto_32;
413
0
    case IMAGE_REL_ARM64_REL32:
414
0
      return &arm64_reloc_howto_32_pcrel;
415
0
    case IMAGE_REL_ARM64_BRANCH26:
416
0
      return &arm64_reloc_howto_branch26;
417
0
    case IMAGE_REL_ARM64_PAGEBASE_REL21:
418
0
      return &arm64_reloc_howto_page21;
419
0
    case IMAGE_REL_ARM64_REL21:
420
0
      return &arm64_reloc_howto_lo21;
421
1
    case IMAGE_REL_ARM64_PAGEOFFSET_12L:
422
1
      return &arm64_reloc_howto_pgoff12l;
423
1
    case IMAGE_REL_ARM64_BRANCH19:
424
1
      return &arm64_reloc_howto_branch19;
425
3
    case IMAGE_REL_ARM64_BRANCH14:
426
3
      return &arm64_reloc_howto_branch14;
427
0
    case IMAGE_REL_ARM64_PAGEOFFSET_12A:
428
0
      return &arm64_reloc_howto_pgoff12a;
429
0
    case IMAGE_REL_ARM64_ADDR32NB:
430
0
      return &arm64_reloc_howto_32nb;
431
0
    case IMAGE_REL_ARM64_SECREL:
432
0
      return &arm64_reloc_howto_secrel;
433
2
    case IMAGE_REL_ARM64_SECTION:
434
2
      return &arm64_reloc_howto_secidx;
435
40
    default:
436
40
      return NULL;
437
313
  }
438
439
0
  return NULL;
440
313
}
Unexecuted instantiation: pei-aarch64.c:coff_aarch64_rtype_lookup
441
442
#define RTYPE2HOWTO(cache_ptr, dst)         \
443
313
  ((cache_ptr)->howto = coff_aarch64_rtype_lookup((dst)->r_type))
444
445
static reloc_howto_type *
446
coff_aarch64_rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
447
           asection *sec ATTRIBUTE_UNUSED,
448
           struct internal_reloc *rel,
449
           struct coff_link_hash_entry *h ATTRIBUTE_UNUSED,
450
           struct internal_syment *sym ATTRIBUTE_UNUSED,
451
           bfd_vma *addendp)
452
0
{
453
0
  reloc_howto_type *howto = coff_aarch64_rtype_lookup (rel->r_type);
454
455
  /* Cancel out code in _bfd_coff_generic_relocate_section.  */
456
0
  *addendp = 0;
457
458
0
  return howto;
459
0
}
Unexecuted instantiation: pe-aarch64.c:coff_aarch64_rtype_to_howto
Unexecuted instantiation: pei-aarch64.c:coff_aarch64_rtype_to_howto
460
461
#define coff_rtype_to_howto coff_aarch64_rtype_to_howto
462
463
29
#define SELECT_RELOC(x,howto) { (x).r_type = (howto)->type; }
464
465
#ifndef bfd_pe_print_pdata
466
#define bfd_pe_print_pdata      NULL
467
#endif
468
469
#ifdef COFF_WITH_PE
470
/* Return TRUE if this relocation should
471
   appear in the output .reloc section.  */
472
473
static bool
474
in_reloc_p (bfd * abfd ATTRIBUTE_UNUSED,
475
            reloc_howto_type * howto)
476
0
{
477
0
  return !howto->pc_relative;
478
0
}
Unexecuted instantiation: pe-aarch64.c:in_reloc_p
Unexecuted instantiation: pei-aarch64.c:in_reloc_p
479
#endif
480
481
static bool
482
coff_pe_aarch64_relocate_section (bfd *output_bfd,
483
          struct bfd_link_info *info,
484
          bfd *input_bfd,
485
          asection *input_section,
486
          bfd_byte *contents,
487
          struct internal_reloc *relocs,
488
          struct internal_syment *syms,
489
          asection **sections)
490
0
{
491
0
  struct internal_reloc *rel;
492
0
  struct internal_reloc *relend;
493
494
0
  if (bfd_link_relocatable (info))
495
0
    return true;
496
497
0
  rel = relocs;
498
0
  relend = rel + input_section->reloc_count;
499
500
  /* The addend for a relocation is stored in the immediate bits of each
501
     opcode.  So for each relocation, we need to extract the immediate value,
502
     use this to calculate what it should be for the symbol, and rewrite the
503
     opcode into the section stream.  */
504
505
0
  for (; rel < relend; rel++)
506
0
    {
507
0
      long symndx;
508
0
      struct coff_link_hash_entry *h;
509
0
      bfd_vma sym_value;
510
0
      asection *sec = NULL;
511
0
      uint64_t dest_vma;
512
513
      /* skip trivial relocations */
514
0
      if (rel->r_type == IMAGE_REL_ARM64_ADDR32
515
0
    || rel->r_type == IMAGE_REL_ARM64_ADDR64
516
0
    || rel->r_type == IMAGE_REL_ARM64_ABSOLUTE)
517
0
  continue;
518
519
0
      symndx = rel->r_symndx;
520
0
      sym_value = syms[symndx].n_value;
521
522
0
      h = obj_coff_sym_hashes (input_bfd)[symndx];
523
524
0
      if (h && h->root.type == bfd_link_hash_defined)
525
0
  {
526
0
    sec = h->root.u.def.section;
527
0
    sym_value = h->root.u.def.value;
528
0
  }
529
0
      else
530
0
  {
531
0
    sec = sections[symndx];
532
0
  }
533
534
0
      if (!sec)
535
0
  continue;
536
537
0
      if (bfd_is_und_section (sec))
538
0
  continue;
539
540
0
      if (discarded_section (sec))
541
0
  continue;
542
543
0
      dest_vma = sec->output_section->vma + sec->output_offset + sym_value;
544
545
0
      if (symndx < 0
546
0
    || (unsigned long) symndx >= obj_raw_syment_count (input_bfd))
547
0
  continue;
548
549
      /* All the relocs handled below operate on 4 bytes.  */
550
0
      if (input_section->size < rel->r_vaddr
551
0
    || input_section->size - rel->r_vaddr < 4)
552
0
  {
553
0
    _bfd_error_handler
554
      /* xgettext: c-format */
555
0
      (_("%pB: bad reloc address %#" PRIx64 " in section `%pA'"),
556
0
       input_bfd, (uint64_t) rel->r_vaddr, input_section);
557
0
    continue;
558
0
  }
559
560
0
      switch (rel->r_type)
561
0
  {
562
0
  case IMAGE_REL_ARM64_ADDR32NB:
563
0
    {
564
0
      uint64_t val;
565
0
      int32_t addend;
566
567
0
      addend = bfd_getl32 (contents + rel->r_vaddr);
568
569
0
      dest_vma += addend;
570
571
0
      val = dest_vma;
572
0
      val -= pe_data (output_bfd)->pe_opthdr.ImageBase;
573
574
0
      if (val > 0xffffffff)
575
0
        (*info->callbacks->reloc_overflow)
576
0
    (info, h ? &h->root : NULL, syms[symndx]._n._n_name,
577
0
    "IMAGE_REL_ARM64_ADDR32NB", addend, input_bfd,
578
0
    input_section, rel->r_vaddr - input_section->vma);
579
580
0
      bfd_putl32 (val, contents + rel->r_vaddr);
581
0
      rel->r_type = IMAGE_REL_ARM64_ABSOLUTE;
582
583
0
      break;
584
0
    }
585
586
0
  case IMAGE_REL_ARM64_BRANCH26:
587
0
    {
588
0
      uint64_t cur_vma;
589
0
      uint32_t opcode;
590
0
      int64_t addend, val;
591
592
0
      opcode = bfd_getl32 (contents + rel->r_vaddr);
593
594
0
      addend = (opcode & 0x3ffffff) << 2;
595
596
0
      if (addend & 0x8000000)
597
0
        addend |= 0xfffffffff0000000;
598
599
0
      dest_vma += addend;
600
0
      cur_vma = input_section->output_section->vma
601
0
          + input_section->output_offset
602
0
          + rel->r_vaddr;
603
604
0
      val = (dest_vma >> 2) - (cur_vma >> 2);
605
606
0
      if (val > 0x1ffffff || val < -0x2000000)
607
0
        (*info->callbacks->reloc_overflow)
608
0
    (info, h ? &h->root : NULL, syms[symndx]._n._n_name,
609
0
    "IMAGE_REL_ARM64_BRANCH26", addend, input_bfd,
610
0
    input_section, rel->r_vaddr - input_section->vma);
611
612
0
      opcode &= 0xfc000000;
613
0
      opcode |= val & 0x3ffffff;
614
615
0
      bfd_putl32 (opcode, contents + rel->r_vaddr);
616
0
      rel->r_type = IMAGE_REL_ARM64_ABSOLUTE;
617
618
0
      break;
619
0
    }
620
621
0
  case IMAGE_REL_ARM64_BRANCH19:
622
0
    {
623
0
      uint64_t cur_vma;
624
0
      uint32_t opcode;
625
0
      int64_t addend, val;
626
627
0
      opcode = bfd_getl32 (contents + rel->r_vaddr);
628
629
0
      addend = (opcode & 0xffffe0) >> 3;
630
631
0
      if (addend & 0x100000)
632
0
        addend |= 0xffffffffffe00000;
633
634
0
      dest_vma += addend;
635
0
      cur_vma = input_section->output_section->vma
636
0
          + input_section->output_offset
637
0
          + rel->r_vaddr;
638
639
0
      val = (dest_vma >> 2) - (cur_vma >> 2);
640
641
0
      if (val > 0x3ffff || val < -0x40000)
642
0
        (*info->callbacks->reloc_overflow)
643
0
    (info, h ? &h->root : NULL, syms[symndx]._n._n_name,
644
0
    "IMAGE_REL_ARM64_BRANCH19", addend, input_bfd,
645
0
    input_section, rel->r_vaddr - input_section->vma);
646
647
0
      opcode &= 0xff00001f;
648
0
      opcode |= (val & 0x7ffff) << 5;
649
650
0
      bfd_putl32 (opcode, contents + rel->r_vaddr);
651
0
      rel->r_type = IMAGE_REL_ARM64_ABSOLUTE;
652
653
0
      break;
654
0
    }
655
656
0
  case IMAGE_REL_ARM64_BRANCH14:
657
0
    {
658
0
      uint64_t cur_vma;
659
0
      uint32_t opcode;
660
0
      int64_t addend, val;
661
662
0
      opcode = bfd_getl32 (contents + rel->r_vaddr);
663
664
0
      addend = (opcode & 0x7ffe0) >> 3;
665
666
0
      if (addend & 0x8000)
667
0
        addend |= 0xffffffffffff0000;
668
669
0
      dest_vma += addend;
670
0
      cur_vma = input_section->output_section->vma
671
0
          + input_section->output_offset
672
0
          + rel->r_vaddr;
673
674
0
      val = (dest_vma >> 2) - (cur_vma >> 2);
675
676
0
      if (val > 0x1fff || val < -0x2000)
677
0
        (*info->callbacks->reloc_overflow)
678
0
    (info, h ? &h->root : NULL, syms[symndx]._n._n_name,
679
0
    "IMAGE_REL_ARM64_BRANCH14", addend, input_bfd,
680
0
    input_section, rel->r_vaddr - input_section->vma);
681
682
0
      opcode &= 0xfff8001f;
683
0
      opcode |= (val & 0x3fff) << 5;
684
685
0
      bfd_putl32 (opcode, contents + rel->r_vaddr);
686
0
      rel->r_type = IMAGE_REL_ARM64_ABSOLUTE;
687
688
0
      break;
689
0
    }
690
691
0
  case IMAGE_REL_ARM64_PAGEBASE_REL21:
692
0
    {
693
0
      uint64_t cur_vma;
694
0
      uint32_t opcode;
695
0
      int64_t addend, val;
696
697
0
      opcode = bfd_getl32 (contents + rel->r_vaddr);
698
699
0
      addend = ((opcode & 0xffffe0) >> 3)
700
0
         | ((opcode & 0x60000000) >> 29);
701
702
0
      if (addend & 0x100000)
703
0
        addend |= 0xffffffffffe00000;
704
705
0
      dest_vma += addend;
706
0
      cur_vma = input_section->output_section->vma
707
0
          + input_section->output_offset
708
0
          + rel->r_vaddr;
709
710
0
      val = (dest_vma >> 12) - (cur_vma >> 12);
711
712
0
      if (val > 0xfffff || val < -0x100000)
713
0
        (*info->callbacks->reloc_overflow)
714
0
    (info, h ? &h->root : NULL, syms[symndx]._n._n_name,
715
0
    "IMAGE_REL_ARM64_PAGEBASE_REL21", addend, input_bfd,
716
0
    input_section, rel->r_vaddr - input_section->vma);
717
718
0
      opcode &= 0x9f00001f;
719
0
      opcode |= (val & 0x3) << 29;
720
0
      opcode |= (val & 0x1ffffc) << 3;
721
722
0
      bfd_putl32 (opcode, contents + rel->r_vaddr);
723
0
      rel->r_type = IMAGE_REL_ARM64_ABSOLUTE;
724
725
0
      break;
726
0
    }
727
728
0
  case IMAGE_REL_ARM64_REL21:
729
0
    {
730
0
      uint64_t cur_vma;
731
0
      uint32_t opcode;
732
0
      int64_t addend, val;
733
734
0
      opcode = bfd_getl32 (contents + rel->r_vaddr);
735
736
0
      addend = ((opcode & 0xffffe0) >> 3)
737
0
         | ((opcode & 0x60000000) >> 29);
738
739
0
      if (addend & 0x100000)
740
0
        addend |= 0xffffffffffe00000;
741
742
0
      dest_vma += addend;
743
0
      cur_vma = input_section->output_section->vma
744
0
          + input_section->output_offset
745
0
          + rel->r_vaddr;
746
747
0
      val = dest_vma - cur_vma;
748
749
0
      if (val > 0xfffff || val < -0x100000)
750
0
        (*info->callbacks->reloc_overflow)
751
0
    (info, h ? &h->root : NULL, syms[symndx]._n._n_name,
752
0
    "IMAGE_REL_ARM64_REL21", addend, input_bfd,
753
0
    input_section, rel->r_vaddr - input_section->vma);
754
755
0
      opcode &= 0x9f00001f;
756
0
      opcode |= (val & 0x3) << 29;
757
0
      opcode |= (val & 0x1ffffc) << 3;
758
759
0
      bfd_putl32 (opcode, contents + rel->r_vaddr);
760
0
      rel->r_type = IMAGE_REL_ARM64_ABSOLUTE;
761
762
0
      break;
763
0
    }
764
765
0
  case IMAGE_REL_ARM64_REL32:
766
0
    {
767
0
      uint64_t cur_vma;
768
0
      int64_t addend, val;
769
770
0
      addend = bfd_getl32 (contents + rel->r_vaddr);
771
772
0
      if (addend & 0x80000000)
773
0
        addend |= 0xffffffff00000000;
774
775
0
      dest_vma += addend;
776
0
      cur_vma = input_section->output_section->vma
777
0
          + input_section->output_offset
778
0
          + rel->r_vaddr;
779
780
0
      val = dest_vma - cur_vma;
781
782
0
      if (val > 0xffffffff || val < -0x100000000)
783
0
        (*info->callbacks->reloc_overflow)
784
0
    (info, h ? &h->root : NULL, syms[symndx]._n._n_name,
785
0
    "IMAGE_REL_ARM64_REL32", addend, input_bfd,
786
0
    input_section, rel->r_vaddr - input_section->vma);
787
788
0
      bfd_putl32 (val, contents + rel->r_vaddr);
789
0
      rel->r_type = IMAGE_REL_ARM64_ABSOLUTE;
790
791
0
      break;
792
0
    }
793
794
0
  case IMAGE_REL_ARM64_PAGEOFFSET_12L:
795
0
    {
796
0
      uint32_t opcode, val;
797
0
      uint8_t shift;
798
0
      int32_t addend;
799
800
0
      opcode = bfd_getl32 (contents + rel->r_vaddr);
801
802
0
      addend = (opcode & 0x3ffc00) >> 10;
803
804
0
      if ((opcode & 0xff800000) == 0x3d800000)
805
0
        {
806
    /* LDR / STR with q register */
807
0
    shift = 4;
808
0
        }
809
0
      else
810
0
        {
811
    /* top two bits represent how much addend should be shifted */
812
0
    shift = opcode >> 30;
813
0
        }
814
815
0
      addend <<= shift;
816
817
0
      dest_vma += addend;
818
819
      /* only interested in bottom 12 bits */
820
0
      val = dest_vma & 0xfff;
821
822
0
      if (val & ((1 << shift) - 1))
823
0
        (*info->callbacks->reloc_overflow)
824
0
    (info, h ? &h->root : NULL, syms[symndx]._n._n_name,
825
0
    "IMAGE_REL_ARM64_PAGEOFFSET_12L", addend, input_bfd,
826
0
    input_section, rel->r_vaddr - input_section->vma);
827
828
0
      val >>= shift;
829
830
0
      opcode &= 0xffc003ff;
831
0
      opcode |= val << 10;
832
833
0
      bfd_putl32 (opcode, contents + rel->r_vaddr);
834
0
      rel->r_type = IMAGE_REL_ARM64_ABSOLUTE;
835
836
0
      break;
837
0
    }
838
839
0
  case IMAGE_REL_ARM64_PAGEOFFSET_12A:
840
0
    {
841
0
      uint32_t opcode, val;
842
0
      int32_t addend;
843
844
0
      opcode = bfd_getl32 (contents + rel->r_vaddr);
845
846
0
      addend = (opcode & 0x3ffc00) >> 10;
847
848
0
      dest_vma += addend;
849
850
      /* only interested in bottom 12 bits */
851
0
      val = dest_vma & 0xfff;
852
853
0
      opcode &= 0xffc003ff;
854
0
      opcode |= val << 10;
855
856
0
      bfd_putl32 (opcode, contents + rel->r_vaddr);
857
0
      rel->r_type = IMAGE_REL_ARM64_ABSOLUTE;
858
859
0
      break;
860
0
    }
861
862
0
  case IMAGE_REL_ARM64_SECREL:
863
0
    {
864
0
      uint64_t val;
865
0
      int32_t addend;
866
867
0
      addend = bfd_getl32 (contents + rel->r_vaddr);
868
869
0
      val = sec->output_offset + sym_value + addend;
870
871
0
      if (val > 0xffffffff)
872
0
        (*info->callbacks->reloc_overflow)
873
0
    (info, h ? &h->root : NULL, syms[symndx]._n._n_name,
874
0
    "IMAGE_REL_ARM64_SECREL", addend, input_bfd,
875
0
    input_section, rel->r_vaddr - input_section->vma);
876
877
0
      bfd_putl32 (val, contents + rel->r_vaddr);
878
0
      rel->r_type = IMAGE_REL_ARM64_ABSOLUTE;
879
880
0
      break;
881
0
    }
882
883
0
  case IMAGE_REL_ARM64_SECTION:
884
0
    {
885
0
      uint16_t idx = 0, i = 1;
886
0
      asection *s;
887
888
0
      s = output_bfd->sections;
889
0
      while (s)
890
0
        {
891
0
    if (s == sec->output_section)
892
0
      {
893
0
        idx = i;
894
0
        break;
895
0
      }
896
897
0
    i++;
898
0
    s = s->next;
899
0
        }
900
901
902
0
      bfd_putl16 (idx, contents + rel->r_vaddr);
903
0
      rel->r_type = IMAGE_REL_ARM64_ABSOLUTE;
904
905
0
      break;
906
0
    }
907
908
0
  default:
909
0
    info->callbacks->fatal (_("%P: Unhandled relocation type %u\n"),
910
0
          rel->r_type);
911
0
  }
912
0
    }
913
914
0
  return _bfd_coff_generic_relocate_section (output_bfd, info, input_bfd,
915
0
               input_section, contents,
916
0
               relocs, syms, sections);
917
0
}
Unexecuted instantiation: pe-aarch64.c:coff_pe_aarch64_relocate_section
Unexecuted instantiation: pei-aarch64.c:coff_pe_aarch64_relocate_section
918
919
#define coff_relocate_section coff_pe_aarch64_relocate_section
920
921
#include "coffcode.h"
922
923
/* Prevent assertion in md_apply_fix by forcing use_rela_p on for new
924
   sections.  */
925
static bool
926
coff_aarch64_new_section_hook (bfd *abfd, asection *section)
927
98.1k
{
928
98.1k
  if (!coff_new_section_hook (abfd, section))
929
0
    return false;
930
931
98.1k
  section->use_rela_p = 1;
932
933
  return true;
934
98.1k
}
pe-aarch64.c:coff_aarch64_new_section_hook
Line
Count
Source
927
34.4k
{
928
34.4k
  if (!coff_new_section_hook (abfd, section))
929
0
    return false;
930
931
34.4k
  section->use_rela_p = 1;
932
933
  return true;
934
34.4k
}
pei-aarch64.c:coff_aarch64_new_section_hook
Line
Count
Source
927
63.7k
{
928
63.7k
  if (!coff_new_section_hook (abfd, section))
929
0
    return false;
930
931
63.7k
  section->use_rela_p = 1;
932
933
  return true;
934
63.7k
}
935
936
#define coff_aarch64_close_and_cleanup coff_close_and_cleanup
937
#define coff_aarch64_bfd_free_cached_info coff_bfd_free_cached_info
938
#define coff_aarch64_get_section_contents coff_get_section_contents
939
940
/* Target vectors.  */
941
const bfd_target
942
#ifdef TARGET_SYM
943
  TARGET_SYM =
944
#else
945
# error "target symbol name not specified"
946
#endif
947
{
948
#ifdef TARGET_NAME
949
  TARGET_NAME,
950
#else
951
# error "target name not specified"
952
#endif
953
  bfd_target_coff_flavour,
954
  BFD_ENDIAN_LITTLE,    /* Data byte order is little.  */
955
  BFD_ENDIAN_LITTLE,    /* Header byte order is little.  */
956
957
  (HAS_RELOC | EXEC_P   /* Object flags.  */
958
   | HAS_LINENO | HAS_DEBUG
959
   | HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED | BFD_COMPRESS | BFD_DECOMPRESS),
960
961
  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* Section flags.  */
962
#if defined(COFF_WITH_PE)
963
   | SEC_LINK_ONCE | SEC_LINK_DUPLICATES | SEC_READONLY | SEC_DEBUGGING
964
#endif
965
   | SEC_CODE | SEC_DATA | SEC_EXCLUDE ),
966
967
#ifdef TARGET_UNDERSCORE
968
  TARGET_UNDERSCORE,    /* Leading underscore.  */
969
#else
970
  0,        /* Leading underscore.  */
971
#endif
972
  '/',        /* Ar_pad_char.  */
973
  15,       /* Ar_max_namelen.  */
974
  0,        /* match priority.  */
975
  TARGET_KEEP_UNUSED_SECTION_SYMBOLS, /* keep unused section symbols.  */
976
  TARGET_MERGE_SECTIONS,
977
978
  /* Data conversion functions.  */
979
  bfd_getl64, bfd_getl_signed_64, bfd_putl64,
980
  bfd_getl32, bfd_getl_signed_32, bfd_putl32,
981
  bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Data.  */
982
  /* Header conversion functions.  */
983
  bfd_getl64, bfd_getl_signed_64, bfd_putl64,
984
  bfd_getl32, bfd_getl_signed_32, bfd_putl32,
985
  bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Hdrs.  */
986
987
  /* Note that we allow an object file to be treated as a core file as well.  */
988
  {       /* bfd_check_format.  */
989
    _bfd_dummy_target,
990
    coff_object_p,
991
    bfd_generic_archive_p,
992
    coff_object_p
993
  },
994
  {       /* bfd_set_format.  */
995
    _bfd_bool_bfd_false_error,
996
    coff_mkobject,
997
    _bfd_generic_mkarchive,
998
    _bfd_bool_bfd_false_error
999
  },
1000
  {       /* bfd_write_contents.  */
1001
    _bfd_bool_bfd_false_error,
1002
    coff_write_object_contents,
1003
    _bfd_write_archive_contents,
1004
    _bfd_bool_bfd_false_error
1005
  },
1006
1007
  BFD_JUMP_TABLE_GENERIC (coff_aarch64),
1008
  BFD_JUMP_TABLE_COPY (coff),
1009
  BFD_JUMP_TABLE_CORE (_bfd_nocore),
1010
  BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
1011
  BFD_JUMP_TABLE_SYMBOLS (coff),
1012
  BFD_JUMP_TABLE_RELOCS (coff),
1013
  BFD_JUMP_TABLE_WRITE (coff),
1014
  BFD_JUMP_TABLE_LINK (coff),
1015
  BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
1016
1017
  NULL,
1018
1019
  COFF_SWAP_TABLE
1020
};
1021
1022
#ifdef COFF_WITH_PE_BIGOBJ
1023
const bfd_target
1024
  TARGET_SYM_BIG =
1025
{
1026
  TARGET_NAME_BIG,
1027
  bfd_target_coff_flavour,
1028
  BFD_ENDIAN_LITTLE,    /* Data byte order is little.  */
1029
  BFD_ENDIAN_LITTLE,    /* Header byte order is little.  */
1030
1031
  (HAS_RELOC | EXEC_P   /* Object flags.  */
1032
   | HAS_LINENO | HAS_DEBUG
1033
   | HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED | BFD_COMPRESS | BFD_DECOMPRESS),
1034
1035
  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* Section flags.  */
1036
#ifdef COFF_WITH_PE
1037
   | SEC_LINK_ONCE | SEC_LINK_DUPLICATES | SEC_READONLY | SEC_DEBUGGING
1038
#endif
1039
   | SEC_CODE | SEC_DATA | SEC_EXCLUDE ),
1040
1041
#ifdef TARGET_UNDERSCORE
1042
  TARGET_UNDERSCORE,    /* Leading underscore.  */
1043
#else
1044
  0,        /* Leading underscore.  */
1045
#endif
1046
  '/',        /* Ar_pad_char.  */
1047
  15,       /* Ar_max_namelen.  */
1048
  0,        /* match priority.  */
1049
  TARGET_KEEP_UNUSED_SECTION_SYMBOLS, /* keep unused section symbols.  */
1050
  TARGET_MERGE_SECTIONS,
1051
1052
  /* Data conversion functions.  */
1053
  bfd_getl64, bfd_getl_signed_64, bfd_putl64,
1054
  bfd_getl32, bfd_getl_signed_32, bfd_putl32,
1055
  bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Data.  */
1056
  /* Header conversion functions.  */
1057
  bfd_getl64, bfd_getl_signed_64, bfd_putl64,
1058
  bfd_getl32, bfd_getl_signed_32, bfd_putl32,
1059
  bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Hdrs.  */
1060
1061
  /* Note that we allow an object file to be treated as a core file as well.  */
1062
  {       /* bfd_check_format.  */
1063
    _bfd_dummy_target,
1064
    coff_object_p,
1065
    bfd_generic_archive_p,
1066
    coff_object_p
1067
  },
1068
  {       /* bfd_set_format.  */
1069
    _bfd_bool_bfd_false_error,
1070
    coff_mkobject,
1071
    _bfd_generic_mkarchive,
1072
    _bfd_bool_bfd_false_error
1073
  },
1074
  {       /* bfd_write_contents.  */
1075
    _bfd_bool_bfd_false_error,
1076
    coff_write_object_contents,
1077
    _bfd_write_archive_contents,
1078
    _bfd_bool_bfd_false_error
1079
  },
1080
1081
  BFD_JUMP_TABLE_GENERIC (coff_aarch64),
1082
  BFD_JUMP_TABLE_COPY (coff),
1083
  BFD_JUMP_TABLE_CORE (_bfd_nocore),
1084
  BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
1085
  BFD_JUMP_TABLE_SYMBOLS (coff),
1086
  BFD_JUMP_TABLE_RELOCS (coff),
1087
  BFD_JUMP_TABLE_WRITE (coff),
1088
  BFD_JUMP_TABLE_LINK (coff),
1089
  BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
1090
1091
  NULL,
1092
1093
  &bigobj_swap_table
1094
};
1095
#endif