From db8503c490928bc47400ef527af5a756e93d2a22 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Tue, 16 May 2000 02:10:00 +0000 Subject: [PATCH] Fix problems introduced with my last change. --- bfd/ChangeLog | 6 ++++++ bfd/peigen.c | 35 ++++++++++++++++------------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 013530a..1a991f7 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2000-05-16 Szabolcs Szakacsits + + * peigen.c (pe_print_idata): Undo part of 2000-05-12 change that + read idata section only from dataoff. + (pe_print_edata): Correctly check for valid eat_member. + Tue May 16 00:04:11 2000 J"orn Rennecke * elf32-sh.c (sh_elf_relax_delete_bytes): Handle R_SH_SWITCH8. diff --git a/bfd/peigen.c b/bfd/peigen.c index ffe9874..6c983ca 100644 --- a/bfd/peigen.c +++ b/bfd/peigen.c @@ -1108,8 +1108,8 @@ pe_print_idata (abfd, vfile) offset = abfd->start_address - rel_section->vma; - start_address = bfd_get_32(abfd, data+offset); - loadable_toc_address = bfd_get_32(abfd, data+offset+4); + start_address = bfd_get_32 (abfd, data + offset); + loadable_toc_address = bfd_get_32 (abfd, data + offset + 4); toc_address = loadable_toc_address - 32768; fprintf(file, @@ -1134,14 +1134,16 @@ pe_print_idata (abfd, vfile) fprintf(file, _(" Table Stamp Chain Name Thunk\n")); - data = (bfd_byte *) bfd_malloc (datasize); + data = (bfd_byte *) bfd_malloc (dataoff + datasize); if (data == NULL) return false; - if (! bfd_get_section_contents (abfd, section, (PTR) data, dataoff, datasize)) + /* Read the whole section. Some of the fields might be before dataoff. */ + if (! bfd_get_section_contents (abfd, section, (PTR) data, + 0, dataoff + datasize)) return false; - adj = section->vma - extra->ImageBase + dataoff; + adj = section->vma - extra->ImageBase; for (i = 0; i < datasize; i += onaline) { @@ -1155,7 +1157,7 @@ pe_print_idata (abfd, vfile) char *dll; /* print (i + extra->DataDirectory[1].VirtualAddress) */ - fprintf (file, " %08lx\t", (unsigned long) (i + adj)); + fprintf (file, " %08lx\t", (unsigned long) (i + adj + dataoff)); if (i + 20 > datasize) { @@ -1163,11 +1165,11 @@ pe_print_idata (abfd, vfile) ; } - hint_addr = bfd_get_32 (abfd, data + i); - time_stamp = bfd_get_32 (abfd, data + i + 4); - forward_chain = bfd_get_32 (abfd, data + i + 8); - dll_name = bfd_get_32 (abfd, data + i + 12); - first_thunk = bfd_get_32 (abfd, data + i + 16); + hint_addr = bfd_get_32 (abfd, data + i + dataoff); + time_stamp = bfd_get_32 (abfd, data + i + 4 + dataoff); + forward_chain = bfd_get_32 (abfd, data + i + 8 + dataoff); + dll_name = bfd_get_32 (abfd, data + i + 12 + dataoff); + first_thunk = bfd_get_32 (abfd, data + i + 16 + dataoff); fprintf (file, "%08lx %08lx %08lx %08lx %08lx\n", (unsigned long) hint_addr, @@ -1257,8 +1259,7 @@ pe_print_idata (abfd, vfile) } else { - ordinal = bfd_get_16(abfd, - data + iat_member - adj); + ordinal = bfd_get_16 (abfd, data + iat_member - adj); member_name = (char *) data + iat_member - adj + 2; fprintf(file, "\t%04lx\t %4d %s\n", (unsigned long) iat_member, @@ -1451,16 +1452,12 @@ pe_print_edata (abfd, vfile) { bfd_vma eat_member = bfd_get_32 (abfd, data + edt.eat_addr + (i * 4) - adj); - bfd_vma eat_actual = eat_member; - bfd_vma edata_start = bfd_get_section_vma (abfd, section); - bfd_vma edata_end = edata_start + datasize; - if (eat_member == 0) continue; - if (edata_start < eat_actual && eat_actual < edata_end) + if (eat_member - adj <= datasize) { - /* this rva is to a name (forwarding function) in our section */ + /* This rva is to a name (forwarding function) in our section. */ /* Should locate a function descriptor */ fprintf (file, "\t[%4ld] +base[%4ld] %04lx %s -- %s\n", -- 2.7.4