Nick Clifton 2143cb
diff -Nrup a/bfd/elf.c b/bfd/elf.c
Nick Clifton 2143cb
--- a/bfd/elf.c	2015-07-28 10:52:10.941754850 -0600
Nick Clifton 2143cb
+++ b/bfd/elf.c	2015-07-28 10:53:34.725982912 -0600
Nick Clifton 2143cb
@@ -4081,11 +4081,18 @@ _bfd_elf_map_sections_to_segments (bfd *
Nick Clifton 2143cb
 	      new_segment = TRUE;
Nick Clifton 2143cb
 	    }
Nick Clifton 2143cb
 	  else if ((last_hdr->flags & (SEC_LOAD | SEC_THREAD_LOCAL)) == 0
Nick Clifton 2143cb
-		   && (hdr->flags & (SEC_LOAD | SEC_THREAD_LOCAL)) != 0)
Nick Clifton 2143cb
+		   && (hdr->flags & (SEC_LOAD | SEC_THREAD_LOCAL)) != 0
Nick Clifton 2143cb
+		   && ((abfd->flags & D_PAGED) == 0
Nick Clifton 2143cb
+		       || (((last_hdr->lma + last_size - 1) & -maxpagesize)
Nick Clifton 2143cb
+			   != (hdr->lma & -maxpagesize))))
Nick Clifton 2143cb
 	    {
Nick Clifton 2143cb
-	      /* We don't want to put a loadable section after a
Nick Clifton 2143cb
-		 nonloadable section in the same segment.
Nick Clifton 2143cb
-		 Consider .tbss sections as loadable for this purpose.  */
Nick Clifton 2143cb
+	      /* We don't want to put a loaded section after a
Nick Clifton 2143cb
+		 nonloaded (ie. bss style) section in the same segment
Nick Clifton 2143cb
+		 as that will force the non-loaded section to be loaded.
Nick Clifton 2143cb
+		 Consider .tbss sections as loaded for this purpose.
Nick Clifton 2143cb
+		 However, like the writable/non-writable case below,
Nick Clifton 2143cb
+		 if they are on the same page then they must be put
Nick Clifton 2143cb
+		 in the same segment.  */
Nick Clifton 2143cb
 	      new_segment = TRUE;
Nick Clifton 2143cb
 	    }
Nick Clifton 2143cb
 	  else if ((abfd->flags & D_PAGED) == 0)