summaryrefslogtreecommitdiff
path: root/bfd/peXXigen.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2002-05-15 15:28:12 +0000
committerNick Clifton <nickc@redhat.com>2002-05-15 15:28:12 +0000
commitef28466ff15d2f7a50a2a049cc66b5f890051197 (patch)
tree2ae9c608ecfef3a57676a5202843d8110cf4696b /bfd/peXXigen.c
parentb74396bfb62d13fc406a221fb89ffa755677bda5 (diff)
downloadgdb-ef28466ff15d2f7a50a2a049cc66b5f890051197.tar.gz
Do not assume that the first thunk is located in the same section as the
import table. Instead check, and if necessary load the section containing the thunk.
Diffstat (limited to 'bfd/peXXigen.c')
-rw-r--r--bfd/peXXigen.c57
1 files changed, 54 insertions, 3 deletions
diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
index 04b741979aa..22f2e3ffa83 100644
--- a/bfd/peXXigen.c
+++ b/bfd/peXXigen.c
@@ -1219,10 +1219,58 @@ pe_print_idata (abfd, vfile)
if (hint_addr != first_thunk && time_stamp == 0)
{
+ bfd_byte *ft_data;
+ asection *ft_section;
+ bfd_vma ft_addr;
+ bfd_size_type ft_datasize;
+ int ft_idx;
int differ = 0;
- int idx2;
+ int ft_allocated = 0;
- idx2 = first_thunk - adj;
+ ft_addr = first_thunk + extra->ImageBase;
+
+ /* Find the section which contains the first thunk. */
+ for (ft_section = abfd->sections;
+ ft_section != NULL;
+ ft_section = ft_section->next)
+ {
+ ft_datasize = bfd_section_size (abfd, ft_section);
+ if (ft_addr >= ft_section->vma
+ && ft_addr < ft_section->vma + ft_datasize)
+ break;
+ }
+
+ if (ft_section == NULL)
+ {
+ fprintf (file,
+ _("\nThere is a first thunk, but the section containing it could not be found\n"));
+ continue;
+ }
+
+ /* Now check to see if this section is the same as our current
+ section. If it is not then we will have to load its data in. */
+ if (ft_section == section)
+ {
+ ft_data = data;
+ ft_idx = first_thunk - adj;
+ }
+ else
+ {
+ ft_idx = first_thunk - (ft_section->vma - extra->ImageBase);
+ ft_data = (bfd_byte *) bfd_malloc (datasize);
+ if (ft_data == NULL)
+ continue;
+
+ /* Read datasize bfd_bytes starting at offset ft_idx. */
+ if (! bfd_get_section_contents (abfd, ft_section, (PTR) ft_data, (bfd_vma) ft_idx, datasize))
+ {
+ free (ft_data);
+ continue;
+ }
+
+ ft_idx = 0;
+ ft_allocated = 1;
+ }
for (j = 0; j < datasize; j += 4)
{
@@ -1233,7 +1281,7 @@ pe_print_idata (abfd, vfile)
if (hint_addr != 0)
hint_member = bfd_get_32 (abfd, data + idx + j);
- iat_member = bfd_get_32 (abfd, data + idx2 + j);
+ iat_member = bfd_get_32 (abfd, ft_data + ft_idx + j);
if (hint_addr == 0 && iat_member == 0)
break;
@@ -1269,6 +1317,9 @@ pe_print_idata (abfd, vfile)
if (differ == 0)
fprintf (file,
_("\tThe Import Address Table is identical\n"));
+
+ if (ft_allocated)
+ free (ft_data);
}
fprintf (file, "\n");