aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog14
-rwxr-xr-xbfd/configure2
-rw-r--r--bfd/elf32-m68hc1x.c64
-rw-r--r--bfd/elf32-nds32.c3
-rw-r--r--bfd/elf64-hppa.c13
-rw-r--r--bfd/elfxx-mips.c26
-rw-r--r--bfd/pef.c3
-rw-r--r--bfd/pei-x86_64.c3
-rw-r--r--bfd/som.c24
-rw-r--r--bfd/warning.m42
-rw-r--r--bfd/xsym.c5
11 files changed, 89 insertions, 70 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 740fd44..fe63bd3 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,17 @@
+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
diff --git a/bfd/configure b/bfd/configure
index 1229323..de5f36d 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -12264,7 +12264,7 @@ 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
diff --git a/bfd/elf32-m68hc1x.c b/bfd/elf32-m68hc1x.c
index 76c9783..912efdf 100644
--- a/bfd/elf32-m68hc1x.c
+++ b/bfd/elf32-m68hc1x.c
@@ -28,7 +28,7 @@
#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 *) \
@@ -592,13 +592,13 @@ m68hc11_elf_export_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
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;
}
@@ -956,6 +956,9 @@ elf32_m68hc11_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
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);
@@ -1113,15 +1116,14 @@ elf32_m68hc11_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
/* 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. */
@@ -1148,17 +1150,16 @@ elf32_m68hc11_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
}
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;
}
@@ -1168,37 +1169,31 @@ elf32_m68hc11_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
&& 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;
@@ -1231,9 +1226,6 @@ elf32_m68hc11_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
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;
@@ -1241,10 +1233,12 @@ elf32_m68hc11_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
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;
}
@@ -1265,8 +1259,6 @@ elf32_m68hc11_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
if (r != bfd_reloc_ok)
{
- const char * msg = (const char *) 0;
-
switch (r)
{
case bfd_reloc_overflow:
diff --git a/bfd/elf32-nds32.c b/bfd/elf32-nds32.c
index 5fffbf2..60cd51e 100644
--- a/bfd/elf32-nds32.c
+++ b/bfd/elf32-nds32.c
@@ -2300,7 +2300,7 @@ nds32_insertion_sort (void *base, size_t nmemb, size_t size,
{
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.
@@ -2324,6 +2324,7 @@ nds32_insertion_sort (void *base, size_t nmemb, size_t size,
memmove (ptr + (j + 1) * size, ptr + j * size, (i - j) * size);
memcpy (ptr + j * size, tmp, size);
}
+ free (tmp);
}
/* Sort relocation by r_offset.
diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c
index 3021ed6..a7bad70 100644
--- a/bfd/elf64-hppa.c
+++ b/bfd/elf64-hppa.c
@@ -26,7 +26,7 @@
#include "elf/hppa.h"
#include "libhppa.h"
#include "elf64-hppa.h"
-
+#include "libiberty.h"
#define ARCH_SIZE 64
@@ -1094,20 +1094,18 @@ allocate_global_data_opd (struct elf_link_hash_entry *eh, void *data)
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;
@@ -2205,9 +2203,7 @@ elf64_hppa_finalize_opd (struct elf_link_hash_entry *eh, void *data)
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);
@@ -2216,6 +2212,7 @@ elf64_hppa_finalize_opd (struct elf_link_hash_entry *eh, void *data)
symbol index. */
if (nh)
dynindx = nh->dynindx;
+ free (new_name);
}
rel.r_addend = 0;
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index e4996fa..a46b2f5 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -1580,17 +1580,20 @@ mips_elf_create_stub_symbol (struct bfd_link_info *info,
{
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. */
@@ -1612,9 +1615,10 @@ mips_elf_create_shadow_symbol (struct bfd_link_info *info,
{
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
@@ -1623,11 +1627,13 @@ mips_elf_create_shadow_symbol (struct bfd_link_info *info,
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. */
diff --git a/bfd/pef.c b/bfd/pef.c
index b08202d..fb9a07a 100644
--- a/bfd/pef.c
+++ b/bfd/pef.c
@@ -217,7 +217,7 @@ bfd_pef_print_symbol (bfd *abfd,
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;
@@ -227,6 +227,7 @@ bfd_pef_print_symbol (bfd *abfd,
len, 0, NULL, file);
if (ret < 0)
fprintf (file, " [ERROR]");
+ free (buf);
}
}
}
diff --git a/bfd/pei-x86_64.c b/bfd/pei-x86_64.c
index aa90b6f..c19b946 100644
--- a/bfd/pei-x86_64.c
+++ b/bfd/pei-x86_64.c
@@ -602,7 +602,7 @@ pex64_bfd_print_pdata_section (bfd *abfd, void *vfile, asection *pdata_section)
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. */
@@ -610,6 +610,7 @@ pex64_bfd_print_pdata_section (bfd *abfd, void *vfile, asection *pdata_section)
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)
diff --git a/bfd/som.c b/bfd/som.c
index 1e2c0c6..859e886 100644
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -24,7 +24,7 @@
#include "sysdep.h"
#include "alloca-conf.h"
#include "bfd.h"
-
+#include "libiberty.h"
#include "libbfd.h"
#include "som.h"
#include "safe-ctype.h"
@@ -3304,11 +3304,12 @@ som_write_space_strings (bfd *abfd,
/* 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. */
@@ -3355,7 +3356,7 @@ som_write_space_strings (bfd *abfd,
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. */
@@ -3391,7 +3392,9 @@ som_write_space_strings (bfd *abfd,
/* 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;
@@ -3408,15 +3411,14 @@ som_write_symbol_strings (bfd *abfd,
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
@@ -3475,7 +3477,7 @@ som_write_symbol_strings (bfd *abfd,
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
@@ -3530,7 +3532,7 @@ som_write_symbol_strings (bfd *abfd,
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. */
@@ -3563,7 +3565,9 @@ som_write_symbol_strings (bfd *abfd,
/* 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;
diff --git a/bfd/warning.m4 b/bfd/warning.m4
index abd1a17..0e838f6 100644
--- a/bfd/warning.m4
+++ b/bfd/warning.m4
@@ -49,7 +49,7 @@ 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
diff --git a/bfd/xsym.c b/bfd/xsym.c
index d10f175..c637f74 100644
--- a/bfd/xsym.c
+++ b/bfd/xsym.c
@@ -1804,7 +1804,7 @@ bfd_sym_print_type_information_table_entry (bfd *abfd,
fprintf (f, "\n ");
- buf = alloca (entry->physical_size);
+ buf = malloc (entry->physical_size);
if (buf == NULL)
{
fprintf (f, "[ERROR]\n");
@@ -1813,11 +1813,13 @@ bfd_sym_print_type_information_table_entry (bfd *abfd,
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;
}
@@ -1837,6 +1839,7 @@ bfd_sym_print_type_information_table_entry (bfd *abfd,
if (offset != entry->physical_size)
fprintf (f, "\n [parser used %lu bytes instead of %lu]", offset, entry->physical_size);
+ free (buf);
}
void