aboutsummaryrefslogtreecommitdiff
path: root/src/debug
AgeCommit message (Collapse)Author
2021-11-16debug/pe,debug/macho: add support for DWARF5 sectionsAlessandro Arzilli
Adds the same logic used in debug/elf to load DWARF5 sections. Fixes #49590 Change-Id: Iee05b9927a6f521842b330eab8942ade3fc2bd86 Reviewed-on: https://go-review.googlesource.com/c/go/+/363895 Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Than McIntosh <thanm@google.com>
2021-11-15debug/dwarf: better error message when reading absent debug_line_strAlessandro Arzilli
When a DW_FORM_line_strp is used without a debug_line_str section a good error message (about the missing section) is generated but immediately overwritten by the underflow error generated by trying to read the non-existent section. Updates #49590 Change-Id: I1c431392123a86c78c95ef1f185ebd6f17f2476a Reviewed-on: https://go-review.googlesource.com/c/go/+/363894 Run-TryBot: Alessandro Arzilli <alessandro.arzilli@gmail.com> Trust: David Chase <drchase@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2021-11-06all: remove more leftover // +build linesTobias Klauser
CL 344955 and CL 359476 removed almost all // +build lines, but leaving some assembly files and generating scripts. Also, some files were added with // +build lines after CL 359476 was merged. Remove these or rename files where more appropriate. For #41184 Change-Id: I7eb85a498ed9788b42a636e775f261d755504ffa Reviewed-on: https://go-review.googlesource.com/c/go/+/361480 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-11-05debug/plan9obj: export ErrNoSymbolsDan Kortschak
This allows callers of *File.Symbols to distinguish absence of symbols from other errors as can already by done in debug/elf. Fixes #48052 Change-Id: I5ba15d8473911e516c016a69c1f1c710f7fc4cd5 Reviewed-on: https://go-review.googlesource.com/c/go/+/350229 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-11-05cmd/link: enable internal linking of PIE binaries on ppc64lePaul E. Murphy
The amd64/arm64 relocation processing is used as a template and updated for ppc64le. This requires updating the TOC relocation handling code to support linux type TOC relocations too (note, AIX uses TOC-indirect accesses). Noteably, the shared flag of go functions is used as a proxy for the local entry point offset encoded in elf objects. Functions in go ppc64le shared objects always[1] insert 2 instructions to regenerate the TOC pointer. [1] excepting a couple special runtime functions, see preprocess in obj9.go for specific details of this behavior. Change-Id: I3646e6dc8a0a0ffe712771a976983315eae5c418 Reviewed-on: https://go-review.googlesource.com/c/go/+/352829 Run-TryBot: Paul Murphy <murp@ibm.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
2021-11-02debug/gosym: bulk allocate SymsJosh Bleecher Snyder
name old time/op new time/op delta 115/NewLineTable-8 80.7ns ± 1% 81.7ns ± 3% ~ (p=0.408 n=10+8) 115/NewTable-8 76.3µs ± 2% 63.3µs ± 3% -17.03% (p=0.000 n=9+9) 115/LineToPC-8 56.8µs ± 2% 56.8µs ± 3% ~ (p=0.905 n=10+9) 115/PCToLine-8 252ns ± 1% 256ns ± 5% ~ (p=0.183 n=10+10) name old alloc/op new alloc/op delta 115/NewLineTable-8 384B ± 0% 384B ± 0% ~ (all equal) 115/NewTable-8 164kB ± 0% 172kB ± 0% +4.97% (p=0.000 n=10+10) 115/LineToPC-8 0.00B 0.00B ~ (all equal) 115/PCToLine-8 0.00B 0.00B ~ (all equal) name old allocs/op new allocs/op delta 115/NewLineTable-8 3.00 ± 0% 3.00 ± 0% ~ (all equal) 115/NewTable-8 1.04k ± 0% 0.01k ± 0% -98.75% (p=0.000 n=10+10) 115/LineToPC-8 0.00 0.00 ~ (all equal) 115/PCToLine-8 0.00 0.00 ~ (all equal) Change-Id: Ibfe6c0cb86737dee8209cb1f58f5b796aa7b30aa Reviewed-on: https://go-review.googlesource.com/c/go/+/353134 Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-10-28debug/macho: fail on invalid dynamic symbol table commandRoland Shoemaker
Fail out when loading a file that contains a dynamic symbol table command that indicates a larger number of symbols than exist in the loaded symbol table. Thanks to Burak Çarıkçı - Yunus Yıldırım (CT-Zer0 Crypttech) for reporting this issue. Fixes #48990 Fixes CVE-2021-41771 Change-Id: Ic3d6e6529241afcc959544b326b21b663262bad5 Reviewed-on: https://go-review.googlesource.com/c/go/+/355990 Reviewed-by: Julie Qiu <julie@golang.org> Reviewed-by: Katie Hockman <katie@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Run-TryBot: Roland Shoemaker <roland@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Trust: Katie Hockman <katie@golang.org>
2021-10-14debug/buildinfo: fix test for build settingsJay Conrod
This CL fixes the debug/buildinfo test, which did not expect build settings. For #37475 Change-Id: Ie8c15ec633b4eec6a976120c8db64f116589d98e Reviewed-on: https://go-review.googlesource.com/c/go/+/356012 Trust: Jay Conrod <jayconrod@google.com> Run-TryBot: Jay Conrod <jayconrod@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-10-14runtime/debug: add GoVersion to BuildInfoJay Conrod
BuildInfo now includes the version of Go used to build a binary, as reported by runtime.Version() or 'go version'. For #37475 Change-Id: Id07dda357dc70599d64a9202dab894c7288de1de Reviewed-on: https://go-review.googlesource.com/c/go/+/353888 Trust: Jay Conrod <jayconrod@google.com> Run-TryBot: Jay Conrod <jayconrod@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-10-14debug/buildinfo: new package with Read and ReadFileJay Conrod
These functions provide access to module information stamped into Go binaries. In the future, they'll provide access to other information (like VCS info). These functions are added in a new package instead of runtime/debug since they use binary parsing packages like debug/elf, which would make runtime/debug an unacceptably heavy dependency. The types in runtime/debug are still used; debug/buildinfo uses them via type aliases. This information is already available for the running binary through debug.ReadBuildInfo and for other binaries with 'go version -m', but until now, there hasn't been a way to get it for other binaries without installing cmd/go. This change copies most of the code in cmd/go/internal/version. A later CL will migrate 'go version -m' to use this package. For #37475 Fixes #39301 Change-Id: I0fbe0896e04f12ef81c6d79fb61b20daede86159 Reviewed-on: https://go-review.googlesource.com/c/go/+/353887 Trust: Jay Conrod <jayconrod@google.com> Run-TryBot: Jay Conrod <jayconrod@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-10-11cmd/compile: adjust debug/gosym to deal with instantiated types/funcs/methodsDan Scales
This changes debug/gosym so it can deal with instantiated types/funcs/methods. I also added tests for instantiated names. My assumption is that the concatenation of PackageName, ReceiverName, and BaseName in order should cover the entire symbol name, so either the ReceiverName or the BaseName should include any bracketed information (either the instantiation of the receiver of a method or the instantiation of function). This can provide a model for how to parse instantiated functions and method names. Fixes #48032 Change-Id: I476781de2d6fc096efbb4be85c197d6f1cafac21 Reviewed-on: https://go-review.googlesource.com/c/go/+/354689 Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2021-10-05cmd/link,runtime: remove functab relocationsJosh Bleecher Snyder
Use an offset from runtime.text instead. This removes the last relocation from functab generation, which lets us simplify that code. size before after Δ % addr2line 3680818 3652498 -28320 -0.769% api 4944850 4892418 -52432 -1.060% asm 4757586 4711266 -46320 -0.974% buildid 2418546 2392578 -25968 -1.074% cgo 4197346 4164818 -32528 -0.775% compile 22076882 21875890 -200992 -0.910% cover 4411362 4358418 -52944 -1.200% dist 3091346 3062738 -28608 -0.925% doc 3563234 3532610 -30624 -0.859% fix 3020658 2991666 -28992 -0.960% link 6164642 6110834 -53808 -0.873% nm 3646818 3618482 -28336 -0.777% objdump 4012594 3983042 -29552 -0.736% pack 2153554 2128338 -25216 -1.171% pprof 13011666 12870114 -141552 -1.088% test2json 2383906 2357554 -26352 -1.105% trace 9736514 9631186 -105328 -1.082% vet 6655058 6580370 -74688 -1.122% total 103927380 102914820 -1012560 -0.974% relocs before after Δ % addr2line 25069 22709 -2360 -9.414% api 17176 13321 -3855 -22.444% asm 18271 15630 -2641 -14.455% buildid 9233 7352 -1881 -20.373% cgo 16222 13044 -3178 -19.591% compile 60421 46299 -14122 -23.373% cover 18479 14526 -3953 -21.392% dist 10135 7733 -2402 -23.700% doc 12735 9940 -2795 -21.947% fix 10820 8341 -2479 -22.911% link 21849 17785 -4064 -18.600% nm 24988 22642 -2346 -9.389% objdump 26060 23462 -2598 -9.969% pack 7665 5936 -1729 -22.557% pprof 60764 50998 -9766 -16.072% test2json 8389 6431 -1958 -23.340% trace 37180 29382 -7798 -20.974% vet 24044 19055 -4989 -20.749% total 409499 334585 -74914 -18.294% Caching the field size in debug/gosym.funcTab avoids a 20% PCToLine performance regression. name old time/op new time/op delta 115/LineToPC-8 56.4µs ± 3% 57.3µs ± 2% +1.66% (p=0.006 n=15+13) 115/PCToLine-8 188ns ± 2% 190ns ± 3% +1.46% (p=0.030 n=15+15) Change-Id: I2816a1b28e62b01852e3b306f08546f1e56cd5ac Reviewed-on: https://go-review.googlesource.com/c/go/+/352191 Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-10-04debug/gosym: add funcTab abstractionJosh Bleecher Snyder
This clarifies the existing code and makes modifications easier. name old time/op new time/op delta 115/LineToPC-8 58.6µs ± 3% 56.4µs ± 3% -3.80% (p=0.000 n=15+15) 115/PCToLine-8 194ns ± 2% 188ns ± 2% -3.31% (p=0.000 n=15+15) Change-Id: Iafdf57af93d5e3c145965c32e0227e37c69ab017 Reviewed-on: https://go-review.googlesource.com/c/go/+/353880 Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-10-04debug/gosym: use sort.Search in findFuncJosh Bleecher Snyder
Use sort.Search instead of open-coding the binary search. This makes the code a lot easier to work on. As a bonus, it speeds it up. name old time/op new time/op delta 115/LineToPC-8 57.4µs ± 5% 59.2µs ± 8% +3.19% (p=0.003 n=15+13) 115/PCToLine-8 255ns ± 1% 192ns ± 3% -24.63% (p=0.000 n=15+15) Change-Id: I41da18bfb0e745c40d24e5b96e50dfdd0c3b79f5 Reviewed-on: https://go-review.googlesource.com/c/go/+/353879 Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-09-30debug/gosym: run TestPCLine on Linux/AMD64 in short modeCherry Mui
Currently TestPCLine is skipped in short mode. The test builds a Linux/AMD64 binary, so it makes sense to skip it if we're cross compiling, as building the runtime takes a while. But if we are on Linux/AMD64, it will only build a small amount of code, which isn't really slow. The test runs in 0.14 second on my machine. I think it is acceptable to run in short mode. Then we'll have trybot coverage for this test. Change-Id: If682f88c28050f7daafde35b4f9e59c03b764a35 Reviewed-on: https://go-review.googlesource.com/c/go/+/353330 Trust: Cherry Mui <cherryyz@google.com> Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-09-30debug/gosym: fix version check in file table accessCherry Mui
Go 1.16 and 1.18 table are the same for that part. Accept 1.18 version number in that code. Fixes #48699. Change-Id: I44eafa279a94bd06444f61518aedd541b25390fd Reviewed-on: https://go-review.googlesource.com/c/go/+/353329 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-09-29cmd/link, runtime: use offset for _func.entryJosh Bleecher Snyder
The first field of the func data stored by the linker is the entry PC for the function. Prior to this change, this was stored as a relocation to the function. Change this to be an offset relative to runtime.text. This reduces the number of relocations on darwin/arm64 by about 10%. It also slightly shrinks binaries: file before after Δ % addr2line 3803058 3791298 -11760 -0.309% api 5140114 5104242 -35872 -0.698% asm 4886850 4840626 -46224 -0.946% buildid 2512466 2503042 -9424 -0.375% cgo 4374770 4342274 -32496 -0.743% compile 22920530 22769202 -151328 -0.660% cover 4624626 4588242 -36384 -0.787% dist 3217570 3205522 -12048 -0.374% doc 3715026 3684498 -30528 -0.822% fix 3148226 3119266 -28960 -0.920% link 6350226 6313362 -36864 -0.581% nm 3768850 3757106 -11744 -0.312% objdump 4140594 4127618 -12976 -0.313% pack 2227474 2218818 -8656 -0.389% pprof 13598706 13506786 -91920 -0.676% test2json 2497234 2487426 -9808 -0.393% trace 10198066 10118498 -79568 -0.780% vet 6930658 6889074 -41584 -0.600% total 108055044 107366900 -688144 -0.637% It should also incrementally speed up binary launching. This is the first step towards removing enough relocations that pages that were previously dirtied by the loader may remain clean, which will offer memory savings useful in constrained environments. Change-Id: Icfba55e696ba2f9c99c4f179125ba5a3ba4369c9 Reviewed-on: https://go-review.googlesource.com/c/go/+/351463 Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-09-29debug/gosym: refactor handling of funcdataJosh Bleecher Snyder
We do a bunch of manual offset calculations everywhere. Add a bit of type safety and some helpers. In addition to making the code clearer and providing a place to hang some documentation, it also makes upcoming changes easier. name old time/op new time/op delta 115/NewLineTable-8 79.9ns ± 1% 90.2ns ±23% ~ (p=0.234 n=9+10) 115/NewTable-8 72.0µs ± 1% 73.4µs ± 1% +1.96% (p=0.000 n=8+8) 115/LineToPC-8 53.3µs ± 1% 54.4µs ± 1% +2.02% (p=0.000 n=10+10) 115/PCToLine-8 249ns ± 0% 249ns ± 2% ~ (p=0.147 n=9+10) name old alloc/op new alloc/op delta 115/NewLineTable-8 384B ± 0% 384B ± 0% ~ (all equal) 115/NewTable-8 164kB ± 0% 164kB ± 0% ~ (p=0.610 n=10+10) 115/LineToPC-8 0.00B 0.00B ~ (all equal) 115/PCToLine-8 0.00B 0.00B ~ (all equal) name old allocs/op new allocs/op delta 115/NewLineTable-8 3.00 ± 0% 3.00 ± 0% ~ (all equal) 115/NewTable-8 1.04k ± 0% 1.04k ± 0% ~ (all equal) 115/LineToPC-8 0.00 0.00 ~ (all equal) 115/PCToLine-8 0.00 0.00 ~ (all equal) Change-Id: If357dce5ae4277e6ddc6d90ba6b5b83e470b9121 Reviewed-on: https://go-review.googlesource.com/c/go/+/352951 Trust: Josh Bleecher Snyder <josharian@gmail.com> Trust: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
2021-09-29debug/gosym: add benchmarkJosh Bleecher Snyder
Use a Go 1.15 executable for the benchmark, because it is handy. Most of the code paths are shared for Go 1.2+. Change-Id: Id7ddc76a05d76335108c58ff9f1ab2ff837b7227 Reviewed-on: https://go-review.googlesource.com/c/go/+/353131 Trust: Josh Bleecher Snyder <josharian@gmail.com> Trust: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
2021-09-29debug/gosym: adjust go12* method commentsJosh Bleecher Snyder
These methods are for use with Go 1.2 _and later_ pcln tables. Make that clearer. Change-Id: Iee06e0828fd5895639b654363b6d91bf9151d224 Reviewed-on: https://go-review.googlesource.com/c/go/+/352950 Trust: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-09-29debug/gosym: add hook to disable recoversJosh Bleecher Snyder
debug/gosym assumes throughout that bogus input means a malformed file. That's generally true, but not when you're changing the package. In that case, the panic usually indicates a newly introduced bug, and seeing the panic is really useful. Add a manually-enabled way to make panics panic. Change-Id: I07af6c7b982c4cf61180db29f07aa63576ba7837 Reviewed-on: https://go-review.googlesource.com/c/go/+/352949 Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-09-27debug/gosym: add pcHeader parsing helpersJosh Bleecher Snyder
A subsequent change will duplicate most of case ver116. Make it easier to read. Change-Id: I3a93181c7f094b12715b8a618e9efef7a1438a27 Reviewed-on: https://go-review.googlesource.com/c/go/+/351909 Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-09-10debug/elf: retain original error message when getSymbols fails.Florin Papa
The original error is currently discarded, and that makes it difficult to know what failed, in case we want to retry only certain errors. Change-Id: Id7e927ec242464249c4dfa5cda0f264adef3c898 Reviewed-on: https://go-review.googlesource.com/c/go/+/317851 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Than McIntosh <thanm@google.com>
2021-09-02debug/dwarf: check for DWARFv4 AttrDataBitOffset valueJoe Sylve
AttrBitOffset is deprecated (but reserved) in DWARFv4. This fix adds logic to check the new AttrDataBitOffset attribute if AttrBitOffset attribute is not present. Fixes #46784 Change-Id: I7406dcaa4c98e95df72361fd4462c39e6be8879d GitHub-Last-Rev: 5aa10d04910a09538320b4de8fbd8a1f5fd8c17d GitHub-Pull-Request: golang/go#46790 Reviewed-on: https://go-review.googlesource.com/c/go/+/328709 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Michael Knyszek <mknyszek@google.com>
2021-06-14debug/elf: don't apply DWARF relocations for ET_EXEC binariesVictor Michel
Some ET_EXEC binaries might have relocations for non-loadable sections like .debug_info. These relocations must not be applied, because: * They may be incorrect * The correct relocations were already applied at link time Binaries in Linux Kernel debug packages like Fedora/Centos kernel-debuginfo are such examples. Relocations for .debug_* sections are included in the final binaries because they are compiled with --emit-relocs, but the resulting relocations are incorrect and shouldn't be used when reading DWARF sections. Fixes #46673 Change-Id: I2b4214f1584bfc243446d0eaee41512657325b95 GitHub-Last-Rev: 8350fad059e70422d13dfaa5bab7fb8a56c0f76f GitHub-Pull-Request: golang/go#46698 Reviewed-on: https://go-review.googlesource.com/c/go/+/327009 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-05-14debug/macho: fix a typo in macho.goitchyny
Change-Id: Ica47b53decf6690fbd37e666e9de5098117b82de GitHub-Last-Rev: 6aabb208a6499e29fe32a2f0d928c4e027d556b2 GitHub-Pull-Request: golang/go#46147 Reviewed-on: https://go-review.googlesource.com/c/go/+/319592 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Trust: Brad Fitzpatrick <bradfitz@golang.org> Trust: Heschi Kreinick <heschi@google.com>
2021-05-13debug/dwarf: delay array type fixup to handle type cyclesThan McIntosh
A user encountered a debug/dwarf crash when running the dwarf2json tool (https://github.com/volatilityfoundation/dwarf2json) on a debug-built copy of the linux kernel. In this crash, the DWARF type reader was trying to examine the contents of an array type while that array type was still in the process of being constructed (due to cycles in the type graph). To avoid such situations, this patch extends the mechanism introduced in https://go-review.googlesource.com/18459 (which handles typedef types) to delay fixup of array types as well. Change-Id: I303f6ce5db1ca4bd79da3581957dfc2bfc17cc01 Reviewed-on: https://go-review.googlesource.com/c/go/+/319329 Trust: Than McIntosh <thanm@google.com> Run-TryBot: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Yi Chou <yich@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-04-23all: do not test internal linking on windows/arm64Russ Cox
(It doesn't work and isn't used by default.) Change-Id: I90118d889bd963471f0915d8183502b55bd9dbf2 Reviewed-on: https://go-review.googlesource.com/c/go/+/312045 Trust: Russ Cox <rsc@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-23debug/dwarf: skip over zero-length compilation unitsRuss Cox
DWARF sections generated by mingw-clang seem to include these (not often - only one out of many in the binary that I am looking at). Skipping over them, everything parses correctly. This makes TestDefaultLinkerDWARF pass on windows/arm64. Change-Id: Ie4a7daa1423f51cbc8c4aac88b1d27c3b52ee880 Reviewed-on: https://go-review.googlesource.com/c/go/+/312031 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-13all: simplify the spelling of LinuxBrad Fitzpatrick
The prefix didn't help clarify anything. Change-Id: I897fd4022ce9df42a548b15714e4b592618ca547 Reviewed-on: https://go-review.googlesource.com/c/go/+/309573 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Filippo Valsorda <filippo@golang.org>
2021-04-12debug/pe: replace os.MkdirTemp with T.TempDirManlio Perillo
Updates #45402 Change-Id: I3d83a66270ca38e82d6bb7f8a1367af3d5343a98 Reviewed-on: https://go-review.googlesource.com/c/go/+/309352 Trust: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-03-17debug/dwarf: support DW_FORM_rnglistx aka formRnglistxIan Lance Taylor
Change-Id: I7df915978af3488f46a27595a1b04d0d33f81f7b Reviewed-on: https://go-review.googlesource.com/c/go/+/302369 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2021-03-13all: remove duplicate wordsJohn Bampton
Change-Id: Ib0469232a2b69a869e58d5d24990ad74ac96ea56 GitHub-Last-Rev: eb38e049ee1e773392ff3747e1eb2af20dd50dcd GitHub-Pull-Request: golang/go#44805 Reviewed-on: https://go-review.googlesource.com/c/go/+/299109 Trust: Emmanuel Odeke <emmanuel@orijtech.com> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-03-02cmd/link,debug/elf: mips32, add .gnu.attributes and .MIPS.abiflags sectionsYunQiang Su
MIPS32 uses .gnu.attributes and .MIPS.abiflags sections to mark FP ABI the object is using, and the kernel will set the correct FP mode for it. Currrently Go doesn't generate these 2 sections. If we link object without these 2 sections togather FPXX objects, the result will be FPXX, which is wrong: FP32 + FPXX -> FP32 FPXX + FP64 -> FP64 FP32 + FP64 -> reject These 2 sections is also needed to support FPXX and FP64 in future. More details about FP32/FPXX/FP64 are explained in: https://web.archive.org/web/20180828210612/https://dmz-portal.mips.com/wiki/MIPS_O32_ABI_-_FR0_and_FR1_Interlinking Fixes #39677 Change-Id: Ia34e7461dee38a4f575dd8ace609988744512ac1 Reviewed-on: https://go-review.googlesource.com/c/go/+/239217 Run-TryBot: Cherry Zhang <cherryyz@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Meng Zhuo <mzh@golangcn.org>
2021-02-20all: go fmt std cmd (but revert vendor)Russ Cox
Make all our package sources use Go 1.17 gofmt format (adding //go:build lines). Part of //go:build change (#41184). See https://golang.org/design/draft-gobuild Change-Id: Ia0534360e4957e58cd9a18429c39d0e32a6addb4 Reviewed-on: https://go-review.googlesource.com/c/go/+/294430 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-19debug/pe: recognize arm64 executablesRuss Cox
We still need to add test data, but as yet we haven't identified a good Windows arm64 compiler to produce small binaries. This CL is part of a stack adding windows/arm64 support (#36439), intended to land in the Go 1.17 cycle. Change-Id: Ifbecb9a6e25f7af38e20b7d7830df7f5efe2798a Reviewed-on: https://go-review.googlesource.com/c/go/+/288820 Trust: Russ Cox <rsc@golang.org> Trust: Jason A. Donenfeld <Jason@zx2c4.com> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-12-14debug/dwarf: don't try to parse addr/rnglists headerIan Lance Taylor
In an executable, the debug_addr and debug_rnglists sections are assembled by concatenating the input sections, and each input section has a header, and each header may have different attributes. So just parsing the single header isn't right. Parsing the header is not necessary to handle offsets into these sections which is all we do. Looking at the header is also problematic because GCC with -gsplit-dwarf when using DWARF versions 2 through 4 emits a .debug_addr section, but it has no header. The header was only added for DWARF 5. So we can't parse the header at all for that case, and we can't even detect that case in general. This CL also fixes SeekPC with addrx and strx formats, by not using the wrong compilation unit to find the address or string base. To make that work when parsing the compilation unit itself, we add support for delay the resolution of those values until we know the base. New test binaries built with gcc -gdwarf-5 -no-pie debug/dwarf/testdata/line[12].c (gcc (Debian 10.2.0-15) 10.2.0) clang -gdwarf-5 -no-pie debug/dwarf/testdata/line[12].c (clang version 9.0.1-14) Change-Id: I66783e0eded629bf80c467767f781164d344a54d Reviewed-on: https://go-review.googlesource.com/c/go/+/277233 Trust: Ian Lance Taylor <iant@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-12-09all: update to use os.ReadFile, os.WriteFile, os.CreateTemp, os.MkdirTempRuss Cox
As part of #42026, these helpers from io/ioutil were moved to os. (ioutil.TempFile and TempDir became os.CreateTemp and MkdirTemp.) Update the Go tree to use the preferred names. As usual, code compiled with the Go 1.4 bootstrap toolchain and code vendored from other sources is excluded. ReadDir changes are in a separate CL, because they are not a simple search and replace. For #42026. Change-Id: If318df0216d57e95ea0c4093b89f65e5b0ababb3 Reviewed-on: https://go-review.googlesource.com/c/go/+/266365 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-10-30cmd/link: emit include directories in DWARF line table prologueThan McIntosh
This patch changes the way the linker emits the DWARF line table prologue, specifically the file table. Previously files were left unmodified, and the directory table was empty. For each compilation unit we now scan the unit file table and build up a common set of directories, emit them into the directory table, and then emit file entries that refer to the dirs. This provides a modest binary size savings. For kubernetes kubelet: $ objdump -h /tmp/kubelet.old | fgrep debug_line 36 .zdebug_line 019a55f5 0000000000000000 0000000000000000 084a5123 2**0 $ objdump -h /tmp/kubelet.new | fgrep debug_line 36 .zdebug_line 01146fd2 0000000000000000 0000000000000000 084a510a 2**0 [where the value following the section name above is the section size in hex, so roughly a 30% decrease in this case.] The actual savings will depend on the length of the pathnames involved, so it's hard to really pin down how much savings we'll see here. In addition, emitting the files this way reduces the "compressibility" of the line table, so there could even be cases where we don't win at all. Updates #6853, #19784, #36495. Change-Id: I298d8561da5ed3ebc9d38aa772874851baa2f4f4 Reviewed-on: https://go-review.googlesource.com/c/go/+/263017 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com> Trust: Than McIntosh <thanm@google.com>
2020-10-24debug/dwarf: add support for DWARFv5 to (*Data).RangesAlessandro Arzilli
Updates the (*Data).Ranges method to work with DWARFv5 which uses the new debug_rnglists section instead of debug_ranges. This does not include supporting DW_FORM_rnglistx. General support for DWARFv5 was added by CL 175138. Change-Id: I01f919a865616a3ff12f5bf649c2c9abf89fcf52 Reviewed-on: https://go-review.googlesource.com/c/go/+/236657 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Emmanuel Odeke <emm.odeke@gmail.com>
2020-10-20all: update references to symbols moved from io/ioutil to ioRuss Cox
The old ioutil references are still valid, but update our code to reflect best practices and get used to the new locations. Code compiled with the bootstrap toolchain (cmd/asm, cmd/dist, cmd/compile, debug/elf) must remain Go 1.4-compatible and is excluded. Also excluded vendored code. For #41190. Change-Id: I6d86f2bf7bc37a9d904b6cee3fe0c7af6d94d5b1 Reviewed-on: https://go-review.googlesource.com/c/go/+/263142 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-09-30[dev.link] Merge branch 'master' into dev.linkJeremy Faller
2 conflicts, that make sense. src/cmd/internal/obj/objfile.go src/cmd/link/internal/loader/loader.go Change-Id: Ib224e2d248cb568fa1e888af79dd908b2f5e05ff
2020-09-23all: add GOOS=iosCherry Zhang
Introduce GOOS=ios for iOS systems. GOOS=ios matches "darwin" build tag, like GOOS=android matches "linux" and GOOS=illumos matches "solaris". Only ios/arm64 is supported (ios/amd64 is not). GOOS=ios and GOOS=darwin remain essentially the same at this point. They will diverge at later time, to differentiate macOS and iOS. Uses of GOOS=="darwin" are changed to (GOOS=="darwin" || GOOS=="ios"), except if it clearly means macOS (e.g. GOOS=="darwin" && GOARCH=="amd64"), it remains GOOS=="darwin". Updates #38485. Change-Id: I4faacdc1008f42434599efb3c3ad90763a83b67c Reviewed-on: https://go-review.googlesource.com/c/go/+/254740 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
2020-09-21debug/dwarf: speed up SkipChildren for compilation unitsDmitry Vyukov
For a common pattern of iterating only over top-level compilation units (CU) Reader.SkipChildren has decode and meterialize all CU subentries just to skip them, because DW_TAG_compile_unit does not have DW_AT_sibling. However, CUs have total size encoded before the unit and we already parse them and know all unit sizes. Optimize Reader.SkipChildren to use that size when skipping CUs children. This speeds up iteration over a 1.3GB object file from 7.5s to 0.73s. Change-Id: I2a8f00955159b4bd13571409f4817805f934cb69 Reviewed-on: https://go-review.googlesource.com/c/go/+/256217 Run-TryBot: Dmitry Vyukov <dvyukov@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Than McIntosh <thanm@google.com>
2020-09-18debug/elf: add many PT_ and DT_ constantsIan Lance Taylor
Change-Id: Icbb5a0f0ff4aa0a425aa4a15477da7bd0d58339c Reviewed-on: https://go-review.googlesource.com/c/go/+/255138 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-09-11[dev.link] all: merge branch 'master' into dev.linkCherry Zhang
Clean merge. Change-Id: Ib773b0bc00fd99d494f9331c3613bcc8285e48e3
2020-08-31debug/elf: support relocations relative to sections with non-zero addressesVictor Michel
commit 72ec930fa70c20ce69b21bf32a7916c04c2e9c2f added basic support for relocations, but assumed that the symbol value would be 0, likely because .debug_info always has address == 0 in the ELF section headers. CL 195679 added further support for relocations, but explicitly encoded the original assumption that section addresses would be 0. This change removes that assumption: all relocations will now be properly computed based on the target symbol value even when that symbol is a section with a non-zero address. Typically, sections that are part of a LOAD program segment have non-zero addresses. For example, .debug_ranges relocations could be relative to .text, which usually has an address > 0. Fixes #40879 Change-Id: Ib0a616bb8b05d6c96d179b03ca33a10946fc5d59 GitHub-Last-Rev: 4200de732641995f3a4958a13a5c78f65b7eae50 GitHub-Pull-Request: golang/go#41038 Reviewed-on: https://go-review.googlesource.com/c/go/+/250559 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-08-30debug/elf: run relocation tests in parallelIan Lance Taylor
Also don't restart DWARF reading from beginning when we are testing multiple entries. Also reformat relocationTests slice to use indexed literals. Change-Id: Ia5f17214483394d0ef033be516df61f0bdc521b6 Reviewed-on: https://go-review.googlesource.com/c/go/+/251637 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-08-18[dev.link] cmd/{compile,link}: remove pcdata tables from pclntab_oldJeremy Faller
Move the pctables out of pclntab_old. Creates a new generator symbol, runtime.pctab, which holds all the deduplicated pctables. Also, tightens up some of the types in runtime. Darwin, cmd/compile statistics: alloc/op Pclntab_GC 26.4MB ± 0% 13.8MB ± 0% allocs/op Pclntab_GC 89.9k ± 0% 86.4k ± 0% liveB Pclntab_GC 25.5M ± 0% 24.2M ± 0% No significant change in binary size. Change-Id: I1560fd4421f8a210f8d4b508fbc54e1780e338f9 Reviewed-on: https://go-review.googlesource.com/c/go/+/248332 Run-TryBot: Jeremy Faller <jeremy@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-08-13[dev.link] debug/gosym: fix file mappingsJeremy Faller
CL 246497 introduced bugs in gosym that the long tests caught. These two bugs were: 1) In 1.16, 0 is now a valid file number from pcfile tables. 2) Also, in 1.16, when we scan all functions looking for a pc/file pair, the values returned from pcfile are no longer the direct offset into the file table. Rather, the values from pcfile are the offset into the cu->file look-up table. This CL fixes those two issues. Change-Id: I0cd280bdcaeda89faaf9fac41809abdb87734499 Reviewed-on: https://go-review.googlesource.com/c/go/+/248317 Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Than McIntosh <thanm@google.com>