fix(arm64): reject bare BTI with a diagnostic and accept the full family
Assisted-by: GLM 5.3 Flash
This commit is contained in:
@@ -675,6 +675,36 @@ func TestArm64AcquireRelease(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestArm64BTI pins the landing-pad family against the toolchain words:
|
||||
// only the uppercase C/J/JC spellings assemble, and bare BTI is a
|
||||
// diagnostic, never a panic.
|
||||
func TestArm64BTI(t *testing.T) {
|
||||
got := arm64Words(t, "\tBTI C\n\tBTI J\n\tBTI JC\n")
|
||||
want := []uint32{
|
||||
0xd503245f, // BTI C
|
||||
0xd503249f, // BTI J
|
||||
0xd50324df, // BTI JC
|
||||
0xd65f03c0, // RET
|
||||
}
|
||||
if len(got) != len(want) {
|
||||
t.Fatalf("got %d words, want %d", len(got), len(want))
|
||||
}
|
||||
for i := range want {
|
||||
if got[i] != want[i] {
|
||||
t.Errorf("word %d = %#x, want %#x", i, got[i], want[i])
|
||||
}
|
||||
}
|
||||
for _, src := range []string{"\tBTI\n", "\tBTI c\n", "\tBTI B\n"} {
|
||||
f, errs := parser.Parse("test_arm64.s", "#include \"textflag.h\"\n\nTEXT ·f(SB), NOSPLIT, $0-0\n"+src+"\tRET\n")
|
||||
if len(errs) > 0 {
|
||||
continue
|
||||
}
|
||||
if _, err := AssembleFileARM64(f); err == nil {
|
||||
t.Errorf("BTI spelling %q should be rejected, as go tool asm rejects it", src)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestArm64System pins BRK, SVC, the barriers, cache maintenance and the
|
||||
// system register accesses.
|
||||
func TestArm64System(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user