2
0
mirror of git://gcc.gnu.org/git/gcc.git synced 2025-04-24 19:21:12 +08:00

CFI-handling : Add a hook to allow target-specific Personality and LSDA indirections.

At present, the output of .cfi_personality and .cfi_lsda assumes
ELF semantics for indirections.  This isn't suitable for all targets
and is one blocker to moving Darwin to use .cfi_xxxx.

The patch adds a target hook that allows non-ELF targets to use
indirections appropriate to their needs.

gcc/ChangeLog:

	* config/darwin-protos.h (darwin_make_eh_symbol_indirect): New.
	* config/darwin.c (darwin_make_eh_symbol_indirect): New. Use
	Mach-O semantics for personality and ldsa indirections.
	* config/darwin.h (TARGET_ASM_MAKE_EH_SYMBOL_INDIRECT): New.
	* doc/tm.texi: Regenerate.
	* doc/tm.texi.in: Add TARGET_ASM_MAKE_EH_SYMBOL_INDIRECT hook.
	* dwarf2out.c (dwarf2out_do_cfi_startproc): If the target defines
	a hook for indirecting personality and ldsa references, use that
	otherwise default to ELF semantics.
	* target.def (make_eh_symbol_indirect): New target hook.
This commit is contained in:
Iain Sandoe 2019-09-16 15:11:00 +01:00
parent 9227f81db7
commit 5d46ec3db2
7 changed files with 43 additions and 2 deletions

@ -69,6 +69,7 @@ extern void darwin_non_lazy_pcrel (FILE *, rtx);
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);
extern void darwin_pragma_ignore (struct cpp_reader *);
extern void darwin_pragma_options (struct cpp_reader *);

@ -2225,6 +2225,17 @@ darwin_emit_except_table_label (FILE *file)
ASM_OUTPUT_LABEL (file, section_start_label);
}
rtx
darwin_make_eh_symbol_indirect (rtx orig, bool ARG_UNUSED (pubvis))
{
if (DARWIN_PPC == 0 && TARGET_64BIT)
return orig;
return gen_rtx_SYMBOL_REF (Pmode,
machopic_indirection_name (orig,
/*stub_p=*/false));
}
/* Return, and mark as used, the name of the stub for the mcount function.
Currently, this is only called by X86 code in the expansion of the
FUNCTION_PROFILER macro, when stubs are enabled. */

@ -591,6 +591,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
/* 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. */
#define NO_PROFILE_COUNTERS 1

@ -9560,6 +9560,10 @@ given instruction. This is only used when @code{TARGET_EXCEPT_UNWIND_INFO}
returns @code{UI_TARGET}.
@end deftypefn
@deftypefn {Target Hook} rtx TARGET_ASM_MAKE_EH_SYMBOL_INDIRECT (rtx @var{origsymbol}, bool @var{pubvis})
If necessary, modify personality and LSDA references to handle indirection. The original symbol is in @code{origsymbol} and if @code{pubvis} is true the symbol is visible outside the TU.
@end deftypefn
@deftypevr {Target Hook} bool TARGET_ASM_UNWIND_EMIT_BEFORE_INSN
True if the @code{TARGET_ASM_UNWIND_EMIT} hook should be called before the assembly for @var{insn} has been emitted, false if the hook should be called afterward.
@end deftypevr

@ -6456,6 +6456,8 @@ the jump-table.
@hook TARGET_ASM_UNWIND_EMIT
@hook TARGET_ASM_MAKE_EH_SYMBOL_INDIRECT
@hook TARGET_ASM_UNWIND_EMIT_BEFORE_INSN
@node Exception Region Output

@ -991,7 +991,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 = dw2_force_const_mem (ref, true);
{
if (targetm.asm_out.make_eh_symbol_indirect != NULL)
ref = targetm.asm_out.make_eh_symbol_indirect (ref, true);
else
ref = dw2_force_const_mem (ref, true);
}
fprintf (asm_out_file, "\t.cfi_personality %#x,", enc);
output_addr_const (asm_out_file, ref);
@ -1009,7 +1014,12 @@ dwarf2out_do_cfi_startproc (bool second)
SYMBOL_REF_FLAGS (ref) = SYMBOL_FLAG_LOCAL;
if (enc & DW_EH_PE_indirect)
ref = dw2_force_const_mem (ref, true);
{
if (targetm.asm_out.make_eh_symbol_indirect != NULL)
ref = targetm.asm_out.make_eh_symbol_indirect (ref, true);
else
ref = dw2_force_const_mem (ref, true);
}
fprintf (asm_out_file, "\t.cfi_lsda %#x,", enc);
output_addr_const (asm_out_file, ref);

@ -185,6 +185,16 @@ DEFHOOK
void, (rtx personality),
NULL)
/* 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 indirection.\
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,