diff options
author | Ian Lance Taylor <ian@airs.com> | 1996-09-17 18:20:06 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 1996-09-17 18:20:06 +0000 |
commit | 7f21c97c444fee0e10ff0e6a3c6737d9a3a4633a (patch) | |
tree | 3b97db7e072d10385804828b56e64470f47f77ec /bfd/coffcode.h | |
parent | 88907d73efe4b270d76730bbd343c839c2518aea (diff) | |
download | gdb-7f21c97c444fee0e10ff0e6a3c6737d9a3a4633a.zip gdb-7f21c97c444fee0e10ff0e6a3c6737d9a3a4633a.tar.gz gdb-7f21c97c444fee0e10ff0e6a3c6737d9a3a4633a.tar.bz2 |
* 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.
Diffstat (limited to 'bfd/coffcode.h')
-rw-r--r-- | bfd/coffcode.h | 52 |
1 files changed, 42 insertions, 10 deletions
diff --git a/bfd/coffcode.h b/bfd/coffcode.h index 8de83a5..508f75e 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; |