* Makefile.in (ALLDEPFILES): Remove alphanbsd-nat.c.
[deliverable/binutils-gdb.git] / bfd / coffgen.c
index 08c39f6770309ce5cc3ca4f7cc541857d90b974f..88591f1499ddacebba67a08f0c4fb4e2200afd24 100644 (file)
@@ -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,
@@ -1645,7 +1658,7 @@ _bfd_coff_read_string_table (abfd)
   if (strsize < STRING_SIZE_SIZE)
     {
       (*_bfd_error_handler)
-       (_("%s: bad string table size %lu"), bfd_get_filename (abfd),
+       (_("%s: bad string table size %lu"), bfd_archive_filename (abfd),
         (unsigned long) strsize);
       bfd_set_error (bfd_error_bad_value);
       return NULL;
@@ -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;
        }
This page took 0.025227 seconds and 4 git commands to generate.