gdb: is_linked_with_cygwin_dll: handle import table not at beginning of .idata section
When loading the file C:\Windows\SysWOW64\msvcrt.dll, taken from a
Windows 10 system, into GDB, we get the following warning:
warning: Failed to parse .idata section: name's virtual address (0x0) is outside .idata section's range [0xb82b8, 0xb97f0[.
This uncovers an issue with how we parse the import table, part of the
.idata section. Right now, we assume that the import table is located
at the beginning of the section. That was the case in everything I had
tried so far, but this file is an example where that's not true.
We need to compute the offset of the import table within the .idata
section, and start there, instead of at the beginning of the .idata
section. Using the file mentioned above, this is the values we have to
work with:
A) bfd_section_vma (idata_section)
101b8000
B) Import table's virtual address b82b8
C) Image base
10100000
The virtual address that BFD returns us for the section has the image
base applied, so we need to subtract it first. The offset of the table
in the section is therefore:
B - (A - C)
This patch implements that.
gdb/ChangeLog:
* windows-tdep.c (is_linked_with_cygwin_dll): Consider case where
import table is not at beginning of .idata section.