When a file is converted from ELF to PE-COFF, there may be holes between sections due to different alignment. But _bfd_XXi_swap_aouthdr_out in peXXigen.c doesn't take into this into account when computing size of image. It just sums sizes of all sections.
bash-3.1$ cat image_size.s .text .global _start _start: .byte 1 .global data .data data: .byte 2 bash-3.1$ cat image_size.t SECTIONS { . = SIZEOF_HEADERS; . = ALIGN(__section_alignment__); .text __image_base__ + ( __section_alignment__ < 0x1000 ? . : __section_alignment__ ) : { *(.text) } . = . + 0x1000; .data BLOCK(__section_alignment__) : { *(.data) } /DISCARD/ : { *(.*) } } bash-3.1$ make dump ./as -o image_size.o image_size.s ./ld -T image_size.t -o image_size image_size.o ./objdump -ph image_size image_size: file format pei-i386 Characteristics 0x307 relocations stripped executable line numbers stripped 32 bit words debugging information removed Time/Date Sat Mar 17 14:35:34 2007 ImageBase 0000000000400000 SectionAlignment 0000000000001000 FileAlignment 0000000000000200 MajorOSystemVersion 4 MinorOSystemVersion 0 MajorImageVersion 1 MinorImageVersion 0 MajorSubsystemVersion 4 MinorSubsystemVersion 0 Win32Version 00000000 SizeOfImage 00003000 SizeOfHeaders 00000200 CheckSum 0000b553 Subsystem 00000003 (Windows CUI) DllCharacteristics 00000000 ... Sections: Idx Name Size VMA LMA File off Algn 0 .text 00000010 0000000000401000 0000000000401000 00000200 2**4 CONTENTS, ALLOC, LOAD, READONLY, CODE 1 .data 00000010 0000000000403000 0000000000403000 00000400 2**4 CONTENTS, ALLOC, LOAD, DATA As it is shown, the size of image is > 00003000. But SizeOfImage is set to 00003000. -- Summary: PE-COFF can't handle holes between sections Product: binutils Version: 2.18 (HEAD) Status: NEW Severity: normal Priority: P2 Component: ld AssignedTo: unassigned at sources dot redhat dot com ReportedBy: hjl at lucon dot org CC: bug-binutils at gnu dot org GCC target triplet: i386-pc-mingw32 http://sourceware.org/bugzilla/show_bug.cgi?id=4210 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils