diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 171f78ff865..5b0816e21f4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,41 @@ +2001-10-22 Stan Shebs + + * target.h (struct gcc_target): Add asm_out.exception_section, + asm_out.eh_frame_section. + * target-def.h (TARGET_ASM_EXCEPTION_SECTION): New macro. + (TARGET_ASM_EH_FRAME_SECTION): New. + (TARGET_INITIALIZER): Update. + * output.h (default_exception_section): Declare. + (default_eh_frame_section): Declare. + * dwarf2out.c: Include target.h. + (output_call_frame_info): Call target hook for eh frames. + (default_eh_frame_section): New function. + * except.c: Include target.h. + (output_function_exception_table): Call target hook for exception + section. + * varasm.c (default_exception_section): Rename from + exception_section, remove EXCEPTION_SECTION macro. + + * config/darwin.h (darwin_eh_frame_section): New function. + (EXCEPTION_SECTION): Remove. + (TARGET_ASM_EXCEPTION_SECTION): Define. + * config/nextstep.h (EH_FRAME_SECTION_ASM_OP): Remove. + (nextstep_exception_section): New function. + (nextstep_eh_frame_section): New function. + (TARGET_ASM_EXCEPTION_SECTION): Define. + (TARGET_ASM_EH_FRAME_SECTION): Define. + + * config/pa/som.h (EXCEPTION_SECTION): Remove. + (TARGET_ASM_EXCEPTION_SECTION): Define. + * config/rs6000/sysv4.h, config/rs6000/xcoff.h + (EXCEPTION_SECTION): Remove. + (TARGET_ASM_EXCEPTION_SECTION): Define. + * config/stormy16/stormy16.h: Remove comments referencing + EXCEPTION_SECTION and EH_FRAME_SECTION_ASM_OP. + + * doc/tm.texi: Document TARGET_ASM_EXCEPTION_SECTION and + TARGET_ASM_EH_FRAME_SECTION. + 2001-10-22 Nick Clifton * config/mips/mips.md (mul_acc_si): Fix precedence of conditional diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index d4a8197ce4a..35207af26d5 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -352,7 +352,7 @@ do { if (!strcmp (alias_name, name)) \ in_machopic_lazy_symbol_ptr, \ in_machopic_symbol_stub, \ in_machopic_picsymbol_stub, \ - in_darwin_exception, \ + in_darwin_exception, in_darwin_eh_frame, \ num_sections #undef EXTRA_SECTION_FUNCTIONS @@ -460,6 +460,9 @@ SECTION_FUNCTION (machopic_picsymbol_stub_section, \ SECTION_FUNCTION (darwin_exception_section, \ in_darwin_exception, \ ".section __TEXT,__gcc_except_tab", 0) \ +SECTION_FUNCTION (darwin_eh_frame_section, \ + in_darwin_eh_frame, \ + ".section __TEXT,__eh_frame", 0) \ \ void \ objc_section_init () \ @@ -781,8 +784,10 @@ enum machopic_addr_class { } \ } while (0) -#define EXCEPTION_SECTION() darwin_exception_section () +#define TARGET_ASM_EXCEPTION_SECTION darwin_exception_section +#define TARGET_ASM_EH_FRAME_SECTION darwin_eh_frame_section + #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \ (((CODE) == 1 || (GLOBAL) == 0) ? DW_EH_PE_pcrel : DW_EH_PE_absptr) diff --git a/gcc/config/nextstep.h b/gcc/config/nextstep.h index 956b9e27d42..827584371e1 100644 --- a/gcc/config/nextstep.h +++ b/gcc/config/nextstep.h @@ -217,13 +217,10 @@ Boston, MA 02111-1307, USA. */ extern void nextstep_asm_out_constructor PARAMS ((struct rtx_def *, int)); extern void nextstep_asm_out_destructor PARAMS ((struct rtx_def *, int)); -/* ??? Should be changed to EH_FRAME_SECTION_NAME, but that requires - named section support. Based on this definition, it seems clear - that the object file format supports named sections, but it has - not been implemented in gcc. */ -#error "Implement named section support" -#define EH_FRAME_SECTION_ASM_OP "\t.section __TEXT,__eh_frame,regular" +#define TARGET_ASM_EXCEPTION_SECTION nextstep_exception_section +#define TARGET_ASM_EH_FRAME_SECTION nextstep_eh_frame_section + /* Don't output a .file directive. That is only used by the assembler for error reporting. */ #undef ASM_FILE_START @@ -326,6 +323,7 @@ FUNCTION () \ #define EXTRA_SECTIONS \ in_const, in_cstring, in_literal4, in_literal8, \ in_constructor, in_destructor, \ + in_nextstep_exception, in_nextstep_eh_frame, \ in_objc_class, in_objc_meta_class, in_objc_category, \ in_objc_class_vars, in_objc_instance_vars, \ in_objc_cls_meth, in_objc_inst_meth, \ @@ -357,6 +355,12 @@ SECTION_FUNCTION (constructor_section, \ SECTION_FUNCTION (destructor_section, \ in_destructor, \ ".destructor", 0, 0) \ +SECTION_FUNCTION (nextstep_exception_section, \ + in_nextstep_exception, \ + ".section __TEXT,__gcc_except_tab,regular", 0, 0) \ +SECTION_FUNCTION (nextstep_eh_frame_section, \ + in_nextstep_eh_frame, \ + ".section __TEXT,__eh_frame,regular", 0, 0) \ SECTION_FUNCTION (objc_class_section, \ in_objc_class, \ ".objc_class", 0, 1) \ diff --git a/gcc/config/pa/som.h b/gcc/config/pa/som.h index 7ce97ef05fa..863b4f78164 100644 --- a/gcc/config/pa/som.h +++ b/gcc/config/pa/som.h @@ -265,7 +265,7 @@ do { \ complain. So, we force exception information into the data section. */ -#define EXCEPTION_SECTION data_section +#define TARGET_ASM_EXCEPTION_SECTION data_section /* Define the .bss section for ASM_OUTPUT_LOCAL to use. */ diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h index 554090cc080..0a24cc30be4 100644 --- a/gcc/config/rs6000/sysv4.h +++ b/gcc/config/rs6000/sysv4.h @@ -1548,5 +1548,6 @@ ncrtn.o%s" ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4) \ : DW_EH_PE_absptr) -#define EXCEPTION_SECTION readonly_data_section +#define TARGET_ASM_EXCEPTION_SECTION readonly_data_section + #define DOUBLE_INT_ASM_OP "\t.quad\t" diff --git a/gcc/config/rs6000/xcoff.h b/gcc/config/rs6000/xcoff.h index 7fbc74aaf93..758a95b30fb 100644 --- a/gcc/config/rs6000/xcoff.h +++ b/gcc/config/rs6000/xcoff.h @@ -495,7 +495,7 @@ toc_section () \ /* Define the name of the section to use for the EH language specific data areas (.gcc_except_table on most other systems). */ -#define EXCEPTION_SECTION data_section +#define TARGET_ASM_EXCEPTION_SECTION data_section /* Define to prevent DWARF2 unwind info in the data section rather than in the .eh_frame section. We do this because the AIX linker diff --git a/gcc/config/stormy16/stormy16.h b/gcc/config/stormy16/stormy16.h index f6d3848c2cf..f625ae8f014 100644 --- a/gcc/config/stormy16/stormy16.h +++ b/gcc/config/stormy16/stormy16.h @@ -4493,23 +4493,6 @@ do { \ This macro need not be defined on most platforms. */ /* #define ASM_OUTPUT_EH_REGION_END() */ -/* A C expression to switch to the section in which the main exception table is - to be placed. The default is a section named `.gcc_except_table' on machines - that support named sections via `ASM_OUTPUT_SECTION_NAME', otherwise if `-fpic' - or `-fPIC' is in effect, the `data_section', otherwise the - `readonly_data_section'. */ -/* #define EXCEPTION_SECTION() */ - -/* If defined, a C string constant for the assembler operation to switch to the - section for exception handling frame unwind information. If not defined, - GNU CC will provide a default definition if the target supports named - sections. `crtstuff.c' uses this macro to switch to the appropriate - section. - - You should define this symbol if your target supports DWARF 2 frame unwind - information and the default definition does not work. */ -/* #define EH_FRAME_SECTION_ASM_OP */ - /* A C expression that is nonzero if the normal exception table output should be omitted. diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 227636f47a0..96c04d982d0 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -7151,15 +7151,6 @@ A C expression to output text to mark the end of an exception region. This macro need not be defined on most platforms. -@findex EXCEPTION_SECTION -@item EXCEPTION_SECTION () -A C expression to switch to the section in which the main -exception table is to be placed (@pxref{Sections}). The default is a -section named @code{.gcc_except_table} on machines that support named -sections via @code{TARGET_ASM_NAMED_SECTION}, otherwise if @option{-fpic} -or @option{-fPIC} is in effect, the @code{data_section}, otherwise the -@code{readonly_data_section}. - @findex EH_FRAME_SECTION_NAME @item EH_FRAME_SECTION_NAME If defined, a C string constant for the name of the section containing @@ -7232,6 +7223,24 @@ the target supports DWARF 2 frame unwind information. @end table +@deftypefn {Target Hook} void TARGET_ASM_EXCEPTION_SECTION () +If defined, a function that switches to the section in which the main +exception table is to be placed (@pxref{Sections}). The default is a +function that switches to a section named @code{.gcc_except_table} on +machines that support named sections via +@code{TARGET_ASM_NAMED_SECTION}, otherwise if @option{-fpic} or +@option{-fPIC} is in effect, the @code{data_section}, otherwise the +@code{readonly_data_section}. +@end deftypefn + +@deftypefn {Target Hook} void TARGET_ASM_EH_FRAME_SECTION () +If defined, a function that switches to the section in which the DWARF 2 +frame unwind information to be placed (@pxref{Sections}). The default +is a function that outputs a standard GAS section directive, if +@code{EH_FRAME_SECTION_NAME} is defined, or else a data section +directive followed by a synthetic label. +@end deftypefn + @node Alignment Output @subsection Assembler Commands for Alignment diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 486c7a20b27..d98b3f2921b 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -59,6 +59,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "tm_p.h" #include "diagnostic.h" #include "debug.h" +#include "target.h" #ifdef DWARF2_DEBUGGING_INFO static void dwarf2out_source_line PARAMS ((unsigned int, const char *)); @@ -1738,18 +1739,7 @@ output_call_frame_info (for_eh) app_enable (); if (for_eh) - { -#ifdef EH_FRAME_SECTION_NAME - named_section_flags (EH_FRAME_SECTION_NAME, SECTION_WRITE); -#else - tree label = get_file_function_name ('F'); - - data_section (); - ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (PTR_SIZE)); - ASM_GLOBALIZE_LABEL (asm_out_file, IDENTIFIER_POINTER (label)); - ASM_OUTPUT_LABEL (asm_out_file, IDENTIFIER_POINTER (label)); -#endif - } + (*targetm.asm_out.eh_frame_section) (); else named_section_flags (DEBUG_FRAME_SECTION, SECTION_DEBUG); @@ -1978,6 +1968,21 @@ output_call_frame_info (for_eh) app_disable (); } +void +default_eh_frame_section () +{ +#ifdef EH_FRAME_SECTION_NAME + named_section_flags (EH_FRAME_SECTION_NAME, SECTION_WRITE); +#else + tree label = get_file_function_name ('F'); + + data_section (); + ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (PTR_SIZE)); + ASM_GLOBALIZE_LABEL (asm_out_file, IDENTIFIER_POINTER (label)); + ASM_OUTPUT_LABEL (asm_out_file, IDENTIFIER_POINTER (label)); +#endif +} + /* Output a marker (i.e. a label) for the beginning of a function, before the prologue. */ diff --git a/gcc/except.c b/gcc/except.c index 6ea1723c24f..788f54ed34f 100644 --- a/gcc/except.c +++ b/gcc/except.c @@ -69,7 +69,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "intl.h" #include "ggc.h" #include "tm_p.h" - +#include "target.h" /* Provide defaults for stuff that may not be defined when using sjlj exceptions. */ @@ -3518,7 +3518,7 @@ output_function_exception_table () /* Note that varasm still thinks we're in the function's code section. The ".endp" directive that will immediately follow will take us back. */ #else - exception_section (); + (*targetm.asm_out.exception_section) (); #endif have_tt_data = (VARRAY_ACTIVE_SIZE (cfun->eh->ttype_data) > 0 diff --git a/gcc/output.h b/gcc/output.h index 18afc85c6e2..585d355bbcb 100644 --- a/gcc/output.h +++ b/gcc/output.h @@ -209,7 +209,10 @@ extern void named_section PARAMS ((tree, const char *, int)); extern void function_section PARAMS ((tree)); /* Tell assembler to switch to the section for the exception table. */ -extern void exception_section PARAMS ((void)); +extern void default_exception_section PARAMS ((void)); + +/* Tell assembler to switch to the section for the EH frames. */ +extern void default_eh_frame_section PARAMS ((void)); /* Tell assembler to switch to the section for string merging. */ extern void mergeable_string_section PARAMS ((tree, unsigned HOST_WIDE_INT, diff --git a/gcc/target-def.h b/gcc/target-def.h index 4b298bc5288..59b5e8de0c8 100644 --- a/gcc/target-def.h +++ b/gcc/target-def.h @@ -19,12 +19,16 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. You are forbidden to forbid anyone else to use, share and improve what you give them. Help stamp out software-hoarding! */ -/* See target.h for a desciption of what this file contains and how to +/* See target.h for a description of what this file contains and how to use it. We want to have non-NULL default definitions of all hook functions, even if they do nothing. */ +/* Note that if one of these macros must be defined in an OS .h file + rather than the .c file, then we need to wrap the default + definition in a #ifndef, since files include tm.h before this one. */ + /* Assembler output. */ #define TARGET_ASM_OPEN_PAREN "(" #define TARGET_ASM_CLOSE_PAREN ")" @@ -72,6 +76,14 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define TARGET_HAVE_NAMED_SECTIONS false #endif +#ifndef TARGET_ASM_EXCEPTION_SECTION +#define TARGET_ASM_EXCEPTION_SECTION default_exception_section +#endif + +#ifndef TARGET_ASM_EH_FRAME_SECTION +#define TARGET_ASM_EH_FRAME_SECTION default_eh_frame_section +#endif + #define TARGET_ASM_OUT {TARGET_ASM_OPEN_PAREN, \ TARGET_ASM_CLOSE_PAREN, \ TARGET_ASM_FUNCTION_PROLOGUE, \ @@ -79,6 +91,8 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. TARGET_ASM_FUNCTION_BEGIN_EPILOGUE, \ TARGET_ASM_FUNCTION_EPILOGUE, \ TARGET_ASM_NAMED_SECTION, \ + TARGET_ASM_EXCEPTION_SECTION, \ + TARGET_ASM_EH_FRAME_SECTION, \ TARGET_ASM_CONSTRUCTOR, \ TARGET_ASM_DESTRUCTOR} diff --git a/gcc/target.h b/gcc/target.h index f7eca62368e..a0545800c27 100644 --- a/gcc/target.h +++ b/gcc/target.h @@ -68,6 +68,12 @@ struct gcc_target specified by FLAGS. */ void (* named_section) PARAMS ((const char *, unsigned int)); + /* Switch to the section that holds the exception table. */ + void (* exception_section) PARAMS ((void)); + + /* Switch to the section that holds the exception frames. */ + void (* eh_frame_section) PARAMS ((void)); + /* Output a constructor for a symbol with a given priority. */ void (* constructor) PARAMS ((rtx, int)); diff --git a/gcc/varasm.c b/gcc/varasm.c index 4d6f4b64836..6658fec22b5 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -603,18 +603,14 @@ variable_section (decl, reloc) table. */ void -exception_section () +default_exception_section () { -#if defined (EXCEPTION_SECTION) - EXCEPTION_SECTION (); -#else if (targetm.have_named_sections) named_section (NULL_TREE, ".gcc_except_table", 0); else if (flag_pic) data_section (); else readonly_data_section (); -#endif } /* Tell assembler to switch to the section for string merging. */