This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Fix a segfault in h8300 port.
- To: gcc-patches at gcc dot gnu dot org
- Subject: [patch] Fix a segfault in h8300 port.
- From: Kazu Hirata <kazu at hxi dot com>
Hi,
Attached is a patch to fix the cause of a segfault in h8300 port.
Specifically, with the patch applied, gcc handles the following
correctly.
char tiny __attribute__ ((tiny_data)) = 0;
char
foo (void)
{
return tiny;
}
Tested on h8300 port. OK to apply to both branches?
Kazu Hirata
2001-10-29 Kazu Hirata <kazu@hxi.com>
* config/h8300/h8300.c (h8300_encode_label): Compute a string
before passing it to ggc_alloc_string.
Index: h8300.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.c,v
retrieving revision 1.72
diff -c -r1.72 h8300.c
*** h8300.c 2001/10/26 21:08:47 1.72
--- h8300.c 2001/10/29 23:42:52
***************
*** 3108,3120 ****
{
const char *str = XSTR (XEXP (DECL_RTL (decl), 0), 0);
int len = strlen (str);
! char *newstr;
! newstr = ggc_alloc_string (NULL, len + 1);
! strcpy (newstr + 1, str);
! *newstr = '&';
! XSTR (XEXP (DECL_RTL (decl), 0), 0) = newstr;
}
const char *
--- 3108,3120 ----
{
const char *str = XSTR (XEXP (DECL_RTL (decl), 0), 0);
int len = strlen (str);
! char *newstr = alloca (len + 2);
! newstr[0] = '&';
! strcpy (&newstr[1], str);
! XSTR (XEXP (DECL_RTL (decl), 0), 0) =
! ggc_alloc_string (newstr, len + 1);
}
const char *