diff options
| author | Cherry Mui <cherryyz@google.com> | 2024-12-10 12:00:10 -0500 |
|---|---|---|
| committer | Cherry Mui <cherryyz@google.com> | 2024-12-11 08:53:20 -0800 |
| commit | 6c25cf1c5fc063cc9ea27aa850ef0c4345f3a5b4 (patch) | |
| tree | 4f0013fcb977679cfb1534f49b80a19966dd9151 /src/cmd/objdump | |
| parent | e0c76d95abfc1621259864adb3d101cf6f1f90fc (diff) | |
| download | go-6c25cf1c5fc063cc9ea27aa850ef0c4345f3a5b4.tar.xz | |
cmd/internal/objfile: break out dissassemblers to another package
Currently, cmd/internal/objfile provides dissassembly routines for
various architectures, which depend on dissassemblers from x/arch.
cmd/internal/objfile is imported in tools that need dissassembly
(objdump, pprof) and tools that don't need dissassembly (nm,
addr2line). Adding/improving disassembly support for more
architectures can cause binary size increase, and for some tools
(nm, addr2line) it is not necessary.
This CL breaks out dissassembly routines to a different package,
which is only imported in tools that need dissassembly. Other
tools can depend on cmd/internal/objfile without the disassembly
code from x/arch.
This reduces binary sizes for those tools. On darwin/arm64,
old new
cmd/addr2line 4554418 3648882 -20%
cmd/addr2line (-ldflags=-w) 3464626 2641650 -24%
cmd/nm 4503874 3616722 -20%
cmd/nm (-ldflags=-w) 3430594 2609490 -24%
For #70699.
Change-Id: Ie45d5d5c5500c5f3882e8b3c4e6eb81f0d815292
Reviewed-on: https://go-review.googlesource.com/c/go/+/634916
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src/cmd/objdump')
| -rw-r--r-- | src/cmd/objdump/main.go | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/cmd/objdump/main.go b/src/cmd/objdump/main.go index b5b0d7f517..c98551e6b8 100644 --- a/src/cmd/objdump/main.go +++ b/src/cmd/objdump/main.go @@ -40,6 +40,7 @@ import ( "strconv" "strings" + "cmd/internal/disasm" "cmd/internal/objfile" "cmd/internal/telemetry/counter" ) @@ -82,7 +83,7 @@ func main() { } defer f.Close() - dis, err := f.Disasm() + dis, err := disasm.DisasmForFile(f) if err != nil { log.Fatalf("disassemble %s: %v", flag.Arg(0), err) } |
