From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11802 invoked by alias); 16 Sep 2019 01:31:04 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 11611 invoked by uid 89); 16 Sep 2019 01:30:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_COUK,KAM_STOCKGEN,MIME_QP_LONG_LINE,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=lucky, labels, introduces, orig X-HELO: smtp1.wavenetuk.net Received: from smtp.wavenetuk.net (HELO smtp1.wavenetuk.net) (195.26.36.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 16 Sep 2019 01:30:22 +0000 Received: from [172.20.0.17] (unknown [67.69.50.154]) by smtp1.wavenetuk.net (Postfix) with ESMTPA id A278D1200976; Mon, 16 Sep 2019 02:30:04 +0100 (BST) From: Iain Sandoe Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: [CFI, Darwin] A hook to allow target-handling of Personality and LSDA indirections. Message-Id: Date: Mon, 16 Sep 2019 01:31:00 -0000 Cc: Jakub Jelinek To: GCC Patches X-SW-Source: 2019-09/txt/msg00920.txt.bz2 If an assembler is used that supports .cfi_xxx, then (usually) GCC's config= uration will detect this and try to use it to generate frame insns. This will not work for Darwin since the default implementation for the pers= onality and LSDA indirection is not correct for Mach-O ABI.=20 As of now we are currently =E2=80=9Clucky=E2=80=9D in that the Darwin imple= mentation of objdump (based on LLVM) does not recognise =E2=80=9C-Wf=E2=80= =9D (and also has slightly different whitespace output) which means that ev= en tho most of the modern assemblers for Darwin *do* consume .cfi_xxxx inst= ructions, the GCC configure is not detecting this and we are falling back t= o the old direct DWARF output for CFA/FDEs. There is no point in fixing the configure, until the codegen will produce u= seful output. So, this patch introduces a target hook to allow target-specific processing= of personality and LSDA indirections (if the hook is not populated, the de= fault implementation is used). Once this fixed is applied it is possible to make progress towards modernis= ing the Darwin handling of the frame insns (and, hopefully, with the newer = dsymutil implementations to progress towards consuming DWARF4, at least). OK for trunk? thanks Iain gcc/ChangeLog: 2019-09-16 Iain Sandoe * config/darwin-protos.h (darwin_make_eh_symbol_indirect): New. * config/darwin.c (darwin_make_eh_symbol_indirect): New. * config/darwin.h (TARGET_ASM_MAKE_EH_SYMBOL_INDIRECT): New hook. * doc/tm.texi: Regenerated. * doc/tm.texi.in: Declare new hook. * dwarf2out.c (dwarf2out_do_cfi_startproc): Allow for target hook to alter= the code gen for personality and LSDA indirections. * target.def: Describe new hook. diff --git a/gcc/config/darwin-protos.h b/gcc/config/darwin-protos.h index e5614b627d..bb3fe19e0d 100644 --- a/gcc/config/darwin-protos.h +++ b/gcc/config/darwin-protos.h @@ -68,6 +68,7 @@ extern void darwin_non_lazy_pcrel (FILE *, rtx); =20 extern void darwin_emit_unwind_label (FILE *, tree, int, int); extern void darwin_emit_except_table_label (FILE *); +extern rtx darwin_make_eh_symbol_indirect (rtx, bool); =20 extern void darwin_pragma_ignore (struct cpp_reader *); extern void darwin_pragma_options (struct cpp_reader *); diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index e62a5c6595..7ef73cc58b 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -2157,6 +2157,18 @@ darwin_emit_except_table_label (FILE *file) except_table_label_num++); ASM_OUTPUT_LABEL (file, section_start_label); } + +rtx +darwin_make_eh_symbol_indirect (rtx orig, bool ARG_UNUSED (pubvis)) +{ + if (DARWIN_PPC =3D=3D 0 && TARGET_64BIT) + return orig; + + return gen_rtx_SYMBOL_REF (Pmode, + machopic_indirection_name (orig, + /*stub_p=3D*/false)); +} + /* Generate a PC-relative reference to a Mach-O non-lazy-symbol. */ =20 void diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index fde191d5c4..06e6f0c3da 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -593,6 +593,9 @@ extern GTY(()) int darwin_ms_struct; /* Emit a label to separate the exception table. */ #define TARGET_ASM_EMIT_EXCEPT_TABLE_LABEL darwin_emit_except_table_label =20 +/* Make an EH (personality or LDSA) symbol indirect as needed. */ +#define TARGET_ASM_MAKE_EH_SYMBOL_INDIRECT darwin_make_eh_symbol_indirect + /* Our profiling scheme doesn't LP labels and counter words. */ =20 #define NO_PROFILE_COUNTERS 1 diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 0b5a08d490..635faa22dc 100644 diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index a9200551ed..c6d457cb5e 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -6445,6 +6445,8 @@ the jump-table. =20 @hook TARGET_ASM_UNWIND_EMIT =20 +@hook TARGET_ASM_MAKE_EH_SYMBOL_INDIRECT + @hook TARGET_ASM_UNWIND_EMIT_BEFORE_INSN =20 @node Exception Region Output diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index aa7fd7eb46..b6d25c109a 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -988,7 +988,12 @@ dwarf2out_do_cfi_startproc (bool second) in the assembler. Further, the assembler can't handle any of the weirder relocation types. */ if (enc & DW_EH_PE_indirect) - ref =3D dw2_force_const_mem (ref, true); + { + if (targetm.asm_out.make_eh_symbol_indirect !=3D NULL) + ref =3D targetm.asm_out.make_eh_symbol_indirect (ref, true); + else + ref =3D dw2_force_const_mem (ref, true); + } =20 fprintf (asm_out_file, "\t.cfi_personality %#x,", enc); output_addr_const (asm_out_file, ref); @@ -1006,7 +1011,12 @@ dwarf2out_do_cfi_startproc (bool second) SYMBOL_REF_FLAGS (ref) =3D SYMBOL_FLAG_LOCAL; =20 if (enc & DW_EH_PE_indirect) - ref =3D dw2_force_const_mem (ref, true); + { + if (targetm.asm_out.make_eh_symbol_indirect !=3D NULL) + ref =3D targetm.asm_out.make_eh_symbol_indirect (ref, true); + else + ref =3D dw2_force_const_mem (ref, true); + } =20 fprintf (asm_out_file, "\t.cfi_lsda %#x,", enc); output_addr_const (asm_out_file, ref); diff --git a/gcc/target.def b/gcc/target.def index ca7e7ad96b..7fdf5a8845 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -185,6 +185,16 @@ DEFHOOK void, (rtx personality), NULL) =20 +/* If necessary, modify personality and LSDA references to handle + indirection. This is used when the assembler supports CFI directives. = */ +DEFHOOK +(make_eh_symbol_indirect, + "If necessary, modify personality and LSDA references to handle indirecti= on.\ + The original symbol is in @code{origsymbol} and if @code{pubvis} is true\ + the symbol is visible outside the TU.", + rtx, (rtx origsymbol, bool pubvis), + NULL) + /* Emit any directives required to unwind this instruction. */ DEFHOOK (unwind_emit, --=20 2.17.1