aboutsummaryrefslogtreecommitdiff
path: root/src/debug
AgeCommit message (Collapse)Author
2023-09-22all: clean unnecessary casts for test filesJes Cok
This is a follow up of CL 528696. Change-Id: I5b71eabedb12567c4b1b36f7182a3d2b0ed662a5 GitHub-Last-Rev: acaf3ac11c38042ad27b99e1c70a3c9f1a554a15 GitHub-Pull-Request: golang/go#62713 Reviewed-on: https://go-review.googlesource.com/c/go/+/529197 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-20debug/elf: don't crash on empty symbol sectionIan Lance Taylor
No test case because the problem can only happen for invalid data. Let the fuzzer find cases like this. Fixes #62649 Change-Id: Ia40b4d415e3bbffaffd143ee280949ba41346579 Reviewed-on: https://go-review.googlesource.com/c/go/+/528655 Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2023-09-08debug/elf,cmd/link: add additional MIPS64 relocation typeJoel Sing
Add R_MIPS_PC32 which is a 32 bit PC relative relocation. These are produced by LLVM on mips64. Fixes #61974 Change-Id: I7b6c6848e40249e6d5ea474ea53c9d7e3ab23f88 Reviewed-on: https://go-review.googlesource.com/c/go/+/469395 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Joel Sing <joel@sing.id.au> Reviewed-by: Junxian Zhu <zhujunxian@oss.cipunited.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-09-07all: use io.{SeekStart, SeekCurrent, SeekEnd}Jes Cok
Currently we include these symbols in bootstrap code. Change-Id: I19b504237b0344f0e87cda0fbe651811c72daba1 GitHub-Last-Rev: 5134baec387659c5e2ca8c4fc65a5e73c07f00ce GitHub-Pull-Request: golang/go#62368 Reviewed-on: https://go-review.googlesource.com/c/go/+/524258 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: qiulaidongfeng <2645477756@qq.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2023-08-31all: rewrite internal/saferio.SliceCap using generics and add func ↵Jes Cok
SliceCapWithSize Change-Id: I265173bf2722796c4be545c968efef3a1a6f7a7d GitHub-Last-Rev: 04d95cdd615f906167545f246f707e1440c39374 GitHub-Pull-Request: golang/go#62365 Reviewed-on: https://go-review.googlesource.com/c/go/+/524257 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-07-31debug/buildinfo: read full data segment to lookup buildinfo magicAlexander Yastrebov
Fixes #61644 Change-Id: I7d40c33e65221994bb6865d22dd0994545603ba8 GitHub-Last-Rev: aca92afcbdef2dd191ed0e5c61da29d3b1cb0698 GitHub-Pull-Request: golang/go#61649 Reviewed-on: https://go-review.googlesource.com/c/go/+/514075 Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-07-31debug/elf: don't use reflection in File.SymbolsTolya Korniltsev
cpu: AMD Ryzen 9 5950X 16-Core Processor | old.txt | new.txt | | sec/op | sec/op vs base | Symbols64-32 18.486µ ± 2% 4.509µ ± 24% -75.61% (p=0.000 n=10) Symbols32-32 17.823µ ± 3% 4.798µ ± 2% -73.08% (p=0.000 n=10) geomean 18.15µ 4.651µ -74.38% | old.txt | new.txt | | B/op | B/op vs base | Symbols64-32 10.680Ki ± 0% 8.922Ki ± 0% -16.46% (p=0.000 n=10) Symbols32-32 9.773Ki ± 0% 8.570Ki ± 0% -12.31% (p=0.000 n=10) geomean 10.22Ki 8.744Ki -14.41% | old.txt | new.txt | | allocs/op | allocs/op vs base | Symbols64-32 119.00 ± 0% 45.00 ± 0% -62.18% (p=0.000 n=10) Symbols32-32 125.00 ± 0% 50.00 ± 0% -60.00% (p=0.000 n=10) geomean 122.0 47.43 -61.11% Fixes #61534 Change-Id: I13a96467108771df31f018853df754e42100e773 Reviewed-on: https://go-review.googlesource.com/c/go/+/512395 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: David Chase <drchase@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-05-24all: fix unavailable urlcui fliter
RISC-V modified the address of github and the suffix of the file. The previous link is no longer accessible. use latest link. Change-Id: I5e33ea8447a59b8183658248df05c79ddd380cba Reviewed-on: https://go-review.googlesource.com/c/go/+/497378 Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: shuang cui <imcusg@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com>
2023-05-23debug/elf: define R_PPC64_REL24_P9NOTOCPaul E. Murphy
This relocation is not (yet?) defined in ELFv2, but has been added to gnu gas a couple years ago. It is the same reloc as R_PPC64_REL24_NOTOC, but hints power10 instructions should not be emitted. See binutils commit 7aba54da426b9999085d8f84e7896b8afdbb9ca6. Fixes #60348 Change-Id: Ie953cd7bf1ffc621b498d4dbebb5de1231833c8f Reviewed-on: https://go-review.googlesource.com/c/go/+/496918 Run-TryBot: Paul Murphy <murp@ibm.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2023-05-01debug/pe: return error on reading from section with uninitialized dataIan Lance Taylor
A section with uninitialized data contains no bytes and occupies no space in the file. This change makes it return an error on reading from this section so that it will force the caller to check for a section with uninitialized data. This is the debug/pe version of CL 429601. This will break programs that expect a byte slice with the length described by the SizeOfRawData field. There are two reasons to introduce this breaking change: 1) uninitialized data is uninitialized and there is no reason to allocate memory for it; 2) it could result in an OOM if the file is corrupted and has a large invalid SizeOfRawData. No test case because the problem can only happen for invalid data. Let the fuzzer find cases like this. For #47653 Fixes #59817 Change-Id: I1ae94e9508f803b37926275d9a571f724a09af9f Reviewed-on: https://go-review.googlesource.com/c/go/+/488475 Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: kortschak <dan@kortschak.io> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-04-18debug/elf: support zstd compressionIan Lance Taylor
Test cases added to debug/dwarf because that is where it matters in practice. The new test binary line-gcc-zstd.elf built with gcc -g -no-pie -Wl,--compress-debug-sections=zstd line[12].c using gcc (Debian 12.2.0-10) 12.2.0 with a development version of the GNU binutils. Fixes #55107 Change-Id: I48507c96902e1f83a174e5647b5cc403d965b52b Reviewed-on: https://go-review.googlesource.com/c/go/+/473256 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2023-04-11all: add wasip1 supportJohan Brandhorst-Satzkorn
Fixes #58141 Co-authored-by: Richard Musiol <neelance@gmail.com> Co-authored-by: Achille Roussel <achille.roussel@gmail.com> Co-authored-by: Julien Fabre <ju.pryz@gmail.com> Co-authored-by: Evan Phoenix <evan@phx.io> Change-Id: I49b66946acc90fdf09ed9223096bfec9a1e5b923 Reviewed-on: https://go-review.googlesource.com/c/go/+/479627 Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Bypass: Ian Lance Taylor <iant@golang.org>
2023-04-11all: re-run stringerIan Lance Taylor
Re-run all go:generate stringer commands. This mostly adds checks that the constant values did not change, but does add new strings for the debug/dwarf and internal/pkgbits packages. Change-Id: I5fc41f20da47338152c183d45d5ae65074e2fccf Reviewed-on: https://go-review.googlesource.com/c/go/+/483717 Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org>
2023-04-11debug/elf: avoid decompress of section twiceMeng Zhuo
In rare cases, elf will get a corrupted section starts with 0x1, which happens to be COMPRESS_ZLIB that causing decompress twice. This CL drops sectionData decompress data after open section. Fixes #59208 Change-Id: I7999a55868b3b3481509e1ac35985f7580f0f688 Reviewed-on: https://go-review.googlesource.com/c/go/+/480895 Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Benny Siegert <bsiegert@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: M Zhuo <mzh@golangcn.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-04-04all: fix misuses of "a" vs "an"cui fliter
Fixes the misuse of "a" vs "an", according to English grammatical expectations and using https://www.a-or-an.com/ Change-Id: I53ac724070e3ff3d33c304483fe72c023c7cda47 Reviewed-on: https://go-review.googlesource.com/c/go/+/480536 Run-TryBot: shuang cui <imcusg@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2023-03-18debug/dwarf: return ErrUnknownPC rather than nil on unknown PCJoel Sing
Currently, on e == nil or e.Tag == 0, SeekPC returns with a nil error. Instead, indicate that the PC is unknown. Change-Id: I9594296034e2df872e399bd800b00cb565c413c9 Reviewed-on: https://go-review.googlesource.com/c/go/+/473695 Reviewed-by: Carlos Amedee <carlos@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org>
2023-03-08debug/buildinfo: recognize macOS fat binary in go versionNikola Jokic
buildinfo did not check for fat magic, which caused go version to report unrecognized file format. This change reads the fat file and passes the first arch file to machoExe. Fixes #58796 Change-Id: I45cd26729352e46cc7ecfb13f2e9a8d96d62e0a0 Reviewed-on: https://go-review.googlesource.com/c/go/+/473615 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-03-07debug/elf: retrieve values for dynamic section tagsFlorin Papa
Add functionality to retrieve values for .dynamic entries that don't correspond to entries in the string table. Fixes #56892 Change-Id: I6edabc8ca331c819e442d06e19b7f4df8343372b Reviewed-on: https://go-review.googlesource.com/c/go/+/452617 Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-03-06debug/buildinfo: use saferio in ReadData methodsIan Lance Taylor
This avoids a very large memory allocation if corrupt data says that we need to read a very long string. No test case because the problem can only happen for invalid data. Let the fuzzer find cases like this. For #47653 Fixes #58886 Change-Id: I4e80ba62a6416d010c8804e4f49ae81bdafaadb8 Reviewed-on: https://go-review.googlesource.com/c/go/+/473657 Run-TryBot: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-02-28debug/macho: use saferio to read dynamic indirect symbolsIan Lance Taylor
No test case because the problem can only happen for invalid data. Let the fuzzer find cases like this. For #47653 Fixes #58755 Change-Id: I5b95a21f47ec306ad90cd6221f0566c6f8b6c3ad Reviewed-on: https://go-review.googlesource.com/c/go/+/471835 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-02-22debug/macho: don't crash if dynamic symtab with no symtabIan Lance Taylor
No test case because the problem can only happen for invalid data. Let the fuzzer find cases like this. For #47653 Fixes #58642 Change-Id: I19fee0dc9bd6239b520c15182b8f1e57bb0049bb Reviewed-on: https://go-review.googlesource.com/c/go/+/470397 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
2023-02-21debug/macho: use saferio to read symbol table stringsIan Lance Taylor
No test case because the problem can only happen for invalid data. Let the fuzzer find cases like this. For #47653 Fixes #58603 Change-Id: I67fc45365c1a5b0b4b381f541bf2fee8ce8ddc3a Reviewed-on: https://go-review.googlesource.com/c/go/+/469895 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org>
2023-02-03debug/elf: add DT_FLAGS_1 constantsFlorin Papa
Add constants for all ELF dynamic flags (pertaining to DT_FLAGS_1). This will help, for example, determining whether an object is a position-independent executable (PIE). The constants are defined according to Table 15-10 in https://docs.oracle.com/en/operating-systems/solaris/oracle-solaris/11.4/linkers-libraries/dynamic-section.html. Fixes #56887 Change-Id: I6cd501af50d9dbcc2aa8a9a002e12c6fb6726761 Reviewed-on: https://go-review.googlesource.com/c/go/+/452496 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-20all: fix typos in go file commentsMarcel Meyer
This is the second round to look for spelling mistakes. This time the manual sifting of the result list was made easier by filtering out capitalized and camelcase words. grep -r --include '*.go' -E '^// .*$' . | aspell list | grep -E -x '[A-Za-z]{1}[a-z]*' | sort | uniq This PR will be imported into Gerrit with the title and first comment (this text) used to generate the subject and body of the Gerrit change. Change-Id: Ie8a2092aaa7e1f051aa90f03dbaf2b9aaf5664a9 GitHub-Last-Rev: fc2bd6e0c51652f13a7588980f1408af8e6080f5 GitHub-Pull-Request: golang/go#57737 Reviewed-on: https://go-review.googlesource.com/c/go/+/461595 Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
2022-12-12debug/buildinfo: check pointer size on buildinfo.ReadNikola Jokic
Previous implementation has a check on pointer size but only if ptrSize is 4. but it does not check on ptrSize 8 causing the panic on read for some inputs. The explicit check for pointer size 8 is added and error is returned if ptrSize is not 4 and not 8. Fixes #57002 Change-Id: Id51de72bdef4da9955d086bfc2a5d735678ee2ac Reviewed-on: https://go-review.googlesource.com/c/go/+/454616 Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
2022-11-05all: fix comment typosDan Kortschak
Change-Id: Ic16824482142d4de4d0b949459e36505ee944ff7 Reviewed-on: https://go-review.googlesource.com/c/go/+/448175 Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Dan Kortschak <dan@kortschak.io> Auto-Submit: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Dan Kortschak <dan@kortschak.io> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-11-04all: fix function names in commentscui fliter
Change-Id: I871a747b4b47bccc889f2fdc93a2bcebb041b719 Reviewed-on: https://go-review.googlesource.com/c/go/+/447895 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-10-26debug/elf: guard access to File.gnuVersymZeke Lu
The size of gnuVersym should be multiples of 2. If not, the input is invalid. No Library and Version information is added to sym in this case. The current implementation of gnuVersion does not report errors for invalid input. While at here, bring back the comment that states that the undef entry at the beginning is skipped. This is not an off-by-one error. No test case because the problem can only happen for invalid data. Let the fuzzer find cases like this. Fixes #56429. Change-Id: Ia39ad8bd509088a81cc77f7a76e23185d40a5765 GitHub-Last-Rev: 3be0cc1b1522874cf5dc509678aa6a5658b6bad5 GitHub-Pull-Request: golang/go#56431 Reviewed-on: https://go-review.googlesource.com/c/go/+/445555 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Run-TryBot: Meng Zhuo <mzh@golangcn.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-10-25debug/elf: use saferio.SliceCap when decoding ELF sectionsZeke Lu
This avoids allocating an overly large slice for corrupt input. No test case because the problem can only happen for invalid data. Let the fuzzer find cases like this. Updates #33121. Change-Id: Ie2d947a3865d3499034286f2d08d3e3204015f3e GitHub-Last-Rev: 6c62fc3cec1c6343c76f22f6a2a4ddae060fa2f4 GitHub-Pull-Request: golang/go#56405 Reviewed-on: https://go-review.googlesource.com/c/go/+/445076 Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
2022-10-14debug/elf: fix inccorrect value in COMPRESS_ZLIB string nameFlorian Zenker
LLVM recently introduced ZSTD compression for ELF sections. The error message when failing to read the compressed section calls this COMPRESS_ZLIB+2 while it should report it as COMPRESS_ZLIB+1. Change-Id: I869aa69baf0c8c86665475b47343c790587cb39b Reviewed-on: https://go-review.googlesource.com/c/go/+/443035 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-10-13debug: add top level security docs for dwarf, elf, macho, pe, and plan9objRoland Shoemaker
Adds a package level doc comment to the debug/dwarf, debug/elf, debug/macho, debug/pe, and debug/plan9obj noting that these packages are not designed to be hardened against adversarial inputs. Change-Id: I678d01bcdc8ad01c23805f09cc59e64cec6c3f76 Reviewed-on: https://go-review.googlesource.com/c/go/+/435417 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Julie Qiu <julieqiu@google.com> Run-TryBot: Roland Shoemaker <roland@golang.org> Auto-Submit: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-10-12debug/elf: validate phentsize and shentsizeIan Lance Taylor
No test case because the problem can only happen for invalid data. Let the fuzzer find cases like this. Fixes #56129 Change-Id: I6c81933781384c5e2c8ba0fd99cec50455b9664a Reviewed-on: https://go-review.googlesource.com/c/go/+/441976 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Joedian Reid <joedian@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org>
2022-10-06debug/buildinfo: correct a typo in calculating next align indexZeke Lu
When it calculates the smallest n such that: n >= i && n % buildInfoAlign == 0 the expression should be (i+buildInfoAlign-1)&^(buildInfoAlign-1) instead of (i+buildInfoAlign-1)&^buildInfoAlign Fixes #54968. Change-Id: Ibb7bdf568a521545b2609acc85e2ab4e05da5dae GitHub-Last-Rev: 479ebc140af9809f0bea039e643cb95b4f857614 GitHub-Pull-Request: golang/go#54971 Reviewed-on: https://go-review.googlesource.com/c/go/+/429815 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com>
2022-10-01debug/dwarf: don't crash on negative range/rnglist offsetIan Lance Taylor
No test case because the problem can only happen for invalid data. Let the fuzzer find cases like this. Fixes #55948 Change-Id: I7ba40ba928d2a14d4ac5b39f966173f3868d4729 Reviewed-on: https://go-review.googlesource.com/c/go/+/436876 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Than McIntosh <thanm@google.com>
2022-09-29debug/elf: fix typo in R_PPC64_TPREL34 and R_PPC64_DTPREL34Paul E. Murphy
The suffix should be 34 not 28. I misread the name because the reloc listed before these two in the ABI is named "R_PC64_PCREL28". Updates #54345 Change-Id: Ie8238f55e441c787d70ead58e0a177c650f8b89e Reviewed-on: https://go-review.googlesource.com/c/go/+/435415 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Paul Murphy <murp@ibm.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-09-27debug/elf: return error on reading from SHT_NOBITS sectionsZeke Lu
An SHT_NOBITS section contains no bytes and occupies no space in the file. This change makes it return an error on reading from this section so that it will force the caller to check for an SHT_NNOBITS section. We have considered another option to return "nil, nil" for the Data method. It's abandoned because it might lead a program to simply do the wrong thing, thinking that the section is empty. Please note that it breaks programs which expect a byte slice with the length described by the sh_size field. There are two reasons to introduce this breaking change: 1. SHT_NOBITS means no data and it's unnecessary to allocate memory for it; 2. it could result in an OOM if the file is corrupted and has a huge sh_size. Fixes #54967. Change-Id: I0c3ed4e097214fe88413d726a89122105ad45d4f GitHub-Last-Rev: 994c12d9da8c7029ce1d26eb1eb4d333ef3b1f97 GitHub-Pull-Request: golang/go#54994 Reviewed-on: https://go-review.googlesource.com/c/go/+/429601 Run-TryBot: Ian Lance Taylor <iant@golang.org> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-09-27debug/elf: suport files with >= 65280 (0xff00) sectionsZeke Lu
The spec https://refspecs.linuxfoundation.org/elf/gabi4+/ch4.eheader.html states: 1. e_shnum: If the number of sections is greater than or equal to SHN_LORESERVE (0xff00), this member has the value zero and the actual number of section header table entries is contained in the sh_size field of the section header at index 0. 2. e_shstrndx: If the section name string table section index is greater than or equal to SHN_LORESERVE (0xff00), this member has the value SHN_XINDEX (0xffff) and the actual index of the section name string table section is contained in the sh_link field of the section header at index 0. This CL makes these changes to support files with >= 0xff00 sections: 1. if shoff > 0 && shnum == 0, read sh_size from the initial section header entry as shnum. 2. if shstrndx == SHN_XINDEX, read sh_link from the initial section header entry as shstrndx. It returns an error if the type of the initial section is not SHT_NULL. A file with >= 0xff00 sections is too big to include in the repository, so the test case constructs one on the fly, with some of the sections zeroed out. While here, remove the unnecessary use of reflect.DeepEqual in the test. Fixes #55294. Change-Id: I15ec43612c7cce6e8decfe4e81da3a5b16de47f7 GitHub-Last-Rev: 797c16480bc76524ff1a7c01ed09b759fcd7d45b GitHub-Pull-Request: golang/go#55295 Reviewed-on: https://go-review.googlesource.com/c/go/+/432255 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-09-27debug/dwarf: don't crash on invalid range/rnglist offsetIan Lance Taylor
No test case because the problem can only happen for invalid data. Let the fuzzer find cases like this. Fixes #53529 Change-Id: I318c87795e545fe5a006d16b4d361cd4bf5d502d Reviewed-on: https://go-review.googlesource.com/c/go/+/434936 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2022-09-25encoding/gob: use saferio.SliceCap when decoding a sliceIan Lance Taylor
This avoids allocating an overly large slice for corrupt input. Change the saferio.SliceCap function to take a pointer to the element type, so that we can handle slices of interface types. This revealed that a couple of existing calls were actually incorrect, passing the slice type rather than the element type. No test case because the problem can only happen for invalid data. Let the fuzzer find cases like this. Fixes #55338 Change-Id: I3c1724183cc275d4981379773b0b8faa01a9cbd2 Reviewed-on: https://go-review.googlesource.com/c/go/+/433296 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-09-19debug/elf: validate shstrndxZeke Lu
Changes: 1. When e_shstrndx holds the value SHN_UNDEF (0), the file has no section name string table. In this case, do not try to set section names . 2. e_shstrndx should point to an SHT_STRTAB section. If it does not, returns an error. Reference: https://refspecs.linuxfoundation.org/elf/gabi4+/ch4.eheader.html Updates #54967. Change-Id: Ic8f228061d996fd7845dfa630719a1ba12d2bb60 GitHub-Last-Rev: aeb70ca8a08e7dbc36ed61bd5a2dabcf432540e9 GitHub-Pull-Request: golang/go#55001 Reviewed-on: https://go-review.googlesource.com/c/go/+/430155 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-18debug/pe: be careful to avoid potential uint32 overflowDan Kortschak
Change-Id: Ic3c1c972bec39e14ea1af50ab2b5d887dac29eab Reviewed-on: https://go-review.googlesource.com/c/go/+/426114 Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Dan Kortschak <dan@kortschak.io> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2022-09-08debug/elf: define additional PPC64 ELFv2 relocationsPaul E. Murphy
The PPC64 ELFv2 supplement version 1.5 defines a handful of new relocation types, similarly some were not added. Fixes #54345 Change-Id: Id39b29d404298fca4a10ccf1e96b5964dc452c9e Reviewed-on: https://go-review.googlesource.com/c/go/+/425555 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-07debug/gosym: rename nameoff to nameOff to match runtimeMichael Pratt
Change-Id: Id33526e56bb25bc06746355f95045c5ef3c795c1 Reviewed-on: https://go-review.googlesource.com/c/go/+/428660 Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Michael Pratt <mpratt@google.com> Auto-Submit: Michael Pratt <mpratt@google.com>
2022-09-06debug/buildinfo: remove redundant type conversionSasha Melentyev
Change-Id: Ia8ffc9a17646ad2c74f633610aaf34fef006c023 GitHub-Last-Rev: 6ab0d107393c9bdfeaed5c539efb452942c00394 GitHub-Pull-Request: golang/go#54856 Reviewed-on: https://go-review.googlesource.com/c/go/+/428235 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-09-06debug: use strings.Buildercuiweixie
Change-Id: I59db11212758b478248f34c031501a167335348c Reviewed-on: https://go-review.googlesource.com/c/go/+/428257 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-02debug/macho: use saferio to allocate load command sliceTobias Klauser
Avoid allocating large amounts of memory for corrupt input. No test case because the problem can only happen for invalid data. Let the fuzzer find cases like this. Fixes #54780 Change-Id: Icdacb16bef7d29ef431da52e6d1da4e883a3e050 Reviewed-on: https://go-review.googlesource.com/c/go/+/427434 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
2022-08-29debug/macho: use saferio to allocate Load and Symbol slicesDan Kortschak
Avoid allocating large amounts of memory for corrupt input. No test case because the problem can only happen for invalid data. Let the fuzzer find cases like this. Change-Id: I2d1745200611f0af06ca58adcc3e2309ad6742d8 Reviewed-on: https://go-review.googlesource.com/c/go/+/425882 Run-TryBot: Dan Kortschak <dan@kortschak.io> Auto-Submit: Dan Kortschak <dan@kortschak.io> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-08-29debug/elf: validate offset and file size rangesDan Kortschak
Change-Id: Iebe31b91c6e81438120f50a8089a8efca3d5339d Reviewed-on: https://go-review.googlesource.com/c/go/+/426115 Run-TryBot: Dan Kortschak <dan@kortschak.io> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-29debug/pe: check size in uint64 to avoid overflowDavid Chase
uint32(sz) != n*uint32(ddSz) can go wrong if the RHS overflows, so do it in wider precision. Fixes #54640. Change-Id: I776563330e46de6cdacd4055f6ff08e7de67797f Reviewed-on: https://go-review.googlesource.com/c/go/+/425364 Reviewed-by: Dan Kortschak <dan@kortschak.io> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-27debug/elf: fix reloc number of R_PPC64_SECTOFF_LO_DSPaul E. Murphy
R_PPC64_SECTOFF_LO_DS is defined as reloc 62 on all PPC64 ELF ABIs. Fixes #53356 Change-Id: I5fabf6be32f3310c5aed47d4d654e05fb7bc9de0 Reviewed-on: https://go-review.googlesource.com/c/go/+/411915 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Paul Murphy <murp@ibm.com> TryBot-Result: Gopher Robot <gobot@golang.org>