gcc/libgcc/config/aarch64/aarch64-unwind.h

91 lines
2.9 KiB
C
Raw Normal View History

2022-01-03 10:42:10 +01:00
/* Copyright (C) 2017-2022 Free Software Foundation, Inc.
Contributed by ARM Ltd.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#if !defined (AARCH64_UNWIND_H) && !defined (__ILP32__)
#define AARCH64_UNWIND_H
#define DWARF_REGNUM_AARCH64_RA_STATE 34
libgcc: fix the handling of return address mangling [PR94891] Mangling, currently only used on AArch64 for return address signing, is an internal representation that should not be exposed via __builtin_return_address return value, __builtin_eh_return handler argument, _Unwind_DebugHook handler argument. Note that a mangled address might not even fit into a void *, e.g. with AArch64 ilp32 ABI the return address is stored as 64bit, so the mangled return address cannot be accessed via _Unwind_GetPtr. This patch changes the unwinder hooks as follows: MD_POST_EXTRACT_ROOT_ADDR is removed: root address comes from __builtin_return_address which is not mangled. MD_POST_EXTRACT_FRAME_ADDR is renamed to MD_DEMANGLE_RETURN_ADDR, it now operates on _Unwind_Word instead of void *, so the hook should work when return address signing is enabled on AArch64 ilp32. (But for that __builtin_aarch64_autia1716 should be fixed to operate on 64bit input instead of a void *.) MD_POST_FROB_EH_HANDLER_ADDR is removed: it is the responsibility of __builtin_eh_return to do the mangling if necessary. 2020-07-13 Szabolcs Nagy <szabolcs.nagy@arm.com> libgcc/ChangeLog: PR target/94891 * config/aarch64/aarch64-unwind.h (MD_POST_EXTRACT_ROOT_ADDR): Remove. (MD_POST_FROB_EH_HANDLER_ADDR): Remove. (MD_POST_EXTRACT_FRAME_ADDR): Rename to ... (MD_DEMANGLE_RETURN_ADDR): This. (aarch64_post_extract_frame_addr): Rename to ... (aarch64_demangle_return_addr): This. (aarch64_post_frob_eh_handler_addr): Remove. * unwind-dw2.c (uw_update_context): Demangle return address. (uw_frob_return_addr): Remove.
2020-06-04 10:33:35 +02:00
#define MD_DEMANGLE_RETURN_ADDR(context, fs, addr) \
aarch64_demangle_return_addr (context, fs, addr)
#define MD_FROB_UPDATE_CONTEXT(context, fs) \
aarch64_frob_update_context (context, fs)
[PATCH 3/3][GCC][AARCH64] Add support for pointer authentication B key gcc/ 2019-05-29 Sam Tebbs <sam.tebbs@arm.com> * config/aarch64/aarch64-builtins.c (aarch64_builtins): Add AARCH64_PAUTH_BUILTIN_AUTIB1716 and AARCH64_PAUTH_BUILTIN_PACIB1716. * config/aarch64/aarch64-builtins.c (aarch64_init_pauth_hint_builtins): Add autib1716 and pacib1716 initialisation. * config/aarch64/aarch64-builtins.c (aarch64_expand_builtin): Add checks for autib1716 and pacib1716. * config/aarch64/aarch64-protos.h (aarch64_key_type, aarch64_post_cfi_startproc): Define. * config/aarch64/aarch64-protos.h (aarch64_ra_sign_key): Define extern. * config/aarch64/aarch64.c (aarch64_handle_standard_branch_protection, aarch64_handle_pac_ret_protection): Set default sign key to A. * config/aarch64/aarch64.c (aarch64_expand_epilogue, aarch64_expand_prologue): Add check for b-key. * config/aarch64/aarch64.c (aarch64_ra_sign_key, aarch64_post_cfi_startproc, aarch64_handle_pac_ret_b_key): Define. * config/aarch64/aarch64.h (TARGET_ASM_POST_CFI_STARTPROC): Define. * config/aarch64/aarch64.c (aarch64_pac_ret_subtypes): Add "b-key". * config/aarch64/aarch64.md (unspec): Add UNSPEC_AUTIA1716, UNSPEC_AUTIB1716, UNSPEC_AUTIASP, UNSPEC_AUTIBSP, UNSPEC_PACIA1716, UNSPEC_PACIB1716, UNSPEC_PACIASP, UNSPEC_PACIBSP. * config/aarch64/aarch64.md (do_return): Add check for b-key. * config/aarch64/aarch64.md (<pauth_mnem_prefix>sp): Replace pauth_hint_num_a with pauth_hint_num. * config/aarch64/aarch64.md (<pauth_mnem_prefix>1716): Replace pauth_hint_num_a with pauth_hint_num. * config/aarch64/aarch64.opt (msign-return-address=): Deprecate. * config/aarch64/iterators.md (PAUTH_LR_SP): Add UNSPEC_AUTIASP, UNSPEC_AUTIBSP, UNSPEC_PACIASP, UNSPEC_PACIBSP. * config/aarch64/iterators.md (PAUTH_17_16): Add UNSPEC_AUTIA1716, UNSPEC_AUTIB1716, UNSPEC_PACIA1716, UNSPEC_PACIB1716. * config/aarch64/iterators.md (pauth_mnem_prefix): Add UNSPEC_AUTIA1716, UNSPEC_AUTIB1716, UNSPEC_PACIA1716, UNSPEC_PACIB1716, UNSPEC_AUTIASP, UNSPEC_AUTIBSP, UNSPEC_PACIASP, UNSPEC_PACIBSP. * config/aarch64/iterators.md (pauth_hint_num_a): Replace UNSPEC_PACI1716 and UNSPEC_AUTI1716 with UNSPEC_PACIA1716 and UNSPEC_AUTIA1716 respectively. * config/aarch64/iterators.md (pauth_hint_num_a): Rename to pauth_hint_num and add UNSPEC_PACIBSP, UNSPEC_AUTIBSP, UNSPEC_PACIB1716, UNSPEC_AUTIB1716. * doc/invoke.texi (-mbranch-protection): Add b-key type. * config/aarch64/aarch64-bti-insert.c (aarch64_pac_insn_p): Rename UNSPEC_PACISP to UNSPEC_PACIASP and UNSPEC_PACIBSP. gcc/testsuite 2019-05-29 Sam Tebbs <sam.tebbs@arm.com> * gcc.target/aarch64/return_address_sign_b_1.c: New file. * gcc.target/aarch64/return_address_sign_b_2.c: New file. * gcc.target/aarch64/return_address_sign_b_3.c: New file. * gcc.target/aarch64/return_address_sign_b_exception.c: New file. * gcc.target/aarch64/return_address_sign_ab_exception.c: New file. * gcc.target/aarch64/return_address_sign_builtin.c: New file libgcc/ 2019-05-29 Sam Tebbs <sam.tebbs@arm.com> * config/aarch64/aarch64-unwind.h (aarch64_cie_signed_with_b_key): New function. * config/aarch64/aarch64-unwind.h (aarch64_post_extract_frame_addr, aarch64_post_frob_eh_handler_addr): Add check for b-key. * config/aarch64/aarch64-unwind-h (aarch64_post_extract_frame_addr, aarch64_post_frob_eh_handler_addr, aarch64_post_frob_update_context): Rename RA_A_SIGNED_BIT to RA_SIGNED_BIT. * unwind-dw2-fde.c (get_cie_encoding): Add check for 'B' in augmentation string. * unwind-dw2.c (extract_cie_info): Add check for 'B' in augmentation string. (RA_A_SIGNED_BIT): Rename to RA_SIGNED_BIT. From-SVN: r271735
2019-05-29 11:22:17 +02:00
static inline int
aarch64_cie_signed_with_b_key (struct _Unwind_Context *context)
{
const struct dwarf_fde *fde = _Unwind_Find_FDE (context->bases.func,
&context->bases);
if (fde != NULL)
{
const struct dwarf_cie *cie = get_cie (fde);
if (cie != NULL)
{
char *aug_str = cie->augmentation;
return strchr (aug_str, 'B') == NULL ? 0 : 1;
}
}
return 0;
}
libgcc: fix the handling of return address mangling [PR94891] Mangling, currently only used on AArch64 for return address signing, is an internal representation that should not be exposed via __builtin_return_address return value, __builtin_eh_return handler argument, _Unwind_DebugHook handler argument. Note that a mangled address might not even fit into a void *, e.g. with AArch64 ilp32 ABI the return address is stored as 64bit, so the mangled return address cannot be accessed via _Unwind_GetPtr. This patch changes the unwinder hooks as follows: MD_POST_EXTRACT_ROOT_ADDR is removed: root address comes from __builtin_return_address which is not mangled. MD_POST_EXTRACT_FRAME_ADDR is renamed to MD_DEMANGLE_RETURN_ADDR, it now operates on _Unwind_Word instead of void *, so the hook should work when return address signing is enabled on AArch64 ilp32. (But for that __builtin_aarch64_autia1716 should be fixed to operate on 64bit input instead of a void *.) MD_POST_FROB_EH_HANDLER_ADDR is removed: it is the responsibility of __builtin_eh_return to do the mangling if necessary. 2020-07-13 Szabolcs Nagy <szabolcs.nagy@arm.com> libgcc/ChangeLog: PR target/94891 * config/aarch64/aarch64-unwind.h (MD_POST_EXTRACT_ROOT_ADDR): Remove. (MD_POST_FROB_EH_HANDLER_ADDR): Remove. (MD_POST_EXTRACT_FRAME_ADDR): Rename to ... (MD_DEMANGLE_RETURN_ADDR): This. (aarch64_post_extract_frame_addr): Rename to ... (aarch64_demangle_return_addr): This. (aarch64_post_frob_eh_handler_addr): Remove. * unwind-dw2.c (uw_update_context): Demangle return address. (uw_frob_return_addr): Remove.
2020-06-04 10:33:35 +02:00
/* Do AArch64 private extraction on ADDR_WORD based on context info CONTEXT and
unwind frame info FS. If ADDR_WORD is signed, we do address authentication
on it using CFA of current frame. */
static inline void *
libgcc: fix the handling of return address mangling [PR94891] Mangling, currently only used on AArch64 for return address signing, is an internal representation that should not be exposed via __builtin_return_address return value, __builtin_eh_return handler argument, _Unwind_DebugHook handler argument. Note that a mangled address might not even fit into a void *, e.g. with AArch64 ilp32 ABI the return address is stored as 64bit, so the mangled return address cannot be accessed via _Unwind_GetPtr. This patch changes the unwinder hooks as follows: MD_POST_EXTRACT_ROOT_ADDR is removed: root address comes from __builtin_return_address which is not mangled. MD_POST_EXTRACT_FRAME_ADDR is renamed to MD_DEMANGLE_RETURN_ADDR, it now operates on _Unwind_Word instead of void *, so the hook should work when return address signing is enabled on AArch64 ilp32. (But for that __builtin_aarch64_autia1716 should be fixed to operate on 64bit input instead of a void *.) MD_POST_FROB_EH_HANDLER_ADDR is removed: it is the responsibility of __builtin_eh_return to do the mangling if necessary. 2020-07-13 Szabolcs Nagy <szabolcs.nagy@arm.com> libgcc/ChangeLog: PR target/94891 * config/aarch64/aarch64-unwind.h (MD_POST_EXTRACT_ROOT_ADDR): Remove. (MD_POST_FROB_EH_HANDLER_ADDR): Remove. (MD_POST_EXTRACT_FRAME_ADDR): Rename to ... (MD_DEMANGLE_RETURN_ADDR): This. (aarch64_post_extract_frame_addr): Rename to ... (aarch64_demangle_return_addr): This. (aarch64_post_frob_eh_handler_addr): Remove. * unwind-dw2.c (uw_update_context): Demangle return address. (uw_frob_return_addr): Remove.
2020-06-04 10:33:35 +02:00
aarch64_demangle_return_addr (struct _Unwind_Context *context,
_Unwind_FrameState *fs ATTRIBUTE_UNUSED,
_Unwind_Word addr_word)
{
libgcc: fix the handling of return address mangling [PR94891] Mangling, currently only used on AArch64 for return address signing, is an internal representation that should not be exposed via __builtin_return_address return value, __builtin_eh_return handler argument, _Unwind_DebugHook handler argument. Note that a mangled address might not even fit into a void *, e.g. with AArch64 ilp32 ABI the return address is stored as 64bit, so the mangled return address cannot be accessed via _Unwind_GetPtr. This patch changes the unwinder hooks as follows: MD_POST_EXTRACT_ROOT_ADDR is removed: root address comes from __builtin_return_address which is not mangled. MD_POST_EXTRACT_FRAME_ADDR is renamed to MD_DEMANGLE_RETURN_ADDR, it now operates on _Unwind_Word instead of void *, so the hook should work when return address signing is enabled on AArch64 ilp32. (But for that __builtin_aarch64_autia1716 should be fixed to operate on 64bit input instead of a void *.) MD_POST_FROB_EH_HANDLER_ADDR is removed: it is the responsibility of __builtin_eh_return to do the mangling if necessary. 2020-07-13 Szabolcs Nagy <szabolcs.nagy@arm.com> libgcc/ChangeLog: PR target/94891 * config/aarch64/aarch64-unwind.h (MD_POST_EXTRACT_ROOT_ADDR): Remove. (MD_POST_FROB_EH_HANDLER_ADDR): Remove. (MD_POST_EXTRACT_FRAME_ADDR): Rename to ... (MD_DEMANGLE_RETURN_ADDR): This. (aarch64_post_extract_frame_addr): Rename to ... (aarch64_demangle_return_addr): This. (aarch64_post_frob_eh_handler_addr): Remove. * unwind-dw2.c (uw_update_context): Demangle return address. (uw_frob_return_addr): Remove.
2020-06-04 10:33:35 +02:00
void *addr = (void *)addr_word;
[PATCH 3/3][GCC][AARCH64] Add support for pointer authentication B key gcc/ 2019-05-29 Sam Tebbs <sam.tebbs@arm.com> * config/aarch64/aarch64-builtins.c (aarch64_builtins): Add AARCH64_PAUTH_BUILTIN_AUTIB1716 and AARCH64_PAUTH_BUILTIN_PACIB1716. * config/aarch64/aarch64-builtins.c (aarch64_init_pauth_hint_builtins): Add autib1716 and pacib1716 initialisation. * config/aarch64/aarch64-builtins.c (aarch64_expand_builtin): Add checks for autib1716 and pacib1716. * config/aarch64/aarch64-protos.h (aarch64_key_type, aarch64_post_cfi_startproc): Define. * config/aarch64/aarch64-protos.h (aarch64_ra_sign_key): Define extern. * config/aarch64/aarch64.c (aarch64_handle_standard_branch_protection, aarch64_handle_pac_ret_protection): Set default sign key to A. * config/aarch64/aarch64.c (aarch64_expand_epilogue, aarch64_expand_prologue): Add check for b-key. * config/aarch64/aarch64.c (aarch64_ra_sign_key, aarch64_post_cfi_startproc, aarch64_handle_pac_ret_b_key): Define. * config/aarch64/aarch64.h (TARGET_ASM_POST_CFI_STARTPROC): Define. * config/aarch64/aarch64.c (aarch64_pac_ret_subtypes): Add "b-key". * config/aarch64/aarch64.md (unspec): Add UNSPEC_AUTIA1716, UNSPEC_AUTIB1716, UNSPEC_AUTIASP, UNSPEC_AUTIBSP, UNSPEC_PACIA1716, UNSPEC_PACIB1716, UNSPEC_PACIASP, UNSPEC_PACIBSP. * config/aarch64/aarch64.md (do_return): Add check for b-key. * config/aarch64/aarch64.md (<pauth_mnem_prefix>sp): Replace pauth_hint_num_a with pauth_hint_num. * config/aarch64/aarch64.md (<pauth_mnem_prefix>1716): Replace pauth_hint_num_a with pauth_hint_num. * config/aarch64/aarch64.opt (msign-return-address=): Deprecate. * config/aarch64/iterators.md (PAUTH_LR_SP): Add UNSPEC_AUTIASP, UNSPEC_AUTIBSP, UNSPEC_PACIASP, UNSPEC_PACIBSP. * config/aarch64/iterators.md (PAUTH_17_16): Add UNSPEC_AUTIA1716, UNSPEC_AUTIB1716, UNSPEC_PACIA1716, UNSPEC_PACIB1716. * config/aarch64/iterators.md (pauth_mnem_prefix): Add UNSPEC_AUTIA1716, UNSPEC_AUTIB1716, UNSPEC_PACIA1716, UNSPEC_PACIB1716, UNSPEC_AUTIASP, UNSPEC_AUTIBSP, UNSPEC_PACIASP, UNSPEC_PACIBSP. * config/aarch64/iterators.md (pauth_hint_num_a): Replace UNSPEC_PACI1716 and UNSPEC_AUTI1716 with UNSPEC_PACIA1716 and UNSPEC_AUTIA1716 respectively. * config/aarch64/iterators.md (pauth_hint_num_a): Rename to pauth_hint_num and add UNSPEC_PACIBSP, UNSPEC_AUTIBSP, UNSPEC_PACIB1716, UNSPEC_AUTIB1716. * doc/invoke.texi (-mbranch-protection): Add b-key type. * config/aarch64/aarch64-bti-insert.c (aarch64_pac_insn_p): Rename UNSPEC_PACISP to UNSPEC_PACIASP and UNSPEC_PACIBSP. gcc/testsuite 2019-05-29 Sam Tebbs <sam.tebbs@arm.com> * gcc.target/aarch64/return_address_sign_b_1.c: New file. * gcc.target/aarch64/return_address_sign_b_2.c: New file. * gcc.target/aarch64/return_address_sign_b_3.c: New file. * gcc.target/aarch64/return_address_sign_b_exception.c: New file. * gcc.target/aarch64/return_address_sign_ab_exception.c: New file. * gcc.target/aarch64/return_address_sign_builtin.c: New file libgcc/ 2019-05-29 Sam Tebbs <sam.tebbs@arm.com> * config/aarch64/aarch64-unwind.h (aarch64_cie_signed_with_b_key): New function. * config/aarch64/aarch64-unwind.h (aarch64_post_extract_frame_addr, aarch64_post_frob_eh_handler_addr): Add check for b-key. * config/aarch64/aarch64-unwind-h (aarch64_post_extract_frame_addr, aarch64_post_frob_eh_handler_addr, aarch64_post_frob_update_context): Rename RA_A_SIGNED_BIT to RA_SIGNED_BIT. * unwind-dw2-fde.c (get_cie_encoding): Add check for 'B' in augmentation string. * unwind-dw2.c (extract_cie_info): Add check for 'B' in augmentation string. (RA_A_SIGNED_BIT): Rename to RA_SIGNED_BIT. From-SVN: r271735
2019-05-29 11:22:17 +02:00
if (context->flags & RA_SIGNED_BIT)
{
_Unwind_Word salt = (_Unwind_Word) context->cfa;
[PATCH 3/3][GCC][AARCH64] Add support for pointer authentication B key gcc/ 2019-05-29 Sam Tebbs <sam.tebbs@arm.com> * config/aarch64/aarch64-builtins.c (aarch64_builtins): Add AARCH64_PAUTH_BUILTIN_AUTIB1716 and AARCH64_PAUTH_BUILTIN_PACIB1716. * config/aarch64/aarch64-builtins.c (aarch64_init_pauth_hint_builtins): Add autib1716 and pacib1716 initialisation. * config/aarch64/aarch64-builtins.c (aarch64_expand_builtin): Add checks for autib1716 and pacib1716. * config/aarch64/aarch64-protos.h (aarch64_key_type, aarch64_post_cfi_startproc): Define. * config/aarch64/aarch64-protos.h (aarch64_ra_sign_key): Define extern. * config/aarch64/aarch64.c (aarch64_handle_standard_branch_protection, aarch64_handle_pac_ret_protection): Set default sign key to A. * config/aarch64/aarch64.c (aarch64_expand_epilogue, aarch64_expand_prologue): Add check for b-key. * config/aarch64/aarch64.c (aarch64_ra_sign_key, aarch64_post_cfi_startproc, aarch64_handle_pac_ret_b_key): Define. * config/aarch64/aarch64.h (TARGET_ASM_POST_CFI_STARTPROC): Define. * config/aarch64/aarch64.c (aarch64_pac_ret_subtypes): Add "b-key". * config/aarch64/aarch64.md (unspec): Add UNSPEC_AUTIA1716, UNSPEC_AUTIB1716, UNSPEC_AUTIASP, UNSPEC_AUTIBSP, UNSPEC_PACIA1716, UNSPEC_PACIB1716, UNSPEC_PACIASP, UNSPEC_PACIBSP. * config/aarch64/aarch64.md (do_return): Add check for b-key. * config/aarch64/aarch64.md (<pauth_mnem_prefix>sp): Replace pauth_hint_num_a with pauth_hint_num. * config/aarch64/aarch64.md (<pauth_mnem_prefix>1716): Replace pauth_hint_num_a with pauth_hint_num. * config/aarch64/aarch64.opt (msign-return-address=): Deprecate. * config/aarch64/iterators.md (PAUTH_LR_SP): Add UNSPEC_AUTIASP, UNSPEC_AUTIBSP, UNSPEC_PACIASP, UNSPEC_PACIBSP. * config/aarch64/iterators.md (PAUTH_17_16): Add UNSPEC_AUTIA1716, UNSPEC_AUTIB1716, UNSPEC_PACIA1716, UNSPEC_PACIB1716. * config/aarch64/iterators.md (pauth_mnem_prefix): Add UNSPEC_AUTIA1716, UNSPEC_AUTIB1716, UNSPEC_PACIA1716, UNSPEC_PACIB1716, UNSPEC_AUTIASP, UNSPEC_AUTIBSP, UNSPEC_PACIASP, UNSPEC_PACIBSP. * config/aarch64/iterators.md (pauth_hint_num_a): Replace UNSPEC_PACI1716 and UNSPEC_AUTI1716 with UNSPEC_PACIA1716 and UNSPEC_AUTIA1716 respectively. * config/aarch64/iterators.md (pauth_hint_num_a): Rename to pauth_hint_num and add UNSPEC_PACIBSP, UNSPEC_AUTIBSP, UNSPEC_PACIB1716, UNSPEC_AUTIB1716. * doc/invoke.texi (-mbranch-protection): Add b-key type. * config/aarch64/aarch64-bti-insert.c (aarch64_pac_insn_p): Rename UNSPEC_PACISP to UNSPEC_PACIASP and UNSPEC_PACIBSP. gcc/testsuite 2019-05-29 Sam Tebbs <sam.tebbs@arm.com> * gcc.target/aarch64/return_address_sign_b_1.c: New file. * gcc.target/aarch64/return_address_sign_b_2.c: New file. * gcc.target/aarch64/return_address_sign_b_3.c: New file. * gcc.target/aarch64/return_address_sign_b_exception.c: New file. * gcc.target/aarch64/return_address_sign_ab_exception.c: New file. * gcc.target/aarch64/return_address_sign_builtin.c: New file libgcc/ 2019-05-29 Sam Tebbs <sam.tebbs@arm.com> * config/aarch64/aarch64-unwind.h (aarch64_cie_signed_with_b_key): New function. * config/aarch64/aarch64-unwind.h (aarch64_post_extract_frame_addr, aarch64_post_frob_eh_handler_addr): Add check for b-key. * config/aarch64/aarch64-unwind-h (aarch64_post_extract_frame_addr, aarch64_post_frob_eh_handler_addr, aarch64_post_frob_update_context): Rename RA_A_SIGNED_BIT to RA_SIGNED_BIT. * unwind-dw2-fde.c (get_cie_encoding): Add check for 'B' in augmentation string. * unwind-dw2.c (extract_cie_info): Add check for 'B' in augmentation string. (RA_A_SIGNED_BIT): Rename to RA_SIGNED_BIT. From-SVN: r271735
2019-05-29 11:22:17 +02:00
if (aarch64_cie_signed_with_b_key (context) != 0)
return __builtin_aarch64_autib1716 (addr, salt);
return __builtin_aarch64_autia1716 (addr, salt);
}
else
return addr;
}
/* Do AArch64 private initialization on CONTEXT based on frame info FS. Mark
CONTEXT as return address signed if bit 0 of DWARF_REGNUM_AARCH64_RA_STATE is
set. */
static inline void
aarch64_frob_update_context (struct _Unwind_Context *context,
_Unwind_FrameState *fs)
{
if (fs->regs.reg[DWARF_REGNUM_AARCH64_RA_STATE].loc.offset & 0x1)
/* The flag is used for re-authenticating EH handler's address. */
[PATCH 3/3][GCC][AARCH64] Add support for pointer authentication B key gcc/ 2019-05-29 Sam Tebbs <sam.tebbs@arm.com> * config/aarch64/aarch64-builtins.c (aarch64_builtins): Add AARCH64_PAUTH_BUILTIN_AUTIB1716 and AARCH64_PAUTH_BUILTIN_PACIB1716. * config/aarch64/aarch64-builtins.c (aarch64_init_pauth_hint_builtins): Add autib1716 and pacib1716 initialisation. * config/aarch64/aarch64-builtins.c (aarch64_expand_builtin): Add checks for autib1716 and pacib1716. * config/aarch64/aarch64-protos.h (aarch64_key_type, aarch64_post_cfi_startproc): Define. * config/aarch64/aarch64-protos.h (aarch64_ra_sign_key): Define extern. * config/aarch64/aarch64.c (aarch64_handle_standard_branch_protection, aarch64_handle_pac_ret_protection): Set default sign key to A. * config/aarch64/aarch64.c (aarch64_expand_epilogue, aarch64_expand_prologue): Add check for b-key. * config/aarch64/aarch64.c (aarch64_ra_sign_key, aarch64_post_cfi_startproc, aarch64_handle_pac_ret_b_key): Define. * config/aarch64/aarch64.h (TARGET_ASM_POST_CFI_STARTPROC): Define. * config/aarch64/aarch64.c (aarch64_pac_ret_subtypes): Add "b-key". * config/aarch64/aarch64.md (unspec): Add UNSPEC_AUTIA1716, UNSPEC_AUTIB1716, UNSPEC_AUTIASP, UNSPEC_AUTIBSP, UNSPEC_PACIA1716, UNSPEC_PACIB1716, UNSPEC_PACIASP, UNSPEC_PACIBSP. * config/aarch64/aarch64.md (do_return): Add check for b-key. * config/aarch64/aarch64.md (<pauth_mnem_prefix>sp): Replace pauth_hint_num_a with pauth_hint_num. * config/aarch64/aarch64.md (<pauth_mnem_prefix>1716): Replace pauth_hint_num_a with pauth_hint_num. * config/aarch64/aarch64.opt (msign-return-address=): Deprecate. * config/aarch64/iterators.md (PAUTH_LR_SP): Add UNSPEC_AUTIASP, UNSPEC_AUTIBSP, UNSPEC_PACIASP, UNSPEC_PACIBSP. * config/aarch64/iterators.md (PAUTH_17_16): Add UNSPEC_AUTIA1716, UNSPEC_AUTIB1716, UNSPEC_PACIA1716, UNSPEC_PACIB1716. * config/aarch64/iterators.md (pauth_mnem_prefix): Add UNSPEC_AUTIA1716, UNSPEC_AUTIB1716, UNSPEC_PACIA1716, UNSPEC_PACIB1716, UNSPEC_AUTIASP, UNSPEC_AUTIBSP, UNSPEC_PACIASP, UNSPEC_PACIBSP. * config/aarch64/iterators.md (pauth_hint_num_a): Replace UNSPEC_PACI1716 and UNSPEC_AUTI1716 with UNSPEC_PACIA1716 and UNSPEC_AUTIA1716 respectively. * config/aarch64/iterators.md (pauth_hint_num_a): Rename to pauth_hint_num and add UNSPEC_PACIBSP, UNSPEC_AUTIBSP, UNSPEC_PACIB1716, UNSPEC_AUTIB1716. * doc/invoke.texi (-mbranch-protection): Add b-key type. * config/aarch64/aarch64-bti-insert.c (aarch64_pac_insn_p): Rename UNSPEC_PACISP to UNSPEC_PACIASP and UNSPEC_PACIBSP. gcc/testsuite 2019-05-29 Sam Tebbs <sam.tebbs@arm.com> * gcc.target/aarch64/return_address_sign_b_1.c: New file. * gcc.target/aarch64/return_address_sign_b_2.c: New file. * gcc.target/aarch64/return_address_sign_b_3.c: New file. * gcc.target/aarch64/return_address_sign_b_exception.c: New file. * gcc.target/aarch64/return_address_sign_ab_exception.c: New file. * gcc.target/aarch64/return_address_sign_builtin.c: New file libgcc/ 2019-05-29 Sam Tebbs <sam.tebbs@arm.com> * config/aarch64/aarch64-unwind.h (aarch64_cie_signed_with_b_key): New function. * config/aarch64/aarch64-unwind.h (aarch64_post_extract_frame_addr, aarch64_post_frob_eh_handler_addr): Add check for b-key. * config/aarch64/aarch64-unwind-h (aarch64_post_extract_frame_addr, aarch64_post_frob_eh_handler_addr, aarch64_post_frob_update_context): Rename RA_A_SIGNED_BIT to RA_SIGNED_BIT. * unwind-dw2-fde.c (get_cie_encoding): Add check for 'B' in augmentation string. * unwind-dw2.c (extract_cie_info): Add check for 'B' in augmentation string. (RA_A_SIGNED_BIT): Rename to RA_SIGNED_BIT. From-SVN: r271735
2019-05-29 11:22:17 +02:00
context->flags |= RA_SIGNED_BIT;
else
context->flags &= ~RA_SIGNED_BIT;
return;
}
#endif /* defined AARCH64_UNWIND_H && defined __ILP32__ */