aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/objfile/elf.go
AgeCommit message (Collapse)Author
2026-02-03all: prealloc slice with possible minimum capabilitiesShulhan
2025-11-04cmd/link: don't generate .gosymtab sectionIan Lance Taylor
Since Go 1.2 the section is always empty. Also remove the code looking for .gosymtab in cmd/internal/objfile. For #76038 Change-Id: Icd34c870ed0c6da8001e8d32305f79905ee2b066 Reviewed-on: https://go-review.googlesource.com/c/go/+/717200 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Commit-Queue: Ian Lance Taylor <iant@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com>
2024-10-29cmd/internal/objfile,cmd/objdump: add disassembly support for riscv64Joel Sing
Add support to `go tool objdump` for disassembling riscv64 binaries. Revendor to bring in cmd/vendor/golang.org/x/arch/riscv64/riscv64asm, which provides the actual disassembly implementation. Fixes #36738 Change-Id: I0f29968509041c0c5698fc2d6910a6a0bea9d3c0 Cq-Include-Trybots: luci.golang.try:gotip-linux-riscv64 Reviewed-on: https://go-review.googlesource.com/c/go/+/622257 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2024-09-19cmd/objdump: add loong64 disassembler supportGuoqi Chen
This CL provides vendor support for loong64 disassembler gnu and plan9 syntax. cd $GOROOT/src/cmd go get golang.org/x/arch@master go mod tidy go mod vendor Change-Id: Ic8b888de0aa11cba58cbf559f8f69337d1d69309 Reviewed-on: https://go-review.googlesource.com/c/go/+/609015 Reviewed-by: Meidan Li <limeidan@loongson.cn> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
2023-04-07cmd/internal/objfile: align the load address of ELF binaryCherry Mui
The ELF ABI just requires that the address and the offset of a segment are congruent modulo the alignment, but does not require the start address to be aligned. While usually the segment's start address is aligned, apparently the zig linker generates binary with unaligned address. At the run time, the memory mapping that contains the segment starts at an aligned address (rounding down). Use the aligned address for the load address, which matches the mapping. Apparently this is what the pprof library expects. Fixes #59466. Change-Id: Ife78909b20b7bc975ac4c76f2c5f5db325ddec9b Reviewed-on: https://go-review.googlesource.com/c/go/+/483035 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com>
2022-09-22cmd/internal/objfile: read file/line information for ELF PIE binariesCherry Mui
For PIE binaries, the .gopclntab section doesn't have the usual name, but .data.rel.ro.gopclntab. Try the relro version as well. If both failed (e.g. for externally linked PIE binaries), try runtime.pclntab symbol. This should make cmd/objdump able to print the file/line information for PIE binaries. I attempted to do this a few years ago, but that wasn't enough, because the pclntab itself contains dynamic relocations which are not applied by the tool. As of Go 1.18 the pclntab is mostly position independent and does not contain dynamic relocations, so this should be possible now. Fixes #17883. Updates #46639. Change-Id: I85dc3d50ffcc1a4b187a349479a6a162de1ab2b5 Reviewed-on: https://go-review.googlesource.com/c/go/+/227483 Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Joel Sing <joel@sing.id.au> TryBot-Result: Gopher Robot <gobot@golang.org>
2018-08-03cmd/internal/objfile: only consider executable segments for load addressIan Lance Taylor
Reportedly on some new Fedora systems the linker is producing extra load segments, basically making the dynamic section non-executable. We were assuming that the first load segment could be used to determine the program's load offset, but that is no longer true. Use the first executable load segment instead. Fixes #26369 Change-Id: I5ee31ddeef2e8caeed3112edc5149065a6448456 Reviewed-on: https://go-review.googlesource.com/127895 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-09-21cmd/nm: handle cgo archiveHiroshi Ioka
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>
2017-08-28cmd/internal/objfile: add arm64 disassembler supportWei Xiao
Fixes #19157 Change-Id: Ieea286e8dc03929c3645f3113c33df569f8e26f3 Reviewed-on: https://go-review.googlesource.com/58930 Reviewed-by: Cherry Zhang <cherryyz@google.com>
2016-10-13cmd/internal/objfile: add ppc64/ppc64le disassembler supportShenghou Ma
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>
2016-05-31runtime/pprof, cmd/pprof: fix profiling for PIEIan Lance Taylor
In order to support pprof for position independent executables, pprof needs to adjust the PC addresses stored in the profile by the address at which the program is loaded. The legacy profiling support which we use already supports recording the GNU/Linux /proc/self/maps data immediately after the CPU samples, so do that. Also change the pprof symbolizer to use the information, if available, when looking up addresses in the Go pcline data. Fixes #15714. Change-Id: I4bf679210ef7c51d85cf873c968ce82db8898e3e Reviewed-on: https://go-review.googlesource.com/23525 Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
2016-03-31cmd/pprof: use DWARF info to lookup unknown PC addressesIan Lance Taylor
Test to follow in a separate CL that arranges for the runtime package to store non-Go addresses in a CPU profile. Change-Id: I33ce1d66b77340b1e62b54505fc9b1abcec108a9 Reviewed-on: https://go-review.googlesource.com/21055 Reviewed-by: Austin Clements <austin@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org>
2016-03-21cmd/internal/objfile: add s390x supportMichael Munday
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>
2016-03-01all: make copyright headers consistent with one space after periodBrad Fitzpatrick
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>
2014-12-05all: power64 is now ppc64Russ Cox
Fixes #8654. LGTM=austin R=austin CC=golang-codereviews https://golang.org/cl/180600043
2014-10-29cmd/objdump: use cmd/internal/objfileRuss Cox
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
2014-08-07cmd/addr2line, cmd/nm: factor object reading into cmd/internal/objfileRuss Cox
To do in another CL: make cmd/objdump use cmd/internal/objfile too. There is a package placement decision in this CL: cmd/internal/objfile instead of internal/objfile. I chose to put internal under cmd to make clear (and enforce) that no standard library packages should use this (it's a bit dependency-heavy). LGTM=r R=r CC=golang-codereviews https://golang.org/cl/123910043