[PATCH] Re: PE/COFF propper _raw_size
Brian Ford
ford@vss.fsi.com
Fri Apr 11 15:15:00 GMT 2003
Well, since I still have not received any comments, here's an attempt at a
patch. It appears to fix one of my gdb DWARF2 on Cygwin
problems. Although, given my lack of understanding of this code, I am not
sure that it is otherwise harmless.
It is simple enough, though. Please review. Thanks.
2003-04-11 Brian Ford <ford@vss.fsi.com>
* peicode.h (coff_swap_scnhdr_in) [!COFF_NO_HACK_SCNHDR_SIZE]:
Always set the s_size field to the unpadded size.
On Wed, 9 Apr 2003, Brian Ford wrote:
> Sorry to follow up my own post.
>
> On Wed, 9 Apr 2003, Brian Ford wrote:
>
> > I believe the correct place to do this is in coffgen.c
> > (make_a_section_from_file), but I hate to introduce a COFF_WITH_PE ifdef
> > there. (Incidentally, if bfd is supposed to support a super-bfd that
> > works with all formats, how can we have ifdef code at all?) Another
> > alternative would be to post process the sections in peicode.h
> > (pe_bfd_object_p).
> >
> After further review, I think the correct place to do this is peicode.h
> (coff_swap_scnhdr_in). I am working on a patch, but the following still
> applies...
>
> > I am still trying to get my feet wet in this mass of code. Just trying
> > to figure out which code is actually used for my particular target
> > seems very challenging. So, I may be off base on the proposed
> > locations for this change. Any comments on the best place to
> > do this, or on the proposed method will be greatly appreciated. Thanks.
--
Brian Ford
Senior Realtime Software Engineer
VITAL - Visual Simulation Systems
FlightSafety International
Phone: 314-551-8460
Fax: 314-551-8444
-------------- next part --------------
Index: peicode.h
===================================================================
RCS file: /cvs/src/src/bfd/peicode.h,v
retrieving revision 1.36
diff -u -p -r1.36 peicode.h
--- peicode.h 3 Apr 2003 11:13:27 -0000 1.36
+++ peicode.h 11 Apr 2003 14:56:33 -0000
@@ -256,15 +256,16 @@ coff_swap_scnhdr_in (abfd, ext, in)
}
#ifndef COFF_NO_HACK_SCNHDR_SIZE
- /* If this section holds uninitialized data, use the virtual size
- (stored in s_paddr) instead of the physical size. */
- if ((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0
- && (scnhdr_int->s_paddr > 0))
+ /* 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))
{
- /* Always set it for non pe-obj files, and don't overwrite it
- if it's zero for object files. */
- if (! bfd_pe_executable_p (abfd) || !scnhdr_int->s_size)
- scnhdr_int->s_size = scnhdr_int->s_paddr;
+ scnhdr_int->s_size = scnhdr_int->s_paddr;
/* This code used to set scnhdr_int->s_paddr to 0. However,
coff_set_alignment_hook stores s_paddr in virt_size, which
More information about the Binutils
mailing list