pe-x86_64.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /* BFD back-end for Intel/AMD x86_64 PECOFF files.
  2. Copyright (C) 2006-2015 Free Software Foundation, Inc.
  3. This file is part of BFD, the Binary File Descriptor library.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  15. MA 02110-1301, USA.
  16. Written by Kai Tietz, OneVision Software GmbH&CoKg. */
  17. #include "sysdep.h"
  18. #include "bfd.h"
  19. #define TARGET_SYM x86_64_pe_vec
  20. #define TARGET_NAME "pe-x86-64"
  21. #define COFF_WITH_PE
  22. #define COFF_WITH_pex64
  23. #define COFF_WITH_PE_BIGOBJ
  24. #define PCRELOFFSET TRUE
  25. #if defined (USE_MINGW64_LEADING_UNDERSCORES)
  26. #define TARGET_UNDERSCORE '_'
  27. #else
  28. #define TARGET_UNDERSCORE 0
  29. #endif
  30. #define COFF_LONG_SECTION_NAMES
  31. #define COFF_SUPPORT_GNU_LINKONCE
  32. #define COFF_LONG_FILENAMES
  33. #define COFF_SECTION_ALIGNMENT_ENTRIES \
  34. { COFF_SECTION_NAME_EXACT_MATCH (".bss"), \
  35. COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \
  36. { COFF_SECTION_NAME_PARTIAL_MATCH (".data"), \
  37. COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \
  38. { COFF_SECTION_NAME_PARTIAL_MATCH (".rdata"), \
  39. COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \
  40. { COFF_SECTION_NAME_PARTIAL_MATCH (".text"), \
  41. COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \
  42. { COFF_SECTION_NAME_PARTIAL_MATCH (".idata"), \
  43. COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
  44. { COFF_SECTION_NAME_EXACT_MATCH (".pdata"), \
  45. COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
  46. { COFF_SECTION_NAME_PARTIAL_MATCH (".debug"), \
  47. COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, \
  48. { COFF_SECTION_NAME_PARTIAL_MATCH (".zdebug"), \
  49. COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, \
  50. { COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi."), \
  51. COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }
  52. /* The function pex64_bfd_print_pdata is implemented in pei-x86_64.c
  53. source, but has be extended to also handle pe objects. */
  54. extern bfd_boolean pex64_bfd_print_pdata (bfd *, void *);
  55. #define bfd_pe_print_pdata pex64_bfd_print_pdata
  56. #include "coff-x86_64.c"
  57. /* Entry for big object files. */
  58. const bfd_target
  59. x86_64_pe_be_vec =
  60. {
  61. "pe-bigobj-x86-64", /* Name. */
  62. bfd_target_coff_flavour,
  63. BFD_ENDIAN_LITTLE, /* Data byte order is little. */
  64. BFD_ENDIAN_LITTLE, /* Header byte order is little. */
  65. (HAS_RELOC | EXEC_P | /* Object flags. */
  66. HAS_LINENO | HAS_DEBUG |
  67. HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED | BFD_COMPRESS | BFD_DECOMPRESS),
  68. (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* Section flags. */
  69. | SEC_LINK_ONCE | SEC_LINK_DUPLICATES | SEC_READONLY | SEC_DEBUGGING
  70. | SEC_CODE | SEC_DATA | SEC_EXCLUDE ),
  71. TARGET_UNDERSCORE, /* Leading underscore. */
  72. '/', /* Ar_pad_char. */
  73. 15, /* Ar_max_namelen. */
  74. 0, /* match priority. */
  75. bfd_getl64, bfd_getl_signed_64, bfd_putl64,
  76. bfd_getl32, bfd_getl_signed_32, bfd_putl32,
  77. bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Data. */
  78. bfd_getl64, bfd_getl_signed_64, bfd_putl64,
  79. bfd_getl32, bfd_getl_signed_32, bfd_putl32,
  80. bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Hdrs. */
  81. /* Note that we allow an object file to be treated as a core file as well. */
  82. { _bfd_dummy_target, amd64coff_object_p, /* BFD_check_format. */
  83. bfd_generic_archive_p, amd64coff_object_p },
  84. { bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format. */
  85. bfd_false },
  86. { bfd_false, coff_write_object_contents, /* bfd_write_contents. */
  87. _bfd_write_archive_contents, bfd_false },
  88. BFD_JUMP_TABLE_GENERIC (coff),
  89. BFD_JUMP_TABLE_COPY (coff),
  90. BFD_JUMP_TABLE_CORE (_bfd_nocore),
  91. BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
  92. BFD_JUMP_TABLE_SYMBOLS (coff),
  93. BFD_JUMP_TABLE_RELOCS (coff),
  94. BFD_JUMP_TABLE_WRITE (coff),
  95. BFD_JUMP_TABLE_LINK (coff),
  96. BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
  97. NULL,
  98. &bigobj_swap_table
  99. };