The check_rev_gating test is compiled with -mv66, but the final linkage
step does not specify the CPU version. The v22.1.0 toolchain contains a
crt1.o compiled for v68, so the linker resolves the v66 + v68 linkage by
selecting the highest version. The resulting binary then executes v68
instructions without gating, leading to a segfault.

Fix this by passing -cpu v66 to QEMU when running the test, so that the
emulated CPU matches the intended v66 target and the revision gating
mechanism works as expected.

Suggested-by: Matheus Tavares Bernardino <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Brian Cain <[email protected]>
---
 tests/tcg/hexagon/Makefile.target | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/tcg/hexagon/Makefile.target 
b/tests/tcg/hexagon/Makefile.target
index 09f0502abc5..70a8ec2e7fb 100644
--- a/tests/tcg/hexagon/Makefile.target
+++ b/tests/tcg/hexagon/Makefile.target
@@ -112,6 +112,7 @@ unaligned_pc: unaligned_pc.c
 
 # Compile for v66 so that the ELF selects a v66 CPU; the test then
 # exercises revision gating by executing a v68 .word instruction.
+run-check_rev_gating: QEMU_OPTS += -cpu v66
 check_rev_gating: check_rev_gating.c
        $(CC) $(CFLAGS) -mv66 -O2 $< -o $@ $(LDFLAGS)
 
-- 
2.34.1

Reply via email to