[PATCH v2] ld: Limit "readelf --got-contents" tests

H.J. Lu hjl.tools@gmail.com
Thu Sep 4 13:59:37 GMT 2025


Since "readelf --got-contents" tests use -melf_i386, -melf_x86_64 and
-melf32_x86_64 emulations, limit theses tests to targets with those
emulations.

	PR ld/33350
	* testsuite/ld-i386/binutils.exp: Limit tests to targets with
	-melf_i386 support.
	* testsuite/ld-x86-64/binutils.exp: Limit -melf_x86_64 tests to
	targets with -melf_x86_64 support and limit -melf32_x86_64 tests
	to targets with -melf32_x86_64 support.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
 ld/testsuite/ld-i386/binutils.exp   |  6 ++++++
 ld/testsuite/ld-x86-64/binutils.exp | 14 ++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/ld/testsuite/ld-i386/binutils.exp b/ld/testsuite/ld-i386/binutils.exp
index 5069c59ca9e..19214dcda74 100644
--- a/ld/testsuite/ld-i386/binutils.exp
+++ b/ld/testsuite/ld-i386/binutils.exp
@@ -27,6 +27,12 @@ if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } {
     return
 }
 
+# Tests here need -melf_i386 support.
+catch "exec $LD -V" linker_emulations
+if ![regexp "elf_i386" $linker_emulations] then {
+    return
+}
+
 run_ld_link_tests [list \
     [list \
 	"Build libgot-1.so" \
diff --git a/ld/testsuite/ld-x86-64/binutils.exp b/ld/testsuite/ld-x86-64/binutils.exp
index fef997368db..73eade7abc4 100644
--- a/ld/testsuite/ld-x86-64/binutils.exp
+++ b/ld/testsuite/ld-x86-64/binutils.exp
@@ -27,6 +27,12 @@ if { ![istarget "x86_64-*-*"] } {
     return
 }
 
+# Tests here need -melf_x86_64 support.
+catch "exec $LD -V" linker_emulations
+if ![regexp "elf_x86_64" $linker_emulations] then {
+    return
+}
+
 run_ld_link_tests [list \
     [list \
 	"Build libgot-1.so" \
@@ -42,6 +48,14 @@ run_ld_link_tests [list \
 	 {readelf {--got-contents -W} libgot-1d.rd}} \
 	"libgot-1.so" \
     ] \
+]
+
+if ![regexp "elf32_x86_64" $linker_emulations] then {
+    return
+}
+
+# Tests here need -melf32_x86_64 support.
+run_ld_link_tests [list \
     [list \
 	"Build libgot-1-x32.so" \
 	"-shared -melf32_x86_64 --no-ld-generated-unwind-info \
-- 
2.51.0



More information about the Binutils mailing list