This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [2/5][AArch64] Generate dwarf information for -msign-return-address
- 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>
- Date: Fri, 13 Jan 2017 16:09:00 +0000
- Subject: Re: [2/5][AArch64] Generate dwarf information for -msign-return-address
- 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> <2718d6de-4571-694b-3eeb-90b7b839a867@foss.arm.com> <4df3fc1f-bf5c-b5a5-d372-0b41fb377700@foss.arm.com>
On 06/01/17 11:47, Jiong Wang wrote:
> On 11/11/16 18:22, Jiong Wang wrote:
>> This patch generate DWARF description for pointer authentication.
>> DWARF value
>> expression is used to describe the authentication action.
>>
>> Please see the cover letter and AArch64 DWARF specification for the
>> semantics
>> of AArch64 DWARF operations.
>>
>> When authentication key index is A key, we use compact DWARF
>> description which
>> can largely save DWARF frame size, otherwise we fallback to general
>> operator.
>>
>>
>>
>> Example
>> ===
>>
>> int
>> cal (int a, int b, int c)
>> {
>> return a + dec (b) + c;
>> }
>>
>> Compact DWARF description
>> (-march=armv8.3-a -msign-return-address)
>> ===
>>
>> DW_CFA_advance_loc: 4 to 0000000000000004
>> DW_CFA_val_expression: r30 (x30) (DW_OP_AARCH64_paciasp)
>> DW_CFA_advance_loc: 4 to 0000000000000008
>> DW_CFA_val_expression: r30 (x30) (DW_OP_AARCH64_paciasp_deref: -24)
>>
>> General DWARF description
>> ===
>> (-march=armv8.3-a -msign-return-address -mpauth-key=b_key)
>>
>> DW_CFA_advance_loc: 4 to 0000000000000004
>> DW_CFA_val_expression: r30 (x30) (DW_OP_breg30 (x30): 0;
>> DW_OP_AARCH64_pauth: 18)
>> DW_CFA_advance_loc: 4 to 0000000000000008
>> DW_CFA_val_expression: r30 (x30) (DW_OP_dup; DW_OP_const1s: -24;
>> DW_OP_plus; DW_OP_deref; DW_OP_AARCH64_pauth: 18)
>>
>> From Linux kernel testing, -msign-return-address will introduce +24%
>> .debug_frame size increase when signing all functions and using compact
>> description, and about +45% .debug_frame size increase if using general
>> description.
>>
>>
>> gcc/
>> 2016-11-11 Jiong Wang<jiong.wang@arm.com>
>>
>> * config/aarch64/aarch64.h (aarch64_pauth_action_type): New
>> enum.
>> * config/aarch64/aarch64.c
>> (aarch64_attach_ra_auth_dwarf_note): New function.
>> (aarch64_attach_ra_auth_dwarf_general): New function.
>> (aarch64_attach_ra_auth_dwarf_shortcut): New function.
>> (aarch64_save_callee_saves): Generate dwarf information if LR
>> is signed.
>> (aarch64_expand_prologue): Likewise.
>> (aarch64_expand_epilogue): Likewise.
>
> This patch is an update on DWARF generation for return address signing.
>
> According to new proposal, we simply needs to generate REG_CFA_WINDOW_SAVE
> annotation.
>
> gcc/
>
> 2017-01-06 Jiong Wang <jiong.wang@arm.com>
>
> * config/aarch64/aarch64.c (aarch64_expand_prologue): Generate
> dwarf
> annotation (REG_CFA_WINDOW_SAVE) for return address signing.
> (aarch64_expand_epilogue): Likewise.
>
>
I don't think we should be overloading REG_CFA_WINDOW_SAVE internally in
the compiler -- it's one thing to do it in the dwarf output tables, but
quite another to be doing it elsewhere in the compiler.
Instead we should create a new reg note kind and use that, but in the
final dwarf output then emit the overloaded opcode.
R.
>
> 2.patch
>
>
> diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
> index 002895a167ce0deb45a5c1726527651af18bb4df..20ed79e5690f45ec121ef516245c686cc0cc82b5 100644
> --- a/gcc/config/aarch64/aarch64.c
> +++ b/gcc/config/aarch64/aarch64.c
> @@ -3553,7 +3553,11 @@ aarch64_expand_prologue (void)
>
> /* Sign return address for functions. */
> if (aarch64_return_address_signing_enabled ())
> - emit_insn (gen_pacisp ());
> + {
> + insn = emit_insn (gen_pacisp ());
> + add_reg_note (insn, REG_CFA_WINDOW_SAVE, const0_rtx);
> + RTX_FRAME_RELATED_P (insn) = 1;
> + }
>
> if (flag_stack_usage_info)
> current_function_static_stack_size = frame_size;
> @@ -3698,7 +3702,11 @@ aarch64_expand_epilogue (bool for_sibcall)
> want to use the CFA of the function which calls eh_return. */
> if (aarch64_return_address_signing_enabled ()
> && (for_sibcall || !TARGET_ARMV8_3 || crtl->calls_eh_return))
> - emit_insn (gen_autisp ());
> + {
> + insn = emit_insn (gen_autisp ());
> + add_reg_note (insn, REG_CFA_WINDOW_SAVE, const0_rtx);
> + RTX_FRAME_RELATED_P (insn) = 1;
> + }
>
> /* Stack adjustment for exception handler. */
> if (crtl->calls_eh_return)
>