summaryrefslogtreecommitdiff
path: root/src/cmd/objdump/main.go
Commit message (Collapse)AuthorAgeFilesLines
* cmd/objdump: add support for -gnu option on Go objdumpLynn Boger2020-03-301-4/+5
| | | | | | | | | | | | | | | | | | | 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: defer closing the file after openingMuhammad Falak R Wani2018-08-211-2/+1
| | | | | | | | | Remove the os.Exit(0) to honor the deferred closing of the file. Change-Id: Iaa9304d8203c8fec0ec728af669a94eadd36905c Reviewed-on: https://go-review.googlesource.com/118915 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
* cmd/objdump: remove two unused typesDamien Lespiau2017-04-231-3/+0
| | | | | | | | | | | | | | | | | | The last mention of those types in this package are in: commit 6bd0d0542ee15fda0da545c16af43fcfd34d6334 Author: Russ Cox <rsc@golang.org> Date: Thu Nov 6 19:56:55 2014 -0500 cmd/objdump, cmd/pprof: factor disassembly into cmd/internal/objfile Found with honnef.co/go/tools/cmd/unused. Change-Id: Iacc2902f7d0784ac0efdd92da239f3e97491469a Reviewed-on: https://go-review.googlesource.com/41472 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* cmd/objdump: print Go code alongside assemblyLorenzo Masini2017-04-051-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/objdump: Fix error loggingKeith Randall2014-12-091-1/+1
| | | | | | Change-Id: I6b1b4d3e8c039ba3198cb4b9765de75859ea8c32 Reviewed-on: https://go-review.googlesource.com/1214 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* cmd/objdump, cmd/pprof: factor disassembly into cmd/internal/objfileRuss Cox2014-11-061-224/+18
| | | | | | | | | | | | | | | | Moving so that new Go 1.4 pprof can use it. The old 'GNU objdump workalike' mode for 'go tool objdump' is now gone, as are the tests for that mode. It was used only by pre-Go 1.4 pprof. You can still specify an address range on the command line; you just get the same output format as you do when dumping the entire binary (without an address limitation). LGTM=r R=r CC=golang-codereviews, iant https://golang.org/cl/167320043
* cmd/objdump: use cmd/internal/objfileRuss Cox2014-10-291-247/+30
| | | | | | | | | | | | This removes a bunch of ugly duplicate code. The end goal is to factor the disassembly code into cmd/internal/objfile too, so that pprof can use it, but one step at a time. LGTM=r, iant R=r, alex.brainman, iant CC=golang-codereviews https://golang.org/cl/149400043
* cmd/objdump: disassemble local text symbolsIan Lance Taylor2014-10-281-1/+1
| | | | | | | | | Fixes #8803. LGTM=rsc R=rsc CC=golang-codereviews https://golang.org/cl/169720043
* cmd/objdump: move armasm, x86asm into internal packagesRuss Cox2014-09-301-4/+7
| | | | | | | | | | | | | | | | | | | | | For Go 1.3 these external packages were collapsed into large single-file implementations stored in the cmd/objdump directory. For Go 1.4 we want pprof to be able to link against them too, so move them into cmd/internal, where they can be shared. The new files are copied from the repo in the file path (rsc.io/...). Those repos were code reviewed during development (mainly by crawshaw and minux), because we knew the main repo would use them. Update #8798 LGTM=bradfitz R=crawshaw, bradfitz CC=golang-codereviews https://golang.org/cl/153750044
* cmd/{addr2line,objdump}: fix finding pclntab and symtab for pe and plan9objMatthew Dempsky2014-08-271-8/+26
| | | | | | | | | | | Broken by 8b5fc7c59d05. Update #8092 LGTM=iant, alex.brainman R=rsc, iant, alex.brainman CC=golang-codereviews https://golang.org/cl/138770043
* cmd/{ld,link,objdump}, runtime, debug/gosym: move linker-defined symbols ↵Matthew Dempsky2014-08-271-2/+2
| | | | | | | | | | | into runtime package Fixes #8092. LGTM=rsc R=iant, rsc CC=golang-codereviews https://golang.org/cl/126790043
* cmd/addr2line, cmd/objdump: fix on amd64 Plan 9David du Colombier2014-07-191-10/+3
| | | | | | | | | | | | | | | | | Fix virtual address of the start of the text segment on amd64 Plan 9. This issue has been partially fixed in cmd/add2line, as part of CL 106460044, but we forgot to report the change to cmd/objdump. In the meantime, we also fixed the textStart address in both cmd/add2line and cmd/objdump. LGTM=aram, ality, mischief R=rsc, mischief, aram, ality CC=golang-codereviews, jas https://golang.org/cl/117920043
* objdump: remove out-of-date commentMatthew Dempsky2014-07-151-3/+0
| | | | | | | LGTM=iant R=rsc, iant CC=golang-codereviews https://golang.org/cl/112320043
* cmd/objdump: add arm disassemblerRuss Cox2014-06-011-15/+41
| | | | | | | | | Fixes #7452. LGTM=minux, iant R=minux, iant CC=golang-codereviews https://golang.org/cl/104770046
* cmd/addr2line, cmd/objdump: handle Plan 9 a.out object filesDavid du Colombier2014-05-161-0/+57
| | | | | | | | | Update #7947. LGTM=iant R=rsc, iant CC=golang-codereviews https://golang.org/cl/91500044
* cmd/addr2line, cmd/objdump: fix pe text section starting addressAlex Brainman2014-05-151-1/+10
| | | | | | | | | fixes windows build LGTM=bradfitz R=golang-codereviews, bradfitz CC=golang-codereviews https://golang.org/cl/97500043
* cmd/nm, cmd/objdump: fix elf symbol typesRuss Cox2014-05-141-0/+9
| | | | | | | | | | | | | | | | | Turns out elf.File.Sections is indexed by the actual section number, not the number minus one. I don't know why I thought the -1 was necessary. Fixes objdump test (and therefore build) on ELF systems. While we're here, fix bounds on gnuDump so that we don't crash when asked to disassemble outside the text segment. May fix Windows build or at least make the failure more interesting. TBR=iant CC=golang-codereviews https://golang.org/cl/92390043
* objdump: implement disassemblyRuss Cox2014-05-141-25/+224
| | | | | | | | | | | | | | | | | There is some duplication here with cmd/nm. There is a TODO to address that after 1.3 is out. Update #7452 x86 disassembly works and is tested. The arm disassembler does not exist yet and is therefore not yet hooked up. LGTM=crawshaw, iant R=crawshaw, iant CC=golang-codereviews https://golang.org/cl/91360046
* cmd/objdump: works with windows pe executables nowAlex Brainman2014-05-121-8/+40
| | | | | | | | | | | | Most code is copy from addr2line change 01dd67e5827f Update #7406 Fixes #7937 LGTM=iant R=golang-codereviews, iant, 0intro CC=golang-codereviews https://golang.org/cl/95090044
* cmd/objdump: actually accept hex address without "0x" prefix.Shenghou Ma2014-05-081-4/+5
| | | | | | | | | Fixes #7936. LGTM=alex.brainman, bradfitz, iant R=golang-codereviews, alex.brainman, bradfitz, iant CC=golang-codereviews https://golang.org/cl/100060043
* addr2line, objdump: write doc commentsRuss Cox2014-04-151-2/+26
| | | | | | | LGTM=r R=r CC=golang-codereviews https://golang.org/cl/88050046
* cmd/objdump: rewrite in GoRuss Cox2014-04-141-0/+162
Update cmd/dist not to build the C version. Update cmd/go to install the Go version to the tool directory. Update #7452 This is the basic logic needed for objdump, and it works well enough to support the pprof list and weblist commands. A real disassembler needs to be added in order to support the pprof disasm command and the per-line assembly displays in weblist. That's still to come. Probably objdump will move to go.tools when the disassembler is added, but it can stay here for now. LGTM=minux.ma R=golang-codereviews, minux.ma CC=golang-codereviews, iant, r https://golang.org/cl/87580043