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 <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/arm64/arm64asm/objdump_test.go b/arm64/arm64asm/objdump_test.go
index c9df701..1e7966d 100644
--- a/arm64/arm64asm/objdump_test.go
+++ b/arm64/arm64asm/objdump_test.go
@@ -12,7 +12,7 @@
func TestObjdumpARM64Testdata(t *testing.T) { testObjdumpARM64(t, testdataCases(t)) }
func TestObjdumpARM64Manual(t *testing.T) { testObjdumpARM64(t, hexCases(t, objdumpManualTests)) }
func TestObjdumpARM64Cond(t *testing.T) { testObjdumpARM64(t, condCases(t)) }
-func TestObjdumpARM64(t *testing.T) { testObjdumpARM64(t, JSONCases(t)) }
+func TestObjdumpARM64(t *testing.T) { testObjdumpARM64(t, JSONCases(t)) }
// objdumpManualTests holds test cases that will be run by TestObjdumpARMManual.
// If you are debugging a few cases that turned up in a longer run, it can be useful
@@ -92,6 +92,12 @@
if strings.Contains(text, "unknown instruction") && hasPrefix(dec.text, "fmla", "fmul", "fmulx", "fcvtzs", "fcvtzu", "fmls", "fmov", "scvtf", "ucvtf") {
return true
}
+ // Some old objdump recognizes ldur*/stur*/prfum as ldr*/str*/prfm
+ for k, v := range oldObjdumpMismatch {
+ if strings.HasPrefix(dec.text, k) && strings.Replace(dec.text, k, v, 1) == text {
+ return true
+ }
+ }
// GNU objdump misses spaces between operands for some instructions (e.g., "ld1 {v10.2s, v11.2s}, [x23],#16")
if strings.Replace(text, " ", "", -1) == strings.Replace(dec.text, " ", "", -1) {
return true
@@ -122,3 +128,18 @@
ins
dup
`)
+
+// Some old objdump wrongly decodes following instructions and allow their mismatches to avoid false alarm
+var oldObjdumpMismatch = map[string]string{
+ //oldObjValue correctValue
+ "ldr": "ldur",
+ "ldrb": "ldurb",
+ "ldrh": "ldurh",
+ "ldrsb": "ldursb",
+ "ldrsh": "ldursh",
+ "ldrsw": "ldursw",
+ "str": "stur",
+ "strb": "sturb",
+ "strh": "sturh",
+ "prfm": "prfum",
+}