From: Jiong Wang Date: Fri, 20 Jan 2017 00:05:30 +0000 (+0000) Subject: [AArch64][2/4] Generate dwarf information for -msign-return-address X-Git-Tag: upstream/12.2.0~41725 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=27169e45d4c16032c2fdee7b89883a1ca62b2b93;p=platform%2Fupstream%2Fgcc.git [AArch64][2/4] Generate dwarf information for -msign-return-address gcc/ * reg-notes.def (CFA_TOGGLE_RA_MANGLE): New reg-note. * combine-stack-adj.c (no_unhandled_cfa): Handle REG_CFA_TOGGLE_RA_MANGLE. * dwarf2cfi.c (dwarf2out_frame_debug): Handle REG_CFA_TOGGLE_RA_MANGLE. * config/aarch64/aarch64.c (aarch64_expand_prologue): Generates DWARF info for return address signing. (aarch64_expand_epilogue): Likewise. From-SVN: r244667 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1f959bb..2abfea0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,15 @@ 2017-01-19 Jiong Wang + * reg-notes.def (CFA_TOGGLE_RA_MANGLE): New reg-note. + * combine-stack-adj.c (no_unhandled_cfa): Handle + REG_CFA_TOGGLE_RA_MANGLE. + * dwarf2cfi.c (dwarf2out_frame_debug): Handle REG_CFA_TOGGLE_RA_MANGLE. + * config/aarch64/aarch64.c (aarch64_expand_prologue): Generates DWARF + info for return address signing. + (aarch64_expand_epilogue): Likewise. + +2017-01-19 Jiong Wang + * config/aarch64/aarch64-opts.h (aarch64_function_type): New enum. * config/aarch64/aarch64-protos.h (aarch64_return_address_signing_enabled): New declaration. diff --git a/gcc/combine-stack-adj.c b/gcc/combine-stack-adj.c index 20cd59a..9ec14a3 100644 --- a/gcc/combine-stack-adj.c +++ b/gcc/combine-stack-adj.c @@ -208,6 +208,7 @@ no_unhandled_cfa (rtx_insn *insn) case REG_CFA_SET_VDRAP: case REG_CFA_WINDOW_SAVE: case REG_CFA_FLUSH_QUEUE: + case REG_CFA_TOGGLE_RA_MANGLE: return false; } diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 62baf58..c3992d8 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -3559,7 +3559,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_TOGGLE_RA_MANGLE, const0_rtx); + RTX_FRAME_RELATED_P (insn) = 1; + } if (flag_stack_usage_info) current_function_static_stack_size = frame_size; @@ -3714,7 +3718,11 @@ aarch64_expand_epilogue (bool for_sibcall) */ 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_TOGGLE_RA_MANGLE, const0_rtx); + RTX_FRAME_RELATED_P (insn) = 1; + } /* Stack adjustment for exception handler. */ if (crtl->calls_eh_return) diff --git a/gcc/dwarf2cfi.c b/gcc/dwarf2cfi.c index 2748e2f..2a527c9 100644 --- a/gcc/dwarf2cfi.c +++ b/gcc/dwarf2cfi.c @@ -2098,7 +2098,9 @@ dwarf2out_frame_debug (rtx_insn *insn) handled_one = true; break; + case REG_CFA_TOGGLE_RA_MANGLE: case REG_CFA_WINDOW_SAVE: + /* We overload both of these operations onto the same DWARF opcode. */ dwarf2out_frame_debug_cfa_window_save (); handled_one = true; break; diff --git a/gcc/reg-notes.def b/gcc/reg-notes.def index ead4a9f..175da11 100644 --- a/gcc/reg-notes.def +++ b/gcc/reg-notes.def @@ -177,6 +177,11 @@ REG_NOTE (CFA_WINDOW_SAVE) the rest of the compiler as a CALL_INSN. */ REG_NOTE (CFA_FLUSH_QUEUE) +/* Attached to insns that are RTX_FRAME_RELATED_P, toggling the mangling status + of return address. Currently it's only used by AArch64. The argument is + ignored. */ +REG_NOTE (CFA_TOGGLE_RA_MANGLE) + /* Indicates what exception region an INSN belongs in. This is used to indicate what region to which a call may throw. REGION 0 indicates that a call cannot throw at all. REGION -1 indicates