aboutsummaryrefslogtreecommitdiff
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
commite4cf60a82276f7b429ef6d31d9698a692008cb19 (patch)
tree35217c2fcbbd5bf078d7af31efe2e4106b4152a5 /bfd/peXXigen.c
parentd1e66cd4a44fed3ffe0f20fa121d06f709a6d99d (diff)
downloadfsf-binutils-gdb-e4cf60a82276f7b429ef6d31d9698a692008cb19.zip
fsf-binutils-gdb-e4cf60a82276f7b429ef6d31d9698a692008cb19.tar.gz
fsf-binutils-gdb-e4cf60a82276f7b429ef6d31d9698a692008cb19.tar.bz2
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 04b7419..22f2e3f 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");