coff-aarch64.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /* BFD back-end for AArch64 COFF files.
  2. Copyright (C) 2021-2022 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. #ifndef COFF_WITH_peAArch64
  17. #define COFF_WITH_peAArch64
  18. #endif
  19. /* Note we have to make sure not to include headers twice.
  20. Not all headers are wrapped in #ifdef guards, so we define
  21. PEI_HEADERS to prevent double including here. */
  22. #ifndef PEI_HEADERS
  23. #include "sysdep.h"
  24. #include "bfd.h"
  25. #include "libbfd.h"
  26. #include "coff/aarch64.h"
  27. #include "coff/internal.h"
  28. #include "coff/pe.h"
  29. #include "libcoff.h"
  30. #include "libiberty.h"
  31. #endif
  32. #include "libcoff.h"
  33. /* The page size is a guess based on ELF. */
  34. #define COFF_PAGE_SIZE 0x1000
  35. /* All users of this file have bfd_octets_per_byte (abfd, sec) == 1. */
  36. #define OCTETS_PER_BYTE(ABFD, SEC) 1
  37. #ifndef PCRELOFFSET
  38. #define PCRELOFFSET true
  39. #endif
  40. /* Currently we don't handle any relocations. */
  41. static reloc_howto_type pe_aarch64_std_reloc_howto[] =
  42. {
  43. };
  44. #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER 2
  45. #define COFF_PAGE_SIZE 0x1000
  46. #ifndef NUM_ELEM
  47. #define NUM_ELEM(a) ((sizeof (a)) / sizeof ((a)[0]))
  48. #endif
  49. #define NUM_RELOCS NUM_ELEM (pe_aarch64_std_reloc_howto)
  50. #define RTYPE2HOWTO(cache_ptr, dst) \
  51. (cache_ptr)->howto = NULL
  52. #ifndef bfd_pe_print_pdata
  53. #define bfd_pe_print_pdata NULL
  54. #endif
  55. /* Return TRUE if this relocation should
  56. appear in the output .reloc section. */
  57. static bool
  58. in_reloc_p (bfd * abfd ATTRIBUTE_UNUSED,
  59. reloc_howto_type * howto)
  60. {
  61. return !howto->pc_relative;
  62. }
  63. #include "coffcode.h"
  64. /* Target vectors. */
  65. const bfd_target
  66. #ifdef TARGET_SYM
  67. TARGET_SYM =
  68. #else
  69. aarch64_pei_vec =
  70. #endif
  71. {
  72. #ifdef TARGET_NAME
  73. TARGET_NAME,
  74. #else
  75. "pei-aarch64-little", /* Name. */
  76. #endif
  77. bfd_target_coff_flavour,
  78. BFD_ENDIAN_LITTLE, /* Data byte order is little. */
  79. BFD_ENDIAN_LITTLE, /* Header byte order is little. */
  80. (HAS_RELOC | EXEC_P /* Object flags. */
  81. | HAS_LINENO | HAS_DEBUG
  82. | HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED | BFD_COMPRESS | BFD_DECOMPRESS),
  83. (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* Section flags. */
  84. #if defined(COFF_WITH_PE)
  85. | SEC_LINK_ONCE | SEC_LINK_DUPLICATES | SEC_READONLY | SEC_DEBUGGING
  86. #endif
  87. | SEC_CODE | SEC_DATA | SEC_EXCLUDE ),
  88. #ifdef TARGET_UNDERSCORE
  89. TARGET_UNDERSCORE, /* Leading underscore. */
  90. #else
  91. 0, /* Leading underscore. */
  92. #endif
  93. '/', /* Ar_pad_char. */
  94. 15, /* Ar_max_namelen. */
  95. 0, /* match priority. */
  96. TARGET_KEEP_UNUSED_SECTION_SYMBOLS, /* keep unused section symbols. */
  97. /* Data conversion functions. */
  98. bfd_getl64, bfd_getl_signed_64, bfd_putl64,
  99. bfd_getl32, bfd_getl_signed_32, bfd_putl32,
  100. bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Data. */
  101. /* Header conversion functions. */
  102. bfd_getl64, bfd_getl_signed_64, bfd_putl64,
  103. bfd_getl32, bfd_getl_signed_32, bfd_putl32,
  104. bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Hdrs. */
  105. /* Note that we allow an object file to be treated as a core file as well. */
  106. { /* bfd_check_format. */
  107. _bfd_dummy_target,
  108. coff_object_p,
  109. bfd_generic_archive_p,
  110. coff_object_p
  111. },
  112. { /* bfd_set_format. */
  113. _bfd_bool_bfd_false_error,
  114. coff_mkobject,
  115. _bfd_generic_mkarchive,
  116. _bfd_bool_bfd_false_error
  117. },
  118. { /* bfd_write_contents. */
  119. _bfd_bool_bfd_false_error,
  120. coff_write_object_contents,
  121. _bfd_write_archive_contents,
  122. _bfd_bool_bfd_false_error
  123. },
  124. BFD_JUMP_TABLE_GENERIC (coff),
  125. BFD_JUMP_TABLE_COPY (coff),
  126. BFD_JUMP_TABLE_CORE (_bfd_nocore),
  127. BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
  128. BFD_JUMP_TABLE_SYMBOLS (coff),
  129. BFD_JUMP_TABLE_RELOCS (coff),
  130. BFD_JUMP_TABLE_WRITE (coff),
  131. BFD_JUMP_TABLE_LINK (coff),
  132. BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
  133. NULL,
  134. COFF_SWAP_TABLE
  135. };