This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: .eh_frame section


Jason Merrill writes:
> 
> > Incidentally, if the DWARF spec requires ...
> 
> But we're also putting the info in a different section, so it doesn't
> really matter.

Fine. So we can replace absolute labels by label differences. I propose
the following: When the compiler output contains either a .gcc_except or
a .eh_table section, the beginning of the text section for this module
is marked as __TEXT_BEGIN__ and subtracted from all labels in the tables.
A new section .text_begin is created which only contains the absolute
__TEXT_BEGIN__.

The code which interprets these tables (in frame.c) would have to make
use of the fact that the words in the .text_begin section are in one-one
correspondance with the dwarf2 table (and that the linker doesn't change
the order of the words within the .text_begin section).

This way, we increase the total executable size by 0.5 percent, but
the .gcc_except and .eh_table (25 percent) won't contain relocations
and can therefore be marked read-only ("a" instead of "aw"). This will
make exception handling more acceptable to people.

                          Bruno


Below is an unfinished hack in this direction, just to illustrate what
I mean.

*** dwarf2out.c.bak	Fri Oct  3 01:22:48 1997
--- dwarf2out.c	Fri Oct 10 10:49:41 1997
***************
*** 1513,1526 ****
        ASM_OUTPUT_LABEL (asm_out_file, l1);
  
        if (for_eh)
! 	ASM_OUTPUT_DWARF_ADDR (asm_out_file, "__FRAME_BEGIN__");
        else
  	ASM_OUTPUT_DWARF_OFFSET (asm_out_file, stripattributes (FRAME_SECTION));
        if (flag_debug_asm)
  	fprintf (asm_out_file, "\t%s FDE CIE offset", ASM_COMMENT_START);
  
        fputc ('\n', asm_out_file);
!       ASM_OUTPUT_DWARF_ADDR (asm_out_file, fde->dw_fde_begin);
        if (flag_debug_asm)
  	fprintf (asm_out_file, "\t%s FDE initial location", ASM_COMMENT_START);
  
--- 1513,1531 ----
        ASM_OUTPUT_LABEL (asm_out_file, l1);
  
        if (for_eh)
! 	ASM_OUTPUT_DWARF_ADDR_DELTA (asm_out_file,
! 				     "__FRAME_BEGIN__", "__FRAME_BEGIN__");
        else
  	ASM_OUTPUT_DWARF_OFFSET (asm_out_file, stripattributes (FRAME_SECTION));
        if (flag_debug_asm)
  	fprintf (asm_out_file, "\t%s FDE CIE offset", ASM_COMMENT_START);
  
        fputc ('\n', asm_out_file);
!       if (for_eh)
! 	ASM_OUTPUT_DWARF_ADDR_DELTA (asm_out_file,
! 				     fde->dw_fde_begin, "__TEXT_BEGIN__");
!       else
! 	ASM_OUTPUT_DWARF_ADDR (asm_out_file, fde->dw_fde_begin);
        if (flag_debug_asm)
  	fprintf (asm_out_file, "\t%s FDE initial location", ASM_COMMENT_START);
  
***************
*** 1535,1541 ****
  	{
  	  /* For now, a pointer to the translation unit's info will do.
  	     ??? Eventually this should point to the function's info.  */
! 	  ASM_OUTPUT_DWARF_ADDR (asm_out_file, "__EXCEPTION_TABLE__");
  	  if (flag_debug_asm)
  	    fprintf (asm_out_file, "\t%s pointer to exception region info",
  		     ASM_COMMENT_START);
--- 1540,1547 ----
  	{
  	  /* For now, a pointer to the translation unit's info will do.
  	     ??? Eventually this should point to the function's info.  */
! 	  ASM_OUTPUT_DWARF_ADDR_DELTA (asm_out_file, "__EXCEPTION_TABLE__",
! 						     "__EXCEPTION_TABLE__");
  	  if (flag_debug_asm)
  	    fprintf (asm_out_file, "\t%s pointer to exception region info",
  		     ASM_COMMENT_START);
*** toplev.c.bak	Sat Sep 27 01:34:30 1997
--- toplev.c	Fri Oct 10 11:23:48 1997
***************
*** 2404,2409 ****
--- 2404,2419 ----
    if (write_symbols == DWARF2_DEBUG)
      TIMEVAR (symout_time, dwarf2out_init (asm_out_file, main_input_filename));
  #endif
+ #if 1
+   if (!output_bytecode)
+     {
+       text_section ();
+       assemble_label ("__TEXT_BEGIN__");
+       named_section (NULL, ".text_begin", 1);
+       assemble_integer (gen_rtx (SYMBOL_REF, Pmode, "__TEXT_BEGIN__"),
+ 			POINTER_SIZE / BITS_PER_UNIT, 1);
+     }
+ #endif
  
    /* Initialize yet another pass.  */
  
*** except.c.bak	Fri Oct  3 12:24:30 1997
--- except.c	Fri Oct 10 11:39:04 1997
***************
*** 1541,1554 ****
--- 1541,1560 ----
  
    ASM_GENERATE_INTERNAL_LABEL (buf, "LEHB", n);
    sym = gen_rtx (SYMBOL_REF, Pmode, buf);
+   sym = gen_rtx (MINUS, Pmode, sym,
+ 			       gen_rtx (SYMBOL_REF, Pmode, "__TEXT_BEGIN__"));
    assemble_integer (sym, POINTER_SIZE / BITS_PER_UNIT, 1);
  
    ASM_GENERATE_INTERNAL_LABEL (buf, "LEHE", n);
    sym = gen_rtx (SYMBOL_REF, Pmode, buf);
+   sym = gen_rtx (MINUS, Pmode, sym,
+ 			       gen_rtx (SYMBOL_REF, Pmode, "__TEXT_BEGIN__"));
    assemble_integer (sym, POINTER_SIZE / BITS_PER_UNIT, 1);
  
    ASM_GENERATE_INTERNAL_LABEL (buf, "L", n);
    sym = gen_rtx (SYMBOL_REF, Pmode, buf);
+   sym = gen_rtx (MINUS, Pmode, sym,
+ 			       gen_rtx (SYMBOL_REF, Pmode, "__TEXT_BEGIN__"));
    assemble_integer (sym, POINTER_SIZE / BITS_PER_UNIT, 1);
  
    putc ('\n', file);		/* blank line */
***************
*** 1562,1580 ****
    int i;
    extern FILE *asm_out_file;
  
-   if (! doing_eh (0) || ! eh_table)
-     return;
- 
    exception_section ();
  
    /* Beginning marker for table.  */
    assemble_align (GET_MODE_ALIGNMENT (ptr_mode));
    assemble_label ("__EXCEPTION_TABLE__");
  
!   for (i = 0; i < eh_table_size; ++i)
!     output_exception_table_entry (asm_out_file, eh_table[i]);
  
!   free (eh_table);
  
    /* Ending marker for table.  */
    assemble_label ("__EXCEPTION_END__");
--- 1568,1586 ----
    int i;
    extern FILE *asm_out_file;
  
    exception_section ();
  
    /* Beginning marker for table.  */
    assemble_align (GET_MODE_ALIGNMENT (ptr_mode));
    assemble_label ("__EXCEPTION_TABLE__");
  
!   if (doing_eh (0) && eh_table)
!     {
!       for (i = 0; i < eh_table_size; ++i)
! 	output_exception_table_entry (asm_out_file, eh_table[i]);
  
!       free (eh_table);
!     }
  
    /* Ending marker for table.  */
    assemble_label ("__EXCEPTION_END__");



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]