+2015-02-03 Nick Clifton <nickc@redhat.com>
+
+ PR binutils/17512
+ * ecoff.c: Use bfd_alloc2 to allocate space for structure arrays.
+ (_bfd_ecoff_slurp_symbol_table): Check for a negative symbol
+ index or an out of range fdr index.
+ * elf-m10300.c (mn10300_info_to_howto): Fix typo in error message.
+ * elf32-arc.c (arc_info_to_howto_rel): Likewise.
+ * elf32-avr.c (avr_info_to_howto_rela): Likewise.
+ * elf32-cr16.c (elf_cr16_info_to_howto): Likewise.
+ * elf32-cr16c.c (elf_cr16c_info_to_howto_rel): Likewise.
+ * elf32-cris.c (cris_info_to_howto_rela): Likewise.
+ * elf32-crx.c (elf_crx_info_to_howto): Likewise.
+ * elf32-d10v.c (d10v_info_to_howto_rel): Likewise.
+ * elf32-d30v.c (d30v_info_to_howto_rel): Likewise.
+ * elf32-epiphany.c (epiphany_info_to_howto_rela): Likewise.
+ * elf32-fr30.c (fr30_info_to_howto_rela): Likewise.
+ * elf32-frv.c (frv_info_to_howto_rela): Likewise.
+ * elf32-i370.c (i370_elf_info_to_howto): Likewise.
+ * elf32-i960.c (elf32_i960_info_to_howto_rel): Likewise.
+ * elf32-ip2k.c (ip2k_info_to_howto_rela): Likewise.
+ * elf32-iq2000.c (iq2000_info_to_howto_rela): Likewise.
+ * elf32-lm32.c (lm32_info_to_howto_rela): Likewise.
+ * elf32-m32c.c (m32c_info_to_howto_rela): Likewise.
+ * elf32-m32r.c (m32r_info_to_howto_rel): Likewise.
+ * elf32-m68hc11.c (m68hc11_info_to_howto_rel): Likewise.
+ * elf32-m68hc12.c (m68hc11_info_to_howto_rel): Likewise.
+ * elf32-mcore.c (mcore_elf_info_to_howto): Likewise.
+ * elf32-mep.c (mep_info_to_howto_rela): Likewise.
+ * elf32-metag.c (metag_info_to_howto_rela): Likewise.
+ * elf32-microblaze.c (microblaze_elf_info_to_howto): Likewise.
+ * elf32-moxie.c (moxie_info_to_howto_rela): Likewise.
+ * elf32-msp430.c (msp430_info_to_howto_rela): Likewise.
+ * elf32-mt.c (mt_info_to_howto_rela): Likewise.
+ * elf32-nds32.c (nds32_info_to_howto_rel): Likewise.
+ * elf32-or1k.c (or1k_info_to_howto_rela): Likewise.
+ * elf32-pj.c (pj_elf_info_to_howto): Likewise.
+ * elf32-ppc.c (ppc_elf_info_to_howto): Likewise.
+ * elf32-rl78.c (rl78_info_to_howto_rela): Likewise.
+ * elf32-rx.c (rx_info_to_howto_rela): Likewise.
+ * elf32-sh.c (sh_elf_info_to_howto): Likewise.
+ * elf32-spu.c (spu_elf_info_to_howto): Likewise.
+ * elf32-v850.c (v850_elf_perform_relocation): Likewise.
+ * elf32-vax.c (rtype_to_howto): Likewise.
+ * elf32-visium.c (visium_info_to_howto_rela): Likewise.
+ * elf32-xgate.c (xgate_info_to_howto_rel): Likewise.
+ * elf32-xtensa.c (elf_xtensa_info_to_howto_rela): Likewise.
+ * elf64-alpha.c (elf64_alpha_info_to_howto): Likewise.
+ * elf64-mmix.c (mmix_info_to_howto_rela): Likewise.
+ * mach-o.c: Use bfd_alloc2 to allocate space for structure arrays.
+ (bfd_mach_o_canonicalize_one_reloc): Fix check on out
+ of range symbol indicies.
+ (bfd_mach_o_canonicalize_relocs): Check for out of range alloc.
+ (bfd_mach_o_canonicalize_dynamic_reloc): Likewise.
+ (bfd_mach_o_build_dysymtab): Likewise.
+ (bfd_mach_o_write_symtab_content): Set the string table size to
+ zero upon error.
+ (bfd_mach_o_read_symtab_symbols): Reset the nsyms value if the
+ read fails.
+ * peXXigen.c (pe_print_edata): Check for numeric overflow in edt
+ fields.
+ * tekhex.c (first_phase): Check for src pointer reaching end of
+ buffer.
+
2015-02-03 Will Newton <will.newton@linaro.org>
* elfnn-aarch64.c (elfNN_aarch64_finish_dynamic_symbol):
struct fdr *fdr_ptr;
bfd_size_type raw_end;
bfd_size_type cb_end;
- bfd_size_type amt;
file_ptr pos;
BFD_ASSERT (debug == &ecoff_data (abfd)->debug_info);
We need to look at the fdr to deal with a lot of information in
the symbols, so we swap them here. */
- amt = internal_symhdr->ifdMax;
- amt *= sizeof (struct fdr);
- debug->fdr = (FDR *) bfd_alloc (abfd, amt);
+ debug->fdr = (FDR *) bfd_alloc2 (abfd, internal_symhdr->ifdMax,
+ sizeof (struct fdr));
if (debug->fdr == NULL)
return FALSE;
external_fdr_size = backend->debug_swap.external_fdr_size;
= backend->debug_swap.swap_ext_in;
void (* const swap_sym_in) (bfd *, void *, SYMR *)
= backend->debug_swap.swap_sym_in;
- bfd_size_type internal_size;
ecoff_symbol_type *internal;
ecoff_symbol_type *internal_ptr;
char *eraw_src;
if (bfd_get_symcount (abfd) == 0)
return TRUE;
- internal_size = bfd_get_symcount (abfd);
- internal_size *= sizeof (ecoff_symbol_type);
- internal = (ecoff_symbol_type *) bfd_alloc (abfd, internal_size);
+ internal = (ecoff_symbol_type *) bfd_alloc2 (abfd, bfd_get_symcount (abfd),
+ sizeof (ecoff_symbol_type));
if (internal == NULL)
return FALSE;
(*swap_ext_in) (abfd, (void *) eraw_src, &internal_esym);
/* PR 17512: file: 3372-1000-0.004. */
- if (internal_esym.asym.iss >= ecoff_data (abfd)->debug_info.symbolic_header.issExtMax)
+ if (internal_esym.asym.iss >= ecoff_data (abfd)->debug_info.symbolic_header.issExtMax
+ || internal_esym.asym.iss < 0)
return FALSE;
internal_ptr->symbol.name = (ecoff_data (abfd)->debug_info.ssext
+ internal_esym.asym.iss);
+
if (!ecoff_set_symbol_info (abfd, &internal_esym.asym,
&internal_ptr->symbol, 1,
internal_esym.weakext))
return FALSE;
-
+
/* The alpha uses a negative ifd field for section symbols. */
if (internal_esym.ifd >= 0)
- internal_ptr->fdr = (ecoff_data (abfd)->debug_info.fdr
- + internal_esym.ifd);
+ {
+ /* PR 17512: file: 3372-1983-0.004. */
+ if (internal_esym.ifd >= ecoff_data (abfd)->debug_info.symbolic_header.ifdMax)
+ internal_ptr->fdr = NULL;
+ else
+ internal_ptr->fdr = (ecoff_data (abfd)->debug_info.fdr
+ + internal_esym.ifd);
+ }
else
internal_ptr->fdr = NULL;
internal_ptr->local = FALSE;
r_type = ELF32_R_TYPE (dst->r_info);
if (r_type >= R_MN10300_MAX)
{
- (*_bfd_error_handler) (_("%A: unrecognised MN10300 reloc number: %d"),
+ (*_bfd_error_handler) (_("%B: unrecognised MN10300 reloc number: %d"),
abfd, r_type);
bfd_set_error (bfd_error_bad_value);
r_type = R_MN10300_NONE;
r_type = ELF32_R_TYPE (dst->r_info);
if (r_type >= (unsigned int) R_ARC_max)
{
- _bfd_error_handler (_("%A: invalid ARC reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid ARC reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = &elf_arc_howto_table[r_type];
r_type = ELF32_R_TYPE (dst->r_info);
if (r_type >= (unsigned int) R_AVR_max)
{
- _bfd_error_handler (_("%A: invalid AVR reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid AVR reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = &elf_avr_howto_table[r_type];
if (r_type >= R_CR16_MAX)
{
- (*_bfd_error_handler) (_("%A: unrecognised CR16 reloc number: %d"),
+ (*_bfd_error_handler) (_("%B: unrecognised CR16 reloc number: %d"),
abfd, r_type);
bfd_set_error (bfd_error_bad_value);
r_type = R_CR16_NONE;
if (r_type >= RINDEX_16C_MAX)
{
- _bfd_error_handler (_("%A; invalid CR16C reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid CR16C reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = &elf_howto_table[r_type];
r_type = ELF32_R_TYPE (dst->r_info);
if (r_type >= R_CRIS_max)
{
- _bfd_error_handler (_("%A: invalid CRIS reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid CRIS reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = & cris_elf_howto_table [r_type];
unsigned int r_type = ELF32_R_TYPE (dst->r_info);
if (r_type >= R_CRX_MAX)
{
- (*_bfd_error_handler) (_("%A: unrecognised CRX reloc number: %d"),
+ (*_bfd_error_handler) (_("%B: unrecognised CRX reloc number: %d"),
abfd, r_type);
bfd_set_error (bfd_error_bad_value);
r_type = R_CRX_NONE;
r_type = ELF32_R_TYPE (dst->r_info);
if (r_type >= (unsigned int) R_D10V_max)
{
- _bfd_error_handler (_("%A: invalid D10V reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid D10V reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = &elf_d10v_howto_table[r_type];
r_type = ELF32_R_TYPE (dst->r_info);
if (r_type >= (unsigned int) R_D30V_max)
{
- _bfd_error_handler (_("%A: invalid D30V reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid D30V reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = &elf_d30v_howto_table[r_type];
r_type = ELF32_R_TYPE (dst->r_info);
if (r_type >= (unsigned int) R_D30V_max)
{
- _bfd_error_handler (_("%A: invalid D30V reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid D30V reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = &elf_d30v_howto_table[r_type];
r_type = ELF32_R_TYPE (dst->r_info);
if (r_type >= (unsigned int) R_EPIPHANY_max)
{
- _bfd_error_handler (_("%A: invalid Epiphany reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid Epiphany reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = & epiphany_elf_howto_table [r_type];
r_type = ELF32_R_TYPE (dst->r_info);
if (r_type >= (unsigned int) R_FR30_max)
{
- _bfd_error_handler (_("%A: invalid FR30 reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid FR30 reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = & fr30_elf_howto_table [r_type];
default:
if (r_type >= (unsigned int) R_FRV_max)
{
- _bfd_error_handler (_("%A: invalid FRV reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid FRV reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = & elf32_frv_howto_table [r_type];
r_type = ELF32_R_TYPE (dst->r_info);
if (r_type >= R_I370_max)
{
- (*_bfd_error_handler) (_("%A: unrecognised I370 reloc number: %d"),
+ (*_bfd_error_handler) (_("%B: unrecognised I370 reloc number: %d"),
abfd, r_type);
bfd_set_error (bfd_error_bad_value);
r_type = R_I370_NONE;
/* PR 17521: file: 9609b8d6. */
if (type >= R_960_max)
{
- _bfd_error_handler (_("%A; invalid i960 reloc number: %d"), abfd, type);
+ _bfd_error_handler (_("%B: invalid i960 reloc number: %d"), abfd, type);
type = 0;
}
r_type = ELF32_R_TYPE (dst->r_info);
if (r_type >= (unsigned int) R_IP2K_max)
{
- _bfd_error_handler (_("%A: invalid IP2K reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid IP2K reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = & ip2k_elf_howto_table [r_type];
default:
if (r_type >= (unsigned int) R_IQ2000_max)
{
- _bfd_error_handler (_("%A: invalid IQ2000 reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid IQ2000 reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = & iq2000_elf_howto_table [r_type];
r_type = ELF32_R_TYPE (dst->r_info);
if (r_type >= (unsigned int) R_LM32_max)
{
- _bfd_error_handler (_("%A: invalid LM32 reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid LM32 reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = &lm32_elf_howto_table[r_type];
r_type = ELF32_R_TYPE (dst->r_info);
if (r_type >= (unsigned int) R_M32C_max)
{
- _bfd_error_handler (_("%A: invalid M32C reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid M32C reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = & m32c_elf_howto_table [r_type];
r_type = ELF32_R_TYPE (dst->r_info);
if (r_type > (unsigned int) R_M32R_GNU_VTENTRY)
{
- _bfd_error_handler (_("%A: invalid M32R reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid M32R reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = &m32r_elf_howto_table[r_type];
r_type = ELF32_R_TYPE (dst->r_info);
if (r_type >= (unsigned int) R_M68HC11_max)
{
- _bfd_error_handler (_("%A: invalid M68HC11 reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid M68HC11 reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = &elf_m68hc11_howto_table[r_type];
r_type = ELF32_R_TYPE (dst->r_info);
if (r_type >= (unsigned int) R_M68HC11_max)
{
- _bfd_error_handler (_("%A: invalid M68HC12 reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid M68HC12 reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = &elf_m68hc11_howto_table[r_type];
r_type = ELF32_R_TYPE (dst->r_info);
if (r_type >= R_MCORE_max)
{
- (*_bfd_error_handler) (_("%A: unrecognised MCore reloc number: %d"),
+ (*_bfd_error_handler) (_("%B: unrecognised MCore reloc number: %d"),
abfd, r_type);
bfd_set_error (bfd_error_bad_value);
r_type = R_MCORE_NONE;
r_type = ELF32_R_TYPE (dst->r_info);
if (r_type >= R_MEP_max)
{
- _bfd_error_handler (_("%A: invalid MEP reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid MEP reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = & mep_elf_howto_table [r_type];
r_type = ELF32_R_TYPE (dst->r_info);
if (r_type >= (unsigned int) R_METAG_MAX)
{
- _bfd_error_handler (_("%A: invalid METAG reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid METAG reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = & elf_metag_howto_table [r_type];
r_type = ELF32_R_TYPE (dst->r_info);
if (r_type >= R_MICROBLAZE_max)
{
- (*_bfd_error_handler) (_("%A: unrecognised MicroBlaze reloc number: %d"),
+ (*_bfd_error_handler) (_("%B: unrecognised MicroBlaze reloc number: %d"),
abfd, r_type);
bfd_set_error (bfd_error_bad_value);
r_type = R_MICROBLAZE_NONE;
r_type = ELF32_R_TYPE (dst->r_info);
if (r_type >= (unsigned int) R_MOXIE_max)
{
- _bfd_error_handler (_("%A: invalid Moxie reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid Moxie reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = & moxie_elf_howto_table [r_type];
{
if (r_type >= (unsigned int) R_MSP430x_max)
{
- _bfd_error_handler (_("%A: invalid MSP430X reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid MSP430X reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = elf_msp430x_howto_table + r_type;
if (r_type >= (unsigned int) R_MSP430_max)
{
- _bfd_error_handler (_("%A: invalid MSP430 reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid MSP430 reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = &elf_msp430_howto_table[r_type];
r_type = ELF32_R_TYPE (dst->r_info);
if (r_type >= (unsigned int) R_MT_max)
{
- _bfd_error_handler (_("%A: invalid MT reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid MT reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = & mt_elf_howto_table [r_type];
r_type = ELF32_R_TYPE (dst->r_info);
if (r_type > R_NDS32_GNU_VTENTRY)
{
- _bfd_error_handler (_("%A: invalid NDS32 reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid NDS32 reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = bfd_elf32_bfd_reloc_type_table_lookup (r_type);
r_type = ELF32_R_TYPE (dst->r_info);
if (r_type >= (unsigned int) R_OR1K_max)
{
- _bfd_error_handler (_("%A: invalid OR1K reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid OR1K reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = & or1k_elf_howto_table[r_type];
if (r >= R_PJ_max)
{
- (*_bfd_error_handler) (_("%A: unrecognised PicoJava reloc number: %d"),
+ (*_bfd_error_handler) (_("%B: unrecognised PicoJava reloc number: %d"),
abfd, r);
bfd_set_error (bfd_error_bad_value);
r = R_PJ_NONE;
r_type = ELF32_R_TYPE (dst->r_info);
if (r_type >= R_PPC_max)
{
- (*_bfd_error_handler) (_("%A: unrecognised PPC reloc number: %d"),
+ (*_bfd_error_handler) (_("%B: unrecognised PPC reloc number: %d"),
abfd, r_type);
bfd_set_error (bfd_error_bad_value);
r_type = R_PPC_NONE;
r_type = ELF32_R_TYPE (dst->r_info);
if (r_type >= (unsigned int) R_RL78_max)
{
- _bfd_error_handler (_("%A: invalid RL78 reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid RL78 reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = rl78_elf_howto_table + r_type;
r_type = ELF32_R_TYPE (dst->r_info);
if (r_type >= (unsigned int) R_RX_max)
{
- _bfd_error_handler (_("%A: invalid RX reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid RX reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = rx_elf_howto_table + r_type;
|| (r >= R_SH_FIRST_INVALID_RELOC_5 && r <= R_SH_LAST_INVALID_RELOC_5)
|| (r >= R_SH_FIRST_INVALID_RELOC_6 && r <= R_SH_LAST_INVALID_RELOC_6))
{
- (*_bfd_error_handler) (_("%A: unrecognised SH reloc number: %d"),
+ (*_bfd_error_handler) (_("%B: unrecognised SH reloc number: %d"),
abfd, r);
bfd_set_error (bfd_error_bad_value);
r = R_SH_NONE;
/* PR 17512: file: 90c2a92e. */
if (r_type >= R_SPU_max)
{
- (*_bfd_error_handler) (_("%A: unrecognised SPU reloc number: %d"),
+ (*_bfd_error_handler) (_("%B: unrecognised SPU reloc number: %d"),
abfd, r_type);
bfd_set_error (bfd_error_bad_value);
r_type = R_SPU_NONE;
{
default:
#ifdef DEBUG
- fprintf (stderr, "reloc number %d not recognised\n", r_type);
+ fprintf (stderr, "%B: reloc number %d not recognised\n", abfd, r_type);
#endif
return bfd_reloc_notsupported;
r_type = ELF32_R_TYPE (dst->r_info);
if (r_type >= (unsigned int) R_V850_max)
{
- _bfd_error_handler (_("%A: invalid V850 reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid V850 reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = &v850_elf_howto_table[r_type];
r_type = ELF32_R_TYPE (dst->r_info);
if (r_type >= (unsigned int) R_V850_max)
{
- _bfd_error_handler (_("%A: invalid V850 reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid V850 reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = &v850_elf_howto_table[r_type];
default:
#ifdef DEBUG
- fprintf (stderr, "reloc number %d not recognised\n", r_type);
+ fprintf (stderr, "%B: reloc number %d not recognised\n", input_bfd, r_type);
#endif
return bfd_reloc_notsupported;
}
};
static void
-rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr,
- Elf_Internal_Rela *dst)
+rtype_to_howto (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)
{
unsigned int r_type;
r_type = ELF32_R_TYPE (dst->r_info);
if (r_type >= R_VAX_max)
{
- (*_bfd_error_handler) (_("%A: unrecognised VAX reloc number: %d"),
+ (*_bfd_error_handler) (_("%B: unrecognised VAX reloc number: %d"),
abfd, r_type);
bfd_set_error (bfd_error_bad_value);
r_type = R_VAX_NONE;
default:
if (r_type >= (unsigned int) R_VISIUM_max)
{
- _bfd_error_handler (_("%A: invalid Visium reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid Visium reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = &visium_elf_howto_table[r_type];
r_type = ELF32_R_TYPE (dst->r_info);
if (r_type >= (unsigned int) R_XGATE_max)
{
- _bfd_error_handler (_("%A: invalid XGate reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid XGate reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = &elf_xgate_howto_table[r_type];
if (r_type >= (unsigned int) R_XTENSA_max)
{
- _bfd_error_handler (_("%A: invalid XTENSA reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid XTENSA reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = &elf_howto_table[r_type];
if (r_type >= R_ALPHA_max)
{
- (*_bfd_error_handler) (_("%A: unrecognised Alpha reloc number: %d"),
+ (*_bfd_error_handler) (_("%B: unrecognised Alpha reloc number: %d"),
abfd, r_type);
bfd_set_error (bfd_error_bad_value);
r_type = R_ALPHA_NONE;
r_type = ELF64_R_TYPE (dst->r_info);
if (r_type >= (unsigned int) R_MMIX_max)
{
- _bfd_error_handler (_("%A: invalid MMIX reloc number: %d"), abfd, r_type);
+ _bfd_error_handler (_("%B: invalid MMIX reloc number: %d"), abfd, r_type);
r_type = 0;
}
cache_ptr->howto = &elf_mmix_howto_table[r_type];
if (xlat)
{
len = strlen (xlat->bfd_name);
- res = bfd_alloc (abfd, len+1);
+ res = bfd_alloc (abfd, len + 1);
if (res == NULL)
return;
memcpy (res, xlat->bfd_name, len+1);
if (reloc.r_extern)
{
/* PR 17512: file: 8396-1185-0.004. */
- if (bfd_get_symcount (abfd) > 0 && num > bfd_get_symcount (abfd))
+ if (num >= bfd_mach_o_count_symbols (abfd))
sym = bfd_und_section_ptr->symbol_ptr_ptr;
else if (syms == NULL)
sym = bfd_und_section_ptr->symbol_ptr_ptr;
/* Allocate and read relocs. */
native_size = count * BFD_MACH_O_RELENT_SIZE;
+ /* PR 17512: file: 09477b57. */
+ if (native_size < count)
+ return -1;
+
native_relocs =
(struct mach_o_reloc_info_external *) bfd_malloc (native_size);
if (native_relocs == NULL)
if (asect->relocation == NULL)
{
+ if (asect->reloc_count * sizeof (arelent) < asect->reloc_count)
+ return -1;
res = bfd_malloc (asect->reloc_count * sizeof (arelent));
if (res == NULL)
return -1;
if (mdata->dyn_reloc_cache == NULL)
{
+ if ((dysymtab->nextrel + dysymtab->nlocrel) * sizeof (arelent)
+ < (dysymtab->nextrel + dysymtab->nlocrel))
+ return -1;
+
res = bfd_malloc ((dysymtab->nextrel + dysymtab->nlocrel)
* sizeof (arelent));
if (res == NULL)
mdata->filelen += sym->strsize;
if (bfd_seek (abfd, sym->stroff, SEEK_SET) != 0)
- return FALSE;
+ goto err;
if (_bfd_stringtab_emit (abfd, strtab) != TRUE)
goto err;
- _bfd_stringtab_free (strtab);
/* Pad string table. */
padlen = bfd_mach_o_pad4 (abfd, sym->strsize);
err:
_bfd_stringtab_free (strtab);
+ sym->strsize = 0;
return FALSE;
}
cmd->indirectsymoff = mdata->filelen;
mdata->filelen += cmd->nindirectsyms * 4;
+ if (cmd->nindirectsyms * 4 < cmd->nindirectsyms)
+ return FALSE;
cmd->indirect_syms = bfd_zalloc (abfd, cmd->nindirectsyms * 4);
if (cmd->indirect_syms == NULL)
return FALSE;
}
mdata->nsects = nsect;
- mdata->sections = bfd_alloc (abfd,
- mdata->nsects * sizeof (bfd_mach_o_section *));
+ mdata->sections = bfd_alloc2 (abfd,
+ mdata->nsects, sizeof (bfd_mach_o_section *));
if (mdata->sections == NULL)
return FALSE;
/* Return now if there are no symbols or if already loaded. */
return TRUE;
- sym->symbols = bfd_alloc (abfd, sym->nsyms * sizeof (bfd_mach_o_asymbol));
-
+ sym->symbols = bfd_alloc2 (abfd, sym->nsyms, sizeof (bfd_mach_o_asymbol));
if (sym->symbols == NULL)
{
(*_bfd_error_handler) (_("bfd_mach_o_read_symtab_symbols: unable to allocate memory for symbols"));
+ sym->nsyms = 0;
return FALSE;
}
if (!bfd_mach_o_read_symtab_strtab (abfd))
- {
- bfd_release (abfd, sym->symbols);
- sym->symbols = NULL;
- return FALSE;
- }
+ goto fail;
for (i = 0; i < sym->nsyms; i++)
- {
- if (!bfd_mach_o_read_symtab_symbol (abfd, sym, &sym->symbols[i], i))
- {
- bfd_release (abfd, sym->symbols);
- sym->symbols = NULL;
- return FALSE;
- }
- }
+ if (!bfd_mach_o_read_symtab_symbol (abfd, sym, &sym->symbols[i], i))
+ goto fail;
return TRUE;
+
+ fail:
+ bfd_release (abfd, sym->symbols);
+ sym->symbols = NULL;
+ sym->nsyms = 0;
+ return FALSE;
}
static const char *
}
/* Allocate threads. */
- cmd->flavours = bfd_alloc
- (abfd, nflavours * sizeof (bfd_mach_o_thread_flavour));
+ cmd->flavours = bfd_alloc2
+ (abfd, nflavours, sizeof (bfd_mach_o_thread_flavour));
if (cmd->flavours == NULL)
return FALSE;
cmd->nflavours = nflavours;
unsigned int module_len = wide ? 56 : 52;
cmd->dylib_module =
- bfd_alloc (abfd, cmd->nmodtab * sizeof (bfd_mach_o_dylib_module));
+ bfd_alloc2 (abfd, cmd->nmodtab, sizeof (bfd_mach_o_dylib_module));
if (cmd->dylib_module == NULL)
return FALSE;
if (cmd->ntoc != 0)
{
- unsigned int i;
+ unsigned long i;
- cmd->dylib_toc = bfd_alloc
- (abfd, cmd->ntoc * sizeof (bfd_mach_o_dylib_table_of_content));
+ cmd->dylib_toc = bfd_alloc2
+ (abfd, cmd->ntoc, sizeof (bfd_mach_o_dylib_table_of_content));
if (cmd->dylib_toc == NULL)
return FALSE;
{
unsigned int i;
- cmd->indirect_syms = bfd_alloc
- (abfd, cmd->nindirectsyms * sizeof (unsigned int));
+ cmd->indirect_syms = bfd_alloc2
+ (abfd, cmd->nindirectsyms, sizeof (unsigned int));
if (cmd->indirect_syms == NULL)
return FALSE;
unsigned long v;
unsigned int i;
- cmd->ext_refs = bfd_alloc
- (abfd, cmd->nextrefsyms * sizeof (bfd_mach_o_dylib_reference));
+ cmd->ext_refs = bfd_alloc2
+ (abfd, cmd->nextrefsyms, sizeof (bfd_mach_o_dylib_reference));
if (cmd->ext_refs == NULL)
return FALSE;
}
/* Allocate sections array. */
- mdata->sections = bfd_alloc (abfd,
- mdata->nsects * sizeof (bfd_mach_o_section *));
+ mdata->sections = bfd_alloc2 (abfd,
+ mdata->nsects, sizeof (bfd_mach_o_section *));
/* Fill the array. */
csect = 0;
mdata->first_command = NULL;
mdata->last_command = NULL;
- cmd = bfd_alloc (abfd, header->ncmds * sizeof (bfd_mach_o_load_command));
+
+ cmd = bfd_alloc2 (abfd, header->ncmds, sizeof (bfd_mach_o_load_command));
if (cmd == NULL)
return FALSE;
goto error;
adata->archentries =
- bfd_alloc (abfd, adata->nfat_arch * sizeof (mach_o_fat_archentry));
+ bfd_alloc2 (abfd, adata->nfat_arch, sizeof (mach_o_fat_archentry));
if (adata->archentries == NULL)
goto error;
}
abfd->tdata.mach_o_fat_data = adata;
+
return abfd->xvec;
error:
/* PR 17512: Handle corrupt PE binaries. */
if (edt.eat_addr + (edt.num_functions * 4) - adj >= datasize
+ /* PR 17512: file: 092b1829 */
+ || (edt.num_functions * 4) < edt.num_functions
/* PR 17512 file: 140-165018-0.004. */
|| data + edt.eat_addr - adj < data)
fprintf (file, _("\tInvalid Export Address Table rva (0x%lx) or entry count (0x%lx)\n"),
/* PR 17512: Handle corrupt PE binaries. */
if (edt.npt_addr + (edt.num_names * 4) - adj >= datasize
+ /* PR 17512: file: bb68816e. */
+ || edt.num_names * 4 < edt.num_names
|| (data + edt.npt_addr - adj) < data)
fprintf (file, _("\tInvalid Name Pointer Table rva (0x%lx) or entry count (0x%lx)\n"),
(long) edt.npt_addr,
return FALSE;
}
alt_section = NULL;
- while (*src)
+ while (src < src_end && *src)
{
switch (*src)
{
+2015-02-03 Nick Clifton <nickc@redhat.com>
+
+ PR binutils/17512
+ * objdump.c (display_any_bfd): Fail if archives nest too deeply.
+
2015-01-28 James Bowman <james.bowman@ftdichip.com>
* readelf.c: Add FT32 support.
{
/* Prevent corrupted files from spinning us into an
infinite loop. 100 is an arbitrary heuristic. */
- non_fatal (_("Archive nesting is too deep"));
+ fatal (_("Archive nesting is too deep"));
return;
}
else