This is the mail archive of the gcc-patches@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]
Other format: [Raw text]

.cfi_escape


A pretense at future-proofing.


r~


        * dw2gencfi.c (struct cfi_escape_data): New.
        (cfi_add_CFA_nop): Remove.
        (CFI_escape, dot_cfi_escape): New.
        (dot_cfi): Remove nop.
        (cfi_pseudo_table): Remove nop; add escape.
        (output_cfi_insn): Likewise.
        (select_cie_for_fde): Stop on escape.
        * dw2gencfi.h (cfi_add_CFA_nop): Remove.
        * read.c, read.h (do_parse_cons_expression): New.
        * doc/as.texinfo (.cfi_escape): New.

Index: dw2gencfi.c
===================================================================
RCS file: /cvs/src/src/gas/dw2gencfi.c,v
retrieving revision 1.11
diff -c -p -d -r1.11 dw2gencfi.c
*** dw2gencfi.c	8 Jun 2003 03:59:44 -0000	1.11
--- dw2gencfi.c	11 Jun 2003 23:15:58 -0000
*************** struct cfi_insn_data
*** 68,73 ****
--- 68,78 ----
        symbolS *lab1;
        symbolS *lab2;
      } ll;
+ 
+     struct cfi_escape_data {
+       struct cfi_escape_data *next;
+       expressionS exp;
+     } *esc;
    } u;
  };
  
*************** cfi_add_CFA_restore_state (void)
*** 330,345 ****
      }
  }
  
- void
- cfi_add_CFA_nop (void)
- {
-   cfi_add_CFA_insn (DW_CFA_nop);
- }
- 
  
  /* Parse CFI assembler directives.  */
  
  static void dot_cfi (int);
  static void dot_cfi_startproc (int);
  static void dot_cfi_endproc (int);
  
--- 335,345 ----
      }
  }
  
  
  /* Parse CFI assembler directives.  */
  
  static void dot_cfi (int);
+ static void dot_cfi_escape (int);
  static void dot_cfi_startproc (int);
  static void dot_cfi_endproc (int);
  
*************** static void dot_cfi_endproc (int);
*** 347,352 ****
--- 347,353 ----
  #define CFI_adjust_cfa_offset	0x100
  #define CFI_return_column	0x101
  #define CFI_rel_offset		0x102
+ #define CFI_escape		0x103
  
  const pseudo_typeS cfi_pseudo_table[] =
    {
*************** const pseudo_typeS cfi_pseudo_table[] =
*** 365,371 ****
      { "cfi_same_value", dot_cfi, DW_CFA_same_value },
      { "cfi_remember_state", dot_cfi, DW_CFA_remember_state },
      { "cfi_restore_state", dot_cfi, DW_CFA_restore_state },
!     { "cfi_nop", dot_cfi, DW_CFA_nop },
      { NULL, NULL, 0 }
    };
  
--- 366,372 ----
      { "cfi_same_value", dot_cfi, DW_CFA_same_value },
      { "cfi_remember_state", dot_cfi, DW_CFA_remember_state },
      { "cfi_restore_state", dot_cfi, DW_CFA_restore_state },
!     { "cfi_escape", dot_cfi_escape, 0 },
      { NULL, NULL, 0 }
    };
  
*************** dot_cfi (int arg)
*** 520,529 ****
        cfi_add_CFA_restore_state ();
        break;
  
-     case DW_CFA_nop:
-       cfi_add_CFA_nop ();
-       break;
- 
      default:
        abort ();
      }
--- 521,526 ----
*************** dot_cfi (int arg)
*** 532,537 ****
--- 529,567 ----
  }
  
  static void
