修訂 | 09038062534606ef9100b5474d136f7d2e543de4 (tree) |
---|---|
時間 | 2018-12-14 01:37:40 |
作者 | Sam Tebbs <sam.tebbs@arm....> |
Commiter | Thomas Preud'homme |
Move aarch64 CIE code to aarch64 backend
This commit moves all aarch64-specific code to deal with CIE structure
introduced in 3a67e1a6b4430374f3073e51bb19347d4c421cfe from
target-independent files to the aarch64 backend.
2018-12-13 Sam Tebbs <sam.tebbs@arm.com>
binutils/
* dwarf.c (read_cie): Add check for 'B'.
gas/
* config/tc-aarch64.h (enum pointer_auth_key,
tc_fde_entry_extras, tc_cie_entry_extras, tc_fde_entry_init_extra,
tc_output_cie_extra, tc_cie_fde_equivalent_extra,
tc_cie_entry_init_extra): Define.
* dw2gencfi.c (struct cie_entry): Add tc_cie_entry_extras invocation.
(alloc_fde_entry, select_cie_for_fde): Add tc_fde_entry_init_extra
invocation.
(output_cie): Add tc_output_cie_extra invocation.
(select_cie_for_fde): Add tc_cie_fde_equivalent_extra invocation.
* dw2gencfi.h (enum pointer_auth_key): Move to config/tc-aarch64.h.
(struct fde_entry): Add tc_fde_entry_extras invocation
@@ -1,3 +1,7 @@ | ||
1 | +2018-12-13 Sam Tebbs <sam.tebbs@arm.com> | |
2 | + | |
3 | + * dwarf.c (read_cie): Add check for 'B'. | |
4 | + | |
1 | 5 | 2018-12-11 Nick Clifton <nickc@redhat.com> |
2 | 6 | |
3 | 7 | * NEWS: Note that recursion limit has increased to 2048. |
@@ -7401,6 +7401,8 @@ read_cie (unsigned char *start, unsigned char *end, | ||
7401 | 7401 | fc->fde_encoding = *q++; |
7402 | 7402 | else if (*p == 'S') |
7403 | 7403 | ; |
7404 | + else if (*p == 'B') | |
7405 | + ; | |
7404 | 7406 | else |
7405 | 7407 | break; |
7406 | 7408 | p++; |
@@ -1,3 +1,17 @@ | ||
1 | +2018-12-13 Sam Tebbs <sam.tebbs@arm.com> | |
2 | + | |
3 | + * config/tc-aarch64.h (enum pointer_auth_key, | |
4 | + tc_fde_entry_extras, tc_cie_entry_extras, tc_fde_entry_init_extra, | |
5 | + tc_output_cie_extra, tc_cie_fde_equivalent_extra, | |
6 | + tc_cie_entry_init_extra): Define. | |
7 | + * dw2gencfi.c (struct cie_entry): Add tc_cie_entry_extras invocation. | |
8 | + (alloc_fde_entry, select_cie_for_fde): Add tc_fde_entry_init_extra | |
9 | + invocation. | |
10 | + (output_cie): Add tc_output_cie_extra invocation. | |
11 | + (select_cie_for_fde): Add tc_cie_fde_equivalent_extra invocation. | |
12 | + * dw2gencfi.h (enum pointer_auth_key): Move to config/tc-aarch64.h. | |
13 | + (struct fde_entry): Add tc_fde_entry_extras invocation | |
14 | + | |
1 | 15 | 2018-12-12 Andre Vieira <andre.simoesdiasvieira@arm.com> |
2 | 16 | |
3 | 17 | * testsuite/gas/arm/blx-local-thumb.d: Skip arm-nto and |
@@ -80,6 +80,43 @@ struct aarch64_fix | ||
80 | 80 | |
81 | 81 | #define tc_frob_section(S) aarch64_frob_section (S) |
82 | 82 | |
83 | +/* The key used to sign a function's return address. */ | |
84 | +enum pointer_auth_key { | |
85 | + AARCH64_PAUTH_KEY_A, | |
86 | + AARCH64_PAUTH_KEY_B | |
87 | +}; | |
88 | + | |
89 | +/* The extra fields required by AArch64 in fde_entry and cie_entry. Currently | |
90 | + only used to store the key used to sign the frame's return address. */ | |
91 | +#define tc_fde_entry_extras enum pointer_auth_key pauth_key; | |
92 | +#define tc_cie_entry_extras enum pointer_auth_key pauth_key; | |
93 | + | |
94 | +/* The extra initialisation steps needed by AArch64 in alloc_fde_entry. | |
95 | + Currently only used to initialise the key used to sign the return | |
96 | + address. */ | |
97 | +#define tc_fde_entry_init_extra(fde) fde->pauth_key = AARCH64_PAUTH_KEY_A; | |
98 | + | |
99 | +/* Extra checks required by AArch64 when outputting the current cie_entry. | |
100 | + Currently only used to output a 'B' if the return address is signed with the | |
101 | + B key. */ | |
102 | +#define tc_output_cie_extra(cie) \ | |
103 | + do \ | |
104 | + { \ | |
105 | + if (cie->pauth_key == AARCH64_PAUTH_KEY_B) \ | |
106 | + out_one ('B'); \ | |
107 | + } \ | |
108 | + while (0) | |
109 | + | |
110 | +/* Extra equivalence checks required by AArch64 when selecting the correct cie | |
111 | + for some fde. Currently only used to check for quivalence between keys used | |
112 | + to sign ther return address. */ | |
113 | +#define tc_cie_fde_equivalent_extra(cie, fde) (cie->pauth_key == fde->pauth_key) | |
114 | + | |
115 | +/* The extra initialisation steps needed by AArch64 in select_cie_for_fde. | |
116 | + Currently only used to initialise the key used to sign the return | |
117 | + address. */ | |
118 | +#define tc_cie_entry_init_extra(cie, fde) cie->pauth_key = fde->pauth_key; | |
119 | + | |
83 | 120 | #define TC_FIX_TYPE struct aarch64_fix |
84 | 121 | #define TC_INIT_FIX_DATA(FIX) { (FIX)->tc_fix_data.inst = NULL; \ |
85 | 122 | (FIX)->tc_fix_data.opnd = AARCH64_OPND_NIL; } |
@@ -403,7 +403,9 @@ struct cie_entry | ||
403 | 403 | unsigned char per_encoding; |
404 | 404 | unsigned char lsda_encoding; |
405 | 405 | expressionS personality; |
406 | - enum pointer_auth_key pauth_key; | |
406 | +#ifdef tc_cie_entry_extras | |
407 | + tc_cie_entry_extras | |
408 | +#endif | |
407 | 409 | struct cfi_insn_data *first, *last; |
408 | 410 | }; |
409 | 411 |
@@ -433,7 +435,9 @@ alloc_fde_entry (void) | ||
433 | 435 | fde->per_encoding = DW_EH_PE_omit; |
434 | 436 | fde->lsda_encoding = DW_EH_PE_omit; |
435 | 437 | fde->eh_header_type = EH_COMPACT_UNKNOWN; |
436 | - fde->pauth_key = AARCH64_PAUTH_KEY_A; | |
438 | +#ifdef tc_fde_entry_init_extra | |
439 | + tc_fde_entry_init_extra (fde) | |
440 | +#endif | |
437 | 441 | |
438 | 442 | return fde; |
439 | 443 | } |
@@ -1858,8 +1862,9 @@ output_cie (struct cie_entry *cie, bfd_boolean eh_frame, int align) | ||
1858 | 1862 | if (cie->lsda_encoding != DW_EH_PE_omit) |
1859 | 1863 | out_one ('L'); |
1860 | 1864 | out_one ('R'); |
1861 | - if (cie->pauth_key == AARCH64_PAUTH_KEY_B) | |
1862 | - out_one ('B'); | |
1865 | +#ifdef tc_output_cie_extra | |
1866 | + tc_output_cie_extra (cie) | |
1867 | +#endif | |
1863 | 1868 | } |
1864 | 1869 | if (cie->signal_frame) |
1865 | 1870 | out_one ('S'); |
@@ -2039,8 +2044,11 @@ select_cie_for_fde (struct fde_entry *fde, bfd_boolean eh_frame, | ||
2039 | 2044 | { |
2040 | 2045 | if (CUR_SEG (cie) != CUR_SEG (fde)) |
2041 | 2046 | continue; |
2047 | +#ifdef tc_cie_fde_equivalent_extra | |
2048 | + if (!tc_cie_fde_equivalent_extra (cie, fde)) | |
2049 | + continue; | |
2050 | +#endif | |
2042 | 2051 | if (cie->return_column != fde->return_column |
2043 | - || cie->pauth_key != fde->pauth_key | |
2044 | 2052 | || cie->signal_frame != fde->signal_frame |
2045 | 2053 | || cie->per_encoding != fde->per_encoding |
2046 | 2054 | || cie->lsda_encoding != fde->lsda_encoding) |
@@ -2147,7 +2155,9 @@ select_cie_for_fde (struct fde_entry *fde, bfd_boolean eh_frame, | ||
2147 | 2155 | cie->lsda_encoding = fde->lsda_encoding; |
2148 | 2156 | cie->personality = fde->personality; |
2149 | 2157 | cie->first = fde->data; |
2150 | - cie->pauth_key = fde->pauth_key; | |
2158 | +#ifdef tc_cie_entry_init_extra | |
2159 | + tc_cie_entry_init_extra (cie, fde) | |
2160 | +#endif | |
2151 | 2161 | |
2152 | 2162 | for (i = cie->first; i ; i = i->next) |
2153 | 2163 | if (i->insn == DW_CFA_advance_loc |
@@ -135,11 +135,6 @@ enum { | ||
135 | 135 | EH_COMPACT_HAS_LSDA |
136 | 136 | }; |
137 | 137 | |
138 | -enum pointer_auth_key { | |
139 | - AARCH64_PAUTH_KEY_A, | |
140 | - AARCH64_PAUTH_KEY_B | |
141 | -}; | |
142 | - | |
143 | 138 | /* Stack of old CFI data, for save/restore. */ |
144 | 139 | struct cfa_save_data |
145 | 140 | { |
@@ -183,8 +178,9 @@ struct fde_entry | ||
183 | 178 | /* For out of line tables and FDEs. */ |
184 | 179 | symbolS *eh_loc; |
185 | 180 | int sections; |
186 | - /* The pointer authentication key used. Only used for AArch64. */ | |
187 | - enum pointer_auth_key pauth_key; | |
181 | +#ifdef tc_fde_entry_extras | |
182 | + tc_fde_entry_extras | |
183 | +#endif | |
188 | 184 | }; |
189 | 185 | |
190 | 186 | /* The list of all FDEs that have been collected. */ |