X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Fcoffgen.c;h=88591f1499ddacebba67a08f0c4fb4e2200afd24;hb=de4112fa387b662c7c7a1dd3e334a1274ca54d28;hp=4a06c68a0037d820be9ac881cd359bf024d29141;hpb=8f615d07046056cd62e6916b1af80223df8641e8;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/coffgen.c b/bfd/coffgen.c index 4a06c68a00..88591f1499 100644 --- a/bfd/coffgen.c +++ b/bfd/coffgen.c @@ -280,7 +280,16 @@ coff_object_p (abfd) bfd_coff_swap_filehdr_in (abfd, filehdr, &internal_f); bfd_release (abfd, filehdr); - if (bfd_coff_bad_format_hook (abfd, &internal_f) == false) + /* The XCOFF format has two sizes for the f_opthdr. SMALL_AOUTSZ + (less than aoutsz) used in object files and AOUTSZ (equal to + aoutsz) in executables. The bfd_coff_swap_aouthdr_in function + expects this header to be aoutsz bytes in length, so we use that + value in the call to bfd_alloc below. But we must be careful to + only read in f_opthdr bytes in the call to bfd_bread. We should + also attempt to catch corrupt or non-COFF binaries with a strange + value for f_opthdr. */ + if (bfd_coff_bad_format_hook (abfd, &internal_f) == false + || internal_f.f_opthdr > aoutsz) { bfd_set_error (bfd_error_wrong_format); return 0; @@ -293,7 +302,7 @@ coff_object_p (abfd) opthdr = bfd_alloc (abfd, aoutsz); if (opthdr == NULL) - return 0;; + return 0; if (bfd_bread (opthdr, (bfd_size_type) internal_f.f_opthdr, abfd) != internal_f.f_opthdr) { @@ -546,15 +555,18 @@ coff_count_linenumbers (abfd) section's linenumber count. */ alent *l = q->lineno; - ++q->symbol.section->output_section->lineno_count; - ++total; - ++l; - while (l->line_number != 0) + do { + asection * sec = q->symbol.section->output_section; + + /* Do not try to update fields in read-only sections. */ + if (! bfd_is_const_section (sec)) + sec->lineno_count ++; + ++total; - ++q->symbol.section->output_section->lineno_count; ++l; } + while (l->line_number != 0); } } } @@ -1054,7 +1066,7 @@ coff_write_alien_symbol (abfd, symbol, written, string_size_p, if (! obj_pe (abfd)) native->u.syment.n_value += symbol->section->output_section->vma; - /* Copy the any flags from the the file header into the symbol. + /* Copy the any flags from the file header into the symbol. FIXME: Why? */ { coff_symbol_type *c = coff_symbol_from (abfd, symbol); @@ -1136,8 +1148,9 @@ coff_write_native_symbol (abfd, symbol, written, string_size_p, } symbol->done_lineno = true; - symbol->symbol.section->output_section->moving_line_filepos += - count * bfd_coff_linesz (abfd); + if (! bfd_is_const_section (symbol->symbol.section->output_section)) + symbol->symbol.section->output_section->moving_line_filepos += + count * bfd_coff_linesz (abfd); } return coff_write_symbol (abfd, &(symbol->symbol), native, written, @@ -2122,7 +2135,7 @@ coff_print_symbol (abfd, filep, symbol, how) next = auxp->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.l; llnos = auxp->u.auxent.x_sym.x_fcnary.x_fcn.x_lnnoptr; fprintf (file, - _("AUX tagndx %ld ttlsiz 0x%lx lnnos %ld next %ld"), + "AUX tagndx %ld ttlsiz 0x%lx lnnos %ld next %ld", tagndx, auxp->u.auxent.x_sym.x_misc.x_fsize, llnos, next); break; @@ -2468,7 +2481,7 @@ bfd_coff_set_symbol_class (abfd, symbol, class) if (! obj_pe (abfd)) native->u.syment.n_value += symbol->section->output_section->vma; - /* Copy the any flags from the the file header into the symbol. + /* Copy the any flags from the file header into the symbol. FIXME: Why? */ native->u.syment.n_flags = bfd_asymbol_bfd (& csym->symbol)->flags; }