]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/objdump: pass the correct execution mode to x86asm.Decode in disasm_x86 on 386
authorHiroshi Ioka <hirochachacha@gmail.com>
Sun, 1 Oct 2017 23:17:15 +0000 (08:17 +0900)
committerKeith Randall <khr@golang.org>
Fri, 10 Nov 2017 20:11:20 +0000 (20:11 +0000)
Fixes #22093
Fixes #19988

Change-Id: Ibd8ec89e091fd527f363999e484676931d7aa6e2
Reviewed-on: https://go-review.googlesource.com/67450
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/internal/objfile/disasm.go
src/cmd/objdump/objdump_test.go

index 18cc4e6fffca5b02a7161294eca5b2aa57938f97..c486016d6cee7c928e3a9ac0087c555650753e29 100644 (file)
@@ -304,7 +304,7 @@ func disasm_amd64(code []byte, pc uint64, lookup lookupFunc, _ binary.ByteOrder)
 }
 
 func disasm_x86(code []byte, pc uint64, lookup lookupFunc, arch int) (string, int) {
-       inst, err := x86asm.Decode(code, 64)
+       inst, err := x86asm.Decode(code, arch)
        var text string
        size := inst.Len
        if err != nil || size == 0 || inst.Op == 0 {
index f0771cdde9d27945e66dcfb30b9f117dba757ec5..a2ca32960900ed8e86a0cf5292445600134ae539 100644 (file)
@@ -148,6 +148,13 @@ func testDisasm(t *testing.T, printCode bool, flags ...string) {
                        ok = false
                }
        }
+       if goarch == "386" {
+               if strings.Contains(text, "(IP)") {
+                       t.Errorf("disassembly contains PC-Relative addressing on 386")
+                       ok = false
+               }
+       }
+
        if !ok {
                t.Logf("full disassembly:\n%s", text)
        }
@@ -234,6 +241,12 @@ func TestDisasmGoobj(t *testing.T) {
                        ok = false
                }
        }
+       if runtime.GOARCH == "386" {
+               if strings.Contains(text, "(IP)") {
+                       t.Errorf("disassembly contains PC-Relative addressing on 386")
+                       ok = false
+               }
+       }
        if !ok {
                t.Logf("full disassembly:\n%s", text)
        }