commit | 955cf0873f7a1c3d54cff34164f81d2b44127c30 | [log] [tgz] |
---|---|---|
author | Than McIntosh <thanm@golang.org> | Wed Mar 12 12:05:11 2025 -0400 |
committer | Than McIntosh <thanm@golang.org> | Wed Mar 12 10:15:52 2025 -0700 |
tree | dc437fc873e2803217638879488e8d0012d5b424 | |
parent | bec12f153a2ad1b0902857bc1dafc635fc5dc06a [diff] |
cmd/internal/dwarf: fix bug in inlined func DIE range DWARF 5 info This patch changes the strategy we use in the compiler for handling range information for inlined subroutine bodies, fixing a bug in how this was handled for DWARF 5. The high and lo PC values being emitted for DW_TAG_inlined_subroutine DIEs were incorrect, pointing to the start of functions instead of the proper location. The fix in this patch is to move to unconditionally using DW_AT_ranges for inlined subroutines, even those with only a single range. Background: prior to this point, if a given inlined function body had a single contiguous range, we'd pick an abbrev entry for it with explicit DW_AT_low_pc and DW_AT_high_pc attributes. If the extent of the code for the inlined body was not contiguous (which can happen), we'd select an abbrev that used a DW_AT_ranges attribute instead. This strategy (preferring explicit hi/lo PC attrs for a single-range func) made sense for DWARF 4, since in DWARF 4 the representation used in the .debug_ranges section was especially heavyweight (lots of space, lots of relocations), so having explicit hi/lo PC attrs was less expensive. With DWARF 5 range info is written to the .debug_rnglists section, and the representation here is much more compact. Specifically, a single hi/lo range can be represented using a base address in addrx format (max of 4 bytes, but more likely 2 or 3) followed by start and endpoints of the range in ULEB128 format. This combination is more compact spacewise than the explicit hi/lo values, and has fewer relocations (0 as opposed to 2). Note: we should at some point consider applying this same strategy to lexical scopes, since we can probably reap some of the same benefits there as well. Updates #26379. Fixes #72821. Change-Id: Ifb65ecc6221601bad2ca3939f9b69964c1fafc7c Reviewed-on: https://go-review.googlesource.com/c/go/+/657175 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com>
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
Gopher image by Renee French, licensed under Creative Commons 4.0 Attribution license.
Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.
Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.
Official binary distributions are available at https://go.dev/dl/.
After downloading a binary release, visit https://go.dev/doc/install for installation instructions.
If a binary distribution is not available for your combination of operating system and architecture, visit https://go.dev/doc/install/source for source installation instructions.
Go is the work of thousands of contributors. We appreciate your help!
To contribute, please read the contribution guidelines at https://go.dev/doc/contribute.
Note that the Go project uses the issue tracker for bug reports and proposals only. See https://go.dev/wiki/Questions for a list of places to ask questions about the Go language.