]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb: is_linked_with_cygwin_dll: handle import table not at beginning of .idata section
authorSimon Marchi <simon.marchi@polymtl.ca>
Thu, 16 Apr 2020 19:46:03 +0000 (15:46 -0400)
committerSimon Marchi <simon.marchi@polymtl.ca>
Thu, 16 Apr 2020 19:46:36 +0000 (15:46 -0400)
commit00ac85d3751b763155adb4e9d15dd134399b4e77
tree70878801a6acb5757be71fd35df4aa770394471f
parent8e4979ac1ea78147ecbcbf81af5e946873dda079
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.
gdb/ChangeLog
gdb/windows-tdep.c