From: H.J. Lu Date: Thu, 22 Mar 2007 15:52:29 +0000 (+0000) Subject: bfd/ X-Git-Tag: drow-reverse-20070409-branchpoint~169 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=50572669e457b60b8eb8e2a10fcd22d217dc7e09;p=platform%2Fupstream%2Fbinutils.git bfd/ 2003-03-22 H.J. Lu PR ld/4210 * peXXigen.c (_bfd_XXi_swap_aouthdr_out): Use the virtual address and virtual size of the last section for the image size. ld/testsuite/ 2003-03-22 H.J. Lu PR ld/4210 * ld-pe/image_size.d: New file. * ld-pe/image_size.s: Likewise. * ld-pe/image_size.t: Likewise. * ld-pe/pe.exp: Run image_size. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 7c6bc2e..e05457a 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2003-03-22 H.J. Lu + + PR ld/4210 + * peXXigen.c (_bfd_XXi_swap_aouthdr_out): Use the virtual + address and virtual size of the last section for the image + size. + 2007-03-22 H.J. Lu PR ld/4007 diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c index 2454436..bbb3c77 100644 --- a/bfd/peXXigen.c +++ b/bfd/peXXigen.c @@ -645,16 +645,22 @@ _bfd_XXi_swap_aouthdr_out (bfd * abfd, void * in, void * out) in the virt_size field). Files have been seen (from MSVC 5.0 link.exe) where the file size of the .data segment is quite small compared to the virtual size. Without this - fix, strip munges the file. */ + fix, strip munges the file. + + FIXME: We need to handle holes between sections, which may + happpen when we covert from another format. We just use + the virtual address and virtual size of the last section + for the image size. */ if (coff_section_data (abfd, sec) != NULL && pei_section_data (abfd, sec) != NULL) - isize += SA (FA (pei_section_data (abfd, sec)->virt_size)); + isize = (sec->vma - extra->ImageBase + + SA (FA (pei_section_data (abfd, sec)->virt_size))); } aouthdr_in->dsize = dsize; aouthdr_in->tsize = tsize; extra->SizeOfHeaders = hsize; - extra->SizeOfImage = SA (hsize) + isize; + extra->SizeOfImage = isize; } H_PUT_16 (abfd, aouthdr_in->magic, aouthdr_out->standard.magic); diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 07f2895..1f15714 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2003-03-22 H.J. Lu + + PR ld/4210 + * ld-pe/image_size.d: New file. + * ld-pe/image_size.s: Likewise. + * ld-pe/image_size.t: Likewise. + + * ld-pe/pe.exp: Run image_size. + 2007-03-22 H.J. Lu PR ld/4007 diff --git a/ld/testsuite/ld-pe/image_size.d b/ld/testsuite/ld-pe/image_size.d new file mode 100644 index 0000000..6d41fcc --- /dev/null +++ b/ld/testsuite/ld-pe/image_size.d @@ -0,0 +1,9 @@ +#name: PE-COFF SizeOfImage +#ld: -T image_size.t +#objdump: -p +#target: i*86-*-mingw32 + +.*: file format .* +#... +SizeOfImage 00004000 +#... diff --git a/ld/testsuite/ld-pe/image_size.s b/ld/testsuite/ld-pe/image_size.s new file mode 100644 index 0000000..3b56d7f --- /dev/null +++ b/ld/testsuite/ld-pe/image_size.s @@ -0,0 +1,8 @@ + .text + .global _start +_start: + .byte 1 + .global data + .data +data: + .byte 2 diff --git a/ld/testsuite/ld-pe/image_size.t b/ld/testsuite/ld-pe/image_size.t new file mode 100644 index 0000000..f646eca --- /dev/null +++ b/ld/testsuite/ld-pe/image_size.t @@ -0,0 +1,15 @@ +SECTIONS +{ + . = SIZEOF_HEADERS; + . = ALIGN(__section_alignment__); + .text __image_base__ + ( __section_alignment__ < 0x1000 ? . : __section_alignment__ ) : + { + *(.text) + } + . = . + 0x1000; + .data BLOCK(__section_alignment__) : + { + *(.data) + } + /DISCARD/ : { *(.*) } +} diff --git a/ld/testsuite/ld-pe/pe.exp b/ld/testsuite/ld-pe/pe.exp index 8657f22..7568f10 100644 --- a/ld/testsuite/ld-pe/pe.exp +++ b/ld/testsuite/ld-pe/pe.exp @@ -32,3 +32,5 @@ set pe_tests { } run_ld_link_tests $pe_tests + +run_dump_test "image_size"