* peXXigen.c (pe_print_edata): Compute the size of the export table from the
authorNick Clifton <nickc@redhat.com>
Fri, 29 Jul 2005 14:07:01 +0000 (14:07 +0000)
committerNick Clifton <nickc@redhat.com>
Fri, 29 Jul 2005 14:07:01 +0000 (14:07 +0000)
  size field in the DataDictionary and not the size of the section.  Some
  linkers embed the export table inside a larger section.

bfd/ChangeLog
bfd/peXXigen.c

index 5c7d2f9d8f5b36a36cc39ee0c74c6bd2cb8cb112..0728b7fd03dbd766e338a515c1c9940590acd142 100644 (file)
@@ -1,3 +1,10 @@
+2005-07-29  Pavel Kankovsky  <peak@argo.troja.mff.cuni.cz>
+
+       * peXXigen.c (pe_print_edata): Compute the size of the export
+       table from the size field in the DataDictionary and not the size
+       of the section.  Some linkers embed the export table inside a
+       larger section.
+
 2005-07-29  Alan Modra  <amodra@bigpond.net.au>
 
        * elf-bfd.h (struct elf_backend_data): Add action_discarded.
index 1be08466b2b8ec22516a48e0727d898b37a35082..652e45c65bf8d4d3c7e7e8bc6fe0c4b606a59b13 100644 (file)
@@ -1346,6 +1346,7 @@ pe_print_edata (bfd * abfd, void * vfile)
        return TRUE;
 
       addr = section->vma;
+      dataoff = 0;
       datasize = section->size;
       if (datasize == 0)
        return TRUE;
@@ -1355,12 +1356,8 @@ pe_print_edata (bfd * abfd, void * vfile)
       addr += extra->ImageBase;
 
       for (section = abfd->sections; section != NULL; section = section->next)
-       {
-         datasize = section->size;
-
-         if (addr >= section->vma && addr < section->vma + datasize)
-           break;
-       }
+       if (addr >= section->vma && addr < section->vma + section->size)
+         break;
 
       if (section == NULL)
        {
@@ -1368,14 +1365,21 @@ pe_print_edata (bfd * abfd, void * vfile)
                   _("\nThere is an export table, but the section containing it could not be found\n"));
          return TRUE;
        }
+
+      dataoff = addr - section->vma;
+      datasize = extra->DataDirectory[0].Size;
+      if (datasize > section->size - dataoff)
+       {
+         fprintf (file,
+                  _("\nThere is an export table in %s, but it does not fit into that section\n"),
+                  section->name);
+         return TRUE;
+       }
     }
 
   fprintf (file, _("\nThere is an export table in %s at 0x%lx\n"),
           section->name, (unsigned long) addr);
 
-  dataoff = addr - section->vma;
-  datasize -= dataoff;
-
   data = bfd_malloc (datasize);
   if (data == NULL)
     return FALSE;
This page took 0.036111 seconds and 4 git commands to generate.