target: consider addressable unit size when reading/writing memory
[deliverable/binutils-gdb.git] / bfd / coffgen.c
index aa015597b78fec48c8b7320fa1aef2caf5cb44e8..2cd7b09c6a21774872d9f25c984f2d60e20904ac 100644 (file)
@@ -178,18 +178,21 @@ make_a_section_from_file (bfd *abfd,
                 abfd, name);
              return FALSE;
            }
-         if (name[1] != 'z')
+         if (return_section->compress_status == COMPRESS_SECTION_DONE)
            {
-             unsigned int len = strlen (name);
+             if (name[1] != 'z')
+               {
+                 unsigned int len = strlen (name);
 
-             new_name = bfd_alloc (abfd, len + 2);
-             if (new_name == NULL)
-               return FALSE;
-             new_name[0] = '.';
-             new_name[1] = 'z';
-             memcpy (new_name + 2, name + 1, len);
+                 new_name = bfd_alloc (abfd, len + 2);
+                 if (new_name == NULL)
+                   return FALSE;
+                 new_name[0] = '.';
+                 new_name[1] = 'z';
+                 memcpy (new_name + 2, name + 1, len);
+               }
            }
-         break;
+         break;
        case decompress:
          if (!bfd_init_section_decompress_status (abfd, return_section))
            {
@@ -468,7 +471,10 @@ _bfd_coff_internal_syment_name (bfd *abfd,
          if (strings == NULL)
            return NULL;
        }
-      if (sym->_n._n_n._n_offset >= obj_coff_strings_len (abfd))
+      /* PR 17910: Only check for string overflow if the length has been set.
+        Some DLLs, eg those produced by Visual Studio, may not set the length field.  */
+      if (obj_coff_strings_len (abfd) > 0
+         && sym->_n._n_n._n_offset >= obj_coff_strings_len (abfd))
        return NULL;
       return strings + sym->_n._n_n._n_offset;
     }
@@ -1802,7 +1808,7 @@ coff_get_normalized_symtab (bfd *abfd)
       if (symbol_ptr->u.syment.n_sclass == C_FILE
          && symbol_ptr->u.syment.n_numaux > 0
          && raw_src + symesz + symbol_ptr->u.syment.n_numaux
-         * sizeof (union internal_auxent) >= raw_end)
+         * symesz > raw_end)
        {
          bfd_release (abfd, internal);
          return NULL;
@@ -1821,7 +1827,6 @@ coff_get_normalized_symtab (bfd *abfd)
            }
 
          raw_src += symesz;
-
          bfd_coff_swap_aux_in (abfd, (void *) raw_src,
                                symbol_ptr->u.syment.n_type,
                                symbol_ptr->u.syment.n_sclass,
@@ -2242,6 +2247,26 @@ coff_find_nearest_line_with_names (bfd *abfd,
                                     &coff_data(abfd)->dwarf2_find_line_info))
     return TRUE;
 
+  /* If the DWARF lookup failed, but there is DWARF information available
+     then the problem might be that the file has been rebased.  This tool
+     changes the VMAs of all the sections, but it does not update the DWARF
+     information.  So try again, using a bias against the address sought.  */
+  if (coff_data (abfd)->dwarf2_find_line_info != NULL)
+    {
+      bfd_signed_vma bias;
+
+      bias = _bfd_dwarf2_find_symbol_bias (symbols,
+                                          & coff_data (abfd)->dwarf2_find_line_info);
+      
+      if (bias
+         && _bfd_dwarf2_find_nearest_line (abfd, symbols, NULL, section,
+                                           offset + bias,
+                                           filename_ptr, functionname_ptr,
+                                           line_ptr, NULL, debug_sections, 0,
+                                           &coff_data(abfd)->dwarf2_find_line_info))
+       return TRUE;
+    }
+
   *filename_ptr = 0;
   *functionname_ptr = 0;
   *line_ptr = 0;
This page took 0.025262 seconds and 4 git commands to generate.