diff options
author | Alan Modra <amodra@gmail.com> | 2016-03-22 22:38:53 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2016-03-22 22:47:05 +1030 |
commit | 39a0d071ae10ab953d6bb986ec40996c771db78f (patch) | |
tree | ae2a382a2f36b610d97e726749bead160afc90ce | |
parent | 96254e5c28ebcaaa89b4bdc24eab0a546dd269f2 (diff) | |
download | gdb-39a0d071ae10ab953d6bb986ec40996c771db78f.zip gdb-39a0d071ae10ab953d6bb986ec40996c771db78f.tar.gz gdb-39a0d071ae10ab953d6bb986ec40996c771db78f.tar.bz2 |
Remove more alloca calls
* config/tc-alpha.c (load_expression): Replace alloca with xmalloc.
(emit_jsrjmp, tc_gen_reloc): Likewise.
* config/tc-i370.c (i370_macro): Likewise.
-rw-r--r-- | gas/ChangeLog | 6 | ||||
-rw-r--r-- | gas/config/tc-alpha.c | 12 | ||||
-rw-r--r-- | gas/config/tc-i370.c | 3 |
3 files changed, 16 insertions, 5 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index 43e467e..9c2b9ec 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,9 @@ +2016-03-22 Alan Modra <amodra@gmail.com> + + * config/tc-alpha.c (load_expression): Replace alloca with xmalloc. + (emit_jsrjmp, tc_gen_reloc): Likewise. + * config/tc-i370.c (i370_macro): Likewise. + 2016-03-22 Nick Clifton <nickc@redhat.com> * configure: Regenerate. diff --git a/gas/config/tc-alpha.c b/gas/config/tc-alpha.c index e849a95..4b86d4b 100644 --- a/gas/config/tc-alpha.c +++ b/gas/config/tc-alpha.c @@ -1384,13 +1384,14 @@ load_expression (int targreg, ptr1 = strstr (symname, "..") + 2; if (ptr1 > ptr2) ptr1 = symname; - ensymname = (char *) alloca (ptr2 - ptr1 + 5); + ensymname = (char *) xmalloc (ptr2 - ptr1 + 5); memcpy (ensymname, ptr1, ptr2 - ptr1); memcpy (ensymname + (ptr2 - ptr1), "..en", 5); gas_assert (insn.nfixups + 1 <= MAX_INSN_FIXUPS); insn.fixups[insn.nfixups].reloc = BFD_RELOC_ALPHA_NOP; ensym = symbol_find_or_make (ensymname); + free (ensymname); symbol_mark_used (ensym); /* The fixup must be the same as the BFD_RELOC_ALPHA_BOH case in emit_jsrjmp. See B.4.5.2 of the OpenVMS Linker @@ -1416,13 +1417,14 @@ load_expression (int targreg, ptr1 = strstr (symname, "..") + 2; if (ptr1 > ptr2) ptr1 = symname; - psymname = (char *) alloca (ptr2 - ptr1 + 1); + psymname = (char *) xmalloc (ptr2 - ptr1 + 1); memcpy (psymname, ptr1, ptr2 - ptr1); psymname [ptr2 - ptr1] = 0; gas_assert (insn.nfixups + 1 <= MAX_INSN_FIXUPS); insn.fixups[insn.nfixups].reloc = BFD_RELOC_ALPHA_LDA; psym = symbol_find_or_make (psymname); + free (psymname); symbol_mark_used (psym); insn.fixups[insn.nfixups].exp.X_op = O_subtract; insn.fixups[insn.nfixups].exp.X_add_symbol = psym; @@ -2881,7 +2883,7 @@ emit_jsrjmp (const expressionS *tok, char *ensymname; /* Build the entry name as 'NAME..en'. */ - ensymname = (char *) alloca (symlen + 5); + ensymname = (char *) xmalloc (symlen + 5); memcpy (ensymname, symname, symlen); memcpy (ensymname + symlen, "..en", 5); @@ -2903,6 +2905,7 @@ emit_jsrjmp (const expressionS *tok, insn.fixups[0].procsym = alpha_evax_proc->symbol; insn.nfixups++; alpha_linkage_symbol = 0; + free (ensymname); } #endif @@ -6279,11 +6282,12 @@ tc_gen_reloc (asection *sec ATTRIBUTE_UNUSED, if (pname_len > 4 && strcmp (pname + pname_len - 4, "..en") == 0) { symbolS *sym; - char *my_pname = (char *) alloca (pname_len - 4 + 1); + char *my_pname = (char *) xmalloc (pname_len - 4 + 1); memcpy (my_pname, pname, pname_len - 4); my_pname [pname_len - 4] = 0; sym = symbol_find (my_pname); + free (my_pname); if (sym == NULL) abort (); diff --git a/gas/config/tc-i370.c b/gas/config/tc-i370.c index bfcc0b3..a20c10c 100644 --- a/gas/config/tc-i370.c +++ b/gas/config/tc-i370.c @@ -1867,7 +1867,7 @@ i370_macro (char *str, const struct i370_macro *macro) } /* Put the string together. */ - complete = s = alloca (len + 1); + complete = s = xmalloc (len + 1); format = macro->format; while (*format != '\0') { @@ -1885,6 +1885,7 @@ i370_macro (char *str, const struct i370_macro *macro) /* Assemble the constructed instruction. */ md_assemble (complete); + free (complete); } /* This routine is called for each instruction to be assembled. */ |