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]

text and data segment merge


Someone noticed recently that ld was merging read-only and read-write
segments when the start of the data segment was near the end of the
text segment.  Well, that is supposed to happen when the two sections
occupy the same page but the test to detect this case was totally
bogus, leading to consolidation when unnecessary.

	* elf.c (map_sections_to_segments): Correct test for start of
	writable section in the same page as end of read-only section.

Applying mainline and branch.

Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.162
diff -u -p -r1.162 elf.c
--- bfd/elf.c	18 Sep 2002 02:39:42 -0000	1.162
+++ bfd/elf.c	28 Sep 2002 02:27:03 -0000
@@ -3317,8 +3317,9 @@ map_sections_to_segments (abfd)
 	}
       else if (! writable
 	       && (hdr->flags & SEC_READONLY) == 0
-	       && (BFD_ALIGN (last_hdr->lma + last_hdr->_raw_size, maxpagesize)
-		   == hdr->lma))
+	       && (((last_hdr->lma + last_hdr->_raw_size - 1)
+		    & ~(maxpagesize - 1))
+		   != (hdr->lma & ~(maxpagesize - 1))))
 	{
 	  /* We don't want to put a writable section in a read only
              segment, unless they are on the same page in memory

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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