This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils 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]

[PATCH] internal error when .cfi_remember_state encounteredfirst in a function


When generating Dwarf unwind information, a .cfi_remember_state
encountered
prior to any advance of the location counter caused an internal error.

Built and tested on i686-pc-linux-gnu.

Jan

gas/
2004-10-07  Jan Beulich  <jbeulich@novell.com>

	* dw2gencfi.c (select_cie_for_fde): When separating CIE out
from
	FDE, treat a DW_CFA_remember_state as we do a
DW_CFA_advance_loc.

gas/testsuite/
2004-10-07  Jan Beulich  <jbeulich@novell.com>

	* cfi/cfi-common-4.[ds]: New.
	* cfi/cfi.exp: Run new test.

---
/home/jbeulich/src/binutils/mainline/2004-10-06.09.37/gas/dw2gencfi.c	2004-10-06
09:35:49.000000000 +0200
+++ 2004-10-06.09.37/gas/dw2gencfi.c	2004-10-07 11:27:11.726089600
+0200
@@ -341,6 +341,8 @@ cfi_add_CFA_restore_state (void)
       cfa_save_stack = p->next;
       free (p);
     }
+  else
+    as_bad (_("CFI state restore without previous remember"));
 }
 
 
@@ -933,8 +935,9 @@ select_cie_for_fde (struct fde_entry *fd
 	  switch (i->insn)
 	    {
 	    case DW_CFA_advance_loc:
-	      /* We reached the first advance in the FDE, but did not
-		 reach the end of the CIE list.  */
+	    case DW_CFA_remember_state:
+	      /* We reached the first advance/remember in the FDE, but
+		 did not reach the end of the CIE list.  */
 	      goto fail;
 
 	    case DW_CFA_offset:
@@ -975,11 +978,12 @@ select_cie_for_fde (struct fde_entry *fd
 	}
 
       /* Success if we reached the end of the CIE list, and we've
either
-	 run out of FDE entries or we've encountered an advance or
-	 escape.  */
+	 run out of FDE entries or we've encountered an advance,
+	 remember, or escape.  */
       if (i == cie->last
 	  && (!j
 	      || j->insn == DW_CFA_advance_loc
+	      || j->insn == DW_CFA_remember_state
 	      || j->insn == CFI_escape))
 	{
 	  *pfirst = j;
@@ -997,6 +1001,7 @@ select_cie_for_fde (struct fde_entry *fd
 
   for (i = cie->first; i ; i = i->next)
     if (i->insn == DW_CFA_advance_loc
+	|| i->insn == DW_CFA_remember_state
 	|| i->insn == CFI_escape)
       break;
 
---
/home/jbeulich/src/binutils/mainline/2004-10-06.09.37/gas/testsuite/gas/cfi/cfi-common-4.d	1970-01-01
01:00:00.000000000 +0100
+++
2004-10-06.09.37/gas/testsuite/gas/cfi/cfi-common-4.d	2004-10-07
11:15:25.000000000 +0200
@@ -0,0 +1,20 @@
+#readelf: -wf
+#name: CFI common 4
+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
+#...
+00000014 00000010 00000018 FDE cie=00000000 pc=.*
+  DW_CFA_remember_state
+  DW_CFA_restore_state
+#...
+00000028 00000010 0000002c FDE cie=00000000 pc=.*
+  DW_CFA_remember_state
+  DW_CFA_restore_state
+#pass
---
/home/jbeulich/src/binutils/mainline/2004-10-06.09.37/gas/testsuite/gas/cfi/cfi-common-4.s	1970-01-01
01:00:00.000000000 +0100
+++
2004-10-06.09.37/gas/testsuite/gas/cfi/cfi-common-4.s	2004-10-07
11:16:54.000000000 +0200
@@ -0,0 +1,9 @@
+	.cfi_startproc simple
+	.cfi_remember_state
+	.cfi_restore_state
+	.cfi_endproc
+
+	.cfi_startproc simple
+	.cfi_remember_state
+	.cfi_restore_state
+	.cfi_endproc
---
/home/jbeulich/src/binutils/mainline/2004-10-06.09.37/gas/testsuite/gas/cfi/cfi.exp	2004-03-18
01:49:23.000000000 +0100
+++ 2004-10-06.09.37/gas/testsuite/gas/cfi/cfi.exp	2004-10-07
11:22:19.538508864 +0200
@@ -64,3 +64,4 @@ run_list_test "cfi-diag-1" ""
 run_dump_test "cfi-common-1"
 run_dump_test "cfi-common-2"
 run_dump_test "cfi-common-3"
+run_dump_test "cfi-common-4"

Attachment: binutils-mainline-cfi-remember-state.patch
Description: Binary data


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