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