* peigen.c (_bfd_pei_swap_aouthdr_in): If some DataDirectory
authorDJ Delorie <dj@redhat.com>
Tue, 26 Sep 2000 20:42:29 +0000 (20:42 +0000)
committerDJ Delorie <dj@redhat.com>
Tue, 26 Sep 2000 20:42:29 +0000 (20:42 +0000)
is empty, make sure that its rva also 0. NT loader dislikes
having otherwise.

bfd/ChangeLog
bfd/peigen.c

index 3dfdb8a800d7b3bdbd0eb935f169759850437b43..737df3c0be2768fff6188708feeaeea9aa5e417c 100644 (file)
@@ -1,3 +1,9 @@
+2000-09-26  Paul Sokolovsky  <Paul.Sokolovsky@technologist.com>
+
+       * peigen.c (_bfd_pei_swap_aouthdr_in): If some DataDirectory
+       is empty, make sure that its rva also 0. NT loader dislikes
+       having otherwise.
+
 2000-09-26  Steve Ellcey <sje@cup.hp.com>
 
        * som.c (som_bfd_derive_misc_symbol_info): Make weak symbols
index 6c983caad7b7a856a9ca30a2f543f98971804559..066a6019c066aa3ba772b96740dfe612c85f7ce4 100644 (file)
@@ -469,10 +469,17 @@ _bfd_pei_swap_aouthdr_in (abfd, aouthdr_ext1, aouthdr_int1)
     int idx;
     for (idx=0; idx < 16; idx++)
       {
-       a->DataDirectory[idx].VirtualAddress =
-         bfd_h_get_32 (abfd, (bfd_byte *)src->DataDirectory[idx][0]);
-       a->DataDirectory[idx].Size =
-         bfd_h_get_32 (abfd, (bfd_byte *)src->DataDirectory[idx][1]);
+        /* If data directory is empty, rva also should be 0 */
+       int size = bfd_h_get_32 (abfd, (bfd_byte *) src->DataDirectory[idx][1]);
+       a->DataDirectory[idx].Size = size;
+
+       if (size)
+          {
+           a->DataDirectory[idx].VirtualAddress =
+             bfd_h_get_32 (abfd, (bfd_byte *) src->DataDirectory[idx][0]);
+          }
+        else
+         a->DataDirectory[idx].VirtualAddress = 0;
       }
   }
 
@@ -527,9 +534,16 @@ add_data_entry (abfd, aout, idx, name, base)
       && (coff_section_data (abfd, sec) != NULL)
       && (pei_section_data (abfd, sec) != NULL))
     {
-      aout->DataDirectory[idx].VirtualAddress = (sec->vma - base) & 0xffffffff;
-      aout->DataDirectory[idx].Size = pei_section_data (abfd, sec)->virt_size;
-      sec->flags |= SEC_DATA;
+      /* If data directory is empty, rva also should be 0 */
+      int size = pei_section_data (abfd, sec)->virt_size;
+      aout->DataDirectory[idx].Size = size;
+
+      if (size)
+        {
+          aout->DataDirectory[idx].VirtualAddress =
+                               (sec->vma - base) & 0xffffffff;
+          sec->flags |= SEC_DATA;
+        }
     }
 }