This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Ping~]Re: [5/5][libgcc] Runtime support for AArch64 return address signing (needs new target macros)
- From: "Richard Earnshaw (lists)" <Richard dot Earnshaw at arm dot com>
- To: Jiong Wang <jiong dot wang at foss dot arm dot com>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Cc: James Greenhalgh <james dot greenhalgh at arm dot com>, Ian Lance Taylor <iant at google dot com>, Joseph Myers <joseph at codesourcery dot com>, Jakub Jelinek <jakub at redhat dot com>
- Date: Thu, 19 Jan 2017 19:02:05 +0000
- Subject: Re: [Ping~]Re: [5/5][libgcc] Runtime support for AArch64 return address signing (needs new target macros)
- Authentication-results: sourceware.org; auth=none
- References: <c9da17a6-c3de-4466-c023-4e4ddbe38efb@foss.arm.com> <4cf21d03-0a88-c6fa-df37-59ec4edf1d89@foss.arm.com> <ac547390-abfc-3d6a-f10b-dbb9e4bad5b2@foss.arm.com> <ae7c1f2a-06e4-55d1-d3be-e43ae7ec76df@foss.arm.com> <60457276-8566-8bef-6073-4b00dd975759@foss.arm.com> <1e3f0dce-74c8-5a80-ed5a-7e6feeec1e63@foss.arm.com> <97fad7f9-cb42-ab1c-f039-ba42d5dc72c8@foss.arm.com> <d0b329fc-d564-3b14-da21-0eb084c6661f@foss.arm.com> <fdda17f4-5594-c983-64ac-158a9ba43e4c@foss.arm.com> <f690322d-1fb1-58dc-ba85-e9820d6aa902@foss.arm.com> <a242b032-db02-244f-eafe-cd36ee608a86@foss.arm.com> <f2c6a806-4c38-834d-8cb2-14f968a1b4b4@foss.arm.com> <fb248360-ec76-ab7d-abe7-977ed7085af0@arm.com> <2298ec38-cd83-9a37-9dbf-14406409d460@foss.arm.com>
On 19/01/17 14:46, Jiong Wang wrote:
> Thanks for the review.
>
> On 19/01/17 14:18, Richard Earnshaw (lists) wrote:
>>
>>>
>>>
>>> diff --git a/libgcc/unwind-dw2.c b/libgcc/unwind-dw2.c
>>> index
>>> 8085a42ace15d53f4cb0c6681717012d906a6d47..cf640135275deb76b820f8209fa51eacfd64c4a2
>>> 100644
>>> --- a/libgcc/unwind-dw2.c
>>> +++ b/libgcc/unwind-dw2.c
>>> @@ -136,6 +136,8 @@ struct _Unwind_Context
>>> #define SIGNAL_FRAME_BIT ((~(_Unwind_Word) 0 >> 1) + 1)
>>> /* Context which has version/args_size/by_value fields. */
>>> #define EXTENDED_CONTEXT_BIT ((~(_Unwind_Word) 0 >> 2) + 1)
>>> + /* Bit reserved on AArch64, return address has been signed with A
>>> key. */
>>> +#define RA_A_SIGNED_BIT ((~(_Unwind_Word) 0 >> 3) + 1)
>>
>> Why is this here? It appears to only be used within the
>> AArch64-specific header file.
>
> I was putting it here so that when we allocate the next general purpose
> bit, we
> know clearly that bit 3 is allocated to AArch64 already, and the new
> general bit
> needs to go to the next one. This can avoid bit collision.
>
Fair enough.
>>
>>> ...
>>>
>>> +/* Frob exception handler's address kept in TARGET before installing
>>> into
>>> + CURRENT context. */
>>> +
>>> +static void *
>>> +uw_frob_return_addr (struct _Unwind_Context *current,
>>> + struct _Unwind_Context *target)
>>> +{
>>> + void *ret_addr = __builtin_frob_return_addr (target->ra);
>>> +#ifdef MD_POST_FROB_EH_HANDLER_ADDR
>>> + ret_addr = MD_POST_FROB_EH_HANDLER_ADDR (current, target, ret_addr);
>>> +#endif
>>> + return ret_addr;
>>> +}
>>> +
>>
>> I think this function should be marked inline. The optimizers would
>> probably inline it anyway, but it seems wrong for us to rely on that.
>
> Thanks, fixed.
>
> Does the updated patch looks OK to you know?
>
> libgcc/
>
> 2017-01-19 Jiong Wang <jiong.wang@arm.com>
>
> * config/aarch64/aarch64-unwind.h: New file.
> (DWARF_REGNUM_AARCH64_RA_STATE): Define.
> (MD_POST_EXTRACT_ROOT_ADDR): Define.
> (MD_POST_EXTRACT_FRAME_ADDR): Define.
> (MD_POST_FROB_EH_HANDLER_ADDR): Define.
> (MD_FROB_UPDATE_CONTEXT): Define.
> (aarch64_post_extract_frame_addr): New function.
> (aarch64_post_frob_eh_handler_addr): New function.
> (aarch64_frob_update_context): New function.
> * config/aarch64/linux-unwind.h: Include aarch64-unwind.h
> * config.host (aarch64*-*-elf, aarch64*-*-rtems*,
> aarch64*-*-freebsd*):
> Initialize md_unwind_header to include aarch64-unwind.h.
> * unwind-dw2.c (struct _Unwind_Context): Define "RA_A_SIGNED_BIT".
> (execute_cfa_program): Multiplex DW_CFA_GNU_window_save for
> __aarch64__.
> (uw_update_context): Honor MD_POST_EXTRACT_FRAME_ADDR.
> (uw_init_context_1): Honor MD_POST_EXTRACT_ROOT_ADDR.
> (uw_frob_return_addr): New function.
> (_Unwind_DebugHook): Use uw_frob_return_addr.
>
OK.
R.