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]

[PATCH] Pad SEC_MERGE sections to entsize boundary in gas


Hi!

Ulrich found long double constants on IA-32 in .rodata.cst16 section
cause the section not to be multiple of sh_entsize.
Although ld SHF_MERGE merging code handles this gracefully by assuming
zero padding, sh_size should be multiple of sh_entsize.
The following patch adds the padding if it was not already provided in
assembly.
Ok to commit?

2002-11-24  Jakub Jelinek  <jakub@redhat.com>
	* write.c (subsegs_finish): For SEC_MERGE sections pad last fragment
	to entsize.

--- gas/write.c.jj	2002-11-21 15:58:39.000000000 +0100
+++ gas/write.c	2002-11-24 23:54:58.000000000 +0100
@@ -1409,7 +1409,25 @@ subsegs_finish ()
          any alignment is meaningless, and, moreover, will look weird
          if we are generating a listing.  */
       if (!had_errors ())
-	alignment = SUB_SEGMENT_ALIGN (now_seg, frchainP);
+	{
+	  alignment = SUB_SEGMENT_ALIGN (now_seg, frchainP);
+#ifdef BFD_ASSEMBLER
+	  if (bfd_get_section_flags (now_seg->owner, now_seg) & SEC_MERGE)
+	    {
+	      unsigned int entsize = now_seg->entsize;
+	      int entalign = 0;
+
+	      know (entsize != 0);
+	      while ((entsize & 1) == 0)
+		{
+		  ++entalign;
+		  entsize >>= 1;
+		}
+	      if (entalign > alignment)
+		alignment = entalign;
+	    }
+#endif
+	}
 
       if (subseg_text_p (now_seg))
 	frag_align_code (alignment, 0);

	Jakub


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