Skip to content

Commit edaf650

Browse files
Wei Xiaocherrymui
Wei Xiao
authored andcommitted
x/arch/arm64: refine objdump test to avoid false alarm
TestObjdumpARM64* is fuzzy test which randomly generates instructions for decoder and uses host objdump to compare results. Some old objdump wrongly decodes ldur*/stur*/prfum as ldr*/str*/prfm. Refine allowedMismatchObjdump function to allow the mismatches to avoid false alarm. Fixes golang/go#21486 Change-Id: I8909ca2657bd86ec5287e1ade7b17fe87f4ced22 Reviewed-on: https://go-review.googlesource.com/56810 Reviewed-by: Cherry Zhang <[email protected]> Run-TryBot: Cherry Zhang <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent ffd22fb commit edaf650

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

arm64/arm64asm/objdump_test.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
func TestObjdumpARM64Testdata(t *testing.T) { testObjdumpARM64(t, testdataCases(t)) }
1313
func TestObjdumpARM64Manual(t *testing.T) { testObjdumpARM64(t, hexCases(t, objdumpManualTests)) }
1414
func TestObjdumpARM64Cond(t *testing.T) { testObjdumpARM64(t, condCases(t)) }
15-
func TestObjdumpARM64(t *testing.T) { testObjdumpARM64(t, JSONCases(t)) }
15+
func TestObjdumpARM64(t *testing.T) { testObjdumpARM64(t, JSONCases(t)) }
1616

1717
// objdumpManualTests holds test cases that will be run by TestObjdumpARMManual.
1818
// If you are debugging a few cases that turned up in a longer run, it can be useful
@@ -92,6 +92,12 @@ func allowedMismatchObjdump(text string, inst *Inst, dec ExtInst) bool {
9292
if strings.Contains(text, "unknown instruction") && hasPrefix(dec.text, "fmla", "fmul", "fmulx", "fcvtzs", "fcvtzu", "fmls", "fmov", "scvtf", "ucvtf") {
9393
return true
9494
}
95+
// Some old objdump recognizes ldur*/stur*/prfum as ldr*/str*/prfm
96+
for k, v := range oldObjdumpMismatch {
97+
if strings.HasPrefix(dec.text, k) && strings.Replace(dec.text, k, v, 1) == text {
98+
return true
99+
}
100+
}
95101
// GNU objdump misses spaces between operands for some instructions (e.g., "ld1 {v10.2s, v11.2s}, [x23],#16")
96102
if strings.Replace(text, " ", "", -1) == strings.Replace(dec.text, " ", "", -1) {
97103
return true
@@ -122,3 +128,18 @@ var Ncover = strings.Fields(`
122128
ins
123129
dup
124130
`)
131+
132+
// Some old objdump wrongly decodes following instructions and allow their mismatches to avoid false alarm
133+
var oldObjdumpMismatch = map[string]string{
134+
//oldObjValue correctValue
135+
"ldr": "ldur",
136+
"ldrb": "ldurb",
137+
"ldrh": "ldurh",
138+
"ldrsb": "ldursb",
139+
"ldrsh": "ldursh",
140+
"ldrsw": "ldursw",
141+
"str": "stur",
142+
"strb": "sturb",
143+
"strh": "sturh",
144+
"prfm": "prfum",
145+
}

0 commit comments

Comments
 (0)