[PATCH] PE reloc overflow section header flags lossage

Brian Ford ford@vss.fsi.com
Thu Mar 25 02:06:00 GMT 2004


This was broken by 1.20 of peiXXigen.c.

In that version, a local variable was used to add in the "must have" flags.
Then, the local was output.  Later (approximately line 1047), if the
number of relocs overflowed, the pre "must have" flags or'ed in the
overflow flag and were re-output.

This patch just eliminates the local since it was not much of an
optimization anyway.

2004-03-24  Brian Ford  <ford@vss.fsi.com>

        * peiXXigen.c (_bfd_XXi_swap_scnhdr_out): Correct section flags
	lossage on reloc overflow.
	(_bfd_XXi_swap_sym_in): Remove redundant section flags
	assignment.

-- 
Brian Ford
Senior Realtime Software Engineer
VITAL - Visual Simulation Systems
FlightSafety International
Phone: 314-551-8460
Fax:   314-551-8444
-------------- next part --------------
Index: peXXigen.c
===================================================================
RCS file: /cvs/src/src/bfd/peXXigen.c,v
retrieving revision 1.22
diff -u -p -r1.22 peXXigen.c
--- peXXigen.c	21 Feb 2004 06:16:02 -0000	1.22
+++ peXXigen.c	24 Mar 2004 21:16:36 -0000
@@ -198,7 +198,6 @@ _bfd_XXi_swap_sym_in (abfd, ext1, in1)
 	  sec->lineno_count = 0;
 	  sec->userdata = NULL;
 	  sec->next = (asection *) NULL;
-	  sec->flags = 0;
 	  sec->alignment_power = 2;
 	  sec->flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_DATA | SEC_LOAD;
 
@@ -983,7 +982,6 @@ _bfd_XXi_swap_scnhdr_out (abfd, in, out)
       };
 
     pe_required_section_flags * p;
-    int flags = scnhdr_int->s_flags;
 
     /* We have defaulted to adding the IMAGE_SCN_MEM_WRITE flag, but now
        we know exactly what this specific section wants so we remove it
@@ -998,12 +996,12 @@ _bfd_XXi_swap_scnhdr_out (abfd, in, out)
 	{
 	  if (strcmp (scnhdr_int->s_name, ".text")
 	      || (bfd_get_file_flags (abfd) & WP_TEXT))
-	    flags &= ~IMAGE_SCN_MEM_WRITE;
-	  flags |= p->must_have;
+	    scnhdr_int->s_flags &= ~IMAGE_SCN_MEM_WRITE;
+	  scnhdr_int->s_flags |= p->must_have;
 	  break;
 	}
 
-    H_PUT_32 (abfd, flags, scnhdr_ext->s_flags);
+    H_PUT_32 (abfd, scnhdr_int->s_flags, scnhdr_ext->s_flags);
   }
 
   if (coff_data (abfd)->link_info


More information about the Binutils mailing list