elfxx-aarch64.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /* AArch64-specific backend routines.
  2. Copyright (C) 2009-2022 Free Software Foundation, Inc.
  3. Contributed by ARM Ltd.
  4. This file is part of BFD, the Binary File Descriptor library.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; see the file COPYING3. If not,
  15. see <http://www.gnu.org/licenses/>. */
  16. extern void bfd_elf64_aarch64_init_maps
  17. (bfd *);
  18. extern void bfd_elf32_aarch64_init_maps
  19. (bfd *);
  20. /* Types of PLTs based on the level of security. This would be a
  21. bit-mask to denote which of the combinations of security features
  22. are enabled:
  23. - No security feature PLTs
  24. - PLTs with BTI instruction
  25. - PLTs with PAC instruction
  26. */
  27. typedef enum
  28. {
  29. PLT_NORMAL = 0x0, /* Normal plts. */
  30. PLT_BTI = 0x1, /* plts with bti. */
  31. PLT_PAC = 0x2, /* plts with pointer authentication. */
  32. PLT_BTI_PAC = PLT_BTI | PLT_PAC
  33. } aarch64_plt_type;
  34. /* To indicate if BTI is enabled with/without warning. */
  35. typedef enum
  36. {
  37. BTI_NONE = 0, /* BTI is not enabled. */
  38. BTI_WARN = 1, /* BTI is enabled with -z force-bti. */
  39. } aarch64_enable_bti_type;
  40. /* A structure to encompass all information coming from BTI or PAC
  41. related command line options. This involves the "PLT_TYPE" to determine
  42. which version of PLTs to pick and "BTI_TYPE" to determine if
  43. BTI should be turned on with any warnings. */
  44. typedef struct
  45. {
  46. aarch64_plt_type plt_type;
  47. aarch64_enable_bti_type bti_type;
  48. } aarch64_bti_pac_info;
  49. /* An enum to define what kind of erratum fixes we should apply. This gives the
  50. user a bit more control over the sequences we generate. */
  51. typedef enum
  52. {
  53. ERRAT_NONE = (1 << 0), /* No erratum workarounds allowed. */
  54. ERRAT_ADR = (1 << 1), /* Erratum workarounds using ADR allowed. */
  55. ERRAT_ADRP = (1 << 2), /* Erratum workarounds using ADRP are allowed. */
  56. } erratum_84319_opts;
  57. extern void bfd_elf64_aarch64_set_options
  58. (bfd *, struct bfd_link_info *, int, int, int, int, erratum_84319_opts, int,
  59. aarch64_bti_pac_info);
  60. extern void bfd_elf32_aarch64_set_options
  61. (bfd *, struct bfd_link_info *, int, int, int, int, erratum_84319_opts, int,
  62. aarch64_bti_pac_info);
  63. /* AArch64 stub generation support for ELF64. Called from the linker. */
  64. extern int elf64_aarch64_setup_section_lists
  65. (bfd *, struct bfd_link_info *);
  66. extern void elf64_aarch64_next_input_section
  67. (struct bfd_link_info *, struct bfd_section *);
  68. extern bool elf64_aarch64_size_stubs
  69. (bfd *, bfd *, struct bfd_link_info *, bfd_signed_vma,
  70. struct bfd_section * (*) (const char *, struct bfd_section *),
  71. void (*) (void));
  72. extern bool elf64_aarch64_build_stubs
  73. (struct bfd_link_info *);
  74. /* AArch64 stub generation support for ELF32. Called from the linker. */
  75. extern int elf32_aarch64_setup_section_lists
  76. (bfd *, struct bfd_link_info *);
  77. extern void elf32_aarch64_next_input_section
  78. (struct bfd_link_info *, struct bfd_section *);
  79. extern bool elf32_aarch64_size_stubs
  80. (bfd *, bfd *, struct bfd_link_info *, bfd_signed_vma,
  81. struct bfd_section * (*) (const char *, struct bfd_section *),
  82. void (*) (void));
  83. extern bool elf32_aarch64_build_stubs
  84. (struct bfd_link_info *);
  85. /* Take the PAGE component of an address or offset. */
  86. #define PG(x) ((x) & ~ (bfd_vma) 0xfff)
  87. #define PG_OFFSET(x) ((x) & (bfd_vma) 0xfff)
  88. #define AARCH64_ADR_OP 0x10000000
  89. #define AARCH64_ADRP_OP 0x90000000
  90. #define AARCH64_ADRP_OP_MASK 0x9F000000
  91. extern bfd_signed_vma
  92. _bfd_aarch64_sign_extend (bfd_vma, int);
  93. extern uint32_t
  94. _bfd_aarch64_decode_adrp_imm (uint32_t);
  95. extern uint32_t
  96. _bfd_aarch64_reencode_adr_imm (uint32_t, uint32_t);
  97. extern bfd_reloc_status_type
  98. _bfd_aarch64_elf_put_addend (bfd *, bfd_byte *, bfd_reloc_code_real_type,
  99. reloc_howto_type *, bfd_signed_vma);
  100. extern bfd_vma
  101. _bfd_aarch64_elf_resolve_relocation (bfd *, bfd_reloc_code_real_type, bfd_vma,
  102. bfd_vma, bfd_vma, bool);
  103. extern bool
  104. _bfd_aarch64_elf_grok_prstatus (bfd *, Elf_Internal_Note *);
  105. extern bool
  106. _bfd_aarch64_elf_grok_psinfo (bfd *, Elf_Internal_Note *);
  107. extern char *
  108. _bfd_aarch64_elf_write_core_note (bfd *, char *, int *, int, ...);
  109. #define elf_backend_grok_prstatus _bfd_aarch64_elf_grok_prstatus
  110. #define elf_backend_grok_psinfo _bfd_aarch64_elf_grok_psinfo
  111. #define elf_backend_write_core_note _bfd_aarch64_elf_write_core_note
  112. extern bfd *
  113. _bfd_aarch64_elf_link_setup_gnu_properties (struct bfd_link_info *,
  114. uint32_t *);
  115. extern enum elf_property_kind
  116. _bfd_aarch64_elf_parse_gnu_properties (bfd *, unsigned int,
  117. bfd_byte *, unsigned int);
  118. extern bool
  119. _bfd_aarch64_elf_merge_gnu_properties (struct bfd_link_info *, bfd *,
  120. elf_property *, elf_property *,
  121. uint32_t);
  122. extern void
  123. _bfd_aarch64_elf_link_fixup_gnu_properties (struct bfd_link_info *,
  124. elf_property_list **);
  125. #define elf_backend_parse_gnu_properties \
  126. _bfd_aarch64_elf_parse_gnu_properties
  127. #define elf_backend_fixup_gnu_properties \
  128. _bfd_aarch64_elf_link_fixup_gnu_properties