bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug binutils/1391] objcopy trashes PE executable when using "add-gn


From: Nick Clifton
Subject: Re: [Bug binutils/1391] objcopy trashes PE executable when using "add-gnu-debuglink"
Date: Tue, 11 Oct 2005 17:15:37 +0100
User-agent: Mozilla Thunderbird 1.0 (X11/20041206)

Hi,

currently one can fix this manually by executing additional step:
objcopy --change-section-vma .gnu_debuglink=+<addr> test_xxx.exe

I did a grep on the sources but could not really find a location where the wrong
VMA might be produced..
Could this be a bug in bfd library itself?

Yes, although I am not sure if an easy fix exists. In the meantime please could you try the attached patch which might work. The problem with it is that it has to guess as to the correct VMA value to use. I am not sure if matters though. It might be that any non-zero value will be valid, even if it overlaps with another section.

Cheers
  Nick


Index: binutils/objcopy.c
===================================================================
RCS file: /cvs/src/src/binutils/objcopy.c,v
retrieving revision 1.87
diff -c -3 -p -r1.87 objcopy.c
*** binutils/objcopy.c  3 Oct 2005 19:37:44 -0000       1.87
--- binutils/objcopy.c  11 Oct 2005 15:40:46 -0000
*************** copy_object (bfd *ibfd, bfd *obfd)
*** 1349,1354 ****
--- 1349,1361 ----
          bfd_nonfatal (gnu_debuglink_filename);
          return FALSE;
        }
+ 
+       if (bfd_get_flavour (obfd) == bfd_target_coff_flavour)
+       /* Try to set the VMA of the section to some non-zero value so
+          that it will work for PE format files.  (We have no way to
+          distinguish between COFF and PE flavours).  If this does not
+          work, just ignore the failure.  */
+       bfd_set_section_vma (obfd, gnu_debuglink_section, 0xf0000000);
      }
  
    if (bfd_count_sections (obfd) == 0)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]