+2016-03-21 Nick Clifton <nickc@redhat.com>
+
+ * warning.m4 (GCC_WARN_CFLAGS): Add -Wstack-usage=262144
+ * configure: Regenerate.
+ * elf32-m68hc1x.c (elf32_m68hc11_relocate_section): Replace use of
+ alloca with call to xmalloc.
+ * elf32-nds32.c: Likewise.
+ * elf64-hppa.c: Likewise.
+ * elfxx-mips.c: Likewise.
+ * pef.c: Likewise.
+ * pei-x86_64.c: Likewise.
+ * som.c: Likewise.
+ * xsym.c: Likewise.
+
2016-03-15 H.J. Lu <hongjiu.lu@intel.com>
PR ld/19827
NO_WERROR=
if test "${ERROR_ON_WARNING}" = yes ; then
- GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror"
+ GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror -Wstack-usage=262144"
NO_WERROR="-Wno-error"
fi
#include "elf32-m68hc1x.h"
#include "elf/m68hc11.h"
#include "opcode/m68hc11.h"
-
+#include "libiberty.h"
#define m68hc12_stub_hash_lookup(table, string, create, copy) \
((struct elf32_m68hc11_stub_hash_entry *) \
result = (* htab->build_one_stub) (gen_entry, in_arg);
/* Make a printable name that does not conflict with the real function. */
- name = alloca (strlen (stub_entry->root.string) + 16);
- sprintf (name, "tramp.%s", stub_entry->root.string);
+ name = concat ("tramp.", stub_entry->root.string, NULL);
/* Export the symbol for debugging/disassembling. */
m68hc11_elf_set_symbol (htab->stub_bfd, info, name,
stub_entry->stub_offset,
stub_entry->stub_sec);
+ free (name);
return result;
}
bfd_boolean is_section_symbol = FALSE;
struct elf_link_hash_entry *h;
bfd_vma val;
+ const char * msg;
+ char * buf;
+ bfd_boolean res;
r_symndx = ELF32_R_SYM (rel->r_info);
r_type = ELF32_R_TYPE (rel->r_info);
/* Get virtual address of instruction having the relocation. */
if (is_far)
{
- const char* msg;
- char* buf;
msg = _("Reference to the far symbol `%s' using a wrong "
"relocation may result in incorrect execution");
- buf = alloca (strlen (msg) + strlen (name) + 10);
+ buf = xmalloc (strlen (msg) + strlen (name) + 10);
sprintf (buf, msg, name);
(* info->callbacks->warning)
(info, buf, name, input_bfd, NULL, rel->r_offset);
+ free (buf);
}
/* Get virtual address of instruction having the relocation. */
}
else
{
- const char * msg;
- char * buf;
-
msg = _("XGATE address (%lx) is not within shared RAM"
"(0xE000-0xFFFF), therefore you must manually offset "
"the address, and possibly manage the page, in your "
"code.");
- buf = alloca (strlen (msg) + 128);
+ buf = xmalloc (strlen (msg) + 128);
sprintf (buf, msg, phys_addr);
- if (!((*info->callbacks->warning) (info, buf, name, input_bfd,
- input_section, insn_addr)))
+ res = (*info->callbacks->warning) (info, buf, name, input_bfd,
+ input_section, insn_addr);
+ free (buf);
+ if (! res)
return FALSE;
break;
}
&& m68hc11_addr_is_banked (pinfo, insn_addr)
&& phys_page != insn_page && !(e_flags & E_M68HC11_NO_BANK_WARNING))
{
- const char * msg;
- char * buf;
-
msg = _("banked address [%lx:%04lx] (%lx) is not in the same bank "
"as current banked address [%lx:%04lx] (%lx)");
-
- buf = alloca (strlen (msg) + 128);
+ buf = xmalloc (strlen (msg) + 128);
sprintf (buf, msg, phys_page, phys_addr,
(long) (relocation + rel->r_addend),
insn_page, m68hc11_phys_addr (pinfo, insn_addr),
(long) (insn_addr));
- if (!((*info->callbacks->warning)
- (info, buf, name, input_bfd, input_section,
- rel->r_offset)))
+ res = (*info->callbacks->warning)
+ (info, buf, name, input_bfd, input_section, rel->r_offset);
+ free (buf);
+ if (! res)
return FALSE;
break;
}
if (phys_page != 0 && insn_page == 0)
{
- const char * msg;
- char * buf;
-
msg = _("reference to a banked address [%lx:%04lx] in the "
"normal address space at %04lx");
-
- buf = alloca (strlen (msg) + 128);
+ buf = xmalloc (strlen (msg) + 128);
sprintf (buf, msg, phys_page, phys_addr, insn_addr);
- if (!((*info->callbacks->warning)
- (info, buf, name, input_bfd, input_section,
- insn_addr)))
+ res = (*info->callbacks->warning)
+ (info, buf, name, input_bfd, input_section, insn_addr);
+ free (buf);
+ if (! res)
return FALSE;
relocation = phys_addr;
relocation += 0xC000;
else
{
- const char * msg;
- char * buf;
-
/* Get virtual address of instruction having the relocation. */
insn_addr = input_section->output_section->vma
+ input_section->output_offset + rel->r_offset;
msg = _("S12 address (%lx) is not within shared RAM"
"(0x2000-0x4000), therefore you must manually "
"offset the address in your code");
- buf = alloca (strlen (msg) + 128);
+ buf = xmalloc (strlen (msg) + 128);
sprintf (buf, msg, phys_addr);
- if (!((*info->callbacks->warning) (info, buf, name, input_bfd,
- input_section, insn_addr)))
+ res = (*info->callbacks->warning) (info, buf, name, input_bfd,
+ input_section, insn_addr);
+ free (buf);
+ if (! res)
return FALSE;
break;
}
if (r != bfd_reloc_ok)
{
- const char * msg = (const char *) 0;
-
switch (r)
{
case bfd_reloc_overflow:
{
char *ptr = (char *) base;
int i, j;
- char *tmp = alloca (size);
+ char *tmp = xmalloc (size);
/* If i is less than j, i is inserted before j.
memmove (ptr + (j + 1) * size, ptr + j * size, (i - j) * size);
memcpy (ptr + j * size, tmp, size);
}
+ free (tmp);
}
/* Sort relocation by r_offset.
#include "elf/hppa.h"
#include "libhppa.h"
#include "elf64-hppa.h"
-
+#include "libiberty.h"
#define ARCH_SIZE 64
char *new_name;
struct elf_link_hash_entry *nh;
- new_name = alloca (strlen (eh->root.root.string) + 2);
- new_name[0] = '.';
- strcpy (new_name + 1, eh->root.root.string);
+ new_name = concat (".", eh->root.root.string, NULL);
nh = elf_link_hash_lookup (elf_hash_table (x->info),
new_name, TRUE, TRUE, TRUE);
+ free (new_name);
nh->root.type = eh->root.type;
nh->root.u.def.value = eh->root.u.def.value;
nh->root.u.def.section = eh->root.u.def.section;
if (! bfd_elf_link_record_dynamic_symbol (x->info, nh))
return FALSE;
-
}
hh->opd_offset = x->ofs;
x->ofs += OPD_ENTRY_SIZE;
char *new_name;
struct elf_link_hash_entry *nh;
- new_name = alloca (strlen (eh->root.root.string) + 2);
- new_name[0] = '.';
- strcpy (new_name + 1, eh->root.root.string);
+ new_name = concat (".", eh->root.root.string, NULL);
nh = elf_link_hash_lookup (elf_hash_table (info),
new_name, TRUE, TRUE, FALSE);
symbol index. */
if (nh)
dynindx = nh->dynindx;
+ free (new_name);
}
rel.r_addend = 0;
{
struct bfd_link_hash_entry *bh;
struct elf_link_hash_entry *elfh;
- const char *name;
+ char *name;
+ bfd_boolean res;
if (ELF_ST_IS_MICROMIPS (h->root.other))
value |= 1;
/* Create a new symbol. */
- name = ACONCAT ((prefix, h->root.root.root.string, NULL));
+ name = concat (prefix, h->root.root.root.string, NULL);
bh = NULL;
- if (!_bfd_generic_link_add_one_symbol (info, s->owner, name,
- BSF_LOCAL, s, value, NULL,
- TRUE, FALSE, &bh))
+ res = _bfd_generic_link_add_one_symbol (info, s->owner, name,
+ BSF_LOCAL, s, value, NULL,
+ TRUE, FALSE, &bh);
+ free (name);
+ if (! res)
return FALSE;
/* Make it a local function. */
{
struct bfd_link_hash_entry *bh;
struct elf_link_hash_entry *elfh;
- const char *name;
+ char *name;
asection *s;
bfd_vma value;
+ bfd_boolean res;
/* Read the symbol's value. */
BFD_ASSERT (h->root.root.type == bfd_link_hash_defined
value = h->root.root.u.def.value;
/* Create a new symbol. */
- name = ACONCAT ((prefix, h->root.root.root.string, NULL));
+ name = concat (prefix, h->root.root.root.string, NULL);
bh = NULL;
- if (!_bfd_generic_link_add_one_symbol (info, s->owner, name,
- BSF_LOCAL, s, value, NULL,
- TRUE, FALSE, &bh))
+ res = _bfd_generic_link_add_one_symbol (info, s->owner, name,
+ BSF_LOCAL, s, value, NULL,
+ TRUE, FALSE, &bh);
+ free (name);
+ if (! res)
return FALSE;
/* Make it local and copy the other attributes from H. */
fprintf (file, " %-5s %s", symbol->section->name, symbol->name);
if (CONST_STRNEQ (symbol->name, "__traceback_"))
{
- unsigned char *buf = alloca (symbol->udata.i);
+ unsigned char *buf = xmalloc (symbol->udata.i);
size_t offset = symbol->value + 4;
size_t len = symbol->udata.i;
int ret;
len, 0, NULL, file);
if (ret < 0)
fprintf (file, " [ERROR]");
+ free (buf);
}
}
}
if (strcmp (pdata_section->name, ".pdata") != 0)
{
size_t len = strlen (pdata_section->name);
- char *xdata_name = alloca (len + 1);
+ char *xdata_name = xmalloc (len + 1);
xdata_name = memcpy (xdata_name, pdata_section->name, len + 1);
/* Transform .pdata prefix into .xdata prefix. */
xdata_name [1] = 'x';
xdata_section = pex64_get_section_by_rva (abfd, xdata_base,
xdata_name);
+ free (xdata_name);
}
/* Second, try the .xdata section itself. */
if (!xdata_section)
#include "sysdep.h"
#include "alloca-conf.h"
#include "bfd.h"
-
+#include "libiberty.h"
#include "libbfd.h"
#include "som.h"
#include "safe-ctype.h"
/* Chunk of memory that we can use as buffer space, then throw
away. */
size_t tmp_space_size = SOM_TMP_BUFSIZE;
- char *tmp_space = alloca (tmp_space_size);
+ char *tmp_space = xmalloc (tmp_space_size);
char *p = tmp_space;
unsigned int strings_size = 0;
asection *section;
bfd_size_type amt;
+ bfd_size_type res;
/* Seek to the start of the space strings in preparation for writing
them out. */
tmp_space_size = length + 5;
else
tmp_space_size = 2 * tmp_space_size;
- tmp_space = alloca (tmp_space_size);
+ tmp_space = xrealloc (tmp_space, tmp_space_size);
}
/* Reset to beginning of the (possibly new) buffer space. */
/* Done with the space/subspace strings. Write out any information
contained in a partial block. */
amt = p - tmp_space;
- if (bfd_bwrite ((void *) &tmp_space[0], amt, abfd) != amt)
+ res = bfd_bwrite ((void *) &tmp_space[0], amt, abfd);
+ free (tmp_space);
+ if (res != amt)
return FALSE;
*string_sizep = strings_size;
return TRUE;
struct som_compilation_unit *compilation_unit)
{
unsigned int i;
-
/* Chunk of memory that we can use as buffer space, then throw
away. */
size_t tmp_space_size = SOM_TMP_BUFSIZE;
- char *tmp_space = alloca (tmp_space_size);
+ char *tmp_space = xmalloc (tmp_space_size);
char *p = tmp_space;
-
unsigned int strings_size = 0;
bfd_size_type amt;
+ bfd_size_type res;
/* This gets a bit gruesome because of the compilation unit. The
strings within the compilation unit are part of the symbol
tmp_space_size = 5 + length;
else
tmp_space_size = 2 * tmp_space_size;
- tmp_space = alloca (tmp_space_size);
+ tmp_space = xrealloc (tmp_space, tmp_space_size);
}
/* Reset to beginning of the (possibly new) buffer
tmp_space_size = 5 + length;
else
tmp_space_size = 2 * tmp_space_size;
- tmp_space = alloca (tmp_space_size);
+ tmp_space = xrealloc (tmp_space, tmp_space_size);
}
/* Reset to beginning of the (possibly new) buffer space. */
/* Scribble out any partial block. */
amt = p - tmp_space;
- if (bfd_bwrite ((void *) &tmp_space[0], amt, abfd) != amt)
+ res = bfd_bwrite ((void *) &tmp_space[0], amt, abfd);
+ free (tmp_space);
+ if (res != amt)
return FALSE;
*string_sizep = strings_size;
NO_WERROR=
if test "${ERROR_ON_WARNING}" = yes ; then
- GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror"
+ GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror -Wstack-usage=262144"
NO_WERROR="-Wno-error"
fi
fprintf (f, "\n ");
- buf = alloca (entry->physical_size);
+ buf = malloc (entry->physical_size);
if (buf == NULL)
{
fprintf (f, "[ERROR]\n");
if (bfd_seek (abfd, entry->offset, SEEK_SET) < 0)
{
fprintf (f, "[ERROR]\n");
+ free (buf);
return;
}
if (bfd_bread (buf, entry->physical_size, abfd) != entry->physical_size)
{
fprintf (f, "[ERROR]\n");
+ free (buf);
return;
}
if (offset != entry->physical_size)
fprintf (f, "\n [parser used %lu bytes instead of %lu]", offset, entry->physical_size);
+ free (buf);
}
void
+2016-03-21 Nick Clifton <nickc@redhat.com>
+
+ * dlltool.c: Replace use of alloca with call to xmalloc.
+ * dllwrap.c: Likewise.
+ * nlmconv.c: Likewise.
+ * objdump.c: Likewise.
+ * resrc.c: Likewise.
+ * winduni.c: Likewise.
+ * configure: Regenerate.
+
2016-03-07 Nick Clifton <nickc@redhat.com>
PR binutils/19775
NO_WERROR=
if test "${ERROR_ON_WARNING}" = yes ; then
- GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror"
+ GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror -Wstack-usage=262144"
NO_WERROR="-Wno-error"
fi
const char *entry, int ord_val, const char *its_name)
{
const char *application_name;
- char *buf;
+ char *buf = NULL;
if (entry != NULL)
application_name = entry;
}
if (dllext != NULL)
- {
- buf = (char *) alloca (strlen (module) + strlen (dllext) + 2);
- sprintf (buf, "%s.%s", module, dllext);
- module = buf;
- }
+ module = buf = concat (module, ".", dllext, NULL);
append_import (application_name, module, ord_val, its_name);
+
+ if (buf)
+ free (buf);
}
void
if (*s == ' ')
i++;
i++;
- argv = alloca (sizeof (char *) * (i + 3));
+ argv = xmalloc (sizeof (char *) * (i + 3));
i = 0;
argv[i++] = what;
s = args;
pid = pexecute (argv[0], (char * const *) argv, program_name, temp_base,
&errmsg_fmt, &errmsg_arg, PEXECUTE_ONE | PEXECUTE_SEARCH);
+ free(argv);
if (pid == -1)
{
{
char * cmd;
- cmd = (char *) alloca (strlen (ASM_SWITCHES) + strlen (as_flags)
- + strlen (source) + strlen (dest) + 50);
+ cmd = xmalloc (strlen (ASM_SWITCHES) + strlen (as_flags)
+ + strlen (source) + strlen (dest) + 50);
sprintf (cmd, "%s %s -o %s %s", ASM_SWITCHES, as_flags, dest, source);
run (as_name, cmd);
+ free (cmd);
}
static const char * temp_file_to_remove[5];
{
char *name;
- name = (char *) alloca (strlen (TMP_STUB) + 10);
+ name = xmalloc (strlen (TMP_STUB) + 10);
for (i = 0; (exp = d_exports_lexically[i]); i++)
{
/* Don't delete non-existent stubs for PRIVATE entries. */
non_fatal (_("cannot delete %s: %s"), name, strerror (errno));
}
}
+ free (name);
}
inform (_("Created lib file"));
if (*s == ' ')
i++;
i++;
- argv = alloca (sizeof (char *) * (i + 3));
+ argv = xmalloc (sizeof (char *) * (i + 3));
i = 0;
argv[i++] = what;
s = args;
pid = pexecute (argv[0], (char * const *) argv, prog_name, temp_base,
&errmsg_fmt, &errmsg_arg, PEXECUTE_ONE | PEXECUTE_SEARCH);
+ free (argv);
if (pid == -1)
{
for (q = inputs; q != NULL; q = q->next)
++c;
- argv = (char **) alloca ((c + 7) * sizeof (char *));
+ argv = (char **) xmalloc ((c + 7) * sizeof (char *));
#ifndef __MSDOS__
if (ld == NULL)
pid = pexecute (ld, argv, program_name, (char *) NULL, &errfmt, &errarg,
PEXECUTE_SEARCH | PEXECUTE_ONE);
+ free (argv);
+
if (pid == -1)
{
fprintf (stderr, _("%s: execution of %s failed: "), program_name, ld);
unsigned int linenumber;
unsigned int discriminator;
bfd_boolean reloc;
+ char *path = NULL;
if (! with_line_numbers && ! with_source_code)
return;
{
char *path_up;
const char *fname = filename;
- char *path = (char *) alloca (prefix_length + PATH_MAX + 1);
+
+ path = xmalloc (prefix_length + PATH_MAX + 1);
if (prefix_length)
memcpy (path, prefix, prefix_length);
path_up = path + prefix_length;
/* Build relocated filename, stripping off leading directories
- from the initial filename if requested. */
+ from the initial filename if requested. */
if (prefix_strip > 0)
{
int level = 0;
const char *s;
- /* Skip selected directory levels. */
+ /* Skip selected directory levels. */
for (s = fname + 1; *s != '\0' && level < prefix_strip; s++)
if (IS_DIR_SEPARATOR(*s))
{
}
}
- /* Update complete filename. */
+ /* Update complete filename. */
strncpy (path_up, fname, PATH_MAX);
path_up[PATH_MAX] = '\0';
if (discriminator != prev_discriminator)
prev_discriminator = discriminator;
+
+ if (path)
+ free (path);
}
/* Pseudo FILE object for strings. */
i++;
i++;
- argv = alloca (sizeof (char *) * (i + 3));
+ argv = xmalloc (sizeof (char *) * (i + 3));
i = 0;
s = cmd;
pid = pexecute (argv[0], (char * const *) argv, program_name, temp_base,
&errmsg_fmt, &errmsg_arg, PEXECUTE_ONE | PEXECUTE_SEARCH);
+ free (argv);
/* Restore stdout to its previous setting. */
dup2 (stdout_save, STDOUT_FILENO);
}
/* Make sure we have zero terminated string. */
- p = tmp = (char *) alloca (a_length + 1);
+ p = tmp = (char *) xmalloc (a_length + 1);
memcpy (tmp, ascii, a_length);
tmp[a_length] = 0;
if (length)
*length = idx;
+
+ free (tmp);
}
/* Convert an unicode string to an ASCII string. We just copy it,
+2016-03-21 Nick Clifton <nickc@redhat.com>
+
+ * atof-generic.c: Replace use of alloca with call to xmalloc.
+ * cgen.c: Likewise.
+ * dwarf2dbg.c: Likewise.
+ * macro.c: Likewise.
+ * remap.c: Likewise.
+ * stabs.c: Likewise.
+ * symbols.c: Likewise.
+ * config/obj-elf.c: Likewise.
+ * config/tc-aarch64.c: Likewise.
+ * config/tc-arc.c: Likewise.
+ * config/tc-arm.c: Likewise.
+ * config/tc-avr.c: Likewise.
+ * config/tc-ia64.c: Likewise.
+ * config/tc-mips.c: Likewise.
+ * config/tc-msp430.c: Likewise.
+ * config/tc-nds32.c: Likewise.
+ * config/tc-ppc.c: Likewise.
+ * config/tc-sh.c: Likewise.
+ * config/tc-tic30.c: Likewise.
+ * config/tc-tic54x.c: Likewise.
+ * config/tc-xstormy16.c: Likewise.
+ * config/te-vms.c: Likewise.
+ * configure: Regenerate.
+
2016-03-20 Trevor Saunders <tbsaunde+binutils@tbsaunde.org>
* tc-i386.c (f32_1): Change type to unsigned char[].
{
int count; /* Number of useful digits left to scan. */
+ LITTLENUM_TYPE *temporary_binary_low = NULL;
+ LITTLENUM_TYPE *power_binary_low = NULL;
LITTLENUM_TYPE *digits_binary_low;
unsigned int precision;
unsigned int maximum_useful_digits;
* sizeof (LITTLENUM_TYPE);
digits_binary_low = (LITTLENUM_TYPE *)
- alloca (size_of_digits_in_chars);
+ xmalloc (size_of_digits_in_chars);
memset ((char *) digits_binary_low, '\0', size_of_digits_in_chars);
* giving return_binary_mantissa and return_binary_exponent.
*/
- LITTLENUM_TYPE *power_binary_low;
int decimal_exponent_is_negative;
/* This refers to the "-56" in "12.34E-56". */
/* FALSE: decimal_exponent is positive (or 0) */
/* TRUE: decimal_exponent is negative */
FLONUM_TYPE temporary_flonum;
- LITTLENUM_TYPE *temporary_binary_low;
unsigned int size_of_power_in_littlenums;
unsigned int size_of_power_in_chars;
size_of_power_in_chars = size_of_power_in_littlenums
* sizeof (LITTLENUM_TYPE) + 2;
- power_binary_low = (LITTLENUM_TYPE *) alloca (size_of_power_in_chars);
- temporary_binary_low = (LITTLENUM_TYPE *) alloca (size_of_power_in_chars);
+ power_binary_low = (LITTLENUM_TYPE *) xmalloc (size_of_power_in_chars);
+ temporary_binary_low = (LITTLENUM_TYPE *) xmalloc (size_of_power_in_chars);
+
memset ((char *) power_binary_low, '\0', size_of_power_in_chars);
*power_binary_low = 1;
power_of_10_flonum.exponent = 0;
(void) putchar ('\n');
#endif
}
-
}
/*
/* Assert sign of the number we made is '+'. */
address_of_generic_floating_point_number->sign = digits_sign_char;
+ if (temporary_binary_low)
+ free (temporary_binary_low);
+ if (power_binary_low)
+ free (power_binary_low);
+ free (digits_binary_low);
}
return return_value;
}
const CGEN_OPERAND *operand = cgen_operand_lookup_by_num (cd, opindex);
const char *errmsg;
bfd_reloc_code_real_type reloc_type;
- CGEN_FIELDS *fields = alloca (CGEN_CPU_SIZEOF_FIELDS (cd));
const CGEN_INSN *insn = fixP->fx_cgen.insn;
#ifdef OBJ_COMPLEX_RELC
int start;
finish the job. Testing for pcrel is a temporary hack. */
|| fixP->fx_pcrel)
{
+ CGEN_FIELDS *fields = xmalloc (CGEN_CPU_SIZEOF_FIELDS (cd));
+
CGEN_CPU_SET_FIELDS_BITSIZE (cd) (fields, CGEN_INSN_BITSIZE (insn));
CGEN_CPU_SET_VMA_OPERAND (cd) (cd, opindex, fields, (bfd_vma) value);
#endif
if (errmsg)
as_bad_where (fixP->fx_file, fixP->fx_line, "%s", errmsg);
+
+ free (fields);
}
if (fixP->fx_done)
if (i == 0)
goto bad;
- name = (char *) alloca (i + 1);
+ name = xmalloc (i + 1);
memcpy (name, s, i);
name[i] = '\0';
{
as_bad (_("Attribute name not recognised: %s"), name);
ignore_rest_of_line ();
+ free (name);
return 0;
}
+ free (name);
}
type = _bfd_elf_obj_attrs_arg_type (stdoutput, vendor, tag);
if (!strcmp ("str", sec->name + strlen (sec->name) - 3))
return;
- name = (char *) alloca (strlen (sec->name) + 4);
- strcpy (name, sec->name);
- strcat (name, "str");
+ name = concat (sec->name, "str", NULL);
strsec = bfd_get_section_by_name (abfd, name);
if (strsec)
strsz = bfd_section_size (abfd, strsec);
bfd_h_put_16 (abfd, nsyms, p + 6);
bfd_h_put_32 (abfd, strsz, p + 8);
+ free (name);
}
#ifdef NEED_ECOFF_DEBUG
nlen = strlen (newname);
#endif
- nbuf = alloca (nlen + 1);
+ nbuf = xmalloc (nlen + 1);
memcpy (nbuf, newname, nlen);
nbuf[nlen] = '\0';
the artificial FOO alias because it has already been created by the
first .req. */
if (insert_reg_alias (nbuf, old->number, old->type) == NULL)
- return TRUE;
+ {
+ free (nbuf);
+ return TRUE;
+ }
}
for (p = nbuf; *p; p++)
insert_reg_alias (nbuf, old->number, old->type);
}
+ free (nbuf);
return TRUE;
}
case OPTION_MCPU:
{
int i;
- char *s = alloca (strlen (arg) + 1);
+ char *s = xmalloc (strlen (arg) + 1);
{
char *t = s;
for (i = 0; cpu_types[i].name; ++i)
{
- if (!strcmp (cpu_types[i].name, s))
+ if (strcmp (cpu_types[i].name, s) == 0)
{
arc_target = cpu_types[i].flags;
arc_target_name = cpu_types[i].name;
}
if (!cpu_types[i].name)
- {
- as_fatal (_("unknown architecture: %s\n"), arg);
- }
+ as_fatal (_("unknown architecture: %s\n"), arg);
+ free (s);
break;
}
nlen = strlen (newname);
#endif
- nbuf = (char *) alloca (nlen + 1);
+ nbuf = xmalloc (nlen + 1);
memcpy (nbuf, newname, nlen);
nbuf[nlen] = '\0';
the artificial FOO alias because it has already been created by the
first .req. */
if (insert_reg_alias (nbuf, old->number, old->type) == NULL)
- return TRUE;
+ {
+ free (nbuf);
+ return TRUE;
+ }
}
for (p = nbuf; *p; p++)
insert_reg_alias (nbuf, old->number, old->type);
}
+ free (nbuf);
return TRUE;
}
namelen = strlen (newname);
#endif
- namebuf = (char *) alloca (namelen + 1);
+ namebuf = xmalloc (namelen + 1);
strncpy (namebuf, newname, namelen);
namebuf[namelen] = '\0';
insert_neon_reg_alias (namebuf, basereg->number, basetype,
typeinfo.defined != 0 ? &typeinfo : NULL);
+ free (namebuf);
return TRUE;
}
if (S_IS_LOCAL (symbolP) || name[0] == '.')
return symbolP;
- real_start = ACONCAT ((STUB_NAME, name, NULL));
+ real_start = concat (STUB_NAME, name, NULL);
new_target = symbol_find (real_start);
+ free (real_start);
if (new_target == NULL)
{
XXX Surely there is a cleaner way to do this. */
char *p = input_line_pointer;
int offset;
- char *save_buf = (char *) alloca (input_line_pointer - base);
+ char *save_buf = xmalloc (input_line_pointer - base);
+
memcpy (save_buf, base, input_line_pointer - base);
memmove (base + (input_line_pointer - before_reloc),
base, before_reloc - base);
memset (p, 0, nbytes);
fix_new_exp (frag_now, p - frag_now->fr_literal + offset,
size, &exp, 0, (enum bfd_reloc_code_real) reloc);
+ free (save_buf);
}
}
}
static void
neon_exchange_operands (void)
{
- void *scratch = alloca (sizeof (inst.operands[0]));
if (inst.operands[1].present)
{
+ void *scratch = xmalloc (sizeof (inst.operands[0]));
+
/* Swap operands[1] and operands[2]. */
memcpy (scratch, &inst.operands[1], sizeof (inst.operands[0]));
inst.operands[1] = inst.operands[2];
memcpy (&inst.operands[2], scratch, sizeof (inst.operands[0]));
+ free (scratch);
}
else
{
case OPTION_MMCU:
{
int i;
- char *s = alloca (strlen (arg) + 1);
+ char *s = xmalloc (strlen (arg) + 1);
{
char *t = s;
if (strcmp (mcu_types[i].name, s) == 0)
break;
+ free (s);
if (!mcu_types[i].name)
{
show_mcu_list (stderr);
type - this for allows passing -mmcu=... via gcc ASM_SPEC as well
as .arch ... in the asm output at the same time. */
if (avr_mcu == &default_mcu || avr_mcu->mach == mcu_types[i].mach)
- {
- specified_mcu.name = mcu_types[i].name;
- specified_mcu.isa |= mcu_types[i].isa;
- specified_mcu.mach = mcu_types[i].mach;
- avr_mcu = &specified_mcu;
- }
+ {
+ specified_mcu.name = mcu_types[i].name;
+ specified_mcu.isa |= mcu_types[i].isa;
+ specified_mcu.mach = mcu_types[i].mach;
+ avr_mcu = &specified_mcu;
+ }
else
as_fatal (_("redefinition of mcu type `%s' to `%s'"),
avr_mcu->name, mcu_types[i].name);
char *sec_name;
const char *prefix = special_section_name [sec_index];
const char *suffix;
- size_t prefix_len, suffix_len, sec_name_len;
sec_text_name = segment_name (text_seg);
text_name = sec_text_name;
suffix += sizeof (".gnu.linkonce.t.") - 1;
}
- prefix_len = strlen (prefix);
- suffix_len = strlen (suffix);
- sec_name_len = prefix_len + suffix_len;
- sec_name = alloca (sec_name_len + 1);
- memcpy (sec_name, prefix, prefix_len);
- memcpy (sec_name + prefix_len, suffix, suffix_len);
- sec_name [sec_name_len] = '\0';
+ sec_name = concat (prefix, suffix, NULL);
/* Handle COMDAT group. */
if ((text_seg->flags & SEC_LINK_ONCE) != 0
&& (elf_section_flags (text_seg) & SHF_GROUP) != 0)
{
char *section;
- size_t len, group_name_len;
const char *group_name = elf_group_name (text_seg);
if (group_name == NULL)
as_bad (_("Group section `%s' has no group signature"),
sec_text_name);
ignore_rest_of_line ();
+ free (sec_name);
return;
}
- /* We have to construct a fake section directive. */
- group_name_len = strlen (group_name);
- len = (sec_name_len
- + 16 /* ,"aG",@progbits, */
- + group_name_len /* ,group_name */
- + 7); /* ,comdat */
-
- section = alloca (len + 1);
- memcpy (section, sec_name, sec_name_len);
- memcpy (section + sec_name_len, ",\"aG\",@progbits,", 16);
- memcpy (section + sec_name_len + 16, group_name, group_name_len);
- memcpy (section + len - 7, ",comdat", 7);
- section [len] = '\0';
+
+ /* We have to construct a fake section directive. */
+ section = concat (sec_name, ",\"aG\",@progbits,", group_name, ",comdat", NULL);
set_section (section);
+ free (section);
}
else
{
}
elf_linked_to_section (now_seg) = text_seg;
+ free (sec_name);
}
static void
}
}
- end = alloca (strlen (name) + 1);
- strcpy (end, name);
+ end = xstrdup (name);
name = ia64_canonicalize_symbol_name (end);
if ((dr = hash_find (md.dynreg_hash, name)))
{
bits. */
e->X_op = O_register;
e->X_add_number = dr->base | (dr->num_regs << 16);
+ free (end);
return 1;
}
+ free (end);
return 0;
}
static void
report_insn_error (const char *str)
{
- const char *msg;
+ const char *msg = concat (insn_error.msg, " `%s'", NULL);
- msg = ACONCAT ((insn_error.msg, " `%s'", NULL));
switch (insn_error.format)
{
case ERR_FMT_PLAIN:
as_bad (msg, insn_error.u.ss[0], insn_error.u.ss[1], str);
break;
}
+
+ free ((char *) msg);
}
/* Initialize vr4120_conflicts. There is a bit of duplication here:
struct mips_opcode *insn;
/* Make a copy of the instruction so that we can fiddle with it. */
- name = alloca (length + 1);
+ name = xmalloc (length + 1);
memcpy (name, start, length);
name[length] = '\0';
/* Look up the instruction as-is. */
insn = (struct mips_opcode *) hash_find (hash, name);
if (insn)
- return insn;
+ goto end;
dot = strchr (name, '.');
if (dot && dot[1])
if (insn && (insn->pinfo2 & INSN2_VU0_CHANNEL_SUFFIX) != 0)
{
*opcode_extra |= mask << mips_vu0_channel_mask.lsb;
- return insn;
+ goto end;
}
}
}
if (insn)
{
forced_insn_length = suffix;
- return insn;
+ goto end;
}
}
}
- return NULL;
+ insn = NULL;
+ end:
+ free (name);
+ return insn;
}
/* Assemble an instruction into its binary format. If the instruction
static void
msp430_set_arch (int option)
{
- char *str = (char *) alloca (32); /* 32 for good measure. */
+ char str[32]; /* 32 for good measure. */
input_line_pointer = extract_word (input_line_pointer, str, 32);
md_assemble (char *str)
{
struct nds32_asm_insn insn;
+ expressionS expr;
char *out;
struct nds32_pseudo_opcode *popcode;
const struct nds32_field *fld = NULL;
}
label_exist = 0;
- insn.info = (expressionS *) alloca (sizeof (expressionS));
+ insn.info = & expr;
asm_desc.result = NASM_OK;
nds32_assemble (&asm_desc, &insn, str);
}
/* Put the string together. */
- complete = s = (char *) alloca (len + 1);
+ complete = s = (char *) xmalloc (len + 1);
format = macro->format;
while (*format != '\0')
{
/* Assemble the constructed instruction. */
md_assemble (complete);
+ free (complete);
}
\f
#ifdef OBJ_ELF
static char *
insert_loop_bounds (char *output, sh_operand_info *operand)
{
- char *name;
symbolS *end_sym;
/* Since the low byte of the opcode will be overwritten by the reloc, we
if (sh_relax)
{
static int count = 0;
+ char name[11];
/* If the last loop insn is a two-byte-insn, it is in danger of being
swapped with the insn after it. To prevent this, create a new
right in the middle, but four byte insns are not swapped anyways. */
/* A REPEAT takes 6 bytes. The SH has a 32 bit address space.
Hence a 9 digit number should be enough to count all REPEATs. */
- name = alloca (11);
sprintf (name, "_R%x", count++ & 0x3fffffff);
end_sym = symbol_new (name, undefined_section, 0, &zero_address_frag);
/* Make this a local symbol. */
tic30_operand (char *token)
{
unsigned int count;
- char ind_buffer[strlen (token)];
operand *current_op;
debug ("In tic30_operand with %s\n", token);
int disp_number = 0;
int buffer_posn = 1;
ind_addr_type *ind_addr_op;
+ char * ind_buffer;
+
+ ind_buffer = xmalloc (strlen (token));
debug ("Found indirect reference\n");
ind_buffer[0] = *token;
if (found_ar)
{
as_bad (_("More than one AR register found in indirect reference"));
+ free (ind_buffer);
return NULL;
}
if (*(token + count + 1) < '0' || *(token + count + 1) > '7')
{
as_bad (_("Illegal AR register in indirect reference"));
+ free (ind_buffer);
return NULL;
}
ar_number = *(token + count + 1) - '0';
if (found_disp)
{
as_bad (_("More than one displacement found in indirect reference"));
+ free (ind_buffer);
return NULL;
}
count++;
if (!is_digit_char (*(token + count)))
{
as_bad (_("Invalid displacement in indirect reference"));
+ free (ind_buffer);
return NULL;
}
disp[disp_posn++] = *(token + (count++));
if (!found_ar)
{
as_bad (_("AR register not found in indirect reference"));
+ free (ind_buffer);
return NULL;
}
{
/* Maybe an implied displacement of 1 again. */
as_bad (_("required displacement wasn't given in indirect reference"));
- return 0;
+ free (ind_buffer);
+ return NULL;
}
}
else
{
as_bad (_("illegal indirect reference"));
+ free (ind_buffer);
return NULL;
}
if (found_disp && (disp_number < 0 || disp_number > 255))
{
as_bad (_("displacement must be an unsigned 8-bit number"));
+ free (ind_buffer);
return NULL;
}
current_op->indirect.disp = disp_number;
current_op->indirect.ARnum = ar_number;
current_op->op_type = Indirect;
+ free (ind_buffer);
}
else
{
int c;
char *name;
char *str;
- char *tmp;
int quoted = *input_line_pointer == '"';
ILLEGAL_WITHIN_STRUCT ();
return;
}
- tmp = xmalloc (strlen (str) + 1);
- strcpy (tmp, str);
- str = tmp;
- tmp = xmalloc (strlen (name) + 1);
- strcpy (tmp, name);
- name = tmp;
+ str = xstrdup (str);
+ name = xstrdup (name);
subsym_create_or_replace (name, str);
(void) restore_line_pointer (c);
demand_empty_rest_of_line ();
symbolS *rootsym,
const char *root_stag_name)
{
- char prefix[strlen (path) + 2];
+ char * prefix;
struct stag_field *field = stag->field;
/* Construct a symbol for every field contained within this structure
including fields within structure fields. */
- strcpy (prefix, path);
- if (*path)
- strcat (prefix, ".");
+ prefix = concat (path, *path ? "." : "", NULL);
while (field != NULL)
{
- int len = strlen (prefix) + strlen (field->name) + 2;
- char *name = xmalloc (len);
- strcpy (name, prefix);
- strcat (name, field->name);
+ char *name = concat (prefix, field->name, NULL);
if (rootsym == NULL)
{
}
else
{
- char *replacement = xmalloc (strlen (name)
- + strlen (stag->name) + 2);
- strcpy (replacement, S_GET_NAME (rootsym));
- strcat (replacement, "+");
- strcat (replacement, root_stag_name);
- strcat (replacement, name + strlen (S_GET_NAME (rootsym)));
+ char *replacement;
+
+ replacement = concat (S_GET_NAME (rootsym), "+", root_stag_name,
+ name + strlen (S_GET_NAME (rootsym)), NULL);
hash_insert (subsym_hash[0], name, replacement);
}
field->offset,
rootsym, root_stag_name);
field = field->next;
+ free (name);
}
+ free (prefix);
}
/* Keep track of stag fields so that when structures are nested we can add the
}
else
{
- char label[strlen (S_GET_NAME (line_label)) + 1];
- strcpy (label, S_GET_NAME (line_label));
- current_stag->sym = symbol_new (label, absolute_section,
+ char * label = xstrdup (S_GET_NAME (line_label));
+ current_stag->sym = symbol_new (label,
+ absolute_section,
(valueT) abs_section_offset,
&zero_address_frag);
+ free (label);
}
current_stag->name = S_GET_NAME (current_stag->sym);
SF_SET_LOCAL (current_stag->sym);
}
else
{
- char label[strlen (S_GET_NAME (line_label)) + 1];
+ char * label;
- strcpy (label, S_GET_NAME (line_label));
+ label = xstrdup (S_GET_NAME (line_label));
if (current_stag != NULL)
stag_add_field (current_stag, label,
abs_section_offset - S_GET_VALUE (current_stag->sym),
{
as_bad (_(".tag target '%s' undefined"), label);
ignore_rest_of_line ();
+ free (label);
return;
}
stag_add_field_symbols (stag, S_GET_NAME (sym),
S_GET_VALUE (stag->sym), sym, stag->name);
}
+ free (label);
}
/* Bump by the struct size, but only if we're within a .struct section. */
}
else
{
- char label[strlen (S_GET_NAME (line_label) + 1)];
+ char * label;
- strcpy (label, S_GET_NAME (line_label));
+ label = xstrdup (S_GET_NAME (line_label));
stag_add_field (current_stag, label,
abs_section_offset - S_GET_VALUE (current_stag->sym),
NULL);
+ free (label);
}
if (current_stag->is_union)
if (value == NULL)
{
char digit[11];
- char *namecopy = strcpy (xmalloc (strlen (name) + 1), name);
+ char *namecopy = xstrdup (name);
value = strcpy (xmalloc (strlen (name) + sizeof (digit) + 1),
name);
substitutions are performed, or a substitution that has been
previously made is encountered again.
- put the symbol into the recursion hash table so we only
+ Put the symbol into the recursion hash table so we only
try to replace a symbol once. */
if (recurse)
{
const CGEN_OPERAND *operand = cgen_operand_lookup_by_num (cd, opindex);
const char *errmsg;
bfd_reloc_code_real_type reloc_type;
- CGEN_FIELDS *fields = alloca (CGEN_CPU_SIZEOF_FIELDS (cd));
const CGEN_INSN *insn = fixP->fx_cgen.insn;
/* If the reloc has been fully resolved finish the operand here. */
/* FIXME: This duplicates the capabilities of code in BFD. */
if (fixP->fx_done)
{
+ CGEN_FIELDS *fields = xmalloc (CGEN_CPU_SIZEOF_FIELDS (cd));
+
CGEN_CPU_SET_FIELDS_BITSIZE (cd) (fields, CGEN_INSN_BITSIZE (insn));
CGEN_CPU_SET_VMA_OPERAND (cd) (cd, opindex, fields, (bfd_vma) value);
#endif
if (errmsg)
as_bad_where (fixP->fx_file, fixP->fx_line, "%s", errmsg);
+
+ free (fields);
}
if (fixP->fx_done)
char *rfo,
int *ver)
{
- char fullname[strlen (dirname) + strlen (filename) + 1];
+ char * fullname;
+
#ifdef VMS
struct FAB fab;
struct NAM nam;
return 0;
}
- strcpy (fullname, dirname);
- strcat (fullname, filename);
-
+ fullname = concat (dirname, filename, NULL);
tryfile = to_vms_file_spec (fullname);
/* Allocate and initialize a FAB and NAM structures. */
/* Validate filespec syntax and device existence. */
status = SYS$PARSE (&fab, 0, 0);
if ((status & 1) != 1)
- return 1;
+ {
+ free (fullname);
+ return 1;
+ }
file.string[nam.nam$b_esl] = 0;
/* Find matching filespec. */
status = SYS$SEARCH (&fab, 0, 0);
if ((status & 1) != 1)
- return 1;
+ {
+ free (fullname);
+ return 1;
+ }
file.string[nam.nam$b_esl] = 0;
result.string[result.length=nam.nam$b_rsl] = 0;
chan = 0;
status = SYS$ASSIGN (&devicedsc, &chan, 0, 0, 0);
if ((status & 1) != 1)
- return 1;
+ {
+ free (fullname);
+ return 1;
+ }
/* Initialize the FIB and fill in the directory id field. */
memset (&fib, 0, sizeof (fib));
= SYS$QIOW (0, chan, IO$_ACCESS|IO$M_ACCESS, &iosb, 0, 0,
&fibdsc, &filedsc, &result.length, &resultdsc, &atrlst, 0);
if ((status & 1) != 1)
- return 1;
+ {
+ free (fullname);
+ return 1;
+ }
+
if ((iosb.status & 1) != 1)
- return 1;
+ {
+ free (fullname);
+ return 1;
+ }
result.string[result.length] = 0;
status = SYS$QIOW (0, chan, IO$_DEACCESS, &iosb, 0, 0, &fibdsc, 0, 0, 0,
&atrlst, 0);
if ((status & 1) != 1)
- return 1;
+ {
+ free (fullname);
+ return 1;
+ }
+
if ((iosb.status & 1) != 1)
- return 1;
+ {
+ free (fullname);
+ return 1;
+ }
/* Deassign the channel and exit. */
status = SYS$DASSGN (chan);
if ((status & 1) != 1)
- return 1;
+ {
+ free (fullname);
+ return 1;
+ }
if (cdt) *cdt = create;
if (siz) *siz = (512 * 65536 * recattr.fat$w_efblkh) +
struct tm *ts;
long long gmtoff, secs, nsecs;
- strcpy (fullname, dirname);
- strcat (fullname, filename);
+ fullname = concat (dirname, filename, NULL);
if ((stat (fullname, &buff)) != 0)
- return 1;
+ {
+ free (fullname);
+ return 1;
+ }
if (cdt)
{
*ver = 1;
#endif /* VMS */
+ free (fullname);
return 0;
}
NO_WERROR=
if test "${ERROR_ON_WARNING}" = yes ; then
- GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror"
+ GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror -Wstack-usage=262144"
NO_WERROR="-Wno-error"
fi
{
size_t dir_len = strlen (dirs[files[filenum].dir]);
size_t file_len = strlen (files[filenum].filename);
- char *cp = (char *) alloca (dir_len + 1 + file_len + 1);
+ char *cp = (char *) xmalloc (dir_len + 1 + file_len + 1);
memcpy (cp, dirs[files[filenum].dir], dir_len);
INSERT_DIR_SEPARATOR (cp, dir_len);
memcpy (cp + dir_len + 1, files[filenum].filename, file_len);
cp[dir_len + file_len + 1] = '\0';
listing_source_file (cp);
+ free (cp);
}
else
listing_source_file (files[filenum].filename);
if (is_name_ender (*s))
++s;
- copy = (char *) alloca (s - line + 1);
+ copy = (char *) xmalloc (s - line + 1);
memcpy (copy, line, s - line);
copy[s - line] = '\0';
for (cls = copy; *cls != '\0'; cls ++)
*cls = TOLOWER (*cls);
macro = (macro_entry *) hash_find (macro_hash, copy);
+ free (copy);
if (macro == NULL)
return 0;
macro_entry *macro;
len = strlen (name);
- copy = (char *) alloca (len + 1);
+ copy = (char *) xmalloc (len + 1);
for (i = 0; i < len; ++i)
copy[i] = TOLOWER (name[i]);
copy[i] = '\0';
}
else
as_warn (_("Attempt to purge non-existant macro `%s'"), copy);
+ free (copy);
}
/* Handle the MRI IRP and IRPC pseudo-ops. These are handled as a
remap_debug_filename (const char *filename)
{
debug_prefix_map *map;
- char *s;
- const char *name;
- size_t name_len;
for (map = debug_prefix_maps; map; map = map->next)
if (filename_ncmp (filename, map->old_prefix, map->old_len) == 0)
- break;
- if (!map)
- return xstrdup (filename);
- name = filename + map->old_len;
- name_len = strlen (name) + 1;
- s = (char *) alloca (name_len + map->new_len);
- memcpy (s, map->new_prefix, map->new_len);
- memcpy (s + map->new_len, name, name_len);
- return xstrdup (s);
+ {
+ const char *name = filename + map->old_len;
+ return concat (map->new_prefix, name, NULL);
+ }
+
+ return xstrdup (filename);
}
char *dir2;
dir = remap_debug_filename (getpwd ());
- dir2 = (char *) alloca (strlen (dir) + 2);
- sprintf (dir2, "%s%s", dir, "/");
+ dir2 = concat (dir, "/", NULL);
generate_asm_file (N_SO, dir2);
+ free (dir2);
xfree ((char *) dir);
}
generate_asm_file (N_SO, file);
if (in_dot_func_p)
{
- buf = (char *) alloca (100 + strlen (current_function_label));
+ buf = (char *) xmalloc (100 + strlen (current_function_label));
sprintf (buf, "%d,0,%d,%s-%s\n", N_SLINE, lineno,
sym, current_function_label);
}
else
{
- buf = (char *) alloca (100);
+ buf = (char *) xmalloc (100);
sprintf (buf, "%d,0,%d,%s\n", N_SLINE, lineno, sym);
}
input_line_pointer = buf;
input_line_pointer = hold;
outputting_stabs_line_debug = 0;
+ free (buf);
}
/* Emit a function stab.
symbolS *
symbol_find_noref (const char *name, int noref)
{
+ symbolS * result;
+ char * copy = NULL;
+
#ifdef tc_canonicalize_symbol_name
{
- char *copy;
- size_t len = strlen (name) + 1;
-
- copy = (char *) alloca (len);
- memcpy (copy, name, len);
+ copy = xstrdup (name);
name = tc_canonicalize_symbol_name (copy);
}
#endif
if (! symbols_case_sensitive)
{
- char *copy;
const char *orig;
+ char *copy2 = NULL;
unsigned char c;
orig = name;
- name = copy = (char *) alloca (strlen (name) + 1);
+ if (copy != NULL)
+ copy2 = copy;
+ name = copy = xmalloc (strlen (name) + 1);
while ((c = *orig++) != '\0')
- {
- *copy++ = TOUPPER (c);
- }
+ *copy++ = TOUPPER (c);
*copy = '\0';
+
+ if (copy2 != NULL)
+ free (copy2);
+ copy = (char *) name;
}
- return symbol_find_exact_noref (name, noref);
+ result = symbol_find_exact_noref (name, noref);
+ if (copy != NULL)
+ free (copy);
+ return result;
}
/* Once upon a time, symbols were kept in a singly linked list. At
NO_WERROR=
if test "${ERROR_ON_WARNING}" = yes ; then
- GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror"
+ GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror -Wstack-usage=262144"
NO_WERROR="-Wno-error"
fi
NO_WERROR=
if test "${ERROR_ON_WARNING}" = yes ; then
- GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror"
+ GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror -Wstack-usage=262144"
NO_WERROR="-Wno-error"
fi
+2016-03-21 Nick Clifton <nickc@redhat.com>
+
+ * emultempl/msp430.em: Replace use of alloca with call to xmalloc.
+ * plugin.c: Likewise.
+ * pe-dll.c: Likewise.
+
2016-03-18 Awson <kyrab@mail.ru>
PR 19531
NO_WERROR=
if test "${ERROR_ON_WARNING}" = yes ; then
- GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror"
+ GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror -Wstack-usage=262144"
NO_WERROR="-Wno-error"
fi
char * lower_name;
char * upper_name;
char * name;
+ char * buf = NULL;
lang_output_section_statement_type * lower;
lang_output_section_statement_type * upper;
lang_output_section_statement_type * os;
only use the part of the name before the second dot. */
if (strchr (secname + 1, '.') != NULL)
{
- name = ACONCAT ((secname, NULL));
+ buf = name = xstrdup (secname);
* strchr (name + 1, '.') = 0;
}
else
name = (char *) secname;
- lower_name = ACONCAT ((".lower", name, NULL));
- upper_name = ACONCAT ((".upper", name, NULL));
+ lower_name = concat (".lower", name, NULL);
+ upper_name = concat (".upper", name, NULL);
/* Find the corresponding lower and upper sections. */
lower = lang_output_section_find (lower_name);
if (upper == NULL)
{
einfo ("%P: error: no section named %s or %s in linker script\n", lower_name, upper_name);
- return NULL;
+ goto end;
}
}
else if (upper == NULL)
}
lang_add_section (& os->children, s, NULL, os);
+ end:
+ free (upper_name);
+ free (lower_name);
+ if (buf)
+ free (buf);
return os;
}
EOF
for (i = 0; i < NE; i++)
{
+ char *int_name = pe_def_file->exports[i].internal_name;
char *name;
- name = xmalloc (strlen (pe_def_file->exports[i].internal_name) + 2);
- if (pe_details->underscored
- && (*pe_def_file->exports[i].internal_name != '@'))
+ name = xmalloc (strlen (int_name) + 2);
+ if (pe_details->underscored && int_name[0] != '@')
{
*name = '_';
- strcpy (name + 1, pe_def_file->exports[i].internal_name);
+ strcpy (name + 1, int_name);
}
else
- strcpy (name, pe_def_file->exports[i].internal_name);
+ strcpy (name, int_name);
blhe = bfd_link_hash_lookup (info->hash,
name,
but we must take care not to be fooled when the user wants to export
a symbol that actually really has a dot in it, so we only check
for them here, after real defined symbols have already been matched. */
- else if (strchr (pe_def_file->exports[i].internal_name, '.'))
+ else if (strchr (int_name, '.'))
{
count_exported++;
if (!pe_def_file->exports[i].flag_noname)
{
/* xgettext:c-format */
einfo (_("%XCannot export %s: symbol not defined\n"),
- pe_def_file->exports[i].internal_name);
+ int_name);
}
else if (blhe)
{
/* xgettext:c-format */
einfo (_("%XCannot export %s: symbol wrong type (%d vs %d)\n"),
- pe_def_file->exports[i].internal_name,
+ int_name,
blhe->type, bfd_link_hash_defined);
}
else
{
/* xgettext:c-format */
einfo (_("%XCannot export %s: symbol not found\n"),
- pe_def_file->exports[i].internal_name);
+ int_name);
}
free (name);
}
struct bfd_link_hash_entry *h = NULL;
struct key_value *kv;
struct key_value key;
- char *at, *lname = (char *) alloca (strlen (name) + 3);
+ char *at, *lname = xmalloc (strlen (name) + 3);
strcpy (lname, name);
{
h = bfd_link_hash_lookup (linfo->hash, kv->oname, FALSE, FALSE, FALSE);
if (h->type == bfd_link_hash_undefined)
- return h;
+ goto return_h;
}
+
if (lname[0] == '?')
- return NULL;
+ goto return_NULL;
+
if (at || lname[0] == '@')
{
if (lname[0] == '@')
{
h = bfd_link_hash_lookup (linfo->hash, kv->oname, FALSE, FALSE, FALSE);
if (h->type == bfd_link_hash_undefined)
- return h;
+ goto return_h;
}
}
if (at)
{
h = bfd_link_hash_lookup (linfo->hash, kv->oname, FALSE, FALSE, FALSE);
if (h->type == bfd_link_hash_undefined)
- return h;
+ goto return_h;
}
- return NULL;
+ goto return_NULL;
}
strcat (lname, "@");
{
h = bfd_link_hash_lookup (linfo->hash, kv->oname, FALSE, FALSE, FALSE);
if (h->type == bfd_link_hash_undefined)
- return h;
+ goto return_h;
}
if (lname[0] == '_' && pe_details->underscored)
{
h = bfd_link_hash_lookup (linfo->hash, kv->oname, FALSE, FALSE, FALSE);
if (h->type == bfd_link_hash_undefined)
- return h;
+ goto return_h;
}
- return NULL;
+ return_NULL:
+ h = NULL;
+ return_h:
+ free (lname);
+ return h;
}
static bfd_boolean
break;
case LDPL_WARNING:
{
- char *newfmt = ACONCAT (("%P: warning: ", format, "\n",
- (const char *) NULL));
+ char *newfmt = concat ("%P: warning: ", format, "\n",
+ (const char *) NULL);
vfinfo (stdout, newfmt, args, TRUE);
+ free (newfmt);
}
break;
case LDPL_FATAL:
case LDPL_ERROR:
default:
{
- char *newfmt = ACONCAT ((level == LDPL_FATAL ? "%P%F" : "%P%X",
- ": error: ", format, "\n",
- (const char *) NULL));
+ char *newfmt = concat (level == LDPL_FATAL ? "%P%F" : "%P%X",
+ ": error: ", format, "\n",
+ (const char *) NULL);
fflush (stdout);
vfinfo (stderr, newfmt, args, TRUE);
fflush (stderr);
+ free (newfmt);
}
break;
}
if (cd->int_insn_p)
{
info = NULL;
- buf = (unsigned char *) alloca (cd->max_insn_bitsize / 8);
+ buf = (unsigned char *) xmalloc (cd->max_insn_bitsize / 8);
cgen_put_insn_value (cd, buf, length, insn_int_value);
base_insn = insn_int_value;
+ free (buf);
}
else
{
NO_WERROR=
if test "${ERROR_ON_WARNING}" = yes ; then
- GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror"
+ GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror -Wstack-usage=262144"
NO_WERROR="-Wno-error"
fi