+ dot_cfi_escape (int ignored ATTRIBUTE_UNUSED)
+ {
+   struct cfi_escape_data *head, **tail, *e;
+   struct cfi_insn_data *insn;
+ 
+   if (!cur_fde_data)
+     {
+       as_bad (_("CFI instruction used without previous .cfi_startproc"));
+       return;
+     }
+ 
+   /* If the last address was not at the current PC, advance to current.  */
+   if (symbol_get_frag (last_address) != frag_now
+       || S_GET_VALUE (last_address) != frag_now_fix ())
+     cfi_add_advance_loc (symbol_temp_new_now ());
+ 
+   tail = &head;
+   do
+     {
+       e = xmalloc (sizeof (*e));
+       do_parse_cons_expression (&e->exp, 1);
+       *tail = e;
+       tail = &e->next;
+     }
+   while (*input_line_pointer++ == ',');
+   *tail = NULL;
+ 
+   insn = alloc_cfi_insn_data ();
+   insn->insn = CFI_escape;
+   insn->u.esc = head;
+ }
+ 
+ static void
  dot_cfi_startproc (int ignored ATTRIBUTE_UNUSED)
  {
    int simple = 0;
*************** output_cfi_insn (struct cfi_insn_data *i
*** 757,766 ****
  
      case DW_CFA_remember_state:
      case DW_CFA_restore_state:
-     case DW_CFA_nop:
        out_one (insn->insn);
        break;
  
      default:
        abort ();
      }
--- 787,803 ----
  
      case DW_CFA_remember_state:
      case DW_CFA_restore_state:
        out_one (insn->insn);
        break;
  
+     case CFI_escape:
+       {
+ 	struct cfi_escape_data *e;
+ 	for (e = insn->u.esc; e ; e = e->next)
+ 	  emit_expr (&e->exp, 1);
+ 	break;
+       }
+ 
      default:
        abort ();
      }
