Add translations for various sub-directories
[binutils-gdb.git] / bfd / elfxx-aarch64.h
blob506f4a93c9d7cd7b99d29f2c4a5fbd6b965af232
1 /* AArch64-specific backend routines.
2 Copyright (C) 2009-2025 Free Software Foundation, Inc.
3 Contributed by ARM Ltd.
5 This file is part of BFD, the Binary File Descriptor library.
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.
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.
17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING3. If not,
19 see <http://www.gnu.org/licenses/>. */
21 extern void bfd_elf64_aarch64_init_maps
22 (bfd *);
24 extern void bfd_elf32_aarch64_init_maps
25 (bfd *);
27 /* Types of PLTs based on the level of security. This would be a
28 bit-mask to denote which of the combinations of security features
29 are enabled:
30 - No security feature PLTs
31 - PLTs with BTI instruction
32 - PLTs with PAC instruction
34 typedef enum
36 PLT_NORMAL = 0x0, /* Normal plts. */
37 PLT_BTI = 0x1, /* plts with BTI. */
38 PLT_PAC = 0x2, /* plts with pointer authentication. */
39 PLT_BTI_PAC = PLT_BTI | PLT_PAC
40 } aarch64_plt_type;
42 /* Indicates whether the linker should generate warnings, errors, or nothing
43 when input objects are missing GNU feature property markings and the output
44 has the markings. */
45 typedef enum
47 MARKING_NONE = 0, /* Does not emit any warning/error messages. */
48 MARKING_WARN = 1, /* Emit warning when the input objects are missing GNU
49 feature property markings, and the output has the
50 markings. */
51 MARKING_ERROR = 2, /* Emit error when the input objects are missing GNU
52 feature property markings, and the output has the
53 markings. */
54 MARKING_UNSET = 3, /* The only purpose of this value is to simulate an
55 optional to detect when the value was not initialized
56 from the command line. */
57 } aarch64_feature_marking_report;
59 /* To indicate whether GNU_PROPERTY_AARCH64_FEATURE_1_GCS bit is
60 enabled/disabled on the output when -z gcs linker
61 command line option is passed. */
62 typedef enum
64 GCS_NEVER = 0, /* gcs is disabled on output. */
65 GCS_IMPLICIT = 1, /* gcs is deduced from input object. */
66 GCS_ALWAYS = 2, /* gsc is enabled on output. */
67 } aarch64_gcs_type;
69 /* A structure to encompass all information about software protections coming
70 from BTI, PAC and GCS related command line options. */
71 struct aarch64_protection_opts
73 /* PLT type to use depending on the selected software proctections. */
74 aarch64_plt_type plt_type;
76 /* Report level for BTI issues. */
77 aarch64_feature_marking_report bti_report;
79 /* Look-up mode for GCS property. */
80 aarch64_gcs_type gcs_type;
82 /* Report level for GCS issues. */
83 aarch64_feature_marking_report gcs_report;
85 /* Report level for GCS issues with dynamic inputs. */
86 aarch64_feature_marking_report gcs_report_dynamic;
88 typedef struct aarch64_protection_opts aarch64_protection_opts;
90 struct elf_aarch64_local_symbol;
91 struct elf_aarch64_obj_tdata
93 struct elf_obj_tdata root;
95 /* local symbol descriptors */
96 struct elf_aarch64_local_symbol *locals;
98 /* Zero to warn when linking objects with incompatible enum sizes. */
99 int no_enum_size_warning;
101 /* Zero to warn when linking objects with incompatible wchar_t sizes. */
102 int no_wchar_size_warning;
104 /* All GNU_PROPERTY_AARCH64_FEATURE_1_AND properties. */
105 uint32_t gnu_property_aarch64_feature_1_and;
107 /* Software protections options. */
108 struct aarch64_protection_opts sw_protections;
110 /* Number of reported BTI issues. */
111 int n_bti_issues;
113 /* Number of reported GCS issues for non-dynamic objects. */
114 int n_gcs_issues;
116 /* Number of reported GCS issues for dynamic objects. */
117 int n_gcs_dynamic_issues;
120 #define elf_aarch64_tdata(bfd) \
121 ((struct elf_aarch64_obj_tdata *) (bfd)->tdata.any)
123 /* An enum to define what kind of erratum fixes we should apply. This gives the
124 user a bit more control over the sequences we generate. */
125 typedef enum
127 ERRAT_NONE = (1 << 0), /* No erratum workarounds allowed. */
128 ERRAT_ADR = (1 << 1), /* Erratum workarounds using ADR allowed. */
129 ERRAT_ADRP = (1 << 2), /* Erratum workarounds using ADRP are allowed. */
130 } erratum_84319_opts;
132 extern void bfd_elf64_aarch64_set_options
133 (bfd *, struct bfd_link_info *, int, int, int, int, erratum_84319_opts, int,
134 const aarch64_protection_opts *);
136 extern void bfd_elf32_aarch64_set_options
137 (bfd *, struct bfd_link_info *, int, int, int, int, erratum_84319_opts, int,
138 const aarch64_protection_opts *);
140 /* AArch64 stub generation support for ELF64. Called from the linker. */
141 extern int elf64_aarch64_setup_section_lists
142 (bfd *, struct bfd_link_info *);
143 extern void elf64_aarch64_next_input_section
144 (struct bfd_link_info *, struct bfd_section *);
145 extern bool elf64_aarch64_size_stubs
146 (bfd *, bfd *, struct bfd_link_info *, bfd_signed_vma,
147 struct bfd_section * (*) (const char *, struct bfd_section *),
148 void (*) (void));
149 extern bool elf64_aarch64_build_stubs
150 (struct bfd_link_info *);
151 /* AArch64 stub generation support for ELF32. Called from the linker. */
152 extern int elf32_aarch64_setup_section_lists
153 (bfd *, struct bfd_link_info *);
154 extern void elf32_aarch64_next_input_section
155 (struct bfd_link_info *, struct bfd_section *);
156 extern bool elf32_aarch64_size_stubs
157 (bfd *, bfd *, struct bfd_link_info *, bfd_signed_vma,
158 struct bfd_section * (*) (const char *, struct bfd_section *),
159 void (*) (void));
160 extern bool elf32_aarch64_build_stubs
161 (struct bfd_link_info *);
163 /* AArch64 relative relocation packing support for ELF64. */
164 extern bool elf64_aarch64_size_relative_relocs
165 (struct bfd_link_info *, bool *);
166 extern bool elf64_aarch64_finish_relative_relocs
167 (struct bfd_link_info *);
168 /* AArch64 relative relocation packing support for ELF32. */
169 extern bool elf32_aarch64_size_relative_relocs
170 (struct bfd_link_info *, bool *);
171 extern bool elf32_aarch64_finish_relative_relocs
172 (struct bfd_link_info *);
174 /* Take the PAGE component of an address or offset. */
175 #define PG(x) ((x) & ~ (bfd_vma) 0xfff)
176 #define PG_OFFSET(x) ((x) & (bfd_vma) 0xfff)
178 #define AARCH64_ADR_OP 0x10000000
179 #define AARCH64_ADRP_OP 0x90000000
180 #define AARCH64_ADRP_OP_MASK 0x9F000000
182 extern bfd_signed_vma
183 _bfd_aarch64_sign_extend (bfd_vma, int);
185 extern uint32_t
186 _bfd_aarch64_decode_adrp_imm (uint32_t);
188 extern uint32_t
189 _bfd_aarch64_reencode_adr_imm (uint32_t, uint32_t);
191 extern bfd_reloc_status_type
192 _bfd_aarch64_elf_put_addend (bfd *, bfd_byte *, bfd_reloc_code_real_type,
193 reloc_howto_type *, bfd_signed_vma);
195 extern bfd_vma
196 _bfd_aarch64_elf_resolve_relocation (bfd *, bfd_reloc_code_real_type, bfd_vma,
197 bfd_vma, bfd_vma, bool);
199 extern bool
200 _bfd_aarch64_elf_grok_prstatus (bfd *, Elf_Internal_Note *);
202 extern bool
203 _bfd_aarch64_elf_grok_psinfo (bfd *, Elf_Internal_Note *);
205 extern char *
206 _bfd_aarch64_elf_write_core_note (bfd *, char *, int *, int, ...);
208 #define elf_backend_grok_prstatus _bfd_aarch64_elf_grok_prstatus
209 #define elf_backend_grok_psinfo _bfd_aarch64_elf_grok_psinfo
210 #define elf_backend_write_core_note _bfd_aarch64_elf_write_core_note
212 extern bfd *
213 _bfd_aarch64_elf_link_setup_gnu_properties (struct bfd_link_info *);
215 extern enum elf_property_kind
216 _bfd_aarch64_elf_parse_gnu_properties (bfd *, unsigned int,
217 bfd_byte *, unsigned int);
219 extern bool
220 _bfd_aarch64_elf_merge_gnu_properties (struct bfd_link_info *, bfd *,
221 elf_property *, elf_property *,
222 uint32_t);
224 extern void
225 _bfd_aarch64_elf_check_bti_report (struct bfd_link_info *, bfd *);
227 extern void
228 _bfd_aarch64_elf_check_gcs_report (struct bfd_link_info *, bfd *);
230 extern void
231 _bfd_aarch64_elf_link_fixup_gnu_properties (struct bfd_link_info *,
232 elf_property_list **);
234 #define elf_backend_parse_gnu_properties \
235 _bfd_aarch64_elf_parse_gnu_properties
237 #define elf_backend_fixup_gnu_properties \
238 _bfd_aarch64_elf_link_fixup_gnu_properties