This is the mail archive of the binutils@sources.redhat.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]
Other format: [Raw text]

PE/COFF _raw_size 2003-04-15 BFD patch breaks my project


Hi,

After doing some misc. upgrades, I noticed my project suddenly and inexplicably failed to link.  I traced it to this patch:
2003-04-15  Brian Ford  <ford@vss.fsi.com>

        * peicode.h (coff_swap_scnhdr_in): If a section holds
        uninitialized data and is from an object file or from an
        executable image that has not initialized the s_size field, or if
        the physical size is padded, use the virtual size (stored in
        s_paddr) instead.

Thread: http://sources.redhat.com/ml/binutils/2003-04/msg00272.html

Specifically, one of the object files (generated by a Microsoft compiler) contains a .text section with a VirtualSize 0x40 but a SizeOfRawData 0x676.  There are relocations into this section with addresses >0x40.  Since this patch causes _raw_size to be set to VirtualSize instead of SizeOfRawData, BFD generates an error at relocation time and the link fails:
ld: myobj.obj: bad reloc address 0x50 in section `.text'
ld: final link failed: Invalid operation

In all honesty, I do not know why the MS compiler generates this kind of object.  There is nothing about it in "Microsoft Portable Executable and Common Object File Format Specification Revision 6.0  - February 1999," at any rate.  (It does not mention the case where SizeOfRawData > VirtualSize.)

However, since this object is part of a library in a Microsoft SDK, which is probably produced by a new version of Microsoft's compiler, it seems reasonable to me that the 2003-04-15 patch should be altered or reversed.

In any case, lieing about the actual size of the section to all of BFD does not seem like a good thing, and may cause problems in addition to those that I am having.  Perhaps a better way to implement Brian Ford's patch might be to compare these two section sizes locally to the parts of BFD that might take advantage from doing so, eg when doing section merging.

Any comments?  If this patch is not critical to maintaining functionality somewhere, I'd recommend it be reversed until a better solution is found.


Aaron W. LaFramboise


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