This is the mail archive of the gcc-bugs@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]

other/4932: the i386 backend crashes on incorrect asm("... %c0 ...")

[Get raw message]

>Number:         4932
>Category:       other
>Synopsis:       the i386 backend crashes on incorrect asm("... %c0 ...")
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          ice-on-illegal-code
>Submitter-Id:   net
>Arrival-Date:   Fri Nov 23 01:46:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Klaus Espenlaub
>Release:        gcc-3.0
>Organization:
>Environment:
System: Linux deadbeef 2.4.4-4GB #2 Fri Jul 20 08:48:42 CEST 2001 i686 unknown
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ./configure --enable-languages=c
>Description:
If an asm(...) output pattern contains the `%c' code, but
the actual operand isn't a constant, then the code in
i386.c tries to treat it as a condition code that should
be reversed - and that fails with a SIGSEGV.
>How-To-Repeat:
gcc testcase.c -S testcase.s
>Fix:
--- i386.c-orig	Fri Nov 23 10:29:42 2001
+++ i386.c	Fri Nov 23 10:35:19 2001
@@ -3522,6 +3522,15 @@ print_operand (file, x, code)
 
 	  /* Like above, but reverse condition */
 	case 'c':
+	  /* Buggy user-written assembler instructions may contain this code
+	   * (the user expects the meaning "output constant value without the
+	   * syntax that normally indicates an immediate operand"), but the
+	   * actual operand the compiler uses isn't a constant after all.  */
+	  if (GET_RTX_CLASS (GET_CODE (x)) != '<')
+	    {
+	      output_operand_lossage ("operand is neither a constant nor a condition code, invalid operand code `c'");
+	      return;
+	    }
 	  put_condition_code (GET_CODE (x), GET_MODE (XEXP (x, 0)), 1, 0, file);
 	  return;
 	case 'f':
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="testcase.c"
Content-Disposition: inline; filename="testcase.c"

void *abc;

int main(void)
{
	__asm__ __volatile__("some assembly code containing %c0"
		: /* no output */ : "ir" (abc));
}


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