aboutsummaryrefslogtreecommitdiff
path: root/src/debug/elf
AgeCommit message (Collapse)Author
5 daysdebug/elf: use saferio.SliceCap for segment sliceIan Lance Taylor
This avoids using a lot of memory for an invalid segment count. No test case because the problem can only happen for invalid ata. Let the fuzzer find cases like this. For #47653 Fixes #78611 Change-Id: I649f5446496bfa46668e7a3e5c84c82131e1d136 Reviewed-on: https://go-review.googlesource.com/c/go/+/765061 Reviewed-by: David Chase <drchase@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Junyang Shao <shaojunyang@google.com>
2026-03-25debug/elf: handle program header count overflowIan Lance Taylor
ELF files only have a 16-bit count for program headers. To handle the very rare case of larger files, a large program header count is stored as 0xffff and the first section header info field holds the actual count. Fixes #78217 Change-Id: I35c7e15025a9677473cb43d09a41f17f75443731 Reviewed-on: https://go-review.googlesource.com/c/go/+/758040 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2026-01-22debug/elf: return FormatError when reading short filesMark F
NewFile returns the raw error from ReadAt when failing to read the ELF identifier, typically io.EOF for empty or short files. This breaks the API contract that all parsing failures should return *FormatError. Wrap the error in FormatError for consistency with other error paths. Fixes #76338 Change-Id: Ic4ed77316fcc459ce8cbe9e9506d7cf8e9286623 Reviewed-on: https://go-review.googlesource.com/c/go/+/736600 Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@golang.org>
2025-12-01debug/elf: correct case of DWARF in commentIan Lance Taylor
Change-Id: I5b80b0e3e50fafdb732c732cdae6e2756d919d20 Reviewed-on: https://go-review.googlesource.com/c/go/+/725360 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Mark Freeman <markfreeman@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Sean Liao <sean@liao.dev> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-12-01debug/elf: make check for empty symbol section consistent for 64-bit and ↵Aditya Sirish A Yelgundhalli
32-bit binaries The check for whether a binary's symbols section is empty is inconsistent across the 32-bit and 64-bit flows. Change-Id: I1abc235320a53cf957cfb83c9e7bcad6e52bc529 GitHub-Last-Rev: f264915ca2964ad8f34ce1deee4f42c2f9dc21bf GitHub-Pull-Request: golang/go#75334 Reviewed-on: https://go-review.googlesource.com/c/go/+/702195 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Keith Randall <khr@google.com>
2025-11-17debug/elf: sync new loong64 relocation types up to LoongArch ELF psABI v20250521WANG Xuerui
Add several new relocation types defined in newer versions of LoongArch ELF psABI v20250521, part of the v2.40 spec bundle. The new relocations are seeing increased adoption because distributions are moving to newer GNU/LLVM toolchain versions, so Go's internal linker must be prepared to handle some of them, especially R_LARCH_CALL36 because the ecosystem is slowly migrating to the "medium" code model by default. The constants R_LARCH_DELETE and R_LARCH_CFA were removed in LoongArch ELF psABI v20231102 (spec bundle v2.20), but they are already part of the public API, so they are retained for now for upholding the go1 compatibility guarantee. Corresponding binutils implementation: * R_LARCH_CALL36: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=dc5f359ed6a36d2c895d89c3e4886f3a2b6d9232 * TLSDESC: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=26265e7fdf19d461563388495b6799eb3719f80a * TLS {LD,GD,DESC} relaxation: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=ae296cc45258b95223210263d1b91115e84beb56 * TLS LE relaxation: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=775dead218e12e3fb94481c7a99aa0238d6a9138 Updates #75562 See: https://github.com/loongson/la-abi-specs/blob/v2.40/laelf.adoc See: https://github.com/loongson-community/discussions/issues/43 Change-Id: Ib023e0b6becc0862d27afc419d3eb84c737359db Reviewed-on: https://go-review.googlesource.com/c/go/+/709716 Reviewed-by: Mark Freeman <markfreeman@google.com> Reviewed-by: Meidan Li <limeidan@loongson.cn> Reviewed-by: abner chenc <chenguoqi@loongson.cn> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Junyang Shao <shaojunyang@google.com> Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
2025-10-17all: remove unnecessary loop variable copies in testsTobias Klauser
Copying the loop variable is no longer necessary since Go 1.22. Change-Id: Iebb21dac44a20ec200567f1d786f105a4ee4999d Reviewed-on: https://go-review.googlesource.com/c/go/+/711640 Reviewed-by: Florian Lehner <lehner.florian86@gmail.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-09-28debug/elf: prevent offset overflowJes Cok
When applying relocations, a malformed ELF file can provide an offset that, when added to the relocation size, overflows. This wrapped-around value could then incorrectly pass the bounds check, leading to a panic when the slice is accessed with the original large offset. This change eliminates the manual bounds and overflow checks and writes a relocation to slice by calling putUint. The putUint helper function centralizes the logic for validating slice access, correctly handling both out-of-bounds and integer overflow conditions. This simplifies the relocation code and improves robustness when parsing malformed ELF files. Fixes #75516 Change-Id: I00d806bf5501a9bf70200585ba4fd0475d7b2ddc GitHub-Last-Rev: 49144311d31fecc63cb81b6c31bf9a206acb0596 GitHub-Pull-Request: golang/go#75522 Reviewed-on: https://go-review.googlesource.com/c/go/+/705075 Reviewed-by: Florian Lehner <lehner.florian86@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Junyang Shao <shaojunyang@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Commit-Queue: Ian Lance Taylor <iant@golang.org>
2025-08-27debug/elf: don't panic if symtab too smallIan Lance Taylor
No test case because the problem can only happen for invalid data. Let the fuzzer find cases like this. For #47653 Fixes #75130 Change-Id: Ie6015564bb98334377383bbc16d79119dc4e36f9 Reviewed-on: https://go-review.googlesource.com/c/go/+/698855 Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Carlos Amedee <carlos@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Florian Lehner <lehner.florian86@gmail.com>
2025-03-14debug/elf: add riscv attributes definitionsMeng Zhuo
This CL adds `riscv.attributes` related ELF section header type and program header type according to [RISC-V ELF Specification](https://github.com/riscv-non-isa/riscv-elf-psabi-doc/releases/download/v1.0/riscv-abi.pdf) Also an riscv64/linux testcase binary built from: ``` gcc -march=rv64g -no-pie -o gcc-riscv64-linux-exec hello.c strip gcc-riscv64-linux-exec ``` Fixes #72843 Change-Id: I7710a0516f69141c0efaba71dd997f05b4c88421 Reviewed-on: https://go-review.googlesource.com/c/go/+/657515 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-12-17debug/elf: adjust version API per issue discussionIan Lance Taylor
This updates the new version API for the discussion on #63952. Note that the current tests do not have symbols with hidden versions. Leaving that for later. For #63952 Change-Id: I1ad4b1e485429a216ba8e5b68f7f4299d120628f Reviewed-on: https://go-review.googlesource.com/c/go/+/637235 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Austin Clements <austin@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Commit-Queue: Ian Lance Taylor <iant@google.com>
2024-12-11debug/elf: adjust version API per issue discussionIan Lance Taylor
This updates the new version API for the discussion on #63952. This change reveals that in fact none of the tests set the VERSYM_HIDDEN bit. The code before this CL set the hidden flag for symbols that appear in DynamicVersionNeed, but that is not an accurate representation of the ELF. The readelf program does print undefined symbols that way (with a single '@'), but that doesn't mean that the hidden flag is set. Leaving tests with the hidden bit set for later. For #63952 Change-Id: Ida60831e0c9922dfc10f10c7a64bc76a2b197537 Reviewed-on: https://go-review.googlesource.com/c/go/+/635079 Reviewed-by: Austin Clements <austin@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com> 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>
2024-11-27debug/elf: check for multiplication overflow for shnum * shentsizeIan Lance Taylor
No test case because the problem can only happen for invalid data. Let the fuzzer find cases like this. For #47653 Fixes #70584 Change-Id: I8a69a27dcb5b258b88f8e01ebaf0ec20cfcd489b Reviewed-on: https://go-review.googlesource.com/c/go/+/632035 Reviewed-by: Veronica Silina <veronicasilina@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-11-07debug/elf: add SHT_GNU_VERDEF section parsingbenbaker76
Fixes #63952 Change-Id: Icf93e57e62243d9c3306d4e1c5dadb3f62747710 GitHub-Last-Rev: 5c2952760063474f3aac338fe5bdb65bde238ab6 GitHub-Pull-Request: golang/go#69850 Reviewed-on: https://go-review.googlesource.com/c/go/+/619077 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-23debug/elf: remove incorrect doc linkIan Lance Taylor
Here Version is a field in Symbol, not the elf.Version type. Change-Id: I0285937d806d1a9b53b49420b45a07744be244c2 Reviewed-on: https://go-review.googlesource.com/c/go/+/563095 Reviewed-by: Ian Lance Taylor <iant@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Austin Clements <austin@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-04-16debug/elf: define non-standard but well-known symbol typesIan Lance Taylor
Fixes #66836 Change-Id: I603faca2acd2bcffabbcaca8b8670d46387d2a5b Reviewed-on: https://go-review.googlesource.com/c/go/+/578995 Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-03-15debug/elf: avoid using binary.Read() in NewFile()Peter Collingbourne
With this change my test program that reads a tree of ELF files runs 1.71 ± 0.12 times faster without parallelism or 1.39 ± 0.06 times faster using 8 goroutines. Change-Id: I443d1a02736f16f5532ef28e1447c97aa87c7126 Reviewed-on: https://go-review.googlesource.com/c/go/+/571436 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>
2024-03-10cmd/link,debug/elf: mark Go binaries with no branch target CFI on openbsdJoel Sing
OpenBSD enables Indirect Branch Tracking (IBT) on amd64 and Branch Target Identification (BTI) on arm64, where hardware permits. Since Go generated binaries do not currently support IBT or BTI, temporarily mark them with PT_OPENBSD_NOBTCFI which prevents branch target CFI from being enforced on execution. This should be removed as soon asn IBT and BTI support are available. Fixes #66040 Updates #66054 Change-Id: I91ac05736e6942c54502bef4b8815eb8740d2d5e Reviewed-on: https://go-review.googlesource.com/c/go/+/568435 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Josh Rickmar <jrick@zettaport.com> Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Joel Sing <joel@sing.id.au> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2023-12-30all: replace outdated linkscui fliter
Change-Id: I7156e7858e8f06459818e03729c644d64e04d43c Reviewed-on: https://go-review.googlesource.com/c/go/+/549356 Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: shuang cui <imcusg@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-30debug/elf: return error in DynValue for invalid dynamic section sizeJes Cok
This is a follow-up to CL 536400. Fixes #64446 Change-Id: I35646732f62cb1937fd448f94ea518544d4295d4 GitHub-Last-Rev: 55db18a909fd44e6b2f2b98fd1a44ad01bb37932 GitHub-Pull-Request: golang/go#64448 Reviewed-on: https://go-review.googlesource.com/c/go/+/545835 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Run-TryBot: Jes Cok <xigua67damn@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-11-02debug/elf,cmd/link: add additional relocations for loong64Guoqi Chen
The Linker Relaxation feature on Loong64 is already supported in binutils 2.41. The intermediate code generated after enabling this feature introduces three reloc types R_LARCH_B26, R_LARCH_ADD32 and R_LARCH_SUB32. The other relocation types are not currently used when running all.bash, but in order to avoid the host tool chain making the decision to use it we don't have to catch it every time. The LoongArch ABI at here: https://github.com/loongson/la-abi-specs/blob/release/la-abi.adoc Corresponding binutils implementation: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=be1ebb6710a8f707bd4b0eecbd00f4f4964050e5 https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=1b6fccd28db14fffe75ff6755307047ef932c81e Fixes #63725 Change-Id: I891115cfdbcf785ab494c881d5f9d1bf8748da8b Reviewed-on: https://go-review.googlesource.com/c/go/+/537615 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Meidan Li <limeidan@loongson.cn> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-10-25debug/elf: return error in DynString for invalid dynamic section sizeIan Lance Taylor
No test case because the problem can only happen for invalid data. Let the fuzzer find cases like this. Fixes #63610 Change-Id: I797b4d9bdb08286ad3e3a9a6f800ee8c90cb7261 Reviewed-on: https://go-review.googlesource.com/c/go/+/536400 Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
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-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/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-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-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-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-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>
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-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-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-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-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-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>
2022-08-11debug/elf: use saferio to read section dataIan Lance Taylor
For #47653 Fixes #45599 Fixes #52522 Change-Id: Id6a80186434080cb0a205978ad7f224252674604 Reviewed-on: https://go-review.googlesource.com/c/go/+/408679 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-08-11debug/elf: add new-style LoongArch reloc typesWANG Xuerui
LoongArch ELF psABI spec update: https://github.com/loongson/LoongArch-Documentation/pull/57 Corresponding binutils implementation: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=6d13722a97cee3fd397e116bde3bcedbb1e220be https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=9801120721c3a702ce3bd50433ef920f92a83502 For #54222 Change-Id: I51e72294205847a69c01d741a3126248f7a7e41c Reviewed-on: https://go-review.googlesource.com/c/go/+/420982 Reviewed-by: Meng Zhuo <mzh@golangcn.org> Run-TryBot: Meng Zhuo <mzh@golangcn.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> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: abner chenc <chenguoqi@loongson.cn>