aboutsummaryrefslogtreecommitdiff
path: root/src/debug/pe
AgeCommit message (Collapse)Author
2023-10-18debug: add available godoc linkcui fliter
Change-Id: I9e7b7e10d9e3d23e4ed540eb8137cd1f4d103711 Reviewed-on: https://go-review.googlesource.com/c/go/+/534761 Reviewed-by: Carlos Amedee <carlos@golang.org> Run-TryBot: shuang cui <imcusg@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@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-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-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-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-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-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-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-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-19debug/pe: fetch section size directly in (*Section).DataIan Lance Taylor
Change-Id: Idc1f8b3fb6b4b2fdcc6dade048cc14c53715319f Reviewed-on: https://go-review.googlesource.com/c/go/+/424197 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2022-08-18debug/pe: use saferio to set symbol slice capacityIan Lance Taylor
No test case because the problem can only happen for invalid data. Let the fuzzer find cases like this. For #47653 Fixes #53530 Change-Id: If1cebbbcabb188fec8be30ef043c8c4c935a9564 Reviewed-on: https://go-review.googlesource.com/c/go/+/413995 Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com>
2022-08-17debug/pe, internal/saferio: use saferio to read PE section dataIan Lance Taylor
For #47653 Fixes #53189 Change-Id: If35b968fc53e4c96b18964cfb020cdc003b881bf Reviewed-on: https://go-review.googlesource.com/c/go/+/412014 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-08-11internal/saferio: new package to avoid OOMIan Lance Taylor
Broken out of debug/pe. Update debug/pe to use it. For #47653 Change-Id: Ib3037ee04073e005c4b435d0128b8437a075b00a Reviewed-on: https://go-review.googlesource.com/c/go/+/408678 Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dan Kortschak <dan@kortschak.io> Reviewed-by: Ian Lance Taylor <iant@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-08-09debug/pe: add IMAGE_FILE_MACHINE_RISCV{32,64,128}Meng Zhuo
https://docs.microsoft.com/en-us/windows/win32/debug/pe-format Fixes #54251 Change-Id: I024130fd9f55b2f1c0439baacdc56cdbc3315215 Reviewed-on: https://go-review.googlesource.com/c/go/+/421357 Reviewed-by: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Meng Zhuo <mzh@golangcn.org>
2022-08-08debug/pe: use correct pe64 test in ImportedSymbolsIan Lance Taylor
64-bit PE is set by the optional header magic number, not by the machine field. Fixes #54250 Change-Id: I4d01bc08553780d5470e63f0b17bbd968323e5d1 Reviewed-on: https://go-review.googlesource.com/c/go/+/421394 Reviewed-by: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-06-29debug/pe: add IMAGE_FILE_MACHINE_LOONGARCH{64,32}Guoqi Chen
Related: https://github.com/MicrosoftDocs/win32/pull/1067 Change-Id: I946253f217a5c616ae4a19be44634000cba5020e Reviewed-on: https://go-review.googlesource.com/c/go/+/411616 Auto-Submit: Ian Lance Taylor <iant@google.com> 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: David Chase <drchase@google.com>
2022-05-19all: gofmt main repoRuss Cox
Excluding vendor and testdata. CL 384268 already reformatted most, but these slipped past. The struct in the doc comment in debug/dwarf/type.go was fixed up by hand to indent the first and last lines as well. For #51082. Change-Id: Iad020f83aafd671ff58238fe491907e85923d0c7 Reviewed-on: https://go-review.googlesource.com/c/go/+/407137 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-05-06debug/pe: rework reading of aux symbols to fix endianity problemsThan McIntosh
This patch reworks CL 394534 to fix things so that reading auxiliary symbol info works properly in a cross-endian mode (running debug/pe-based tool on a big-endian system). The previous implementation read in all symbol records using the primary symbol format, then just used a pointer cast to convert to the auxiliary format, which doesn't play well if host and target have different endianness. Fixes #52079. Change-Id: I143d94d9313a265f11ca7befd254bdb150698834 Reviewed-on: https://go-review.googlesource.com/c/go/+/397485 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-04-25debug/pe: fix off by one error in valid symbol index testThan McIntosh
Fix an off-by-one error in COFFSymbolReadSectionDefAux, specifically the code that tests whether a symbol index is valid. Fixes #52525. Change-Id: I1b6e5dacfd99249c694bef5ae606e90fdb2ef521 Reviewed-on: https://go-review.googlesource.com/c/go/+/402156 Run-TryBot: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-15debug/pe: read string table in 10M chunksIan Lance Taylor
No separate test because this makes no difference for valid PE files. Fixes #52350 Change-Id: I2aa011a4e8b34cb08052222e94c52627ebe99fbf Reviewed-on: https://go-review.googlesource.com/c/go/+/400378 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-03-31debug/pe: skip TestReadCOFFSymbolAuxInfo on big-endian systemsThan McIntosh
Disable the new TestReadCOFFSymbolAuxInfo testpoint on big endian systems, pending resolution of issue 52079. The newly added interfaces for reading symbol definition aux info is not working properly when reading PE objects obj big-endian systems. Updates #52079. Change-Id: I8d55c7e4c03fc6444ef06a6a8154cb50596ca58a Reviewed-on: https://go-review.googlesource.com/c/go/+/397294 Trust: Than McIntosh <thanm@google.com> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-03-31debug/pe: add APIs for reading section def aux infoThan McIntosh
Add hooks to support reading of section definition symbol aux data (including COMDAT information) from the aux symbols associated with section definition symbols. The COFF symbol array made available by "pe.File" includes entries for aux symbols, but doesn't expose their structure (since it varies depending on the type of aux symbol). This patch adds a function for returning a specific class of aux symbol ("type 5") that immediately follows a COFF symbol corresponding to a section definition. Updates #35006. Updates #51868. Change-Id: I21fcc057150f7a3c64f01a5961aabca0fa43399e Reviewed-on: https://go-review.googlesource.com/c/go/+/394534 Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Trust: Alex Brainman <alex.brainman@gmail.com> Trust: Than McIntosh <thanm@google.com> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-13all: gofmt -w -r 'interface{} -> any' srcRuss Cox
And then revert the bootstrap cmd directories and certain testdata. And adjust tests as needed. Not reverting the changes in std that are bootstrapped, because some of those changes would appear in API docs, and we want to use any consistently. Instead, rewrite 'any' to 'interface{}' in cmd/dist for those directories when preparing the bootstrap copy. A few files changed as a result of running gofmt -w not because of interface{} -> any but because they hadn't been updated for the new //go:build lines. Fixes #49884. Change-Id: Ie8045cba995f65bd79c694ec77a1b3d1fe01bb09 Reviewed-on: https://go-review.googlesource.com/c/go/+/368254 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
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-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-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-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-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-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-04-19debug/pe: improve testpoint error messageThan McIntosh
A DWARF testpoint was calling t.Fatal() but should have been calling t.Fatalf(); switch it to the correct method. Change-Id: I996a1041adea4299cda85c147a35b513a219b970 Reviewed-on: https://go-review.googlesource.com/c/go/+/228790 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-03-10debug/pe: copy some consts from cmd/link/internal/ldAlex Brainman
This CL copies IMAGE_FILE_*, IMAGE_SUBSYSTEM_* and IMAGE_DLLCHARACTERISTICS_* consts from cmd/link/internal/ld package. The consts are also used in cmd/go and debug/pe tests. So avoid the duplication. The consts are defined in https://docs.microsoft.com/en-us/windows/win32/debug/pe-format and might be useful to other Go users. The CL also adds some related consts. RELNOTE=yes Change-Id: Iaa868deaffc7c61051f2273397f3e7e101880a5b Reviewed-on: https://go-review.googlesource.com/c/go/+/222637 Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-11-15all: fix a bunch of misspellingsVille Skyttä
Change-Id: I5b909df0fd048cd66c5a27fca1b06466d3bcaac7 GitHub-Last-Rev: 778c5d21311abee09a5fbda2e4005a5fd4cc3f9f GitHub-Pull-Request: golang/go#35624 Reviewed-on: https://go-review.googlesource.com/c/go/+/207421 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-09-08all: fix typosAinar Garipov
Use the following (suboptimal) script to obtain a list of possible typos: #!/usr/bin/env sh set -x git ls-files |\ grep -e '\.\(c\|cc\|go\)$' |\ xargs -n 1\ awk\ '/\/\// { gsub(/.*\/\//, ""); print; } /\/\*/, /\*\// { gsub(/.*\/\*/, ""); gsub(/\*\/.*/, ""); }' |\ hunspell -d en_US -l |\ grep '^[[:upper:]]\{0,1\}[[:lower:]]\{1,\}$' |\ grep -v -e '^.\{1,4\}$' -e '^.\{16,\}$' |\ sort -f |\ uniq -c |\ awk '$1 == 1 { print $2; }' Then, go through the results manually and fix the most obvious typos in the non-vendored code. Change-Id: I3cb5830a176850e1a0584b8a40b47bde7b260eae Reviewed-on: https://go-review.googlesource.com/c/go/+/193848 Reviewed-by: Robert Griesemer <gri@golang.org>
2019-08-29debug/pe: enable parsing of variable length optional header in PE filePrashant Agrawal
The debug/pe package assumes there are always 16 entries in DataDirectory in OptionalHeader32/64 ref pe.go: ... NumberOfRvaAndSizes uint32 DataDirectory [16]DataDirectory } ... But that is not always the case, there could be less no of entries (PE signed linux kernel for example): $ sudo pev /boot/vmlinuz-4.15.0-47-generic .... Data-dictionary entries: 6 .... In such case, the parsing gives incorrect results. This changes aims to fix that by: 1. Determining type of optional header by looking at header magic instead of size 2. Parsing optional header in 2 steps: a. Fixed part b. Variable data directories part Testing: 1. Fixed existing test cases to reflect the change 2. Added new file (modified linux kernel image) which has smaller number of data directories Fixes #32126 Change-Id: Iee56ecc4369a0e75a4be805e7cb8555c7d81ae2f Reviewed-on: https://go-review.googlesource.com/c/go/+/177959 Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2019-02-27debug/pe: prevent slice out of bounds access in (*File).ImportedSymbolsTobias Klauser
Fixes #30253 Change-Id: I0c3d67649ea379b67f3575c1219fe05a04f056ae Reviewed-on: https://go-review.googlesource.com/c/162859 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2019-02-27debug/pe: omit panic in (*File).ImportedSymbols on empty optional headersTobias Klauser
If a PE file with invalid optional header size (neither sizeofOptionalHeader32 nor sizeofOptionalHeader64) is passed to NewFile, the File.OptionalHeader will be nil which leads to a panic in (*File).ImportedSymbols(). Fixes #30250 Change-Id: Ie97306de4a0e2dcfdc7b1b599891f574aa63adca Reviewed-on: https://go-review.googlesource.com/c/162858 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2018-11-29debug/pe: use ws2_32.dll in TestImportTableInUnknownSectionAlex Brainman
Apparently (see https://github.com/golang/go/issues/27904#issuecomment-442140627 for details) kernel32.dll file is not present on windows/arm, so use ws2_32.dll instead. ws2_32.dll imports table also lives in '.rdata' section, so ws2_32.dll is as good as kernel32.dll for testing issue #16103. Updates #27904 Change-Id: Ibc72b24eea9a4d85abd371ffdcf00442e711b745 Reviewed-on: https://go-review.googlesource.com/c/151480 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2018-11-27debug/pe: correct TestImportTableInUnknownSection error messageAlex Brainman
TestImportTableInUnknownSection uses kernel32.dll file, but the error message mentions atmfd.dll. Adjust error message to match the test. This change should have been part of CL 151137. Updates #27904 Change-Id: Ifc31a12134b328472191122f8426ab6ed234fbd4 Reviewed-on: https://go-review.googlesource.com/c/151477 Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2018-11-24debug/pe: use kernel32.dll in TestImportTableInUnknownSectionAlex Brainman
TestImportTableInUnknownSection was introduced in CL 110555 to test PE executable with import table located in section other than ".idata". We used atmfd.dll for that purpose, but it seems atmfd.dll is not present on some systems. Use kernel32.dll instead. kernel32.dll import table is located in ".rdata" section, so it should do the job. And every Windows system has kernel32.dll file. Also make TestImportTableInUnknownSection run on windows-arm, since windows-arm should also have kernel32.dll file. Updates #27904 Change-Id: Ie005ee10e46ae0c06e83929d581e89f86c051eea Reviewed-on: https://go-review.googlesource.com/c/151137 Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-05debug/pe: fix TestDWARF to work with relocationsJordan Rhee
Fixes #27904 Change-Id: Ie2aad20cd66785b6cc1018c0048824382cb39f8c Reviewed-on: https://go-review.googlesource.com/c/140158 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-04debug/pe: skip a test on windows/armBrad Fitzpatrick
It requires a DLL that's not available on windows/arm apparently. Fixes #27904 Change-Id: I082a273f62976b7184636c6aeca6201a7871d238 Reviewed-on: https://go-review.googlesource.com/c/139720 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Katie Hockman <katie@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-08-20debug/pe: support windows/armJordan Rhee
Enable 'go tool objdump' to disassemble windows/arm images. Updates #26148 Change-Id: I7d11226f01d92288061f8e25980334b9bd82c41f Reviewed-on: https://go-review.googlesource.com/125649 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-19debug/elf,macho,pe: support compressed DWARFHeschi Kreinick
Since we're going to start compressing DWARF on Windows and maybe Darwin, copy the ELF support for .zdebug sections to macho and pe. The code is almost completely the same across the three. While I was here I added support for compressed .debug_type sections, which I presume were overlooked before. Tests will come in a later CL once we can actually generate compressed PE/Mach-O binaries, since there's no other good way to get test data. Updates #25927, #11799 Change-Id: Ie920b6a16e9270bc3df214ce601a263837810376 Reviewed-on: https://go-review.googlesource.com/119815 Run-TryBot: Heschi Kreinick <heschi@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Austin Clements <austin@google.com>
2018-06-07debug/pe: add IMAGE_FILE_MACHINE_ARM64Brad Fitzpatrick
Fixes #20849 Change-Id: If2a330185aa7e95eb84dccdbc4c7f3e9b970cca1 Reviewed-on: https://go-review.googlesource.com/117056 Reviewed-by: Matti Moell <matti.moell@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-23debug/pe: gofmtTobias Klauser
CL 110555 introduced some changes which were not properly gofmt'ed. Because the CL was sent via Github the gofmt checks usually performed by git-codereview didn't catch this (see #24946). Change-Id: I65c1271620690dbeec88b4ce482d158f7d6df45d Reviewed-on: https://go-review.googlesource.com/114255 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2018-05-19debug/pe: parse the import directory correctlyAli Rizvi-Santiago
This parses the import table properly which allows for debug/pe to extract import symbols from pecoffs linked with an import table in a section named something other than ".idata" The section names in a pecoff object aren't guaranteed to actually mean anything, so hardcoding a search for the ".idata" section is not guaranteed to find the import table in all shared libraries. This resulted in debug/pe being unable to read import symbols from some libraries. The proper way to locate the import table is to validate the number of data directory entries, locate the import entry, and then use the va to identify the section containing the import table. This patch does exactly this. Fixes #16103. Change-Id: I3ab6de7f896a0c56bb86c3863e504e8dd4c8faf3 GitHub-Last-Rev: ce8077cb154f18ada7a86e152ab03de813937816 GitHub-Pull-Request: golang/go#25193 Reviewed-on: https://go-review.googlesource.com/110555 Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2018-03-07debug/pe: use bytes.IndexByte instead of a loopTobias Klauser
Follow CL 98759 Change-Id: I58c8b769741b395e5bf4e723505b149d063d492a Reviewed-on: https://go-review.googlesource.com/99095 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-05-15cmd/link: actually generate .debug_gdb_scripts section on windowsAlex Brainman
Adjust finddebugruntimepath to look for runtime/debug.go file instead of runtime/runtime.go. This actually finds runtime.GOMAXPROCS in every Go executable (including windows). I also included "-Wl,-T,fix_debug_gdb_scripts.ld" parameter to gcc invocation on windows to work around gcc bug (see #20183 for details). This CL only fixes windows -buildmode=exe, buildmode=c-archive is still broken. Thanks to Egon Elbre and Nick Clifton for investigation. Fixes #20183 Fixes #20218 Change-Id: I5369a4db3913226aef3d9bd6317446856b0a1c34 Reviewed-on: https://go-review.googlesource.com/43331 Reviewed-by: Ian Lance Taylor <iant@golang.org>