Throw away dodgy coff line number info earlier
authorAlan Modra <amodra@gmail.com>
Wed, 12 Nov 2014 04:21:38 +0000 (14:51 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 12 Nov 2014 04:45:03 +0000 (15:15 +1030)
PR 17521
* coffcode.h (coff_slurp_line_table): Drop line number info
not preceded by a valid function entry.  Revert last change.

bfd/ChangeLog
bfd/coffcode.h

index 9f48d57849b6d220fce2563aec2953df47c80367..a04b9240b416fc0e2d4b36b701464d50b434dafc 100644 (file)
@@ -1,3 +1,9 @@
+2014-11-12  Alan Modra  <amodra@gmail.com>
+
+       PR binutils/17512
+       * coffcode.h (coff_slurp_line_table): Drop line number info
+       not preceded by a valid function entry.  Revert last change.
+
 2014-11-11  Nick Clifton  <nickc@redhat.com>
 
        PR binutils/17512
@@ -33,7 +39,6 @@
        lineno.  Don't both allocating terminator in n_lineno_cache.
        Redirect sym->lineno pointer to where n_lineno_cache will be
        copied, and free n_lineno_cache.
-
        * pe-mips.c (NUM_HOWTOS): Typo fix.
 
 2014-11-11  Alan Modra  <amodra@gmail.com>
index 4bc80bd25a6f40ca51fa3336d6234e824d7fbe13..acc7360e3d90bda4a5e3adf9c0681a83baf1c8f1 100644 (file)
@@ -4513,6 +4513,7 @@ coff_slurp_line_table (bfd *abfd, asection *asect)
   int ordered = 1;
   unsigned int nbr_func;
   LINENO *src;
+  bfd_boolean have_func;
 
   BFD_ASSERT (asect->lineno == NULL);
 
@@ -4535,6 +4536,7 @@ coff_slurp_line_table (bfd *abfd, asection *asect)
   asect->lineno = lineno_cache;
   src = native_lineno;
   nbr_func = 0;
+  have_func = FALSE;
 
   for (counter = 0; counter < asect->lineno_count; counter++, src++)
     {
@@ -4552,6 +4554,7 @@ coff_slurp_line_table (bfd *abfd, asection *asect)
          bfd_vma symndx;
          coff_symbol_type *sym;
 
+         have_func = FALSE;
          symndx = dst.l_addr.l_symndx;
          if (symndx >= obj_raw_syment_count (abfd))
            {
@@ -4577,6 +4580,7 @@ coff_slurp_line_table (bfd *abfd, asection *asect)
              continue;
            }
 
+         have_func = TRUE;
          nbr_func++;
          cache_ptr->u.sym = (asymbol *) sym;
          if (sym->lineno != NULL)
@@ -4589,6 +4593,10 @@ coff_slurp_line_table (bfd *abfd, asection *asect)
            ordered = 0;
          prev_offset = sym->symbol.value;
        }
+      else if (!have_func)
+       /* Drop line information that has no associated function.
+          PR 17521: file: 078-10659-0.004.  */
+       continue;
       else
        cache_ptr->u.offset = (dst.l_addr.l_paddr
                               - bfd_section_vma (abfd, asect));
@@ -4642,15 +4650,7 @@ coff_slurp_line_table (bfd *abfd, asection *asect)
                    *n_cache_ptr++ = *old_ptr++;
                  while (old_ptr->line_number != 0);
                }
-             /* PR 17521: file: 078-10659-0.004.  */
-             if (n_cache_ptr < n_lineno_cache + asect->lineno_count)
-               {
-                 amt = n_cache_ptr - n_lineno_cache;
-                 memcpy (lineno_cache, n_lineno_cache, amt * sizeof (alent));
-                 memset (lineno_cache + amt, 0, (asect->lineno_count - amt) * sizeof (alent));
-               }
-             else
-               memcpy (lineno_cache, n_lineno_cache, amt);
+             memcpy (lineno_cache, n_lineno_cache, amt);
            }
          bfd_release (abfd, func_table);
        }
This page took 0.027536 seconds and 4 git commands to generate.