From: Alan Modra Date: Thu, 1 Feb 2001 01:11:28 +0000 (+0000) Subject: pa.c (hppa_encode_label): Correct size of alloca buffer so we don't overrun it. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=10d17cb7bdfbdb3fe483e5825fc8d11223d6f11d;p=gcc.git pa.c (hppa_encode_label): Correct size of alloca buffer so we don't overrun it. * pa.c (hppa_encode_label): Correct size of alloca buffer so we don't overrun it. Correct leading `*' case. * pa.h (STRIP_NAME_ENCODING): Simplify now that we don't need to handle `*@'. (FUNCTION_NAME_P): Likewise. From-SVN: r39385 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d8c0c5afe4c..f9c693afdc7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2001-01-31 Alan Modra + + * pa.c (hppa_encode_label): Correct size of alloca buffer + so we don't overrun it. Correct leading `*' case. + * pa.h (STRIP_NAME_ENCODING): Simplify now that we don't + need to handle `*@'. + (FUNCTION_NAME_P): Likewise. + 2001-01-31 Richard Henderson * config.gcc (alpha-osf5): Use float-i128.h. diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c index aad9345ed35..738afbeb344 100644 --- a/gcc/config/pa/pa.c +++ b/gcc/config/pa/pa.c @@ -5965,18 +5965,17 @@ hppa_encode_label (sym) rtx sym; { const char *str = XSTR (sym, 0); - int len = strlen (str); - char *newstr = alloca (len + 1); + int len = strlen (str) + 1; + char *newstr, *p; + p = newstr = alloca (len + 1); if (str[0] == '*') - *newstr++ = *str++; - strcpy (newstr + 1, str); - *newstr = '@'; - - /* Prepending '@' increases the length of the string. That's important - to note since we're going to allocate persistent storage for the - new string. */ - len++; + { + str++; + len--; + } + *p++ = '@'; + strcpy (p, str); XSTR (sym,0) = ggc_alloc_string (newstr, len); } diff --git a/gcc/config/pa/pa.h b/gcc/config/pa/pa.h index 898008e7305..a5c7a32d955 100644 --- a/gcc/config/pa/pa.h +++ b/gcc/config/pa/pa.h @@ -1488,8 +1488,7 @@ do { \ || (TREE_CODE_CLASS (TREE_CODE (DECL)) == 'c' \ && !(TREE_CODE (DECL) == STRING_CST && flag_writable_strings))) -#define FUNCTION_NAME_P(NAME) \ -(*(NAME) == '@' || (*(NAME) == '*' && *((NAME) + 1) == '@')) +#define FUNCTION_NAME_P(NAME) (*(NAME) == '@') #define ENCODE_SECTION_INFO(DECL)\ do \ @@ -1511,9 +1510,8 @@ while (0) This is sort of inverse to ENCODE_SECTION_INFO. */ #define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \ - (VAR) = ((SYMBOL_NAME) + ((SYMBOL_NAME)[0] == '*' ? \ - 1 + (SYMBOL_NAME)[1] == '@'\ - : (SYMBOL_NAME)[0] == '@')) + (VAR) = ((SYMBOL_NAME) \ + + (*(SYMBOL_NAME) == '*' || *(SYMBOL_NAME) == '@')) /* Specify the machine mode that this machine uses for the index in the tablejump instruction. */