This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
exception-section patch, part 3
- To: egcs-patches at cygnus dot com
- Subject: exception-section patch, part 3
- From: Bruno Haible <haible at ilog dot fr>
- Date: Wed, 1 Jul 1998 00:02:07 +0200 (MET DST)
This patch adds the low-level primitives for switching to the eh_text
section.
Sun Jun 28 19:49:33 1998 Bruno Haible <bruno@linuix.math.u-bordeaux.fr>
* output.h (function_eh_section): Declare.
* varasm.c (in_section): New enum value in_eh_text.
(eh_text_section): New function.
(eh_frame_section): Add comment.
(function_eh_section): New function.
diff -c3p egcs-19980628/gcc/output.h.bak egcs-19980628/gcc/output.h
*** egcs-19980628/gcc/output.h.bak Mon Jun 8 20:30:18 1998
--- egcs-19980628/gcc/output.h Tue Jun 30 13:08:35 1998
*************** extern void named_section PROTO((tree,
*** 158,163 ****
--- 161,170 ----
/* Tell assembler to switch to the section for function DECL. */
extern void function_section PROTO((tree));
+
+ /* Tell assembler to switch to the section for exception handling code of
+ function DECL. */
+ extern void function_eh_section PROTO((tree));
/* Tell assembler to switch to the section for the exception table. */
extern void exception_section PROTO((void));
diff -c3p egcs-19980628/gcc/varasm.c.bak egcs-19980628/gcc/varasm.c
*** egcs-19980628/gcc/varasm.c.bak Thu Jun 25 17:14:30 1998
--- egcs-19980628/gcc/varasm.c Tue Jun 30 13:06:30 1998
*************** static enum in_section { no_section, in_
*** 176,181 ****
--- 176,184 ----
#ifdef BSS_SECTION_ASM_OP
, in_bss
#endif
+ #ifdef EH_TEXT_SECTION_ASM_OP
+ , in_eh_text
+ #endif
#ifdef EH_FRAME_SECTION_ASM_OP
, in_eh_frame
#endif
*************** asm_output_aligned_bss (file, decl, name
*** 396,402 ****
--- 399,429 ----
#endif /* BSS_SECTION_ASM_OP */
+ /* Tell assembler to switch to the section containing the exception
+ handling code for DECL. */
+
+ void
+ eh_text_section (decl)
+ tree decl;
+ {
+ if (decl == NULL_TREE || TREE_CODE (decl) != FUNCTION_DECL)
+ abort ();
+ #ifdef EH_TEXT_SECTION_ASM_OP
+ if (in_section != in_eh_text)
+ {
+ fprintf (asm_out_file, "%s\n", EH_TEXT_SECTION_ASM_OP);
+ in_section = in_eh_text;
+ }
+ #else
+ named_section (decl, ".eh_text", 0);
+ #endif
+ }
+
#ifdef EH_FRAME_SECTION_ASM_OP
+
+ /* Tell assembler to switch to the section containing the frame tables
+ used for exception handling of the entire compilation unit. */
+
void
eh_frame_section ()
{
*************** eh_frame_section ()
*** 405,412 ****
fprintf (asm_out_file, "%s\n", EH_FRAME_SECTION_ASM_OP);
in_section = in_eh_frame;
}
! }
! #endif
/* Switch to the section for function DECL.
--- 432,440 ----
fprintf (asm_out_file, "%s\n", EH_FRAME_SECTION_ASM_OP);
in_section = in_eh_frame;
}
! }
!
! #endif /* EH_FRAME_SECTION_ASM_OP */
/* Switch to the section for function DECL.
*************** function_section (decl)
*** 423,428 ****
--- 451,490 ----
named_section (decl, (char *) 0, 0);
else
text_section ();
+ }
+
+ /* Switch to the section for exception handling code of function DECL. */
+
+ void
+ function_eh_section (decl)
+ tree decl;
+ {
+ if (decl != NULL_TREE
+ && DECL_SECTION_NAME (decl) != NULL_TREE)
+ {
+ /* Small heuristic for finding the eh_text section name, given the
+ normal section name. This is here because we don't want to store
+ two section names in every decl. */
+ char *name = TREE_STRING_POINTER (DECL_SECTION_NAME (decl));
+ char *name_eh;
+ if (! strncmp (name, ".gnu.linkonce.t.", 16))
+ {
+ name_eh = alloca (strlen (name) + 1);
+ strcpy (name_eh, name);
+ name_eh[14] = 'u';
+ }
+ else
+ {
+ name_eh = alloca (3 + strlen (name) + 1);
+ if (name[0] == '.')
+ sprintf (name_eh, ".eh_%s", &name[1]);
+ else
+ sprintf (name_eh, "eh_%s", name);
+ }
+ named_section (decl, name_eh, 0);
+ }
+ else
+ eh_text_section (decl);
}
/* Switch to section for variable DECL.
diff -c3p egcs-19980628/gcc/tm.texi.bak egcs-19980628/gcc/tm.texi
*** egcs-19980628/gcc/tm.texi.bak Sun Jun 28 00:42:09 1998
--- egcs-19980628/gcc/tm.texi Tue Jun 30 13:06:30 1998
*************** A C expression to output text to mark th
*** 6205,6210 ****
--- 6205,6221 ----
This macro need not be defined on most platforms.
+ @findex EH_TEXT_SECTION_ASM_OP
+ @item EH_TEXT_SECTION_ASM_OP
+ If defined, a C string constant for the assembler operation to switch to
+ the section for exception handling code. If not defined, GNU CC will
+ use the macro @code{ASM_OUTPUT_SECTION_NAME} to switch to a section
+ called @samp{.eh_text}. If @code{ASM_OUTPUT_SECTION_NAME} is not defined
+ either, exception handling code will be output to the text section.
+
+ You should define this symbol if your target supports named sections
+ but @samp{.eh_text} is not a suitable section name.
+
@findex EXCEPTION_SECTION
@item EXCEPTION_SECTION ()
A C expression to switch to the section in which the main