Skip to content

Commit dc3a4e4

Browse files
hirochachacharandall77
authored andcommittedNov 10, 2017
cmd/objdump: pass the correct execution mode to x86asm.Decode in disasm_x86 on 386
Fixes golang#22093 Fixes golang#19988 Change-Id: Ibd8ec89e091fd527f363999e484676931d7aa6e2 Reviewed-on: https://go-review.googlesource.com/67450 Reviewed-by: Keith Randall <[email protected]> Run-TryBot: Keith Randall <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 3af20c0 commit dc3a4e4

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed
 

‎src/cmd/internal/objfile/disasm.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ func disasm_amd64(code []byte, pc uint64, lookup lookupFunc, _ binary.ByteOrder)
304304
}
305305

306306
func disasm_x86(code []byte, pc uint64, lookup lookupFunc, arch int) (string, int) {
307-
inst, err := x86asm.Decode(code, 64)
307+
inst, err := x86asm.Decode(code, arch)
308308
var text string
309309
size := inst.Len
310310
if err != nil || size == 0 || inst.Op == 0 {

‎src/cmd/objdump/objdump_test.go

+13
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,13 @@ func testDisasm(t *testing.T, printCode bool, flags ...string) {
148148
ok = false
149149
}
150150
}
151+
if goarch == "386" {
152+
if strings.Contains(text, "(IP)") {
153+
t.Errorf("disassembly contains PC-Relative addressing on 386")
154+
ok = false
155+
}
156+
}
157+
151158
if !ok {
152159
t.Logf("full disassembly:\n%s", text)
153160
}
@@ -234,6 +241,12 @@ func TestDisasmGoobj(t *testing.T) {
234241
ok = false
235242
}
236243
}
244+
if runtime.GOARCH == "386" {
245+
if strings.Contains(text, "(IP)") {
246+
t.Errorf("disassembly contains PC-Relative addressing on 386")
247+
ok = false
248+
}
249+
}
237250
if !ok {
238251
t.Logf("full disassembly:\n%s", text)
239252
}

0 commit comments

Comments
 (0)
Please sign in to comment.