diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index e01fd38137c..a2f7328138d 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2015-04-13  Luis Machado  <lgustavo@codesourcery.com>
+
+	* gdb.base/bp-permanent.exp (test): Handle the case of being unable
+	to write to the .text section.
+
 2015-04-13  Luis Machado  <lgustavo@codesourcery.com>
 
 	* gdb.base/coredump-filter.exp: Restrict test to Linux systems only.
diff --git a/gdb/testsuite/gdb.base/bp-permanent.exp b/gdb/testsuite/gdb.base/bp-permanent.exp
index 81a5293e632..e802eee263d 100644
--- a/gdb/testsuite/gdb.base/bp-permanent.exp
+++ b/gdb/testsuite/gdb.base/bp-permanent.exp
@@ -104,7 +104,18 @@ proc test {always_inserted sw_watchpoint} {
 	# to memory manually.
 	set count [expr $address_after_bp - $address_bp]
 	for {set i 0} {$i < $count} {incr i} {
-	    gdb_test "p /x addr_bp\[$i\] = buffer\[$i\]" " = .*"
+	    gdb_test_multiple "p /x addr_bp\[$i\] = buffer\[$i\]" $test {
+		-re "Cannot access memory at address $hex.*$gdb_prompt $" {
+		    # Some targets (QEMU for one) will disallow writes to the
+		    # .text section under certain circumstances.  It is no use
+		    # continuing with the test at this point.  Just return.
+		    unsupported "Cannot modify memory"
+		    return
+		}
+		-re " = .*$gdb_prompt $" {
+		    pass $test
+		}
+	    }
 	}
     }