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.w...@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.w...@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) >