Re: [PATCH 1/3][GCC] Add new target hook asm_post_cfi_startproc
On 12/13/18 7:03 PM, Jason Merrill wrote: > And this seems consistent with the other stuff in > dwarf2out_do_cfi_startproc. You might amend the documentation to > mention that the expected use is to add more .cfi_* directives. OK > with that change. > > Jason Hi Jason, Thanks for the approval. Committed with your proposal as r267135.
Re: [PATCH 1/3][GCC] Add new target hook asm_post_cfi_startproc
On 11/5/18 5:18 AM, Sam Tebbs wrote: On 11/05/2018 07:54 AM, Richard Biener wrote: On Fri, 2 Nov 2018, Sam Tebbs wrote: On 11/02/2018 05:28 PM, Sam Tebbs wrote: Hi all, This patch adds a new target hook called "asm_post_cfi_startproc". This hook is intended to be used by the aarch64 backend to emit a directive that enables support for unwinding frames signed with the pointer authentication B-key. This hook is triggered after the ".cfi_startproc" directive is emitted in gcc/dwarf2out.c. Bootstrapped on aarch64-none-linux-gnu and tested on aarch64-none-elf with no regressions. Ok for trunk? Can you explain why existing prologue/cfi emission points are not enough? I couldn't find any target hooks that were triggered at the assembly-printing level at the correct point in time (after .cfi_startproc is emitted), please do point me to one if that is not the case. An alternative could have been to implement a new reg_note but that would have meant adding target-specific code to target-agnostic files and wouldn't have been as flexible. And this seems consistent with the other stuff in dwarf2out_do_cfi_startproc. You might amend the documentation to mention that the expected use is to add more .cfi_* directives. OK with that change. Jason
Re: [PATCH 1/3][GCC] Add new target hook asm_post_cfi_startproc
On 11/5/18 10:18 AM, Sam Tebbs wrote: > On 11/05/2018 07:54 AM, Richard Biener wrote: >> On Fri, 2 Nov 2018, Sam Tebbs wrote: >> >>> On 11/02/2018 05:28 PM, Sam Tebbs wrote: >>> Hi all, This patch adds a new target hook called "asm_post_cfi_startproc". This hook is intended to be used by the aarch64 backend to emit a directive that enables support for unwinding frames signed with the pointer authentication B-key. This hook is triggered after the ".cfi_startproc" directive is emitted in gcc/dwarf2out.c. Bootstrapped on aarch64-none-linux-gnu and tested on aarch64-none-elf with no regressions. Ok for trunk? >> Can you explain why existing prologue/cfi emission points are not >> enough? > I couldn't find any target hooks that were triggered at the > assembly-printing level at the correct point in time (after > .cfi_startproc is emitted), please do point me to one if that is not the > case. > > An alternative could have been to implement a new reg_note but that > would have meant adding target-specific code to target-agnostic files > and wouldn't have been as flexible. > > Sam > gcc/ 2018-11-02 Sam Tebbs * doc/tm.texi (TARGET_ASM_POST_CFI_STARTPROC): Define. * doc/tm.texi.in (TARGET_ASM_POST_CFI_STARTPROC): Define. * dwarf2out.c (dwarf2out_do_cfi_startproc): Trigger the hook. * hooks.c (hook_void_FILEptr_tree): Define. * hooks.h (hook_void_FILEptr_tree): Define. * target.def (post_cfi_startproc): Define. >>> CCing global reviewers and dwarf maintainers. >>> >>> >>> ping 4. There are previous pings in another thread with more maintainers CC'ed, but pinging here as this is where the conversation has been.
Re: [PATCH 1/3][GCC] Add new target hook asm_post_cfi_startproc
On 11/21/18 4:40 PM, Sam Tebbs wrote: > On 11/2/18 6:07 PM, Sam Tebbs wrote: >> On 11/02/2018 05:28 PM, Sam Tebbs wrote: >> >>> Hi all, >>> >>> This patch adds a new target hook called "asm_post_cfi_startproc". This >>> hook is >>> intended to be used by the aarch64 backend to emit a directive that enables >>> support for unwinding frames signed with the pointer authentication B-key. >>> This >>> hook is triggered after the ".cfi_startproc" directive is emitted in >>> gcc/dwarf2out.c. >>> >>> Bootstrapped on aarch64-none-linux-gnu and tested on aarch64-none-elf with >>> no regressions. >>> >>> Ok for trunk? >>> >>> gcc/ >>> 2018-11-02 Sam Tebbs >>> >>> * doc/tm.texi (TARGET_ASM_POST_CFI_STARTPROC): Define. >>> * doc/tm.texi.in (TARGET_ASM_POST_CFI_STARTPROC): Define. >>> * dwarf2out.c (dwarf2out_do_cfi_startproc): Trigger the hook. >>> * hooks.c (hook_void_FILEptr_tree): Define. >>> * hooks.h (hook_void_FILEptr_tree): Define. >>> * target.def (post_cfi_startproc): Define. >> CCing global reviewers and dwarf maintainers. >> > ping ping. cc'ing some more global reviewers.
Re: [PATCH 1/3][GCC] Add new target hook asm_post_cfi_startproc
On 11/2/18 6:07 PM, Sam Tebbs wrote: > On 11/02/2018 05:28 PM, Sam Tebbs wrote: > >> Hi all, >> >> This patch adds a new target hook called "asm_post_cfi_startproc". This hook >> is >> intended to be used by the aarch64 backend to emit a directive that enables >> support for unwinding frames signed with the pointer authentication B-key. >> This >> hook is triggered after the ".cfi_startproc" directive is emitted in >> gcc/dwarf2out.c. >> >> Bootstrapped on aarch64-none-linux-gnu and tested on aarch64-none-elf with >> no regressions. >> >> Ok for trunk? >> >> gcc/ >> 2018-11-02 Sam Tebbs >> >> * doc/tm.texi (TARGET_ASM_POST_CFI_STARTPROC): Define. >> * doc/tm.texi.in (TARGET_ASM_POST_CFI_STARTPROC): Define. >> * dwarf2out.c (dwarf2out_do_cfi_startproc): Trigger the hook. >> * hooks.c (hook_void_FILEptr_tree): Define. >> * hooks.h (hook_void_FILEptr_tree): Define. >> * target.def (post_cfi_startproc): Define. > CCing global reviewers and dwarf maintainers. > ping
Re: [PATCH 1/3][GCC] Add new target hook asm_post_cfi_startproc
On 11/05/2018 07:54 AM, Richard Biener wrote: > On Fri, 2 Nov 2018, Sam Tebbs wrote: > >> On 11/02/2018 05:28 PM, Sam Tebbs wrote: >> >>> Hi all, >>> >>> This patch adds a new target hook called "asm_post_cfi_startproc". This >>> hook is >>> intended to be used by the aarch64 backend to emit a directive that enables >>> support for unwinding frames signed with the pointer authentication B-key. >>> This >>> hook is triggered after the ".cfi_startproc" directive is emitted in >>> gcc/dwarf2out.c. >>> >>> Bootstrapped on aarch64-none-linux-gnu and tested on aarch64-none-elf with >>> no regressions. >>> >>> Ok for trunk? > Can you explain why existing prologue/cfi emission points are not > enough? I couldn't find any target hooks that were triggered at the assembly-printing level at the correct point in time (after .cfi_startproc is emitted), please do point me to one if that is not the case. An alternative could have been to implement a new reg_note but that would have meant adding target-specific code to target-agnostic files and wouldn't have been as flexible. Sam > >>> gcc/ >>> 2018-11-02 Sam Tebbs >>> >>> * doc/tm.texi (TARGET_ASM_POST_CFI_STARTPROC): Define. >>> * doc/tm.texi.in (TARGET_ASM_POST_CFI_STARTPROC): Define. >>> * dwarf2out.c (dwarf2out_do_cfi_startproc): Trigger the hook. >>> * hooks.c (hook_void_FILEptr_tree): Define. >>> * hooks.h (hook_void_FILEptr_tree): Define. >>> * target.def (post_cfi_startproc): Define. >> CCing global reviewers and dwarf maintainers. >> >>
Re: [PATCH 1/3][GCC] Add new target hook asm_post_cfi_startproc
On Fri, 2 Nov 2018, Sam Tebbs wrote: > On 11/02/2018 05:28 PM, Sam Tebbs wrote: > > > Hi all, > > > > This patch adds a new target hook called "asm_post_cfi_startproc". This > > hook is > > intended to be used by the aarch64 backend to emit a directive that enables > > support for unwinding frames signed with the pointer authentication B-key. > > This > > hook is triggered after the ".cfi_startproc" directive is emitted in > > gcc/dwarf2out.c. > > > > Bootstrapped on aarch64-none-linux-gnu and tested on aarch64-none-elf with > > no regressions. > > > > Ok for trunk? Can you explain why existing prologue/cfi emission points are not enough? > > gcc/ > > 2018-11-02 Sam Tebbs > > > > * doc/tm.texi (TARGET_ASM_POST_CFI_STARTPROC): Define. > > * doc/tm.texi.in (TARGET_ASM_POST_CFI_STARTPROC): Define. > > * dwarf2out.c (dwarf2out_do_cfi_startproc): Trigger the hook. > > * hooks.c (hook_void_FILEptr_tree): Define. > > * hooks.h (hook_void_FILEptr_tree): Define. > > * target.def (post_cfi_startproc): Define. > > CCing global reviewers and dwarf maintainers. > > -- Richard Biener SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)
Re: [PATCH 1/3][GCC] Add new target hook asm_post_cfi_startproc
On 11/02/2018 05:28 PM, Sam Tebbs wrote: > Hi all, > > This patch adds a new target hook called "asm_post_cfi_startproc". This hook > is > intended to be used by the aarch64 backend to emit a directive that enables > support for unwinding frames signed with the pointer authentication B-key. > This > hook is triggered after the ".cfi_startproc" directive is emitted in > gcc/dwarf2out.c. > > Bootstrapped on aarch64-none-linux-gnu and tested on aarch64-none-elf with no > regressions. > > Ok for trunk? > > gcc/ > 2018-11-02 Sam Tebbs > > * doc/tm.texi (TARGET_ASM_POST_CFI_STARTPROC): Define. > * doc/tm.texi.in (TARGET_ASM_POST_CFI_STARTPROC): Define. > * dwarf2out.c (dwarf2out_do_cfi_startproc): Trigger the hook. > * hooks.c (hook_void_FILEptr_tree): Define. > * hooks.h (hook_void_FILEptr_tree): Define. > * target.def (post_cfi_startproc): Define. CCing global reviewers and dwarf maintainers.
[PATCH 1/3][GCC] Add new target hook asm_post_cfi_startproc
Hi all, This patch adds a new target hook called "asm_post_cfi_startproc". This hook is intended to be used by the aarch64 backend to emit a directive that enables support for unwinding frames signed with the pointer authentication B-key. This hook is triggered after the ".cfi_startproc" directive is emitted in gcc/dwarf2out.c. Bootstrapped on aarch64-none-linux-gnu and tested on aarch64-none-elf with no regressions. Ok for trunk? gcc/ 2018-11-02 Sam Tebbs * doc/tm.texi (TARGET_ASM_POST_CFI_STARTPROC): Define. * doc/tm.texi.in (TARGET_ASM_POST_CFI_STARTPROC): Define. * dwarf2out.c (dwarf2out_do_cfi_startproc): Trigger the hook. * hooks.c (hook_void_FILEptr_tree): Define. * hooks.h (hook_void_FILEptr_tree): Define. * target.def (post_cfi_startproc): Define. diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index f841527..e26c0a7 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -9413,6 +9413,14 @@ If this macro is not defined, nothing special is output at the end of the jump-table. @end defmac +@deftypefn {Target Hook} void TARGET_ASM_POST_CFI_STARTPROC (FILE *@var{}, @var{tree}) +This target hook is used to emit assembly strings required by the target +after the .cfi_startproc directive. The first argument is the file stream to +write the strings to and the second argument is the function's declaration. + +The default is to not output any assembly strings. +@end deftypefn + @deftypefn {Target Hook} void TARGET_ASM_EMIT_UNWIND_LABEL (FILE *@var{stream}, tree @var{decl}, int @var{for_eh}, int @var{empty}) This target hook emits a label at the beginning of each FDE@. It should be defined on targets where FDEs need special labels, and it diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 967ef3a..7d933c0 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -6426,6 +6426,8 @@ If this macro is not defined, nothing special is output at the end of the jump-table. @end defmac +@hook TARGET_ASM_POST_CFI_STARTPROC + @hook TARGET_ASM_EMIT_UNWIND_LABEL @hook TARGET_ASM_EMIT_EXCEPT_TABLE_LABEL diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 30bbfee..6c1531a 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -969,6 +969,8 @@ dwarf2out_do_cfi_startproc (bool second) fprintf (asm_out_file, "\t.cfi_startproc\n"); + targetm.asm_out.post_cfi_startproc (asm_out_file, current_function_decl); + /* .cfi_personality and .cfi_lsda are only relevant to DWARF2 eh unwinders. */ if (targetm_common.except_unwind_info (_options) != UI_DWARF2) diff --git a/gcc/hooks.h b/gcc/hooks.h index 0ed5b95..bcfc231 100644 --- a/gcc/hooks.h +++ b/gcc/hooks.h @@ -82,6 +82,7 @@ extern void hook_void_FILEptr_constcharptr_const_tree (FILE *, const char *, const_tree); extern bool hook_bool_FILEptr_rtx_false (FILE *, rtx); extern void hook_void_rtx_tree (rtx, tree); +extern void hook_void_FILEptr_tree (FILE *, tree); extern void hook_void_tree (tree); extern void hook_void_tree_treeptr (tree, tree *); extern void hook_void_int_int (int, int); diff --git a/gcc/hooks.c b/gcc/hooks.c index 780cc1e..46bf2a8 100644 --- a/gcc/hooks.c +++ b/gcc/hooks.c @@ -277,6 +277,11 @@ hook_void_tree (tree) } void +hook_void_FILEptr_tree (FILE *, tree) +{ +} + +void hook_void_rtx_tree (rtx, tree) { } diff --git a/gcc/target.def b/gcc/target.def index ad27d35..3b0022d 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -87,6 +87,17 @@ when the relevant string is @code{NULL}.", bool, (rtx x, unsigned int size, int aligned_p), default_assemble_integer) +/* Assembly strings required after the .cfi_startproc label. */ +DEFHOOK +(post_cfi_startproc, + "This target hook is used to emit assembly strings required by the target\n\ +after the .cfi_startproc directive. The first argument is the file stream to\n\ +write the strings to and the second argument is the function\'s declaration.\n\ +\n\ +The default is to not output any assembly strings.", + void, (FILE *, tree), + hook_void_FILEptr_tree) + /* Notify the backend that we have completed emitting the data for a decl. */ DEFHOOK