Commit bf1431e3 by Tristan Gingold Committed by Tristan Gingold

eh_personality.cc (__gxx_personality_seh0): New function.

libstdc++-v3/
	* libsupc++/eh_personality.cc (__gxx_personality_seh0): New function.
	Adjust for SEH.
	* config/abi/pre/gnu.ver: Add __gxx_personality_seh0.

libobjc/
	* exception.c (__gnu_objc_personality_seh0): New function.

libjava/
	* libgcj.ver: Add __gcj_personality_seh0.
	* exception.cc (__gcj_personality_seh0): New function.
	Adjust for SEH.

libgcc/
	* unwind-seh.c: New file.
	* unwind-generic.h: Include windows.h for SEH.
	(_Unwind_Exception): Use 6 private fields for SEH.
	(_GCC_specific_handler): Declare.
	* unwind-c.c (__gcc_personality_seh0): New function.
	Adjust for SEH.
	* config/i386/libgcc-cygming.ver: New file.
	* config/i386/t-seh-eh: New file.
	* config.host (x86_64-*-mingw*): Default to seh.

gcc/
	* opts.c (finish_options): Handle UI_SEH.
	* expr.c (build_personality_function): Handle UI_SEH.
	* dwarf2out.c (dwarf2out_begin_prologue): Handle UI_SEH.
	* coretypes.h (unwind_info_type): Add UI_SEH.
	* config/i386/winnt.c (i386_pe_seh_emit_except_personality):
	New function.
	(i386_pe_seh_init_sections): Likewise.
	* config/i386/cygming.h (TARGET_ASM_EMIT_EXCEPT_PERSONALITY): Define.
	(TARGET_ASM_INIT_SECTIONS): Define.
	* common/config/i386/i386-common.c (TARGET_EXCEPT_UNWIND_INFO): Define.
	(i386_except_unwind_info): New function.


Co-Authored-By: Richard Henderson <rth@redhat.com>

