Also, lest I forget, I've just applied this binutils patch to
fix bogus import table sizes.  Danny, you had it right in the
export table size, looks like you just forgot to propagate
the fix.

-- 
Pedro Alves

2009-12-31  Pedro Alves <pedroal...@users.sourceforge.net>

        bfd/
        peXXigen.c (_bfd_XXi_final_link_postscript): Fix import directory
        size.  Remove debug printfs.

---
 bfd/peXXigen.c |   19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

Index: binutils/bfd/peXXigen.c
===================================================================
--- binutils.orig/bfd/peXXigen.c        2009-12-31 14:25:06.000000000 +0000
+++ binutils/bfd/peXXigen.c     2009-12-31 16:26:53.000000000 +0000
@@ -2429,21 +2429,28 @@ _bfd_XXi_final_link_postscript (bfd * ab
       && pe_data 
(abfd)->pe_opthdr.DataDirectory[PE_IMPORT_TABLE].VirtualAddress == 0)
     {
       struct coff_link_hash_entry *h2;
-      int sz;
 
       h2 = coff_link_hash_lookup (coff_hash_table (info),
                  "__idata_end__", FALSE, FALSE, TRUE);
       if (h2 != NULL)
        {
-         sz = (int) ((int)h2) - ((int)h1);
+         int a1, a2;
+
+         a1 = h1->root.u.def.value
+           + h1->root.u.def.section->output_section->vma
+           + h1->root.u.def.section->output_offset
+           - pe_data (abfd)->pe_opthdr.ImageBase;
+         a2 = h2->root.u.def.value
+           + h2->root.u.def.section->output_section->vma
+           + h2->root.u.def.section->output_offset
+           - pe_data (abfd)->pe_opthdr.ImageBase;
+
          pe_data 
(abfd)->pe_opthdr.DataDirectory[PE_IMPORT_TABLE].VirtualAddress =
            h1->root.u.def.value
            + h1->root.u.def.section->output_section->vma
            + h1->root.u.def.section->output_offset
            - pe_data (abfd)->pe_opthdr.ImageBase;
-         pe_data (abfd)->pe_opthdr.DataDirectory[PE_IMPORT_TABLE].Size = sz;
-
-//       fprintf(stderr, "Yow import %p 0x%04x\n", (void *)pe_data 
(abfd)->pe_opthdr.DataDirectory[PE_IMPORT_TABLE].VirtualAddress, sz);
+         pe_data (abfd)->pe_opthdr.DataDirectory[PE_IMPORT_TABLE].Size = a2 - 
a1;
        }
       else
         {
@@ -2477,8 +2484,6 @@ _bfd_XXi_final_link_postscript (bfd * ab
 
          pe_data 
(abfd)->pe_opthdr.DataDirectory[PE_EXPORT_TABLE].VirtualAddress = a1;
          pe_data (abfd)->pe_opthdr.DataDirectory[PE_EXPORT_TABLE].Size = a2 - 
a1;
-
-//       fprintf(stderr, "Yow export %p 0x%04x\n", (void *)pe_data 
(abfd)->pe_opthdr.DataDirectory[PE_EXPORT_TABLE].VirtualAddress, a2-a1);
        }
       else
         {

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Cegcc-devel mailing list
Cegcc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cegcc-devel

Reply via email to