From 3028b4c011d1fe85d381b04a310c400742a2e6f3 Mon Sep 17 00:00:00 2001 From: DJ Delorie Date: Tue, 26 Sep 2000 20:42:29 +0000 Subject: [PATCH] * peigen.c (_bfd_pei_swap_aouthdr_in): If some DataDirectory is empty, make sure that its rva also 0. NT loader dislikes having otherwise. --- bfd/ChangeLog | 6 ++++++ bfd/peigen.c | 28 +++++++++++++++++++++------- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 3dfdb8a800d..737df3c0be2 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2000-09-26 Paul Sokolovsky + + * 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 * som.c (som_bfd_derive_misc_symbol_info): Make weak symbols diff --git a/bfd/peigen.c b/bfd/peigen.c index 6c983caad7b..066a6019c06 100644 --- a/bfd/peigen.c +++ b/bfd/peigen.c @@ -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; + } } } -- 2.30.2