summaryrefslogtreecommitdiff
path: root/src/cmd/internal/objfile/disasm.go
Commit message (Collapse)AuthorAgeFilesLines
* all: replace package ioutil with os and io in srcAndy Pan2022-09-201-3/+3
| | | | | | | | | | | | | For #45557 Change-Id: I56824135d86452603dd4ed4bab0e24c201bb0683 Reviewed-on: https://go-review.googlesource.com/c/go/+/426257 Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Andy Pan <panjf2000@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
* cmd/objdump: add support for -gnu option on Go objdumpLynn Boger2020-03-301-15/+27
| | | | | | | | | | | | | | | | | | | This adds support for the -gnu option on Go objdump. When this option is used, then output will include gnu assembly in comments alongside the Go assembly. The objdump test was updated to test this new option. This option is supported for the arches found in golang.org/x that provide the GNUsyntax function. Updates #34372 Change-Id: I9e60e1691526607dda3c857c4564dcef408b8391 Reviewed-on: https://go-review.googlesource.com/c/go/+/225459 Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
* cmd/objdump: guard against out-of-range lines from directives.David Chase2020-03-121-0/+5
| | | | | | | | | | | | | | //line bogo.go:9999999 will cause 'go tool objdump' to crash unless bogo.go has that many lines. Guard the array index and return innocuous values (nil, nil) from the file cache. Fixes #36683 Change-Id: I4a9f8444dc611654d270cc876e8848dfd2f84770 Reviewed-on: https://go-review.googlesource.com/c/go/+/223081 Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
* all: remove nacl (part 3, more amd64p32)Brad Fitzpatrick2019-10-101-16/+14
| | | | | | | | | | | | | | | | | | | Part 1: CL 199499 (GOOS nacl) Part 2: CL 200077 (amd64p32 files, toolchain) Part 3: stuff that arguably should've been part of Part 2, but I forgot one of my grep patterns when splitting the original CL up into two parts. This one might also have interesting stuff to resurrect for any future x32 ABI support. Updates #30439 Change-Id: I2b4143374a253a003666f3c69e776b7e456bdb9c Reviewed-on: https://go-review.googlesource.com/c/go/+/200318 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* cmd/internal/objfile: provide consistent output in objdump on ppc64xLynn Boger2018-12-061-1/+1
| | | | | | | | | | | This makes a change to disasm.go so it provides consistent output with the recent updates to arch/ppc64. Change-Id: I812e5da2423fd1a84406032fd91ddf9cc86b7c69 Reviewed-on: https://go-review.googlesource.com/c/152761 Reviewed-by: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
* cmd/internal/objfile: emit trailing tab outside of Disasm.DecodeJosh Bleecher Snyder2018-04-181-9/+4
| | | | | | | | | | | | | | | | | | | | Disasm.Decode currently always appends a tab to the formatted instruction, although not to any relocations after it. Decode has two clients: objdump and pprof. pprof emits plain text, so it would be better not to have a trailing tab. objdump wants the trailing tab for text/tabwriter, but it is easy to add that to the Fprintf call. Shifting the responsibility for the trailing tab to the caller simplifies the code, increases correctness, and slightly improves performance by reducing and coalescing string concatenations. Change-Id: I0c85518ee185949e385de819e2e703bce757eba9 Reviewed-on: https://go-review.googlesource.com/106983 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* cmd/internal/objfile: reuse tabwriter across symbols when disassemblingJosh Bleecher Snyder2018-04-131-1/+1
| | | | | | | | | | | | | | | | | | | | Since the tabwriter is flushed at every symbol, it can be re-used with no impact on the output. This cuts allocated space when objdump-ing the compiler by almost 40%, and enables further upcoming improvements. It also speeds up objdump. name old time/op new time/op delta ObjdumpCompile 9.22s ± 3% 8.77s ± 3% -4.79% (p=0.000 n=10+9) Change-Id: Ief114d6c2680a4e762b5f439d3ca8dc7a89b9b27 Reviewed-on: https://go-review.googlesource.com/106978 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* cmd/internal/objfile: clean up some commentsJosh Bleecher Snyder2018-04-121-3/+3
| | | | | | | | Change-Id: Iba6feea74d65a961f30c12fb6c677ccd3b2c3591 Reviewed-on: https://go-review.googlesource.com/106695 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* cmd: some semi-automated cleanupsDaniel Martí2018-04-061-3/+1
| | | | | | | | | | | | | | * Remove some redundant returns * Replace HasPrefix with TrimPrefix * Remove some obviously dead code Passes toolstash -cmp on std cmd. Change-Id: Ifb0d70a45cbb8a8553758a8c4878598b7fe932bc Reviewed-on: https://go-review.googlesource.com/105017 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* cmd/internal/objfile: make lookupFunc an alias typeCherry Zhang2017-11-291-1/+1
| | | | | | | | | | | | | | In the x/arch repo, CL 45098 introduced SymLookup type, replacing the unnamed function type for lookup functions. This affects the signature of x86asm.GoSyntax. In particular, it cannot convert one named type, namely lookupFunc, to the other without an explicit cast. Make lookupFunc unnamed to fix. Change-Id: I973300d29ef1dbfdbd7fc2429e89c5849e6a7329 Reviewed-on: https://go-review.googlesource.com/80842 Run-TryBot: Cherry Zhang <cherryyz@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* cmd/objdump: pass the correct execution mode to x86asm.Decode in disasm_x86 ↵Hiroshi Ioka2017-11-101-1/+1
| | | | | | | | | | | | | on 386 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>
* cmd/internal/objfile: allow disassemble amd64p32 binariesCherry Zhang2017-11-021-14/+16
| | | | | | | | Change-Id: Ifa7701e97c0ec7d113e952b2b366edf422d6df2f Reviewed-on: https://go-review.googlesource.com/69351 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* cmd/nm: handle cgo archiveHiroshi Ioka2017-09-211-5/+5
| | | | | | | | | | | | This CL also make cmd/nm accept PE object file. Fixes #21706 Change-Id: I4a528b7d53da1082e61523ebeba02c4c514a43a7 Reviewed-on: https://go-review.googlesource.com/64890 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* cmd/internal/objfile: add arm64 disassembler supportWei Xiao2017-08-281-0/+14
| | | | | | | | Fixes #19157 Change-Id: Ieea286e8dc03929c3645f3113c33df569f8e26f3 Reviewed-on: https://go-review.googlesource.com/58930 Reviewed-by: Cherry Zhang <cherryyz@google.com>
* cmd/objdump: print Go code alongside assemblyLorenzo Masini2017-04-051-3/+105
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added -S flag to print go source file line above corresponding disassembly: $ go tool objdump -S -s main.main fmthello TEXT main.main(SB) /home/rugginoso/Documents/src/go/src/cmd/objdump/testdata/fmthello.go func main() { 0x47d450 64488b0c25f8ffffff FS MOVQ FS:0xfffffff8, CX 0x47d459 483b6110 CMPQ 0x10(CX), SP 0x47d45d 7631 JBE 0x47d490 0x47d45f 4883ec18 SUBQ $0x18, SP 0x47d463 48896c2410 MOVQ BP, 0x10(SP) 0x47d468 488d6c2410 LEAQ 0x10(SP), BP Println("hello, world") 0x47d46d 488d0563b00200 LEAQ 0x2b063(IP), AX 0x47d474 48890424 MOVQ AX, 0(SP) 0x47d478 48c74424080c000000 MOVQ $0xc, 0x8(SP) 0x47d481 e81a000000 CALL main.Println(SB) } 0x47d486 488b6c2410 MOVQ 0x10(SP), BP 0x47d48b 4883c418 ADDQ $0x18, SP 0x47d48f c3 RET func main() { 0x47d490 e8ebf1fcff CALL runtime.morestack_noctxt(SB) 0x47d495 ebb9 JMP main.main(SB) Execution time: $ time go tool objdump testdata/fmthello > /dev/null real 0m0.430s user 0m0.440s sys 0m0.000s $ time go tool objdump -S testdata/fmthello > /dev/null real 0m0.471s user 0m0.476s sys 0m0.012s Fixes #18245 Change-Id: I9b2f8338f9ee443c1352efd270d3ba85e3dd9b78 Reviewed-on: https://go-review.googlesource.com/37953 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
* cmd/internal/objfile: remove debugging printRuss Cox2016-10-241-1/+0
| | | | | | | | | | Crept into CL 9682, committed last week. Change-Id: I5b8e9119dbfeb0bc3005623ab74dbd29311d17ae Reviewed-on: https://go-review.googlesource.com/31814 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* cmd/internal/objfile: add ppc64/ppc64le disassembler supportShenghou Ma2016-10-131-8/+25
| | | | | | | | Change-Id: I7d213b4f8e4cda73ea7687fb97dbd22e58163948 Reviewed-on: https://go-review.googlesource.com/9682 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
* cmd/objdump: implement objdump of .o filesKeith Randall2016-08-241-3/+21
| | | | | | | | | | | | | | | | | | | Update goobj reader so it can provide all the information necessary to disassemble .o (and .a) files. Grab architecture of .o files from header. .o files have relocations in them. This CL also contains a simple mechanism to disassemble relocations and add relocation info as an extra column in the output. Fixes #13862 Change-Id: I608fd253ff1522ea47f18be650b38d528dae9054 Reviewed-on: https://go-review.googlesource.com/24818 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* cmd/vendor: move cmd/internal/unvendor packages to cmd/vendorKonstantin Shaposhnikov2016-05-141-2/+2
| | | | | | | | | | Updates #14047 Change-Id: I4b150533393bfb90e840497095ac32bcca4f04c2 Reviewed-on: https://go-review.googlesource.com/23114 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* cmd/internal/objfile: add s390x supportMichael Munday2016-03-211-0/+1
| | | | | | | | Change-Id: I39aa6569c9a6f327f7aaa01f8b4ace814fd5b766 Reviewed-on: https://go-review.googlesource.com/20943 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* all: make copyright headers consistent with one space after periodBrad Fitzpatrick2016-03-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | This is a subset of https://golang.org/cl/20022 with only the copyright header lines, so the next CL will be smaller and more reviewable. Go policy has been single space after periods in comments for some time. The copyright header template at: https://golang.org/doc/contribute.html#copyright also uses a single space. Make them all consistent. Change-Id: Icc26c6b8495c3820da6b171ca96a74701b4a01b0 Reviewed-on: https://go-review.googlesource.com/20111 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
* build: mv cmd/vendor cmd/internal/unvendorRuss Cox2016-02-091-2/+2
| | | | | | | | | | | | | | And update two imports in cmd/internal/objfile/disasm.go. This makes GO15VENDOREXPERIMENT=0 ./make.bash work. For Go 1.7 we will move it back. Fixes #14236. Change-Id: I429c9af4baff8496f83d113b1b03b90e309f4f48 Reviewed-on: https://go-review.googlesource.com/19384 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* cmd/internal/objfile: use golang.org/x/arch instead of rsc.ioRuss Cox2015-08-281-4/+4
| | | | | | Change-Id: I5348774ff01a5f0f706a1dba4aa9500661841f47 Reviewed-on: https://go-review.googlesource.com/14020 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* all: power64 is now ppc64Russ Cox2014-12-051-5/+5
| | | | | | | | | Fixes #8654. LGTM=austin R=austin CC=golang-codereviews https://golang.org/cl/180600043
* cmd/internal/objfile: minor editsRuss Cox2014-11-091-9/+14
| | | | | | | | | | Follow-up in response to comments on TBR'ed CL 171260043. LGTM=r R=r CC=golang-codereviews https://golang.org/cl/172080043
* cmd/internal/objfile: add DisasmRuss Cox2014-11-061-0/+243
This was missing from CL 167320043. Happy to apply comments in a followup. TBR to fix build. TBR=r CC=golang-codereviews https://golang.org/cl/171260043