This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] fix out of bound access on hard_regno_nregs
- From: Martin Koegler <mkoegler at auto dot tuwien dot ac dot at>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 19 Dec 2004 17:19:04 +0100
- Subject: [PATCH] fix out of bound access on hard_regno_nregs
true_regnum can return in certain situations the number of a pseudo-register.
In that case, the return value will be used to access hard_regno_nregs.
hard_regno_nregs has only FIRST_PSEUDO_REGISTER elements, so an undefined value
may be used or gcc can even segfault.
The patch redirects these situation to the pseudo-register case.
The patch is against the cvs mainline.
Index: reload.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reload.c,v
retrieving revision 1.261
diff -u -r1.261 reload.c
--- reload.c 15 Dec 2004 20:22:26 -0000 1.261
+++ reload.c 19 Dec 2004 15:56:18 -0000
@@ -2371,7 +2371,7 @@
case REG:
val.reg_flag = 1;
val.start = true_regnum (x);
- if (val.start < 0)
+ if (val.start < 0 || val.start >= FIRST_PSEUDO_REGISTER)
{
/* A pseudo with no hard reg. */
val.start = REGNO (x);
@@ -2388,7 +2388,7 @@
return decompose (SUBREG_REG (x));
val.reg_flag = 1;
val.start = true_regnum (x);
- if (val.start < 0)
+ if (val.start < 0 || val.start >= FIRST_PSEUDO_REGISTER)
return decompose (SUBREG_REG (x));
else
/* A hard reg. */
For more information see
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18877
mfg Martin Kögler
e9925248@stud4.tuwien.ac.at