This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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]

sim/ppc: fix aliasing bugs


invalid_arithemetic_operation expects a unsigned64*, but was passed a
double* or even float*.

Andreas.

2010-02-01  Andreas Schwab  <schwab@linux-m68k.org>

	* ppc-instructions: Fix aliasing bugs when calling
	invalid_arithemetic_operation.

Index: sim/ppc/ppc-instructions
===================================================================
RCS file: /cvs/src/src/sim/ppc/ppc-instructions,v
retrieving revision 1.11
diff -u -a -p -r1.11 sim/ppc/ppc-instructions
--- sim/ppc/ppc-instructions	12 Jan 2009 20:04:36 -0000	1.11
+++ sim/ppc/ppc-instructions	1 Feb 2010 18:41:58 -0000
@@ -3973,12 +3973,14 @@ void::function::invalid_zero_divide_oper
 	                         fpscr_vxsnan | fpscr_vximz,
 	                         0, /*single?*/
 	                         0) /*negate?*/) {
+	  union { double d; unsigned64 u; } tmp;
 	  invalid_arithemetic_operation(processor, cia,
-	                                (unsigned64*)&product, *frA, 0, *frC,
+	                                &tmp.u, *frA, 0, *frC,
 	                                0, /*instruction_is_frsp*/
 	                                0, /*instruction_is_convert_to_64bit*/
 	                                0, /*instruction_is_convert_to_32bit*/
 	                                0); /*single-precision*/
+	  product = tmp.d;
 	}
 	else {
 	  /*HACK!*/
@@ -4018,12 +4020,14 @@ void::function::invalid_zero_divide_oper
 	                         fpscr_vxsnan | fpscr_vximz,
 	                         1, /*single?*/
 	                         0) /*negate?*/) {
+	  union { double d; unsigned64 u; } tmp;
 	  invalid_arithemetic_operation(processor, cia,
-	                                (unsigned64*)&product, *frA, 0, *frC,
+	                                &tmp.u, *frA, 0, *frC,
 	                                0, /*instruction_is_frsp*/
 	                                0, /*instruction_is_convert_to_64bit*/
 	                                0, /*instruction_is_convert_to_32bit*/
 	                                0); /*single-precision*/
+	  product = tmp.d;
 	}
 	else {
 	  /*HACK!*/
@@ -4063,12 +4067,14 @@ void::function::invalid_zero_divide_oper
 	                         fpscr_vxsnan | fpscr_vximz,
 	                         0, /*single?*/
 	                         0) /*negate?*/) {
+	  union { double d; unsigned64 u; } tmp;
 	  invalid_arithemetic_operation(processor, cia,
-	                                (unsigned64*)&product, *frA, 0, *frC,
+	                                &tmp.u, *frA, 0, *frC,
 	                                0, /*instruction_is_frsp*/
 	                                0, /*instruction_is_convert_to_64bit*/
 	                                0, /*instruction_is_convert_to_32bit*/
 	                                0); /*single-precision*/
+	  product = tmp.d;
 	}
 	else {
 	  /*HACK!*/
@@ -4108,12 +4114,14 @@ void::function::invalid_zero_divide_oper
 	                         fpscr_vxsnan | fpscr_vximz,
 	                         1, /*single?*/
 	                         0) /*negate?*/) {
+	  union { double d; unsigned64 u; } tmp;
 	  invalid_arithemetic_operation(processor, cia,
-	                                (unsigned64*)&product, *frA, 0, *frC,
+	                                &tmp.u, *frA, 0, *frC,
 	                                0, /*instruction_is_frsp*/
 	                                0, /*instruction_is_convert_to_64bit*/
 	                                0, /*instruction_is_convert_to_32bit*/
 	                                0); /*single-precision*/
+	  product = tmp.d;
 	}
 	else {
 	  /*HACK!*/
@@ -4153,8 +4161,9 @@ void::function::invalid_zero_divide_oper
 	                         fpscr_vxsnan | fpscr_vximz,
 	                         0, /*single?*/
 	                         0) /*negate?*/) {
+	  union { double d; unsigned64 u; } tmp;
 	  invalid_arithemetic_operation(processor, cia,
-	                                (unsigned64*)&product, *frA, 0, *frC,
+	                                &tmp.u, *frA, 0, *frC,
 	                                0, /*instruction_is_frsp*/
 	                                0, /*instruction_is_convert_to_64bit*/
 	                                0, /*instruction_is_convert_to_32bit*/
@@ -4198,12 +4207,14 @@ void::function::invalid_zero_divide_oper
 	                         fpscr_vxsnan | fpscr_vximz,
 	                         1, /*single?*/
 	                         0) /*negate?*/) {
+	  union { double d; unsigned64 u; } tmp;
 	  invalid_arithemetic_operation(processor, cia,
-	                                (unsigned64*)&product, *frA, 0, *frC,
+	                                &tmp.u, *frA, 0, *frC,
 	                                0, /*instruction_is_frsp*/
 	                                0, /*instruction_is_convert_to_64bit*/
 	                                0, /*instruction_is_convert_to_32bit*/
 	                                0); /*single-precision*/
+	  product = tmp.d;
 	}
 	else {
 	  /*HACK!*/
@@ -4243,12 +4254,14 @@ void::function::invalid_zero_divide_oper
 	                         fpscr_vxsnan | fpscr_vximz,
 	                         0, /*single?*/
 	                         0) /*negate?*/) {
+	  union { double d; unsigned64 u; } tmp;
 	  invalid_arithemetic_operation(processor, cia,
-	                                (unsigned64*)&product, *frA, 0, *frC,
+	                                &tmp.u, *frA, 0, *frC,
 	                                0, /*instruction_is_frsp*/
 	                                0, /*instruction_is_convert_to_64bit*/
 	                                0, /*instruction_is_convert_to_32bit*/
 	                                0); /*single-precision*/
+	  product = tmp.d;
 	}
 	else {
 	  /*HACK!*/
@@ -4288,12 +4301,14 @@ void::function::invalid_zero_divide_oper
 	                         fpscr_vxsnan | fpscr_vximz,
 	                         1, /*single?*/
 	                         0) /*negate?*/) {
+	  union { double d; unsigned64 u; } tmp;
 	  invalid_arithemetic_operation(processor, cia,
-	                                (unsigned64*)&product, *frA, 0, *frC,
+	                                &tmp.u, *frA, 0, *frC,
 	                                0, /*instruction_is_frsp*/
 	                                0, /*instruction_is_convert_to_64bit*/
 	                                0, /*instruction_is_convert_to_32bit*/
 	                                0); /*single-precision*/
+	  product = tmp.d;
 	}
 	else {
 	  /*HACK!*/

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


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