[binutils-gdb] bfd/PE: correct SizeOfImage calculation

Jan Beulich jbeulich@sourceware.org
Fri Sep 6 06:36:51 GMT 2024


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a844415db8784bf92c0adc7163dc9b5c552a84e1

commit a844415db8784bf92c0adc7163dc9b5c552a84e1
Author: Jan Beulich <jbeulich@suse.com>
Date:   Fri Sep 6 08:34:24 2024 +0200

    bfd/PE: correct SizeOfImage calculation
    
    We don't really want to align the last section's size to object
    alignment (when that section may itself not be aligned as much), we want
    image size to be a multiple thereof.

Diff:
---
 bfd/peXXigen.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
index 51b567e6a64..c09d16ed0c0 100644
--- a/bfd/peXXigen.c
+++ b/bfd/peXXigen.c
@@ -699,8 +699,8 @@ _bfd_XXi_swap_aouthdr_out (bfd * abfd, void * in, void * out)
 	   for the image size.  */
 	if (coff_section_data (abfd, sec) != NULL
 	    && pei_section_data (abfd, sec) != NULL)
-	  isize = (sec->vma - extra->ImageBase
-		   + SA (FA (pei_section_data (abfd, sec)->virt_size)));
+	  isize = SA (sec->vma - extra->ImageBase
+		      + FA (pei_section_data (abfd, sec)->virt_size));
       }
 
     aouthdr_in->dsize = dsize;


More information about the Binutils-cvs mailing list