Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/spf13/pflag v1.0.9
go.starlark.net v0.0.0-20231101134539-556fd59b42f6
go.yaml.in/yaml/v3 v3.0.4
golang.org/x/arch v0.11.0
golang.org/x/arch v0.28.0
golang.org/x/sys v0.46.0
golang.org/x/telemetry v0.0.0-20241106142447-58a1122356f5
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ go.starlark.net v0.0.0-20231101134539-556fd59b42f6 h1:+eC0F/k4aBLC4szgOcjd7bDTEn
go.starlark.net v0.0.0-20231101134539-556fd59b42f6/go.mod h1:LcLNIzVOMp4oV+uusnpk+VU+SzXaJakUuBjoCSWH5dM=
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
golang.org/x/arch v0.11.0 h1:KXV8WWKCXm6tRpLirl2szsO5j/oOODwZf4hATmGVNs4=
golang.org/x/arch v0.11.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
golang.org/x/arch v0.28.0 h1:wVwVdqsTuUbJvhYVCspQYwZXHNYeLSoZnmHD+ggddpQ=
golang.org/x/arch v0.28.0/go.mod h1:0X+GdSIP+kL5wPmpK7sdkEVTt2XoYP0cSjQSbZBwOi8=
golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2 h1:Jvc7gsqn21cJHCmAWx0LiimpP18LZmUxkT5Mp7EZ1mI=
golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=
Expand Down
13 changes: 2 additions & 11 deletions pkg/proc/x86_disasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ func x86AsmDecode(asmInst *AsmInstruction, mem []byte, regs *op.DwarfRegisters,

asmInst.Size = inst.Len
asmInst.Bytes = mem[:asmInst.Size]
patchPCRelX86(asmInst.Loc.PC, &inst)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is somewhat scary because this line has been there since 2016. I remove it (and add the handling of x86asm.Rel arguments to resolveCallArgX86) because changing the arguments of CALL instructions to immediates violates assumptions in the formatting code of golang.org/x/arch/x86/x86asm, see the comment in golang.org/x/arch/x86/x86asm/plan9x.go function plan9Arg, case Imm.

It should be fine since the other architectures, in particular arm64, does not patch out relative addresses, so this makes the two codepaths more similar.

asmInst.Inst = (*x86Inst)(&inst)
asmInst.Kind = OtherInstruction

Expand All @@ -40,16 +39,6 @@ func x86AsmDecode(asmInst *AsmInstruction, mem []byte, regs *op.DwarfRegisters,
return nil
}

// converts PC relative arguments to absolute addresses
func patchPCRelX86(pc uint64, inst *x86asm.Inst) {
for i := range inst.Args {
rel, isrel := inst.Args[i].(x86asm.Rel)
if isrel {
inst.Args[i] = x86asm.Imm(int64(pc) + int64(rel) + int64(inst.Len))
}
}
}

func (inst *x86Inst) Text(flavour AssemblyFlavour, pc uint64, symLookup func(uint64) (string, uint64)) string {
if inst == nil {
return "?"
Expand Down Expand Up @@ -117,6 +106,8 @@ func resolveCallArgX86(inst *x86asm.Inst, instAddr uint64, currentGoroutine bool
if err != nil {
return nil
}
case x86asm.Rel:
pc = instAddr + uint64(arg) + uint64(inst.Len)
default:
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/terminal/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1474,7 +1474,7 @@ func TestDisassPosCmd(t *testing.T) {
term.MustExec("continue")
out := term.MustExec("step-instruction")
t.Logf("%q\n", out)
if !strings.Contains(out, "call $runtime.Breakpoint") && !strings.Contains(out, "CALL runtime.Breakpoint(SB)") {
if !strings.Contains(out, "call runtime.Breakpoint") && !strings.Contains(out, "CALL runtime.Breakpoint") {
t.Errorf("output doesn't look like disassembly")
}
})
Expand Down
216 changes: 108 additions & 108 deletions vendor/golang.org/x/arch/arm64/arm64asm/inst.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 4 additions & 17 deletions vendor/golang.org/x/arch/arm64/arm64asm/plan9x.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading