Skip to content

Commit 0d56058

Browse files
srinivas-pokalagopherbot
authored andcommitted
cmd/objdump: add s390x GNU disasm support
This CL provides vendor support for s390x disassembler gnu syntax. go get golang.org/x/arch@master go mod tidy go mod vendor For #15255 Change-Id: Ia75fa515e7ea7d56913a28147c65650a7ab3062c Reviewed-on: https://go-review.googlesource.com/c/go/+/581015 Reviewed-by: Cherry Mui <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Vishwanatha HD <[email protected]> Run-TryBot: Cherry Mui <[email protected]> Auto-Submit: Cherry Mui <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Bill O'Farrell <[email protected]>
1 parent a96e736 commit 0d56058

File tree

11 files changed

+6836
-6
lines changed

11 files changed

+6836
-6
lines changed

src/cmd/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.24
44

55
require (
66
github.com/google/pprof v0.0.0-20240722153945-304e4f0156b8
7-
golang.org/x/arch v0.8.1-0.20240716161256-b863392466ea
7+
golang.org/x/arch v0.9.1-0.20240807172201-9d90945922a7
88
golang.org/x/build v0.0.0-20240722200705-b9910f320300
99
golang.org/x/mod v0.20.0
1010
golang.org/x/sync v0.8.0

src/cmd/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20240312041847-bd984b5ce465 h1:KwWnWVW
66
github.com/ianlancetaylor/demangle v0.0.0-20240312041847-bd984b5ce465/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw=
77
github.com/yuin/goldmark v1.6.0 h1:boZcn2GTjpsynOsC0iJHnBWa4Bi0qzfJjthwauItG68=
88
github.com/yuin/goldmark v1.6.0/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
9-
golang.org/x/arch v0.8.1-0.20240716161256-b863392466ea h1:+dKVGZM+cuxx3fooVKLDxZIPzKR1HYO1Xkd12Je4Z9k=
10-
golang.org/x/arch v0.8.1-0.20240716161256-b863392466ea/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
9+
golang.org/x/arch v0.9.1-0.20240807172201-9d90945922a7 h1:4+03DsxQb03qtr7e32FA8tiq18ytCUClXaXxQBDRGbs=
10+
golang.org/x/arch v0.9.1-0.20240807172201-9d90945922a7/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
1111
golang.org/x/build v0.0.0-20240722200705-b9910f320300 h1:2Cqg4LnvfD2ZpG8+6KbyYUkweWhNS3SgfcN/eeVseJ0=
1212
golang.org/x/build v0.0.0-20240722200705-b9910f320300/go.mod h1:YsGhg4JUVUWLzdqU2wCrtpRrOveOql6w56FLDHq/CJ4=
1313
golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=

src/cmd/internal/objfile/disasm.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"golang.org/x/arch/arm/armasm"
2525
"golang.org/x/arch/arm64/arm64asm"
2626
"golang.org/x/arch/ppc64/ppc64asm"
27+
"golang.org/x/arch/s390x/s390xasm"
2728
"golang.org/x/arch/x86/x86asm"
2829
)
2930

@@ -383,13 +384,31 @@ func disasm_ppc64(code []byte, pc uint64, lookup lookupFunc, byteOrder binary.By
383384
return text, size
384385
}
385386

387+
func disasm_s390x(code []byte, pc uint64, lookup lookupFunc, _ binary.ByteOrder, gnuAsm bool) (string, int) {
388+
inst, err := s390xasm.Decode(code)
389+
var text string
390+
size := inst.Len
391+
if err != nil || size == 0 || inst.Op == 0 {
392+
size = 2
393+
text = "?"
394+
} else {
395+
if gnuAsm {
396+
text = fmt.Sprintf("%s", s390xasm.GNUSyntax(inst, pc))
397+
} else {
398+
text = fmt.Sprintf("%s", "Go/plan9 syntax unsupported..!!")
399+
}
400+
}
401+
return text, size
402+
}
403+
386404
var disasms = map[string]disasmFunc{
387405
"386": disasm_386,
388406
"amd64": disasm_amd64,
389407
"arm": disasm_arm,
390408
"arm64": disasm_arm64,
391409
"ppc64": disasm_ppc64,
392410
"ppc64le": disasm_ppc64,
411+
"s390x": disasm_s390x,
393412
}
394413

395414
var byteOrders = map[string]binary.ByteOrder{

src/cmd/objdump/objdump_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ var ppcGnuNeed = []string{
104104
"beq",
105105
}
106106

107+
var s390xGnuNeed = []string{
108+
"brasl",
109+
"j",
110+
"clije",
111+
}
112+
107113
func mustHaveDisasm(t *testing.T) {
108114
switch runtime.GOARCH {
109115
case "loong64":
@@ -112,8 +118,6 @@ func mustHaveDisasm(t *testing.T) {
112118
t.Skipf("skipping on %s, issue 12559", runtime.GOARCH)
113119
case "riscv64":
114120
t.Skipf("skipping on %s, issue 36738", runtime.GOARCH)
115-
case "s390x":
116-
t.Skipf("skipping on %s, issue 15255", runtime.GOARCH)
117121
}
118122
}
119123

@@ -202,6 +206,8 @@ func testDisasm(t *testing.T, srcfname string, printCode bool, printGnuAsm bool,
202206
need = append(need, armGnuNeed...)
203207
case "ppc64", "ppc64le":
204208
need = append(need, ppcGnuNeed...)
209+
case "s390x":
210+
need = append(need, s390xGnuNeed...)
205211
}
206212
}
207213
args = []string{

src/cmd/vendor/golang.org/x/arch/s390x/s390xasm/Makefile

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cmd/vendor/golang.org/x/arch/s390x/s390xasm/decode.go

Lines changed: 241 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)