This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patch to fix core dumps displaying contents of a PE DLL.


Hi Guys,

  The patch below fixes a couple of segmentation faults that can occur
  when using objdump to display the contents of a PE format DLL.  The
  code was forgetting to inclue the value of ImageBase in its
  computation of the adjustment to be applied when extracting data
  from the DLL.

  Is this patch OK to apply ?

Cheers
	Nick


1999-11-18  Nick Clifton  <nickc@cygnus.com>

	* peigen.c (pe_print_idata): Include ImageBase in adjustment.
	(pe_print_edata): Include ImageBase in adjustment.

Index: peigen.c
===================================================================
RCS file: /cvs/binutils/binutils/bfd/peigen.c,v
retrieving revision 1.6
diff -p -r1.6 peigen.c
*** peigen.c	1999/09/12 00:45:26	1.6
--- peigen.c	1999/11/18 12:34:51
*************** pe_print_idata (abfd, vfile)
*** 1114,1120 ****
    if (! bfd_get_section_contents (abfd, section, (PTR) data, 0, secsize))
      return false;
  
!   adj = - section->vma;
  
    for (i = 0; i < datasize; i += onaline)
      {
--- 1114,1120 ----
    if (! bfd_get_section_contents (abfd, section, (PTR) data, 0, secsize))
      return false;
  
!   adj = (extra->ImageBase - section->vma) & 0xffffffff;
  
    for (i = 0; i < datasize; i += onaline)
      {
*************** pe_print_idata (abfd, vfile)
*** 1153,1160 ****
        if (hint_addr == 0 && first_thunk == 0)
  	break;
  
!       dll = (char *) data + dll_name - section->vma + dataoff;
!       fprintf(file, _("\n\tDLL Name: %s\n"), dll);
  
        if (hint_addr != 0)
  	{
--- 1153,1160 ----
        if (hint_addr == 0 && first_thunk == 0)
  	break;
  
!       dll = (char *) data + dll_name + adj;
!       fprintf (file, _("\n\tDLL Name: %s\n"), dll);
  
        if (hint_addr != 0)
  	{
*************** pe_print_edata (abfd, vfile)
*** 1348,1354 ****
    edt.npt_addr       = bfd_get_32(abfd, data+32);
    edt.ot_addr        = bfd_get_32(abfd, data+36);
  
!   adj = - (section->vma + dataoff);
  
    /* Dump the EDT first first */
    fprintf(file,
--- 1348,1354 ----
    edt.npt_addr       = bfd_get_32(abfd, data+32);
    edt.ot_addr        = bfd_get_32(abfd, data+36);
  
!   adj = (extra->ImageBase - (section->vma + dataoff)) & 0xffffffff;
  
    /* Dump the EDT first first */
    fprintf(file,

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]