*************** select_cie_for_fde (struct fde_entry *fd
*** 891,896 ****
--- 928,937 ----
  	      if (i->u.i != j->u.i)
  		goto fail;
  	      break;
+ 
+ 	    case CFI_escape:
+ 	      /* Don't bother matching these for now.  */
+ 	      goto fail;
  
  	    default:
  	      abort ();
Index: dw2gencfi.h
===================================================================
RCS file: /cvs/src/src/gas/dw2gencfi.h,v
retrieving revision 1.3
diff -c -p -d -r1.3 dw2gencfi.h
*** dw2gencfi.h	5 Jun 2003 09:23:47 -0000	1.3
--- dw2gencfi.h	11 Jun 2003 23:15:58 -0000
*************** extern void cfi_add_CFA_undefined (unsig
*** 48,53 ****
  extern void cfi_add_CFA_same_value (unsigned);
  extern void cfi_add_CFA_remember_state (void);
  extern void cfi_add_CFA_restore_state (void);
- extern void cfi_add_CFA_nop (void);
  
  #endif /* DW2GENCFI_H */
--- 48,52 ----
Index: read.c
===================================================================
RCS file: /cvs/src/src/gas/read.c,v
retrieving revision 1.63
diff -c -p -d -r1.63 read.c
*** read.c	2 Jun 2003 22:48:58 -0000	1.63
--- read.c	11 Jun 2003 23:15:58 -0000
*************** parse_repeat_cons PARAMS ((expressionS *
*** 3346,3351 ****
--- 3346,3358 ----
  #endif
  #endif
  
+ void
+ do_parse_cons_expression (expressionS *exp, int nbytes)
+ {
+   TC_PARSE_CONS_EXPRESSION (exp, nbytes);
+ }
+ 
+ 
  /* Worker to do .byte etc statements.
     Clobbers input_line_pointer and checks end-of-line.  */
  
Index: read.h
===================================================================
RCS file: /cvs/src/src/gas/read.h,v
retrieving revision 1.17
diff -c -p -d -r1.17 read.h
*** read.h	3 May 2003 06:10:59 -0000	1.17
--- read.h	11 Jun 2003 23:15:58 -0000
*************** extern void stabs_generate_asm_func PARA
*** 133,138 ****
--- 133,139 ----
  extern void stabs_generate_asm_endfunc PARAMS ((const char *, const char *));
  extern void do_repeat PARAMS((int,const char *,const char *));
  extern void end_repeat PARAMS((int));
+ extern void do_parse_cons_expression PARAMS ((expressionS *, int));
  
  extern void generate_lineno_debug PARAMS ((void));
  
Index: doc/as.texinfo
===================================================================
RCS file: /cvs/src/src/gas/doc/as.texinfo,v
retrieving revision 1.84
diff -c -p -d -r1.84 as.texinfo
*** doc/as.texinfo	10 Jun 2003 06:46:34 -0000	1.84
--- doc/as.texinfo	11 Jun 2003 23:15:59 -0000
*************** Some machine configurations provide addi
*** 3691,3703 ****
  * Byte::                        @code{.byte @var{expressions}}
  * Comm::                        @code{.comm @var{symbol} , @var{length} }
  
! * CFI directives::		@code{.cfi_startproc}
! 				@code{.cfi_endproc}
! 				@code{.cfi_def_cfa @var{register}, @var{offset}}
! 				@code{.cfi_def_cfa_register @var{register}}
! 				@code{.cfi_def_cfa_offset @var{offset}}
! 				@code{.cfi_adjust_cfa_offset @var{offset}}
! 				@code{.cfi_offset @var{register}, @var{offset}}
  
  * Data::                        @code{.data @var{subsection}}
  @ifset COFF
--- 3691,3697 ----
  * Byte::                        @code{.byte @var{expressions}}
  * Comm::                        @code{.comm @var{symbol} , @var{length} }
  
! * CFI directives::		@code{.cfi_startproc}, @code{.cfi_endproc}, etc.
  
  * Data::                        @code{.data @var{subsection}}
  @ifset COFF
*************** using the known displacement of the CFA 
*** 4020,4027 ****
  This is often easier to use, because the number will match the
  code it's annotating.
  
! @node Comm
! @section @code{.comm @var{symbol} , @var{length} }
  
  @cindex @code{comm} directive
  @cindex symbol, common
--- 4014,4023 ----
  This is often easier to use, because the number will match the
  code it's annotating.
  
! @section @code{.cfi_escape} @var{expression}[, @dots{}]
! Allows the user to add arbitrary bytes to the unwind info.  One
! might use this to add OS-specific CFI opcodes, or generic CFI
! opcodes that GAS does not yet support.
  
  @cindex @code{comm} directive
  @cindex symbol, common
Index: testsuite/gas/cfi/cfi-common-3.d
===================================================================
RCS file: testsuite/gas/cfi/cfi-common-3.d
diff -N testsuite/gas/cfi/cfi-common-3.d
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/gas/cfi/cfi-common-3.d	11 Jun 2003 23:15:59 -0000
***************
*** 0 ****
--- 1,21 ----
+ #readelf: -wf
+ #name: CFI common 2
+ The section .eh_frame contains:
+ 
+ 00000000 00000010 00000000 CIE
+   Version:               1
+   Augmentation:          "zR"
+   Code alignment factor: .*
+   Data alignment factor: .*
+   Return address column: .*
+   Augmentation data:     1b
+ 
+   DW_CFA_nop
+   DW_CFA_nop
+   DW_CFA_nop
+ 
+ 00000014 00000010 00000018 FDE cie=00000000 pc=.*
+   DW_CFA_advance_loc: 4 to .*
+   DW_CFA_remember_state
+   DW_CFA_restore_state
+ 
Index: testsuite/gas/cfi/cfi-common-3.s
===================================================================
RCS file: testsuite/gas/cfi/cfi-common-3.s
diff -N testsuite/gas/cfi/cfi-common-3.s
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/gas/cfi/cfi-common-3.s	11 Jun 2003 23:15:59 -0000
***************
*** 0 ****
--- 1,4 ----
+ 	.cfi_startproc simple
+ 	.long 0
+ 	.cfi_escape 10, 11
+ 	.cfi_endproc
Index: testsuite/gas/cfi/cfi.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/cfi/cfi.exp,v
retrieving revision 1.6
diff -c -p -d -r1.6 cfi.exp
*** testsuite/gas/cfi/cfi.exp	10 Jun 2003 13:31:59 -0000	1.6
--- testsuite/gas/cfi/cfi.exp	11 Jun 2003 23:15:59 -0000
*************** if [istarget "x86_64-*"] then {
*** 34,36 ****
--- 34,37 ----
  run_list_test "cfi-diag-1" ""
  run_dump_test "cfi-common-1"
  run_dump_test "cfi-common-2"
+ run_dump_test "cfi-common-3"


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