Automatic date update in version.in
[binutils-gdb.git] / bfd / coffgen.c
index 40f1ac718e48c74f1a95576a6ed9aa2c8a79f2af..57f380a64250dc5ecb0d5782b7c195b4b317983e 100644 (file)
@@ -1,5 +1,5 @@
 /* Support for the generic parts of COFF, for BFD.
-   Copyright (C) 1990-2021 Free Software Foundation, Inc.
+   Copyright (C) 1990-2022 Free Software Foundation, Inc.
    Written by Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -1036,7 +1036,10 @@ coff_write_symbol (bfd *abfd,
        {
          BFD_ASSERT (! (native + j + 1)->is_sym);
 
-         if (native->u.syment.n_sclass == C_FILE && j > 0)
+         /* Adjust auxent only if this isn't the filename
+            auxiliary entry.  */
+         if (native->u.syment.n_sclass == C_FILE
+             && (native + j + 1)->u.auxent.x_file.x_ftype)
            coff_write_auxent_fname (abfd, (char *) (native + j + 1)->extrap,
                                     &(native + j + 1)->u.auxent, string_size_p);
 
@@ -1089,6 +1092,7 @@ coff_write_alien_symbol (bfd *abfd,
        memset (isym, 0, sizeof (*isym));
       return true;
     }
+  memset (dummy, 0, sizeof dummy);
   native = dummy;
   native->is_sym = true;
   native[1].is_sym = false;
@@ -1423,6 +1427,11 @@ coff_write_symbols (bfd *abfd)
                  char *str;
                  size_t str_length;
 
+                 /* Add strings from aux entries only if this isn't the
+                    filename auxiliary entry.  */
+                 if (!c_symbol->native[j + 1].u.auxent.x_file.x_ftype)
+                   continue;
+
                  if (c_symbol->native[j + 1].u.auxent.x_file.x_n.x_fname[0] != 0)
                    continue;
 
@@ -2122,10 +2131,10 @@ coff_get_symbol_info (bfd *abfd, asymbol *symbol, symbol_info *ret)
   if (coffsymbol (symbol)->native != NULL
       && coffsymbol (symbol)->native->fix_value
       && coffsymbol (symbol)->native->is_sym)
-    ret->value =
-      ((coffsymbol (symbol)->native->u.syment.n_value -
-       (bfd_hostptr_t) obj_raw_syments (abfd))
-       / sizeof (combined_entry_type));
+    ret->value
+      = (((bfd_hostptr_t) coffsymbol (symbol)->native->u.syment.n_value
+         - (bfd_hostptr_t) obj_raw_syments (abfd))
+        / sizeof (combined_entry_type));
 }
 
 /* Print out information about COFF symbol.  */
@@ -2173,10 +2182,11 @@ coff_print_symbol (bfd *abfd,
          if (! combined->fix_value)
            val = (bfd_vma) combined->u.syment.n_value;
          else
-           val = ((combined->u.syment.n_value - (bfd_hostptr_t) root)
+           val = (((bfd_hostptr_t) combined->u.syment.n_value
+                   - (bfd_hostptr_t) root)
                   / sizeof (combined_entry_type));
 
-         fprintf (file, "(sec %2d)(fl 0x%02x)(ty %3x)(scl %3d) (nx %d) 0x",
+         fprintf (file, "(sec %2d)(fl 0x%02x)(ty %4x)(scl %3d) (nx %d) 0x",
                   combined->u.syment.n_scnum,
                   combined->u.syment.n_flags,
                   combined->u.syment.n_type,
@@ -2207,7 +2217,7 @@ coff_print_symbol (bfd *abfd,
                  fprintf (file, "File ");
                  /* Add additional information if this isn't the filename
                     auxiliary entry.  */
-                 if (aux)
+                 if (auxp->u.auxent.x_file.x_ftype)
                    fprintf (file, "ftype %d fname \"%s\"",
                             auxp->u.auxent.x_file.x_ftype,
                             (char *) auxp->u.auxent.x_file.x_n.x_n.x_offset);
@@ -2372,7 +2382,7 @@ coff_find_nearest_line_with_names (bfd *abfd,
        }
 
       if (sec_data != NULL && sec_data->saved_bias)
-       bias = sec_data->saved_bias;
+       bias = sec_data->bias;
       else if (symbols)
        {
          bias = _bfd_dwarf2_find_symbol_bias (symbols,