go/src/cmd/internal
Than McIntosh e7cd4979be cmd: initial compiler+linker support for DWARF5 .debug_addr
This patch rolls the main .debug_info DWARF section from version 4 to
version 5, and also introduces machinery in the Go compiler and linker
for taking advantage of the DWARF5 ".debug_addr" section for
subprogram DIE "high" and "low" PC attributes. All functionality is
gated by GOEXPERIMENT=dwarf5.

For the compiler portion of this patch, we add a new DIE attribute
form "DW_FORM_addrx", which accepts as an argument a function (text)
symbol.  The dwarf "putattr" function is enhanced to handle this
format by invoking a new dwarf context method "AddIndirectTextRef".
Under the hood, this method invokes the Lsym method WriteDwTxtAddrx,
which emits a new objabi.R_DWTXTADDR_* relocation. The size of the
relocation is dependent on the number of functions in the package; we
pick a size that is just big enough for the largest func index.

In the linker portion of this patch, we now switch over to writing out
a version number of 5 (instead of 4) in the compile unit header (this
is required if we want to use addrx attributes). In the parallel portion
of DWARF gen, within each compilation unit we scan subprogram DIEs to
look for R_DWTXTADDR_* relocations, and when we find such a reloc,
we assign a slot in the .debug_addr section for the func targeted.
After the parallel portion is complete, we then walk through all of the
compilation units to assign a value to their DW_AT_addr_base attribute,
which points to the portion of the single .debug_addr section containing
the text addrs for that compilation unit.

Note that once this patch is in, programs built with GOEXPERIMENT=dwarf5
will have broken/damaged DWARF info; in particular, since we've changed
only the CU and subprogram DIEs and haven't incorported the other
changes mandated by DWARF5 (ex: .debug_ranges => .debug_rnglists)
a lot of the variable location info will be missing/incorrect. This
will obviously change in subsequent patches.

Note also that R_DWTXTADDR_* can't be used effectively for lexical
scope DIE hi/lo PC attrs, since there isn't a viable way to encode
"addrx + constant" in the attribute value (you would need a new entry
for each attr endpoint in .debug_addr, which would defeat the point).

Updates #26379.

Change-Id: I2dfc45c9a8333e7b2a58f8e3b88fc8701fefd006
Reviewed-on: https://go-review.googlesource.com/c/go/+/635337
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-02-22 20:38:27 -08:00
..
archive cmd/internal/archive: skip sentinel archive entries created by Go cmd 2023-08-15 15:39:57 +00:00
bio cmd/internal/bio: remove unused MustWriter 2025-02-10 08:22:10 -08:00
bootstrap_test cmd: remove support for GOROOT_FINAL 2024-02-21 22:16:54 +00:00
browser
buildid cmd/internal/buildid: skip over GNU build ID from buildid computation 2024-10-21 17:56:51 +00:00
codesign cmd: do not use notsha256 2024-09-04 18:23:49 +00:00
cov all: remove coverageredesign experiment 2025-02-03 12:10:28 -08:00
disasm cmd/internal/disasm: correct instruction length handling for riscv64 2025-01-06 23:43:06 -08:00
dwarf cmd: initial compiler+linker support for DWARF5 .debug_addr 2025-02-22 20:38:27 -08:00
edit
gcprog
goobj runtime: rename mapiterinit and mapiternext 2025-01-28 10:54:43 -08:00
hash cmd: use cmd/internal/hash.New32 and Sum32 only 2025-02-13 12:34:30 -08:00
macho cmd/internal/macho: new package for handling mach-o files in toolchain 2024-10-21 17:56:21 +00:00
metadata internal/sysinfo: print cpu type from cpuinfo when internal cpu name is empty on Linux 2023-08-17 21:40:36 +00:00
moddeps cmd: remove support for GOROOT_FINAL 2024-02-21 22:16:54 +00:00
obj cmd: initial compiler+linker support for DWARF5 .debug_addr 2025-02-22 20:38:27 -08:00
objabi cmd/internal/objabi,cmd/link/internal/sym: add SDWARFADDR symbol type 2025-02-22 13:32:37 -08:00
objfile cmd/internal/objfile: break out dissassemblers to another package 2024-12-11 08:53:20 -08:00
osinfo cmd/internal/osinfo: stop importing golang.org/x/sys/unix 2024-10-30 18:19:19 +00:00
par cmd: relocate cmd/go/internal/par to cmd/internal/par 2024-07-29 15:37:29 +00:00
pathcache cmd: extract cmd/go's cfg.LookPath into separate pathcache package 2024-07-29 15:38:33 +00:00
pgo all: run gofmt 2025-02-03 09:55:31 -08:00
pkgpath cmd/internal/pkgpath: use MustHaveExec in TestToSymbolFunc 2022-09-27 18:26:59 +00:00
pkgpattern
quoted
robustio cmd: relocate cmd/go/internal/robustio to cmd/internal/robustio 2024-07-29 15:38:00 +00:00
script all: fix some function names and typos in comment 2024-11-21 22:16:20 +00:00
src all: remove unnecessary symbols and add missing symbols 2024-09-09 16:44:45 +00:00
sys cmd/internal/sys: allow unaligned loads on big-endian ppc64 2025-02-04 09:39:01 -08:00
telemetry cmd/internal: separate counter package from telemetry package 2024-06-21 19:58:04 +00:00
test2json cmd/go: print build errors during go test -json in JSON 2024-11-17 14:32:05 +00:00
testdir cmd/go: add rva23u64 as a valid value for GORISCV64 2025-02-05 03:44:40 -08:00