Committed: cris: bfd: Default selected target to the configured target

Hans-Peter Nilsson hp@axis.com
Wed Oct 8 03:54:00 GMT 2025


Macro, if you could, please re-check at least that the
cris-elf oddity you observed is gone, after this.  I tried
but the test-case in PR33485 didn't show the bug, so I had
to weasel-word the phrase below that "bugs *like* that"
could manifest.  Maybe I ham-fisted the test-case or...maybe
it's all just a red herring?

brgds, H-P

-- >8 --
Whether targ_defvec is set to the best match for the configured target
or some of the other supported targets usually doesn't matter, as the
actual target being used, usually is set by some other mechanism, like
an input object file.

In some situations it matters though: it might be confusing to see
--help output not showing the configured target first in the list of
supported targets.  Also, some corner cases risk running into bugs like
PR33485, for cris-elf and cris-linux because cris_aout_vec is the
default target where instead the bug-free behavior of
cris_elf32_us_vec or cris_elf32_vec would be expected.

The test just verifies that the target list emitted for the --help
option has the expected target first.

bfd:

	* config.bfd <cris-*-* | crisv32-*-*>: Split into <cris-*-*aout*>,
	<cris-*-linux-* | crisv32-*-linux-*>, <cris-*-* | crisv32-*-*> cases
	respectively setting targ_defvec per the target instead of always
	cris_aout_vec.

binutils:

	* testsuite/binutils-all/cris: New directory intended for
	tests focused on behavior of the binutils programs, not the assembler
	or linker.
	* testsuite/binutils-all/cris/cris.exp: New file with run_dump_test
	loop.
	testsuite/binutils-all/cris/tgt-a.d,
	testsuite/binutils-all/cris/tgt-e.d,
	testsuite/binutils-all/cris/tgt-l.d: New tests.

Co-authored-by: Maciej W. Rozycki <macro@redhat.com>
---
 bfd/config.bfd                                | 20 ++++++++++----
 binutils/testsuite/binutils-all/cris/cris.exp | 26 +++++++++++++++++++
 binutils/testsuite/binutils-all/cris/nop.s    |  1 +
 binutils/testsuite/binutils-all/cris/tgt-a.d  |  6 +++++
 binutils/testsuite/binutils-all/cris/tgt-e.d  |  6 +++++
 binutils/testsuite/binutils-all/cris/tgt-l.d  |  6 +++++
 6 files changed, 60 insertions(+), 5 deletions(-)
 create mode 100644 binutils/testsuite/binutils-all/cris/cris.exp
 create mode 100644 binutils/testsuite/binutils-all/cris/nop.s
 create mode 100644 binutils/testsuite/binutils-all/cris/tgt-a.d
 create mode 100644 binutils/testsuite/binutils-all/cris/tgt-e.d
 create mode 100644 binutils/testsuite/binutils-all/cris/tgt-l.d

diff --git a/bfd/config.bfd b/bfd/config.bfd
index 9fa1c51a9a29..1cf11bc3c416 100644
--- a/bfd/config.bfd
+++ b/bfd/config.bfd
@@ -455,13 +455,23 @@ case "${targ}" in
     targ_underscore=yes
     ;;
 
-  cris-*-* | crisv32-*-*)
+  cris-*-*aout*)
     targ_defvec=cris_aout_vec
     targ_selvecs="cris_elf32_us_vec cris_elf32_vec"
-    case "${targ}" in
-	*-*-linux*) ;;
-	*) targ_underscore=yes ;;
-    esac
+    targ_underscore=yes
+    want64=true
+    ;;
+
+  cris-*-linux-* | crisv32-*-linux-*)
+    targ_defvec=cris_elf32_vec
+    targ_selvecs="cris_elf32_us_vec cris_aout_vec"
+    want64=true
+    ;;
+
+  cris-*-* | crisv32-*-*)
+    targ_defvec=cris_elf32_us_vec
+    targ_selvecs="cris_aout_vec cris_elf32_vec"
+    targ_underscore=yes
     want64=true
     ;;
 
diff --git a/binutils/testsuite/binutils-all/cris/cris.exp b/binutils/testsuite/binutils-all/cris/cris.exp
new file mode 100644
index 000000000000..c75e4158f49b
--- /dev/null
+++ b/binutils/testsuite/binutils-all/cris/cris.exp
@@ -0,0 +1,26 @@
+#   Copyright (C) 2025 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+
+if {![istarget "cris-*-*"] && ![istarget "crisv32-*-*"]} {
+    return
+}
+
+set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
+foreach t $test_list {
+    # We need to strip the ".d", but can leave the dirname.
+    verbose [file rootname $t]
+    run_dump_test [file rootname $t]
+}
diff --git a/binutils/testsuite/binutils-all/cris/nop.s b/binutils/testsuite/binutils-all/cris/nop.s
new file mode 100644
index 000000000000..76829510633b
--- /dev/null
+++ b/binutils/testsuite/binutils-all/cris/nop.s
@@ -0,0 +1 @@
+ nop
diff --git a/binutils/testsuite/binutils-all/cris/tgt-a.d b/binutils/testsuite/binutils-all/cris/tgt-a.d
new file mode 100644
index 000000000000..59ca12c3e45d
--- /dev/null
+++ b/binutils/testsuite/binutils-all/cris/tgt-a.d
@@ -0,0 +1,6 @@
+#source: nop.s
+#objdump: --help
+#xfail: cris*-linux* cris*-elf*
+#...
+.*objdump: supported targets: a.out-cris .*
+#pass
diff --git a/binutils/testsuite/binutils-all/cris/tgt-e.d b/binutils/testsuite/binutils-all/cris/tgt-e.d
new file mode 100644
index 000000000000..3e6c3c866a18
--- /dev/null
+++ b/binutils/testsuite/binutils-all/cris/tgt-e.d
@@ -0,0 +1,6 @@
+#source: nop.s
+#objdump: --help
+#xfail: cris*-aout cris*-linux*
+#...
+.*objdump: supported targets: elf32-us-cris .*
+#pass
diff --git a/binutils/testsuite/binutils-all/cris/tgt-l.d b/binutils/testsuite/binutils-all/cris/tgt-l.d
new file mode 100644
index 000000000000..c8f88ca33e7b
--- /dev/null
+++ b/binutils/testsuite/binutils-all/cris/tgt-l.d
@@ -0,0 +1,6 @@
+#source: nop.s
+#objdump: --help
+#xfail: cris*-aout cris*-elf*
+#...
+.*objdump: supported targets: elf32-cris .*
+#pass
-- 
2.39.2



More information about the Binutils mailing list