+# So as to avoid rewriting every last test case here in a nacl variant,
+# we use black magic to massage the generic cases into nacl-variant cases.
+if [istarget "*-*-nacl*"] {
+ # Change all the -melf_i386 to -melf_i386_nacl so linking can succeed.
+ regsub -all elf_i386 $i386tests elf_i386_nacl i386tests
+
+ # Same, applied to all the run_dump_test cases.
+ set options_regsub(ld) {-melf_i386 -melf_i386_nacl}
+
+ # The section/segment layout differs too much for the vanilla
+ # readelf output files to match. So massage the cases so that
+ # they refer to a foo-nacl.rd file instead of a foo.rd file.
+ regsub -all {([a-z0-9]+)\.rd} $i386tests {\1-nacl.rd} i386tests
+
+ # Likewise for PLTs.
+ regsub -all -- {([a-z0-9]+)\.pd} $i386tests {\1-nacl.pd} i386tests
+}
+