diff --git a/binutils/testsuite/lib/binutils-common.exp b/binutils/testsuite/lib/binutils-common.exp
index 5026c0c0a9a..edaad35a97e 100644
--- a/binutils/testsuite/lib/binutils-common.exp
+++ b/binutils/testsuite/lib/binutils-common.exp
@@ -424,6 +424,23 @@ proc check_memory_seal_support { } {
     return $memory_seal_available_saved
 }
 
+proc check_rosegment_support { } {
+    global rosegment_available_saved
+    global ld
+
+    if {![info exists rosegment_available_saved]} {
+	set ld_output [remote_exec host $ld "--no-rosegment"]
+	if { [string first "not supported" $ld_output] >= 0
+	     || [string first "unrecognized option" $ld_output] >= 0
+	     || [string first "--no-rosegment ignored" $ld_output] >= 0 } {
+	    set rosegment_available_saved 0
+	} else {
+	    set rosegment_available_saved 1
+	}
+    }
+    return $rosegment_available_saved
+}
+
 # Check for support of the .noinit section, used for data that is not
 # initialized at load, or during the application's initialization sequence.
 proc supports_noinit_section {} {
@@ -1036,6 +1053,7 @@ proc run_dump_test { name {extra_options {}} } {
     global SIZE SIZEFLAGS
     global copyfile env runtests srcdir subdir verbose base_dir
     global DT_RELR_LDFLAGS NO_DT_RELR_LDFLAGS
+    global NO_ROSEGMENT_LDFLAGS
 
     if [string match "*/*" $name] {
 	set file $name
diff --git a/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp
index 8a67721fa4e..2796f719f22 100644
--- a/ld/testsuite/config/default.exp
+++ b/ld/testsuite/config/default.exp
@@ -399,6 +399,14 @@ if { ![info exists NO_MEMORY_SEAL_LDFLAGS] } then {
     }
 }
 
+if { ![info exists NO_ROSEGMENT_LDFLAGS] } then {
+    if { [check_rosegment_support] } then {
+	set NO_ROSEGMENT_LDFLAGS "--no-rosegment"
+    } else {
+	set NO_ROSEGMENT_LDFLAGS {}
+    }
+}
+
 # Set LD_CLASS to "64bit" for a 64-bit *host* linker.
 if { ![info exists LD_CLASS] } then {
     set REAL_LD [findfile $base_dir/.libs/ld-new .libs/ld-new $LD [transform ld]]
diff --git a/ld/testsuite/ld-elf/mbind1a.d b/ld/testsuite/ld-elf/mbind1a.d
index 0e9f900c868..310160063f0 100644
--- a/ld/testsuite/ld-elf/mbind1a.d
+++ b/ld/testsuite/ld-elf/mbind1a.d
@@ -1,5 +1,5 @@
 #source: mbind1.s
-#ld: -z common-page-size=0x1000 -z max-page-size=0x200000
+#ld: -z common-page-size=0x1000 -z max-page-size=0x200000 $NO_ROSEGMENT_LDFLAGS
 #readelf: -S -l --wide
 #target: *-*-linux* *-*-gnu* arm*-*-uclinuxfdpiceabi
 
diff --git a/ld/testsuite/ld-elf/pr26256-2b.d b/ld/testsuite/ld-elf/pr26256-2b.d
index 3f8c37e267b..aa797dcc1a4 100644
--- a/ld/testsuite/ld-elf/pr26256-2b.d
+++ b/ld/testsuite/ld-elf/pr26256-2b.d
@@ -1,5 +1,5 @@
 #source: pr26256-2.s
-#ld: -e _start
+#ld: -e _start $NO_ROSEGMENT_LDFLAGS
 #nm: -n
 #notarget: fr30-*-* iq2000-*-* ip2k-*-* xgate-*-* xstormy16-*-*
 # These targets place .linkorder sections before .text sections.
diff --git a/ld/testsuite/ld-srec/srec.exp b/ld/testsuite/ld-srec/srec.exp
index 39efcc49852..55959528f5f 100644
--- a/ld/testsuite/ld-srec/srec.exp
+++ b/ld/testsuite/ld-srec/srec.exp
@@ -348,7 +348,7 @@ set test2 "S-records with constructors"
 # See whether the default linker script uses SIZEOF_HEADERS.
 set exec_output [run_host_cmd "$ld" "--verbose"]
 set sizeof_headers [string match "*SIZEOF_HEADERS*" $exec_output]
-set extra_flags " $NO_MEMORY_SEAL_LDFLAGS"
+set extra_flags " $NO_MEMORY_SEAL_LDFLAGS $NO_ROSEGMENT_LDFLAGS"
 
 # First test linking a C program.  We don't require any libraries.  We
 # link it normally, and objcopy to the S-record format, and then link
diff --git a/ld/testsuite/ld-x86-64/no-plt.exp b/ld/testsuite/ld-x86-64/no-plt.exp
index 235bcb8b48d..69e34924064 100644
--- a/ld/testsuite/ld-x86-64/no-plt.exp
+++ b/ld/testsuite/ld-x86-64/no-plt.exp
@@ -72,7 +72,7 @@ run_cc_link_tests [list \
     [list \
 	"Build no PLT (dynamic 1a)" \
 	"$NOPIE_LDFLAGS tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
-	 tmpdir/no-plt-func1.o tmpdir/no-plt-extern1.o" \
+	 -Wl,--no-rosegment tmpdir/no-plt-func1.o tmpdir/no-plt-extern1.o" \
 	"-Wa,-mx86-used-note=yes" \
 	{dummy.s} \
 	{{readelf -Wr no-plt-1a.rd} {objdump -dwrj.text no-plt-1a.dd}} \
@@ -80,7 +80,7 @@ run_cc_link_tests [list \
     ] \
     [list \
 	"Build no PLT (dynamic 1b)" \
-	"tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
+	"-Wl,--no-rosegment tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
 	 tmpdir/libno-plt-1a.so tmpdir/libno-plt-1b.so" \
 	"-Wa,-mx86-used-note=yes" \
 	{dummy.s} \
@@ -90,7 +90,7 @@ run_cc_link_tests [list \
     [list \
 	"Build no PLT (dynamic 1c)" \
 	"$NOPIE_LDFLAGS tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
-	 tmpdir/no-plt-func1.o tmpdir/libno-plt-1b.so" \
+	 -Wl,--no-rosegment tmpdir/no-plt-func1.o tmpdir/libno-plt-1b.so" \
 	"-Wa,-mx86-used-note=yes" \
 	{dummy.s} \
 	{{readelf -Wr no-plt-1c.rd} {objdump -dwrj.text no-plt-1c.dd}} \
@@ -99,7 +99,7 @@ run_cc_link_tests [list \
     [list \
 	"Build no PLT (static 1d)" \
 	"-static tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
-	 tmpdir/no-plt-func1.o tmpdir/no-plt-extern1.o" \
+	 -Wl,--no-rosegment tmpdir/no-plt-func1.o tmpdir/no-plt-extern1.o" \
 	"-Wa,-mx86-used-note=yes" \
 	{dummy.s} \
 	{{readelf -Wr no-plt-1d.rd} {objdump -dwrj.text no-plt-1d.dd}} \
@@ -108,7 +108,7 @@ run_cc_link_tests [list \
     [list \
 	"Build no PLT (PIE 1e)" \
 	"-pie tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
-	 tmpdir/no-plt-func1.o tmpdir/no-plt-extern1.o" \
+	 -Wl,--no-rosegment tmpdir/no-plt-func1.o tmpdir/no-plt-extern1.o" \
 	"-Wa,-mx86-used-note=yes" \
 	{dummy.s} \
 	{{readelf -Wr no-plt-1e.rd} {nm -gD no-plt-1e.nd} {objdump -dwrj.text no-plt-1e.dd}} \
@@ -117,7 +117,7 @@ run_cc_link_tests [list \
     [list \
 	"Build no PLT (PIE 1f)" \
 	"-pie tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
-	 tmpdir/libno-plt-1a.so tmpdir/libno-plt-1b.so" \
+	 -Wl,--no-rosegment tmpdir/libno-plt-1a.so tmpdir/libno-plt-1b.so" \
 	"-Wa,-mx86-used-note=yes" \
 	{ dummy.s } \
 	{{readelf -Wr no-plt-1f.rd} {objdump -dwrj.text no-plt-1f.dd}} \
@@ -126,7 +126,7 @@ run_cc_link_tests [list \
     [list \
 	"Build no PLT (PIE 1g)" \
 	"-pie tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \
-	 tmpdir/no-plt-func1.o tmpdir/libno-plt-1b.so" \
+	 -Wl,--no-rosegment tmpdir/no-plt-func1.o tmpdir/libno-plt-1b.so" \
 	"-Wa,-mx86-used-note=yes" \
 	{ dummy.s } \
 	{{readelf -Wr no-plt-1g.rd} {objdump -dwrj.text no-plt-1g.dd}} \
diff --git a/ld/testsuite/ld-x86-64/pr27491-1c.d b/ld/testsuite/ld-x86-64/pr27491-1c.d
index 1288361463d..be74f50c258 100644
--- a/ld/testsuite/ld-x86-64/pr27491-1c.d
+++ b/ld/testsuite/ld-x86-64/pr27491-1c.d
@@ -1,6 +1,6 @@
 #source: pr27491-1.s
 #as: --64
-#ld: --gc-sections -melf_x86_64 -shared
+#ld: --gc-sections -melf_x86_64 -shared --no-rosegment
 #objdump: --syms -dw
 
 .*: +file format elf64-x86-64
diff --git a/ld/testsuite/ld-x86-64/pr27491-2.d b/ld/testsuite/ld-x86-64/pr27491-2.d
index 753ebb64082..949c3cece09 100644
--- a/ld/testsuite/ld-x86-64/pr27491-2.d
+++ b/ld/testsuite/ld-x86-64/pr27491-2.d
@@ -1,5 +1,5 @@
 #as: --64
-#ld: --gc-sections -melf_x86_64 -z start-stop-gc -shared
+#ld: --gc-sections -melf_x86_64 -z start-stop-gc -shared --no-rosegment
 #objdump: --syms -dw
 
 .*: +file format elf64-x86-64
diff --git a/ld/testsuite/ld-x86-64/pr27491-3.d b/ld/testsuite/ld-x86-64/pr27491-3.d
index 6dda5424fff..c7cba38d0a6 100644
--- a/ld/testsuite/ld-x86-64/pr27491-3.d
+++ b/ld/testsuite/ld-x86-64/pr27491-3.d
@@ -1,5 +1,5 @@
 #as: --64
-#ld: --gc-sections -melf_x86_64 -z start-stop-gc -shared
+#ld: --gc-sections -melf_x86_64 -z start-stop-gc -shared --no-rosegment
 #objdump: --syms -dw
 
 .*: +file format elf64-x86-64
diff --git a/ld/testsuite/ld-x86-64/pr27491-4.d b/ld/testsuite/ld-x86-64/pr27491-4.d
index 54542fd2d1a..44d6c2f9af3 100644
--- a/ld/testsuite/ld-x86-64/pr27491-4.d
+++ b/ld/testsuite/ld-x86-64/pr27491-4.d
@@ -1,7 +1,7 @@
 #source: pr27491-4a.s
 #source: pr27491-4b.s
 #as: --64
-#ld: --gc-sections -melf_x86_64 -z start-stop-gc -shared
+#ld: --gc-sections -melf_x86_64 -z start-stop-gc -shared --no-rosegment
 #objdump: --syms -dw
 
 .*: +file format elf64-x86-64
