public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] internal error when .cfi_remember_state encountered first in a function
@ 2004-10-07  9:43 Jan Beulich
  2004-10-07 15:19 ` Nick Clifton
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2004-10-07  9:43 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 3531 bytes --]

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"));
 }
 
 \f
@@ -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 #2: binutils-mainline-cfi-remember-state.patch --]
[-- Type: application/octet-stream, Size: 3530 bytes --]

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"));
 }
 
 \f
@@ -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"

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] internal error when .cfi_remember_state encountered first in a function
  2004-10-07  9:43 [PATCH] internal error when .cfi_remember_state encountered first in a function Jan Beulich
@ 2004-10-07 15:19 ` Nick Clifton
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Clifton @ 2004-10-07 15:19 UTC (permalink / raw)
  To: Jan Beulich; +Cc: binutils

Hi 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.

Approved and applied.

Cheers
   Nick


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-10-07 15:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-07  9:43 [PATCH] internal error when .cfi_remember_state encountered first in a function Jan Beulich
2004-10-07 15:19 ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).