diff options
author | DJ Delorie <dj@redhat.com> | 2000-09-26 20:42:29 +0000 |
---|---|---|
committer | DJ Delorie <dj@redhat.com> | 2000-09-26 20:42:29 +0000 |
commit | 3028b4c011d1fe85d381b04a310c400742a2e6f3 (patch) | |
tree | 97e5584e5cfef36c44a92e4cf1eeba8d01d0d0b5 /bfd/peigen.c | |
parent | 6d4c43bfc62a1f237431df1be13ced96d7cade6c (diff) | |
download | gdb-3028b4c011d1fe85d381b04a310c400742a2e6f3.zip gdb-3028b4c011d1fe85d381b04a310c400742a2e6f3.tar.gz gdb-3028b4c011d1fe85d381b04a310c400742a2e6f3.tar.bz2 |
* peigen.c (_bfd_pei_swap_aouthdr_in): If some DataDirectory
is empty, make sure that its rva also 0. NT loader dislikes
having otherwise.
Diffstat (limited to 'bfd/peigen.c')
-rw-r--r-- | bfd/peigen.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/bfd/peigen.c b/bfd/peigen.c index 6c983ca..066a601 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; + } } } |