From-SVN: r189644
parent fa4a66d1
2012-07-19 Tristan Gingold <gingold@adacore.com>
Richard Henderson <rth@redhat.com>
* opts.c (finish_options): Handle UI_SEH.
* expr.c (build_personality_function): Handle UI_SEH.
* dwarf2out.c (dwarf2out_begin_prologue): Handle UI_SEH.
* coretypes.h (unwind_info_type): Add UI_SEH.
* config/i386/winnt.c (i386_pe_seh_emit_except_personality):
New function.
(i386_pe_seh_init_sections): Likewise.
* config/i386/cygming.h (TARGET_ASM_EMIT_EXCEPT_PERSONALITY): Define.
(TARGET_ASM_INIT_SECTIONS): Define.
* common/config/i386/i386-common.c (TARGET_EXCEPT_UNWIND_INFO): Define.
(i386_except_unwind_info): New function.
2012-07-18 Maciej W. Rozycki <macro@codesourcery.com>
Chao-ying Fu <fu@mips.com>
......
......@@ -667,6 +667,30 @@ ix86_supports_split_stack (bool report ATTRIBUTE_UNUSED,
return ret;
}
/* Implement TARGET_EXCEPT_UNWIND_INFO. */
static enum unwind_info_type
i386_except_unwind_info (struct gcc_options *opts)
{
/* Honor the --enable-sjlj-exceptions configure switch. */
#ifdef CONFIG_SJLJ_EXCEPTIONS
if (CONFIG_SJLJ_EXCEPTIONS)
return UI_SJLJ;
#endif
/* On windows 64, prefer SEH exceptions over anything else. */
if (TARGET_64BIT && DEFAULT_ABI == MS_ABI && opts->x_flag_unwind_tables)
return UI_SEH;
if (DWARF2_UNWIND_INFO)
return UI_DWARF2;
return UI_SJLJ;
}
#undef TARGET_EXCEPT_UNWIND_INFO
#define TARGET_EXCEPT_UNWIND_INFO i386_except_unwind_info
#undef TARGET_DEFAULT_TARGET_FLAGS
#define TARGET_DEFAULT_TARGET_FLAGS \
(TARGET_DEFAULT \
......
......@@ -48,6 +48,10 @@ along with GCC; see the file COPYING3. If not see
#define TARGET_ASM_UNWIND_EMIT_BEFORE_INSN false
#undef TARGET_ASM_FUNCTION_END_PROLOGUE
#define TARGET_ASM_FUNCTION_END_PROLOGUE i386_pe_seh_end_prologue
#undef TARGET_ASM_EMIT_EXCEPT_PERSONALITY
#define TARGET_ASM_EMIT_EXCEPT_PERSONALITY i386_pe_seh_emit_except_personality
#undef TARGET_ASM_INIT_SECTIONS
#define TARGET_ASM_INIT_SECTIONS i386_pe_seh_init_sections
#define SUBTARGET_ASM_UNWIND_INIT i386_pe_seh_init
#undef DEFAULT_ABI
......
......@@ -258,6 +258,8 @@ extern tree i386_pe_mangle_assembler_name (const char *);
extern void i386_pe_seh_init (FILE *);
extern void i386_pe_seh_end_prologue (FILE *);
extern void i386_pe_seh_unwind_emit (FILE *, rtx);
extern void i386_pe_seh_emit_except_personality (rtx);
extern void i386_pe_seh_init_sections (void);
/* In winnt-cxx.c and winnt-stubs.c */
extern void i386_pe_adjust_class_at_definition (tree);
......
......@@ -1145,6 +1145,48 @@ i386_pe_seh_unwind_emit (FILE *asm_out_file, rtx insn)
}
void
i386_pe_seh_emit_except_personality (rtx personality)
{
int flags = 0;
if (!TARGET_SEH)
return;
fputs ("\t.seh_handler\t", asm_out_file);
output_addr_const (asm_out_file, personality);
#if 0
/* ??? The current implementation of _GCC_specific_handler requires
both except and unwind handling, regardless of which sorts the
user-level function requires. */
eh_region r;
FOR_ALL_EH_REGION(r)
{
if (r->type == ERT_CLEANUP)
flags |= 1;
else
flags |= 2;
}
#else
flags = 3;
#endif
if (flags & 1)
fputs (", @unwind", asm_out_file);
if (flags & 2)
fputs (", @except", asm_out_file);
fputc ('\n', asm_out_file);
}
void
i386_pe_seh_init_sections (void)
{
if (TARGET_SEH)
exception_section = get_unnamed_section (0, output_section_asm_op,
"\t.seh_handlerdata");
}
void
i386_pe_start_function (FILE *f, const char *name, tree decl)
{
i386_pe_maybe_record_exported_symbol (decl, name, 0);
......
......@@ -116,7 +116,8 @@ enum unwind_info_type
UI_NONE,
UI_SJLJ,
UI_DWARF2,
UI_TARGET
UI_TARGET,
UI_SEH
};
/* Callgraph node profile representation. */
......
......@@ -976,7 +976,7 @@ dwarf2out_begin_prologue (unsigned int line ATTRIBUTE_UNUSED,
call-site information. We must emit this label if it might be used. */
if (!do_frame
&& (!flag_exceptions
|| targetm_common.except_unwind_info (&global_options) != UI_TARGET))
|| targetm_common.except_unwind_info (&global_options) == UI_SJLJ))
return;
fnsec = function_section (current_function_decl);
......
......@@ -11011,6 +11011,9 @@ build_personality_function (const char *lang)
case UI_TARGET:
unwind_and_version = "_v0";
break;
case UI_SEH:
unwind_and_version = "_seh0";
break;
default:
gcc_unreachable ();
}
......
......@@ -717,7 +717,7 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
if (opts->x_flag_exceptions
&& opts->x_flag_reorder_blocks_and_partition
&& (ui_except == UI_SJLJ || ui_except == UI_TARGET))
&& (ui_except == UI_SJLJ || ui_except >= UI_TARGET))
{
inform (loc,
"-freorder-blocks-and-partition does not work "
......@@ -732,7 +732,7 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
if (opts->x_flag_unwind_tables
&& !targetm_common.unwind_tables_default
&& opts->x_flag_reorder_blocks_and_partition
&& (ui_except == UI_SJLJ || ui_except == UI_TARGET))
&& (ui_except == UI_SJLJ || ui_except >= UI_TARGET))
{
inform (loc,
"-freorder-blocks-and-partition does not support "
......@@ -749,7 +749,7 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
&& (!targetm_common.have_named_sections
|| (opts->x_flag_unwind_tables
&& targetm_common.unwind_tables_default
&& (ui_except == UI_SJLJ || ui_except == UI_TARGET))))
&& (ui_except == UI_SJLJ || ui_except >= UI_TARGET))))
{
inform (loc,
"-freorder-blocks-and-partition does not work "
......
2012-07-19 Tristan Gingold <gingold@adacore.com>
Richard Henderson <rth@redhat.com>
* unwind-seh.c: New file.
* unwind-generic.h: Include windows.h for SEH.
(_Unwind_Exception): Use 6 private fields for SEH.
(_GCC_specific_handler): Declare.
* unwind-c.c (__gcc_personality_seh0): New function.
Adjust for SEH.
* config/i386/libgcc-cygming.ver: New file.
* config/i386/t-seh-eh: New file.
* config.host (x86_64-*-mingw*): Default to seh.
2012-07-14 Steven Bosscher <steven@gcc.gnu.org>
* config/t-darwin (crt3.0): Remove work-around for fixed PR26840.
......
......@@ -618,7 +618,7 @@ x86_64-*-mingw*)
if test x$enable_sjlj_exceptions = xyes; then
tmake_eh_file="i386/t-sjlj-eh"
else
tmake_eh_file="i386/t-dw2-eh"
tmake_eh_file="i386/t-seh-eh"
fi
# Shared libgcc DLL install dir depends on cross/native build.
if test x${build} = x${host} ; then
......
# Copyright (C) 2012 Free Software Foundation, Inc.
#
# This file is part of GCC.
#
# GCC is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# GCC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GCC; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
GCC_4.8 {
_GCC_specific_handler
__gcc_personality_seh0
}
# We are using SEH EH.
EH_MODEL = seh
# Use SEH exception handling.
LIB2ADDEH = $(srcdir)/unwind-seh.c $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c
......@@ -55,4 +55,4 @@ SHLIB_MKMAP = $(srcdir)/mkmap-flat.awk
# We'd like to use SHLIB_SONAME here too, but shlib_base_name
# does not get substituted before mkmap-flat.awk is run.
SHLIB_MKMAP_OPTS = -v pe_dll=libgcc_s_$(EH_MODEL)-$(SHLIB_SOVERSION)$(SHLIB_EXT)
SHLIB_MAPFILES = libgcc-std.ver
SHLIB_MAPFILES = libgcc-std.ver $(srcdir)/config/i386/libgcc-cygming.ver
......@@ -93,6 +93,8 @@ parse_lsda_header (struct _Unwind_Context *context, const unsigned char *p,
#ifdef __USING_SJLJ_EXCEPTIONS__
#define PERSONALITY_FUNCTION __gcc_personality_sj0
#define __builtin_eh_return_data_regno(x) x
#elif defined(__SEH__)
#define PERSONALITY_FUNCTION __gcc_personality_imp
#else
#define PERSONALITY_FUNCTION __gcc_personality_v0
#endif
......@@ -107,6 +109,9 @@ PERSONALITY_FUNCTION (_Unwind_State state,
struct _Unwind_Exception * ue_header,
struct _Unwind_Context * context)
#else
#ifdef __SEH__
static
#endif
_Unwind_Reason_Code
PERSONALITY_FUNCTION (int, _Unwind_Action, _Unwind_Exception_Class,
struct _Unwind_Exception *, struct _Unwind_Context *);
......@@ -227,3 +232,13 @@ PERSONALITY_FUNCTION (int version,
_Unwind_SetIP (context, landing_pad);
return _URC_INSTALL_CONTEXT;
}
#ifdef __SEH__
EXCEPTION_DISPOSITION
__gcc_personality_seh0 (PEXCEPTION_RECORD ms_exc, void *this_frame,
PCONTEXT ms_orig_context, PDISPATCHER_CONTEXT ms_disp)
{
return _GCC_specific_handler (ms_exc, this_frame, ms_orig_context,
ms_disp, __gcc_personality_imp);
}
#endif /* SEH */
......@@ -28,6 +28,11 @@
#ifndef _UNWIND_H
#define _UNWIND_H
#ifdef __SEH__
/* Only for _GCC_specific_handler. */
#include <windows.h>
#endif
#ifndef HIDE_EXPORTS
#pragma GCC visibility push(default)
#endif
......@@ -86,8 +91,13 @@ struct _Unwind_Exception
{
_Unwind_Exception_Class exception_class;
_Unwind_Exception_Cleanup_Fn exception_cleanup;
#if !defined (__USING_SJLJ_EXCEPTIONS__) && defined (__SEH__)
_Unwind_Word private_[6];
#else
_Unwind_Word private_1;
_Unwind_Word private_2;
#endif
/* @@@ The IA-64 ABI says that this structure must be double-word aligned.
Taking that literally does not make much sense generically. Instead we
......@@ -265,6 +275,13 @@ extern void * _Unwind_FindEnclosingFunction (void *pc);
# error "What type shall we use for _sleb128_t?"
#endif
#ifdef __SEH__
/* Handles the mapping from SEH to GCC interfaces. */
EXCEPTION_DISPOSITION _GCC_specific_handler (PEXCEPTION_RECORD, void *,
PCONTEXT, PDISPATCHER_CONTEXT,
_Unwind_Personality_Fn);
#endif
#ifdef __cplusplus
}
#endif
......
2012-07-19 Tristan Gingold <gingold@adacore.com>
Richard Henderson <rth@redhat.com>
* libgcj.ver: Add __gcj_personality_seh0.
* exception.cc (__gcj_personality_seh0): New function.
Adjust for SEH.
2012-07-18 H.J. Lu <hongjiu.lu@intel.com>
PR libjava/53973
......
......@@ -197,6 +197,8 @@ get_ttype_entry (_Unwind_Context *context, lsda_header_info *info, long i)
#ifdef SJLJ_EXCEPTIONS
#define PERSONALITY_FUNCTION __gcj_personality_sj0
#define __builtin_eh_return_data_regno(x) x
#elif defined (__SEH__)
#define PERSONALITY_FUNCTION __gcj_personality_imp
#else
#define PERSONALITY_FUNCTION __gcj_personality_v0
#endif
......@@ -220,7 +222,12 @@ PERSONALITY_FUNCTION (_Unwind_State state,
#define CONTINUE_UNWINDING return _URC_CONTINUE_UNWIND
extern "C" _Unwind_Reason_Code
#ifdef __SEH__
static
#else
extern "C"
#endif
_Unwind_Reason_Code
PERSONALITY_FUNCTION (int version,
_Unwind_Action actions,
_Unwind_Exception_Class exception_class,
......@@ -484,3 +491,14 @@ PERSONALITY_FUNCTION (int version,
#endif
return _URC_INSTALL_CONTEXT;
}
#ifdef __SEH__
extern "C"
EXCEPTION_DISPOSITION
__gcj_personality_seh0 (PEXCEPTION_RECORD ms_exc, void *this_frame,
PCONTEXT ms_orig_context, PDISPATCHER_CONTEXT ms_disp)
{
return _GCC_specific_handler (ms_exc, this_frame, ms_orig_context,
ms_disp, __gcj_personality_imp);
}
#endif /* SEH */
......@@ -7,6 +7,7 @@
_Jv_*;
__gcj_personality_v0;
__gcj_personality_sj0;
__gcj_personality_seh0;
_Z*;
local:
*;
......
2012-07-19 Tristan Gingold <gingold@adacore.com>
Richard Henderson <rth@redhat.com>
* exception.c (__gnu_objc_personality_seh0): New function.
2012-05-16 H.J. Lu <hongjiu.lu@intel.com>
* configure: Regenerated.
......
......@@ -202,6 +202,8 @@ get_ttype_entry (struct lsda_header_info *info, _Unwind_Word i)
#ifdef SJLJ_EXCEPTIONS
#define PERSONALITY_FUNCTION __gnu_objc_personality_sj0
#define __builtin_eh_return_data_regno(x) x
#elif defined(__SEH__)
#define PERSONALITY_FUNCTION __gnu_objc_personality_imp
#else
#define PERSONALITY_FUNCTION __gnu_objc_personality_v0
#endif
......@@ -225,6 +227,9 @@ PERSONALITY_FUNCTION (_Unwind_State state,
#define CONTINUE_UNWINDING return _URC_CONTINUE_UNWIND
#ifdef __SEH__
static
#endif
_Unwind_Reason_Code
PERSONALITY_FUNCTION (int version,
_Unwind_Action actions,
......@@ -519,3 +524,13 @@ objc_exception_throw (id exception)
abort ();
}
#ifdef __SEH__
EXCEPTION_DISPOSITION
__gnu_objc_personality_seh0 (PEXCEPTION_RECORD ms_exc, void *this_frame,
PCONTEXT ms_orig_context,
PDISPATCHER_CONTEXT ms_disp)
{
return _GCC_specific_handler (ms_exc, this_frame, ms_orig_context,
ms_disp, __gnu_objc_personality_imp);
}
#endif /* SEH */
2012-07-19 Tristan Gingold <gingold@adacore.com>
Richard Henderson <rth@redhat.com>
* libsupc++/eh_personality.cc (__gxx_personality_seh0): New function.
Adjust for SEH.
* config/abi/pre/gnu.ver: Add __gxx_personality_seh0.
2012-07-18 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/51213
......
......@@ -1357,6 +1357,7 @@ CXXABI_1.3 {
__cxa_vec_new3;
__gxx_personality_v0;
__gxx_personality_sj0;
__gxx_personality_seh0;
__dynamic_cast;
# *_type_info classes, ctor and dtor
......
......@@ -332,11 +332,18 @@ namespace __cxxabiv1
#ifdef _GLIBCXX_SJLJ_EXCEPTIONS
#define PERSONALITY_FUNCTION __gxx_personality_sj0
#define __builtin_eh_return_data_regno(x) x
#elif defined(__SEH__)
#define PERSONALITY_FUNCTION __gxx_personality_imp
#else
#define PERSONALITY_FUNCTION __gxx_personality_v0
#endif
extern "C" _Unwind_Reason_Code
#ifdef __SEH__
static
#else
extern "C"
#endif
_Unwind_Reason_Code
#ifdef __ARM_EABI_UNWINDER__
PERSONALITY_FUNCTION (_Unwind_State state,
struct _Unwind_Exception* ue_header,
......@@ -778,4 +785,15 @@ __cxa_call_unexpected (void *exc_obj_in)
}
#endif
#ifdef __SEH__
extern "C"
EXCEPTION_DISPOSITION
__gxx_personality_seh0 (PEXCEPTION_RECORD ms_exc, void *this_frame,
PCONTEXT ms_orig_context, PDISPATCHER_CONTEXT ms_disp)
{
return _GCC_specific_handler (ms_exc, this_frame, ms_orig_context,
ms_disp, __gxx_personality_imp);
}
#endif /* SEH */
} // namespace __cxxabiv1
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment