gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / bfd / coff-i386.c
1 /* BFD back-end for Intel 386 COFF files.
2 Copyright (C) 1990-2020 Free Software Foundation, Inc.
3 Written by Cygnus Support.
4
5 This file is part of BFD, the Binary File Descriptor library.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
21
22 #include "sysdep.h"
23 #include "bfd.h"
24 #include "libbfd.h"
25
26 #include "coff/i386.h"
27
28 #include "coff/internal.h"
29
30 #ifdef COFF_WITH_PE
31 #include "coff/pe.h"
32 #endif
33
34 #ifndef bfd_pe_print_pdata
35 #define bfd_pe_print_pdata NULL
36 #endif
37
38 #include "libcoff.h"
39
40 /* All users of this file have bfd_octets_per_byte (abfd, sec) == 1. */
41 #define OCTETS_PER_BYTE(ABFD, SEC) 1
42
43 static reloc_howto_type *coff_i386_rtype_to_howto
44 (bfd *, asection *, struct internal_reloc *,
45 struct coff_link_hash_entry *, struct internal_syment *,
46 bfd_vma *);
47 static reloc_howto_type *coff_i386_reloc_type_lookup
48 (bfd *, bfd_reloc_code_real_type);
49
50 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
51 /* The page size is a guess based on ELF. */
52
53 #define COFF_PAGE_SIZE 0x1000
54
55 /* For some reason when using i386 COFF the value stored in the .text
56 section for a reference to a common symbol is the value itself plus
57 any desired offset. Ian Taylor, Cygnus Support. */
58
59 /* If we are producing relocatable output, we need to do some
60 adjustments to the object file that are not done by the
61 bfd_perform_relocation function. This function is called by every
62 reloc type to make any required adjustments. */
63
64 static bfd_reloc_status_type
65 coff_i386_reloc (bfd *abfd,
66 arelent *reloc_entry,
67 asymbol *symbol,
68 void * data,
69 asection *input_section,
70 bfd *output_bfd,
71 char **error_message ATTRIBUTE_UNUSED)
72 {
73 symvalue diff;
74
75 #ifndef COFF_WITH_PE
76 if (output_bfd == (bfd *) NULL)
77 return bfd_reloc_continue;
78 #endif
79
80 if (bfd_is_com_section (symbol->section))
81 {
82 #ifndef COFF_WITH_PE
83 /* We are relocating a common symbol. The current value in the
84 object file is ORIG + OFFSET, where ORIG is the value of the
85 common symbol as seen by the object file when it was compiled
86 (this may be zero if the symbol was undefined) and OFFSET is
87 the offset into the common symbol (normally zero, but may be
88 non-zero when referring to a field in a common structure).
89 ORIG is the negative of reloc_entry->addend, which is set by
90 the CALC_ADDEND macro below. We want to replace the value in
91 the object file with NEW + OFFSET, where NEW is the value of
92 the common symbol which we are going to put in the final
93 object file. NEW is symbol->value. */
94 diff = symbol->value + reloc_entry->addend;
95 #else
96 /* In PE mode, we do not offset the common symbol. */
97 diff = reloc_entry->addend;
98 #endif
99 }
100 else
101 {
102 /* For some reason bfd_perform_relocation always effectively
103 ignores the addend for a COFF target when producing
104 relocatable output. This seems to be always wrong for 386
105 COFF, so we handle the addend here instead. */
106 #ifdef COFF_WITH_PE
107 if (output_bfd == (bfd *) NULL)
108 {
109 reloc_howto_type *howto = reloc_entry->howto;
110
111 /* Although PC relative relocations are very similar between
112 PE and non-PE formats, but they are off by 1 << howto->size
113 bytes. For the external relocation, PE is very different
114 from others. See md_apply_fix3 () in gas/config/tc-i386.c.
115 When we link PE and non-PE object files together to
116 generate a non-PE executable, we have to compensate it
117 here. */
118 if (howto->pc_relative && howto->pcrel_offset)
119 diff = -(1 << howto->size);
120 else if (symbol->flags & BSF_WEAK)
121 diff = reloc_entry->addend - symbol->value;
122 else
123 diff = -reloc_entry->addend;
124 }
125 else
126 #endif
127 diff = reloc_entry->addend;
128 }
129
130 #ifdef COFF_WITH_PE
131 /* FIXME: How should this case be handled? */
132 if (reloc_entry->howto->type == R_IMAGEBASE
133 && output_bfd != NULL
134 && bfd_get_flavour(output_bfd) == bfd_target_coff_flavour)
135 diff -= pe_data (output_bfd)->pe_opthdr.ImageBase;
136 #endif
137
138 #define DOIT(x) \
139 x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))
140
141 if (diff != 0)
142 {
143 reloc_howto_type *howto = reloc_entry->howto;
144 bfd_size_type octets = (reloc_entry->address
145 * OCTETS_PER_BYTE (abfd, input_section));
146 unsigned char *addr = (unsigned char *) data + octets;
147
148 if (!bfd_reloc_offset_in_range (howto, abfd, input_section, octets))
149 return bfd_reloc_outofrange;
150
151 switch (howto->size)
152 {
153 case 0:
154 {
155 char x = bfd_get_8 (abfd, addr);
156 DOIT (x);
157 bfd_put_8 (abfd, x, addr);
158 }
159 break;
160
161 case 1:
162 {
163 short x = bfd_get_16 (abfd, addr);
164 DOIT (x);
165 bfd_put_16 (abfd, (bfd_vma) x, addr);
166 }
167 break;
168
169 case 2:
170 {
171 long x = bfd_get_32 (abfd, addr);
172 DOIT (x);
173 bfd_put_32 (abfd, (bfd_vma) x, addr);
174 }
175 break;
176
177 default:
178 abort ();
179 }
180 }
181
182 /* Now let bfd_perform_relocation finish everything up. */
183 return bfd_reloc_continue;
184 }
185
186 #ifdef COFF_WITH_PE
187 /* Return TRUE if this relocation should appear in the output .reloc
188 section. */
189
190 static bfd_boolean in_reloc_p (bfd * abfd ATTRIBUTE_UNUSED,
191 reloc_howto_type *howto)
192 {
193 return ! howto->pc_relative && howto->type != R_IMAGEBASE
194 && howto->type != R_SECREL32;
195 }
196 #endif /* COFF_WITH_PE */
197
198 #ifndef PCRELOFFSET
199 #define PCRELOFFSET FALSE
200 #endif
201
202 static reloc_howto_type howto_table[] =
203 {
204 EMPTY_HOWTO (0),
205 EMPTY_HOWTO (1),
206 EMPTY_HOWTO (2),
207 EMPTY_HOWTO (3),
208 EMPTY_HOWTO (4),
209 EMPTY_HOWTO (5),
210 HOWTO (R_DIR32, /* type */
211 0, /* rightshift */
212 2, /* size (0 = byte, 1 = short, 2 = long) */
213 32, /* bitsize */
214 FALSE, /* pc_relative */
215 0, /* bitpos */
216 complain_overflow_bitfield, /* complain_on_overflow */
217 coff_i386_reloc, /* special_function */
218 "dir32", /* name */
219 TRUE, /* partial_inplace */
220 0xffffffff, /* src_mask */
221 0xffffffff, /* dst_mask */
222 TRUE), /* pcrel_offset */
223 /* PE IMAGE_REL_I386_DIR32NB relocation (7). */
224 HOWTO (R_IMAGEBASE, /* type */
225 0, /* rightshift */
226 2, /* size (0 = byte, 1 = short, 2 = long) */
227 32, /* bitsize */
228 FALSE, /* pc_relative */
229 0, /* bitpos */
230 complain_overflow_bitfield, /* complain_on_overflow */
231 coff_i386_reloc, /* special_function */
232 "rva32", /* name */
233 TRUE, /* partial_inplace */
234 0xffffffff, /* src_mask */
235 0xffffffff, /* dst_mask */
236 FALSE), /* pcrel_offset */
237 EMPTY_HOWTO (010),
238 EMPTY_HOWTO (011),
239 EMPTY_HOWTO (012),
240 #ifdef COFF_WITH_PE
241 /* 32-bit longword section relative relocation (013). */
242 HOWTO (R_SECREL32, /* type */
243 0, /* rightshift */
244 2, /* size (0 = byte, 1 = short, 2 = long) */
245 32, /* bitsize */
246 FALSE, /* pc_relative */
247 0, /* bitpos */
248 complain_overflow_bitfield, /* complain_on_overflow */
249 coff_i386_reloc, /* special_function */
250 "secrel32", /* name */
251 TRUE, /* partial_inplace */
252 0xffffffff, /* src_mask */
253 0xffffffff, /* dst_mask */
254 TRUE), /* pcrel_offset */
255 #else
256 EMPTY_HOWTO (013),
257 #endif
258 EMPTY_HOWTO (014),
259 EMPTY_HOWTO (015),
260 EMPTY_HOWTO (016),
261 /* Byte relocation (017). */
262 HOWTO (R_RELBYTE, /* type */
263 0, /* rightshift */
264 0, /* size (0 = byte, 1 = short, 2 = long) */
265 8, /* bitsize */
266 FALSE, /* pc_relative */
267 0, /* bitpos */
268 complain_overflow_bitfield, /* complain_on_overflow */
269 coff_i386_reloc, /* special_function */
270 "8", /* name */
271 TRUE, /* partial_inplace */
272 0x000000ff, /* src_mask */
273 0x000000ff, /* dst_mask */
274 PCRELOFFSET), /* pcrel_offset */
275 /* 16-bit word relocation (020). */
276 HOWTO (R_RELWORD, /* type */
277 0, /* rightshift */
278 1, /* size (0 = byte, 1 = short, 2 = long) */
279 16, /* bitsize */
280 FALSE, /* pc_relative */
281 0, /* bitpos */
282 complain_overflow_bitfield, /* complain_on_overflow */
283 coff_i386_reloc, /* special_function */
284 "16", /* name */
285 TRUE, /* partial_inplace */
286 0x0000ffff, /* src_mask */
287 0x0000ffff, /* dst_mask */
288 PCRELOFFSET), /* pcrel_offset */
289 /* 32-bit longword relocation (021). */
290 HOWTO (R_RELLONG, /* type */
291 0, /* rightshift */
292 2, /* size (0 = byte, 1 = short, 2 = long) */
293 32, /* bitsize */
294 FALSE, /* pc_relative */
295 0, /* bitpos */
296 complain_overflow_bitfield, /* complain_on_overflow */
297 coff_i386_reloc, /* special_function */
298 "32", /* name */
299 TRUE, /* partial_inplace */
300 0xffffffff, /* src_mask */
301 0xffffffff, /* dst_mask */
302 PCRELOFFSET), /* pcrel_offset */
303 /* Byte PC relative relocation (022). */
304 HOWTO (R_PCRBYTE, /* type */
305 0, /* rightshift */
306 0, /* size (0 = byte, 1 = short, 2 = long) */
307 8, /* bitsize */
308 TRUE, /* pc_relative */
309 0, /* bitpos */
310 complain_overflow_signed, /* complain_on_overflow */
311 coff_i386_reloc, /* special_function */
312 "DISP8", /* name */
313 TRUE, /* partial_inplace */
314 0x000000ff, /* src_mask */
315 0x000000ff, /* dst_mask */
316 PCRELOFFSET), /* pcrel_offset */
317 /* 16-bit word PC relative relocation (023). */
318 HOWTO (R_PCRWORD, /* type */
319 0, /* rightshift */
320 1, /* size (0 = byte, 1 = short, 2 = long) */
321 16, /* bitsize */
322 TRUE, /* pc_relative */
323 0, /* bitpos */
324 complain_overflow_signed, /* complain_on_overflow */
325 coff_i386_reloc, /* special_function */
326 "DISP16", /* name */
327 TRUE, /* partial_inplace */
328 0x0000ffff, /* src_mask */
329 0x0000ffff, /* dst_mask */
330 PCRELOFFSET), /* pcrel_offset */
331 /* 32-bit longword PC relative relocation (024). */
332 HOWTO (R_PCRLONG, /* type */
333 0, /* rightshift */
334 2, /* size (0 = byte, 1 = short, 2 = long) */
335 32, /* bitsize */
336 TRUE, /* pc_relative */
337 0, /* bitpos */
338 complain_overflow_signed, /* complain_on_overflow */
339 coff_i386_reloc, /* special_function */
340 "DISP32", /* name */
341 TRUE, /* partial_inplace */
342 0xffffffff, /* src_mask */
343 0xffffffff, /* dst_mask */
344 PCRELOFFSET) /* pcrel_offset */
345 };
346
347 #define NUM_HOWTOS (sizeof (howto_table) / sizeof (howto_table[0]))
348
349 /* Turn a howto into a reloc nunmber */
350
351 #define SELECT_RELOC(x,howto) { x.r_type = howto->type; }
352 #define BADMAG(x) I386BADMAG(x)
353 #define I386 1 /* Customize coffcode.h */
354
355 #define RTYPE2HOWTO(cache_ptr, dst) \
356 ((cache_ptr)->howto = \
357 ((dst)->r_type < NUM_HOWTOS \
358 ? howto_table + (dst)->r_type \
359 : NULL))
360
361 /* For 386 COFF a STYP_NOLOAD | STYP_BSS section is part of a shared
362 library. On some other COFF targets STYP_BSS is normally
363 STYP_NOLOAD. */
364 #define BSS_NOLOAD_IS_SHARED_LIBRARY
365
366 /* Compute the addend of a reloc. If the reloc is to a common symbol,
367 the object file contains the value of the common symbol. By the
368 time this is called, the linker may be using a different symbol
369 from a different object file with a different value. Therefore, we
370 hack wildly to locate the original symbol from this file so that we
371 can make the correct adjustment. This macro sets coffsym to the
372 symbol from the original file, and uses it to set the addend value
373 correctly. If this is not a common symbol, the usual addend
374 calculation is done, except that an additional tweak is needed for
375 PC relative relocs.
376 FIXME: This macro refers to symbols and asect; these are from the
377 calling function, not the macro arguments. */
378
379 #define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
380 { \
381 coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
382 if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
383 coffsym = (obj_symbols (abfd) \
384 + (cache_ptr->sym_ptr_ptr - symbols)); \
385 else if (ptr) \
386 coffsym = coff_symbol_from (ptr); \
387 if (coffsym != (coff_symbol_type *) NULL \
388 && coffsym->native->u.syment.n_scnum == 0) \
389 cache_ptr->addend = - coffsym->native->u.syment.n_value; \
390 else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
391 && ptr->section != (asection *) NULL) \
392 cache_ptr->addend = - (ptr->section->vma + ptr->value); \
393 else \
394 cache_ptr->addend = 0; \
395 if (ptr && reloc.r_type < NUM_HOWTOS \
396 && howto_table[reloc.r_type].pc_relative) \
397 cache_ptr->addend += asect->vma; \
398 }
399
400 /* We use the special COFF backend linker. For normal i386 COFF, we
401 can use the generic relocate_section routine. For PE, we need our
402 own routine. */
403
404 #ifndef COFF_WITH_PE
405
406 #define coff_relocate_section _bfd_coff_generic_relocate_section
407
408 #else /* COFF_WITH_PE */
409
410 /* The PE relocate section routine. The only difference between this
411 and the regular routine is that we don't want to do anything for a
412 relocatable link. */
413
414 static bfd_boolean
415 coff_pe_i386_relocate_section (bfd *output_bfd,
416 struct bfd_link_info *info,
417 bfd *input_bfd,
418 asection *input_section,
419 bfd_byte *contents,
420 struct internal_reloc *relocs,
421 struct internal_syment *syms,
422 asection **sections)
423 {
424 if (bfd_link_relocatable (info))
425 return TRUE;
426
427 return _bfd_coff_generic_relocate_section (output_bfd, info, input_bfd,
428 input_section, contents,
429 relocs, syms, sections);
430 }
431
432 #define coff_relocate_section coff_pe_i386_relocate_section
433
434 #endif /* COFF_WITH_PE */
435
436 /* Convert an rtype to howto for the COFF backend linker. */
437
438 static reloc_howto_type *
439 coff_i386_rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
440 asection *sec,
441 struct internal_reloc *rel,
442 struct coff_link_hash_entry *h,
443 struct internal_syment *sym,
444 bfd_vma *addendp)
445 {
446 reloc_howto_type *howto;
447
448 if (rel->r_type >= NUM_HOWTOS)
449 {
450 bfd_set_error (bfd_error_bad_value);
451 return NULL;
452 }
453
454 howto = howto_table + rel->r_type;
455
456 #ifdef COFF_WITH_PE
457 /* Cancel out code in _bfd_coff_generic_relocate_section. */
458 *addendp = 0;
459 #endif
460
461 if (howto->pc_relative)
462 *addendp += sec->vma;
463
464 if (sym != NULL && sym->n_scnum == 0 && sym->n_value != 0)
465 {
466 /* This is a common symbol. The section contents include the
467 size (sym->n_value) as an addend. The relocate_section
468 function will be adding in the final value of the symbol. We
469 need to subtract out the current size in order to get the
470 correct result. */
471
472 BFD_ASSERT (h != NULL);
473
474 #ifndef COFF_WITH_PE
475 /* I think we *do* want to bypass this. If we don't, I have
476 seen some data parameters get the wrong relocation address.
477 If I link two versions with and without this section bypassed
478 and then do a binary comparison, the addresses which are
479 different can be looked up in the map. The case in which
480 this section has been bypassed has addresses which correspond
481 to values I can find in the map. */
482 *addendp -= sym->n_value;
483 #endif
484 }
485
486 #ifndef COFF_WITH_PE
487 /* If the output symbol is common (in which case this must be a
488 relocatable link), we need to add in the final size of the
489 common symbol. */
490 if (h != NULL && h->root.type == bfd_link_hash_common)
491 *addendp += h->root.u.c.size;
492 #endif
493
494 #ifdef COFF_WITH_PE
495 if (howto->pc_relative)
496 {
497 *addendp -= 4;
498
499 /* If the symbol is defined, then the generic code is going to
500 add back the symbol value in order to cancel out an
501 adjustment it made to the addend. However, we set the addend
502 to 0 at the start of this function. We need to adjust here,
503 to avoid the adjustment the generic code will make. FIXME:
504 This is getting a bit hackish. */
505 if (sym != NULL && sym->n_scnum != 0)
506 *addendp -= sym->n_value;
507 }
508
509 if (rel->r_type == R_IMAGEBASE
510 && (bfd_get_flavour(sec->output_section->owner)
511 == bfd_target_coff_flavour))
512 {
513 *addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase;
514 }
515
516 /* PR 17099 - Absolute R_PCRLONG relocations do not need a symbol. */
517 if (rel->r_type == R_PCRLONG && sym == NULL)
518 *addendp -= rel->r_vaddr;
519 else
520 BFD_ASSERT (sym != NULL);
521
522 if (rel->r_type == R_SECREL32 && sym != NULL)
523 {
524 bfd_vma osect_vma;
525
526 if (h && (h->root.type == bfd_link_hash_defined
527 || h->root.type == bfd_link_hash_defweak))
528 osect_vma = h->root.u.def.section->output_section->vma;
529 else
530 {
531 asection *s;
532 int i;
533
534 /* Sigh, the only way to get the section to offset against
535 is to find it the hard way. */
536
537 for (s = abfd->sections, i = 1; i < sym->n_scnum; i++)
538 s = s->next;
539
540 osect_vma = s->output_section->vma;
541 }
542
543 *addendp -= osect_vma;
544 }
545 #endif
546
547 return howto;
548 }
549
550 #define coff_bfd_reloc_type_lookup coff_i386_reloc_type_lookup
551 #define coff_bfd_reloc_name_lookup coff_i386_reloc_name_lookup
552
553 static reloc_howto_type *
554 coff_i386_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
555 bfd_reloc_code_real_type code)
556 {
557 switch (code)
558 {
559 case BFD_RELOC_RVA:
560 return howto_table + R_IMAGEBASE;
561 case BFD_RELOC_32:
562 return howto_table + R_DIR32;
563 case BFD_RELOC_32_PCREL:
564 return howto_table + R_PCRLONG;
565 case BFD_RELOC_16:
566 return howto_table + R_RELWORD;
567 case BFD_RELOC_16_PCREL:
568 return howto_table + R_PCRWORD;
569 case BFD_RELOC_8:
570 return howto_table + R_RELBYTE;
571 case BFD_RELOC_8_PCREL:
572 return howto_table + R_PCRBYTE;
573 #ifdef COFF_WITH_PE
574 case BFD_RELOC_32_SECREL:
575 return howto_table + R_SECREL32;
576 #endif
577 default:
578 BFD_FAIL ();
579 return 0;
580 }
581 }
582
583 static reloc_howto_type *
584 coff_i386_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
585 const char *r_name)
586 {
587 unsigned int i;
588
589 for (i = 0; i < NUM_HOWTOS; i++)
590 if (howto_table[i].name != NULL
591 && strcasecmp (howto_table[i].name, r_name) == 0)
592 return &howto_table[i];
593
594 return NULL;
595 }
596
597 #define coff_rtype_to_howto coff_i386_rtype_to_howto
598
599 #ifdef TARGET_UNDERSCORE
600
601 /* If i386 gcc uses underscores for symbol names, then it does not use
602 a leading dot for local labels, so if TARGET_UNDERSCORE is defined
603 we treat all symbols starting with L as local. */
604
605 static bfd_boolean
606 coff_i386_is_local_label_name (bfd *abfd, const char *name)
607 {
608 if (name[0] == 'L')
609 return TRUE;
610
611 return _bfd_coff_is_local_label_name (abfd, name);
612 }
613
614 #define coff_bfd_is_local_label_name coff_i386_is_local_label_name
615
616 #endif /* TARGET_UNDERSCORE */
617
618 #include "coffcode.h"
619
620 const bfd_target
621 #ifdef TARGET_SYM
622 TARGET_SYM =
623 #else
624 i386_coff_vec =
625 #endif
626 {
627 #ifdef TARGET_NAME
628 TARGET_NAME,
629 #else
630 "coff-i386", /* name */
631 #endif
632 bfd_target_coff_flavour,
633 BFD_ENDIAN_LITTLE, /* data byte order is little */
634 BFD_ENDIAN_LITTLE, /* header byte order is little */
635
636 (HAS_RELOC | EXEC_P | /* object flags */
637 HAS_LINENO | HAS_DEBUG |
638 HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED | BFD_COMPRESS | BFD_DECOMPRESS ),
639
640 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* section flags */
641 #ifdef COFF_WITH_PE
642 | SEC_LINK_ONCE | SEC_LINK_DUPLICATES | SEC_READONLY | SEC_DEBUGGING
643 #endif
644 | SEC_CODE | SEC_DATA | SEC_EXCLUDE ),
645
646 #ifdef TARGET_UNDERSCORE
647 TARGET_UNDERSCORE, /* leading underscore */
648 #else
649 0, /* leading underscore */
650 #endif
651 '/', /* ar_pad_char */
652 15, /* ar_max_namelen */
653 0, /* match priority. */
654
655 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
656 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
657 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
658 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
659 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
660 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
661
662 #ifndef COFF_CHECK_FORMAT
663 #define COFF_CHECK_FORMAT coff_object_p
664 #endif
665 #ifndef COFF_WRITE_CONTENTS
666 #define COFF_WRITE_CONTENTS coff_write_object_contents
667 #endif
668
669 /* Note that we allow an object file to be treated as a core file as well. */
670
671 { /* bfd_check_format */
672 _bfd_dummy_target,
673 COFF_CHECK_FORMAT,
674 bfd_generic_archive_p,
675 COFF_CHECK_FORMAT
676 },
677 { /* bfd_set_format */
678 _bfd_bool_bfd_false_error,
679 coff_mkobject,
680 _bfd_generic_mkarchive,
681 _bfd_bool_bfd_false_error
682 },
683 { /* bfd_write_contents */
684 _bfd_bool_bfd_false_error,
685 COFF_WRITE_CONTENTS,
686 _bfd_write_archive_contents,
687 _bfd_bool_bfd_false_error
688 },
689
690 BFD_JUMP_TABLE_GENERIC (coff),
691 BFD_JUMP_TABLE_COPY (coff),
692 BFD_JUMP_TABLE_CORE (_bfd_nocore),
693 BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
694 BFD_JUMP_TABLE_SYMBOLS (coff),
695 BFD_JUMP_TABLE_RELOCS (coff),
696 BFD_JUMP_TABLE_WRITE (coff),
697 BFD_JUMP_TABLE_LINK (coff),
698 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
699
700 NULL,
701
702 COFF_SWAP_TABLE
703 };
704
705 #ifdef COFF_WITH_PE_BIGOBJ
706 const bfd_target
707 TARGET_SYM_BIG =
708 {
709 TARGET_NAME_BIG,
710 bfd_target_coff_flavour,
711 BFD_ENDIAN_LITTLE, /* data byte order is little */
712 BFD_ENDIAN_LITTLE, /* header byte order is little */
713
714 (HAS_RELOC | EXEC_P | /* object flags */
715 HAS_LINENO | HAS_DEBUG |
716 HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED | BFD_COMPRESS | BFD_DECOMPRESS ),
717
718 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* section flags */
719 #ifdef COFF_WITH_PE
720 | SEC_LINK_ONCE | SEC_LINK_DUPLICATES | SEC_READONLY | SEC_DEBUGGING
721 #endif
722 | SEC_CODE | SEC_DATA | SEC_EXCLUDE ),
723
724 #ifdef TARGET_UNDERSCORE
725 TARGET_UNDERSCORE, /* leading underscore */
726 #else
727 0, /* leading underscore */
728 #endif
729 '/', /* ar_pad_char */
730 15, /* ar_max_namelen */
731 0, /* match priority. */
732
733 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
734 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
735 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
736 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
737 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
738 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
739
740 /* Note that we allow an object file to be treated as a core file as well. */
741
742 { /* bfd_check_format */
743 _bfd_dummy_target,
744 COFF_CHECK_FORMAT,
745 bfd_generic_archive_p,
746 COFF_CHECK_FORMAT
747 },
748 { /* bfd_set_format */
749 _bfd_bool_bfd_false_error,
750 coff_mkobject,
751 _bfd_generic_mkarchive,
752 _bfd_bool_bfd_false_error
753 },
754 { /* bfd_write_contents */
755 _bfd_bool_bfd_false_error,
756 COFF_WRITE_CONTENTS,
757 _bfd_write_archive_contents,
758 _bfd_bool_bfd_false_error
759 },
760
761 BFD_JUMP_TABLE_GENERIC (coff),
762 BFD_JUMP_TABLE_COPY (coff),
763 BFD_JUMP_TABLE_CORE (_bfd_nocore),
764 BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
765 BFD_JUMP_TABLE_SYMBOLS (coff),
766 BFD_JUMP_TABLE_RELOCS (coff),
767 BFD_JUMP_TABLE_WRITE (coff),
768 BFD_JUMP_TABLE_LINK (coff),
769 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
770
771 NULL,
772
773 &bigobj_swap_table
774 };
775 #endif
This page took 0.045177 seconds and 4 git commands to generate.