PE/COFF _raw_size 2003-04-15 BFD patch breaks my project
Brian Ford
ford@vss.fsi.com
Tue Oct 21 20:33:00 GMT 2003
Sorry, Nick. I knew the patch was going to be simple. I just didn't
reallize it was sitting there staring me in the face :)!
For some reason, I had thought that bfd_pe_executable_p () just tested
for pe, not for pe executables only. Given its name, and that it was used
in a pe specific file, I should have known better.
The patch looks good. Pedantic corrections follow.
On Tue, 21 Oct 2003, Nick Clifton wrote:
> Brian Ford wrote:
> > Agreed. How about simply "only remove the padding when the bfd
> > represents an executable"?
>
> What, something like the patch below ? (This patch is completely
> untested by me, but if it does work, let me know and I can apply it).
>
> 2003-10-21 Nick Clifton <nickc@redhat.com>
>
> * peicode.h (coff_swap_scnhdr_in): Only remove padding when
> creating an executable.
>
Use reading/processing or something instead of creating?
> Index: bfd/peicode.h
> ===================================================================
> RCS file: /cvs/src/src/bfd/peicode.h,v
> retrieving revision 1.37
> diff -c -3 -p -r1.37 peicode.h
> *** bfd/peicode.h 15 Apr 2003 14:26:06 -0000 1.37
> --- bfd/peicode.h 21 Oct 2003 12:16:35 -0000
> *************** coff_swap_scnhdr_in (abfd, ext, in)
> *** 258,269 ****
> #ifndef COFF_NO_HACK_SCNHDR_SIZE
> /* If this section holds uninitialized data and is from an object file
> or from an executable image that has not initialized the field,
> ! or if the physical size is padded, use the virtual size (stored in
> ! s_paddr) instead. */
> if (scnhdr_int->s_paddr > 0
> && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0
> ! && (! bfd_pe_executable_p (abfd) || scnhdr_int->s_size == 0))
> ! || scnhdr_int->s_size > scnhdr_int->s_paddr))
> {
> scnhdr_int->s_size = scnhdr_int->s_paddr;
>
> --- 258,269 ----
> #ifndef COFF_NO_HACK_SCNHDR_SIZE
> /* If this section holds uninitialized data and is from an object file
> or from an executable image that has not initialized the field,
> ! or if the this is an executable file and the physical size is padded,
* ^^^ image (for consistency?)
> ! use the virtual size (stored in s_paddr) instead. */
> if (scnhdr_int->s_paddr > 0
> && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0
> ! && (! bfd_pe_executable_p (abfd) || scnhdr_int->s_size == 0))
> ! || (bfd_pe_executable_p (abfd) && scnhdr_int->s_size > scnhdr_int->s_paddr)))
> {
> scnhdr_int->s_size = scnhdr_int->s_paddr;
>
--
Brian Ford
Senior Realtime Software Engineer
VITAL - Visual Simulation Systems
FlightSafety International
Phone: 314-551-8460
Fax: 314-551-8444
More information about the Binutils
mailing list