+2014-11-11 Nick Clifton <nickc@redhat.com>
+
+ PR binutils/17531
+ * binutils/readelf.c (dynamic_nent): Change type to size_t.
+ (slurp_rela_relocs): Use size_t type for nrelas.
+ (slurp_rel_relocs): Likewise.
+ (get_program_headers): Improve out of memory error message.
+ (get_32bit_section_headers): Likewise.
+ (get_32bit_section_headers): Likewise.
+ (get_64bit_section_headers): Likewise.
+ (get_32bit_elf_symbols): Likewise.
+ (get_64bit_elf_symbols): Likewise.
+ (process_section_groups): Likewise.
+ (get_32bit_dynamic_section): Likewise.
+ (get_64bit_dynamic_section): Likewise.
+ (process_dynamic_section): Likewise.
+ (process_version_sections): Likewise.
+ (get_symbol_index_type): Likewise.
+ (process_mips_specific): Likewise.
+ (process_corefile_note_segment): Likewise.
+ (process_version_sections): Use size_t type for total.
+ (get_dynamic_data): Change type of number parameter to size_t.
+ Improve out of memory error messages.
+ (process_symbol_table): Change type of nbuckets and nchains to
+ size_t. Skip processing of sections headers if there are none.
+ Improve out of memory error messages.
+
2014-11-11 Nick Clifton <nickc@redhat.com>
* po/fr.po: Updated French translation.
static bfd_size_type current_file_size;
static unsigned long dynamic_addr;
static bfd_size_type dynamic_size;
-static unsigned int dynamic_nent;
+static size_t dynamic_nent;
static char * dynamic_strings;
static unsigned long dynamic_strings_length;
static char * string_table;
unsigned long * nrelasp)
{
Elf_Internal_Rela * relas;
- unsigned long nrelas;
+ size_t nrelas;
unsigned int i;
if (is_32bit_elf)
unsigned long * nrelsp)
{
Elf_Internal_Rela * rels;
- unsigned long nrels;
+ size_t nrels;
unsigned int i;
if (is_32bit_elf)
if (phdrs == NULL)
{
- error (_("Out of memory\n"));
+ error (_("Out of memory reading %u program headers\n"),
+ elf_header.e_phnum);
return 0;
}
if (section_headers == NULL)
{
if (!probe)
- error (_("Out of memory\n"));
+ error (_("Out of memory reading %u section headers\n"), num);
return FALSE;
}
if (section_headers == NULL)
{
if (! probe)
- error (_("Out of memory\n"));
+ error (_("Out of memory reading %u section headers\n"), num);
return FALSE;
}
if (isyms == NULL)
{
- error (_("Out of memory\n"));
+ error (_("Out of memory reading %lu symbols\n"),
+ (unsigned long) number);
goto exit_point;
}
if (isyms == NULL)
{
- error (_("Out of memory\n"));
+ error (_("Out of memory reading %lu symbols\n"),
+ (unsigned long) number);
goto exit_point;
}
if (section_headers_groups == NULL)
{
- error (_("Out of memory\n"));
+ error (_("Out of memory reading %u section group headers\n"),
+ elf_header.e_shnum);
return 0;
}
if (section_groups == NULL)
{
- error (_("Out of memory\n"));
+ error (_("Out of memory reading %lu groups\n"),
+ (unsigned long) group_count);
return 0;
}
sizeof (* entry));
if (dynamic_section == NULL)
{
- error (_("Out of memory\n"));
+ error (_("Out of memory allocating space for %lu dynamic entries\n"),
+ (unsigned long) dynamic_nent);
free (edyn);
return 0;
}
sizeof (* entry));
if (dynamic_section == NULL)
{
- error (_("Out of memory\n"));
+ error (_("Out of memory allocating space for %lu dynamic entries\n"),
+ (unsigned long) dynamic_nent);
free (edyn);
return 0;
}
dynamic_syminfo = (Elf_Internal_Syminfo *) malloc (syminsz);
if (dynamic_syminfo == NULL)
{
- error (_("Out of memory\n"));
+ error (_("Out of memory allocating %lu byte for dynamic symbol info\n"),
+ (unsigned long) syminsz);
return 0;
}
}
if (do_dynamic && dynamic_addr)
- printf (_("\nDynamic section at offset 0x%lx contains %u entries:\n"),
- dynamic_addr, dynamic_nent);
+ printf (_("\nDynamic section at offset 0x%lx contains %lu entries:\n"),
+ dynamic_addr, (unsigned long) dynamic_nent);
if (do_dynamic)
printf (_(" Tag Type Name/Value\n"));
case SHT_GNU_versym:
{
Elf_Internal_Shdr * link_section;
- int total;
- int cnt;
+ size_t total;
+ unsigned int cnt;
unsigned char * edata;
unsigned short * data;
char * strtab;
break;
}
- printf (_("\nVersion symbols section '%s' contains %d entries:\n"),
- printable_section_name (section), total);
+ printf (_("\nVersion symbols section '%s' contains %lu entries:\n"),
+ printable_section_name (section), (unsigned long) total);
printf (_(" Addr: "));
printf_vma (section->sh_addr);
}
static bfd_vma *
-get_dynamic_data (FILE * file, unsigned int number, unsigned int ent_size)
+get_dynamic_data (FILE * file, size_t number, unsigned int ent_size)
{
unsigned char * e_data;
bfd_vma * i_data;
e_data = (unsigned char *) cmalloc (number, ent_size);
-
if (e_data == NULL)
{
- error (_("Out of memory\n"));
+ error (_("Out of memory reading %lu dynamic entries\n"),
+ (unsigned long) number);
return NULL;
}
}
i_data = (bfd_vma *) cmalloc (number, sizeof (*i_data));
-
if (i_data == NULL)
{
- error (_("Out of memory\n"));
+ error (_("Out of memory allocating space for %lu dynamic entries\n"),
+ (unsigned long) number);
free (e_data);
return NULL;
}
process_symbol_table (FILE * file)
{
Elf_Internal_Shdr * section;
- bfd_vma nbuckets = 0;
- bfd_vma nchains = 0;
+ bfd_size_type nbuckets = 0;
+ bfd_size_type nchains = 0;
bfd_vma * buckets = NULL;
bfd_vma * chains = NULL;
bfd_vma ngnubuckets = 0;
{
unsigned char nb[8];
unsigned char nc[8];
- int hash_ent_size = 4;
+ unsigned int hash_ent_size = 4;
if ((elf_header.e_machine == EM_ALPHA
|| elf_header.e_machine == EM_S390
}
}
}
- else if (do_dyn_syms || (do_syms && !do_using_dynamic))
+ else if ((do_dyn_syms || (do_syms && !do_using_dynamic))
+ && section_headers != NULL)
{
unsigned int i;
printf (_("\nHistogram for bucket list length (total of %lu buckets):\n"),
(unsigned long) nbuckets);
- printf (_(" Length Number %% of total Coverage\n"));
lengths = (unsigned long *) calloc (nbuckets, sizeof (*lengths));
if (lengths == NULL)
{
- error (_("Out of memory\n"));
+ error (_("Out of memory allocating space for histogram buckets\n"));
return 0;
}
+
+ printf (_(" Length Number %% of total Coverage\n"));
for (hn = 0; hn < nbuckets; ++hn)
{
for (si = buckets[hn]; si > 0 && si < nchains; si = chains[si])
if (counts == NULL)
{
free (lengths);
- error (_("Out of memory\n"));
+ error (_("Out of memory allocating space for histogram counts\n"));
return 0;
}
unsigned long nzero_counts = 0;
unsigned long nsyms = 0;
+ printf (_("\nHistogram for `.gnu.hash' bucket list length (total of %lu buckets):\n"),
+ (unsigned long) ngnubuckets);
+
lengths = (unsigned long *) calloc (ngnubuckets, sizeof (*lengths));
if (lengths == NULL)
{
- error (_("Out of memory\n"));
+ error (_("Out of memory allocating space for gnu histogram buckets\n"));
return 0;
}
- printf (_("\nHistogram for `.gnu.hash' bucket list length (total of %lu buckets):\n"),
- (unsigned long) ngnubuckets);
printf (_(" Length Number %% of total Coverage\n"));
for (hn = 0; hn < ngnubuckets; ++hn)
if (counts == NULL)
{
free (lengths);
- error (_("Out of memory\n"));
+ error (_("Out of memory allocating space for gnu histogram counts\n"));
return 0;
}
cmalloc ((sect->sh_size / sizeof (eopt)), sizeof (* iopt));
if (iopt == NULL)
{
- error (_("Out of memory\n"));
+ error (_("Out of memory allocatinf space for MIPS options\n"));
return 0;
}
iconf = (Elf32_Conflict *) cmalloc (conflictsno, sizeof (* iconf));
if (iconf == NULL)
{
- error (_("Out of memory\n"));
+ error (_("Out of memory allocating space for dynamic conflicts\n"));
return 0;
}
if (temp == NULL)
{
- error (_("Out of memory\n"));
+ error (_("Out of memory allocating space for inote name\n"));
res = 0;
break;
}