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

[patch] Fix a segfault in h8300 port.


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 *


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