From: Ian Lance Taylor Date: Tue, 17 Sep 1996 18:20:06 +0000 (+0000) Subject: * coffcode.h (coff_slurp_line_table): Warn about illegal symbol X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7f21c97c444fee0e10ff0e6a3c6737d9a3a4633a;p=binutils-gdb.git * coffcode.h (coff_slurp_line_table): Warn about illegal symbol indices, rather than crashing. (coff_slurp_reloc_table): Likewise. Check whether the howto field is NULL. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 5718b146162..4bac85b3341 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +Tue Sep 17 14:18:31 1996 Ian Lance Taylor + + * coffcode.h (coff_slurp_line_table): Warn about illegal symbol + indices, rather than crashing. + (coff_slurp_reloc_table): Likewise. Check whether the howto field + is NULL. + Mon Sep 16 12:39:36 1996 Ian Lance Taylor * coff-arm.c (aoutarm_std_reloc_howto): Change dst_mask for ARM26D diff --git a/bfd/coffcode.h b/bfd/coffcode.h index 8de83a543b7..508f75e0639 100644 --- a/bfd/coffcode.h +++ b/bfd/coffcode.h @@ -2986,7 +2986,7 @@ coff_set_section_contents (abfd, section, location, offset, count) if (abfd->output_has_begun == false) /* set by bfd.c handler */ coff_compute_section_file_positions (abfd); -#ifdef _LIB +#if defined(_LIB) && !defined(TARG_AUX) /* The physical address field of a .lib section is used to hold the number of shared libraries in the section. This code counts the @@ -3138,11 +3138,27 @@ coff_slurp_line_table (abfd, asect) if (cache_ptr->line_number == 0) { - coff_symbol_type *sym = - (coff_symbol_type *) (dst.l_addr.l_symndx - + obj_raw_syments (abfd))->u.syment._n._n_n._n_zeroes; + boolean warned; + long symndx; + coff_symbol_type *sym; + + warned = false; + symndx = dst.l_addr.l_symndx; + if (symndx < 0 || symndx >= obj_raw_syment_count (abfd)) + { + (*_bfd_error_handler) + ("%s: warning: illegal symbol index %ld in line numbers", + bfd_get_filename (abfd), dst.l_addr.l_symndx); + symndx = 0; + warned = true; + } + /* FIXME: We should not be casting between ints and + pointers like this. */ + sym = ((coff_symbol_type *) + ((symndx + obj_raw_syments (abfd)) + ->u.syment._n._n_n._n_zeroes)); cache_ptr->u.sym = (asymbol *) sym; - if (sym->lineno != NULL) + if (sym->lineno != NULL && ! warned) { (*_bfd_error_handler) ("%s: warning: duplicate line number information for `%s'", @@ -3604,11 +3620,20 @@ coff_slurp_reloc_table (abfd, asect, symbols) if (dst.r_symndx != -1) { - /* @@ Should never be greater than count of symbols! */ - if (dst.r_symndx >= obj_conv_table_size (abfd)) - abort (); - cache_ptr->sym_ptr_ptr = symbols + obj_convert (abfd)[dst.r_symndx]; - ptr = *(cache_ptr->sym_ptr_ptr); + if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd)) + { + (*_bfd_error_handler) + ("%s: warning: illegal symbol index %ld in relocs", + bfd_get_filename (abfd), dst.r_symndx); + cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; + ptr = 0; + } + else + { + cache_ptr->sym_ptr_ptr = (symbols + + obj_convert (abfd)[dst.r_symndx]); + ptr = *(cache_ptr->sym_ptr_ptr); + } } else { @@ -3633,6 +3658,13 @@ coff_slurp_reloc_table (abfd, asect, symbols) RTYPE2HOWTO (cache_ptr, &dst); #endif + if (cache_ptr->howto == NULL) + { + (*_bfd_error_handler) + ("%s: illegal relocation type %d at address 0x%lx", + bfd_get_filename (abfd), dst.r_type, (long) dst.r_vaddr); + return false; + } } asect->relocation = reloc_cache;