]> git.feebdaed.xyz Git - 0xmirror/go.git/commit
cmd/link: build shstrtab from ELF sections
authorIan Lance Taylor <iant@golang.org>
Fri, 7 Nov 2025 20:25:03 +0000 (12:25 -0800)
committerIan Lance Taylor <iant@golang.org>
Thu, 27 Nov 2025 04:03:00 +0000 (20:03 -0800)
commit4bc3410b6cf4f4e4535c6620e2643e0aa36ed99f
tree4ba95e2c4c8a7fd3ca13de88a6d1df02e150a847
parentb0c278be4072b2aec941e4600852f7a5ff40fe22
cmd/link: build shstrtab from ELF sections

Since before Go 1 the Go linker has handled ELF by first building the
ELF section string table, and then pointing ELF section headers to it.
This duplicates code as sections are effectively created twice,
once with the name and then again with the full section header.
The code duplication also means that it's easy to create unnecessary
section names; for example, every internally linked Go program
currently contains the string ".go.fuzzcntrs" although most do not
have a section by that name.

This CL changes the linker to simply build the section string table
after all the sections are known.

Change-Id: I27ba15b2af3dc1b8d7436b6c409f818aa8e6bfb4
Reviewed-on: https://go-review.googlesource.com/c/go/+/718840
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/cmd/link/internal/ld/dwarf.go
src/cmd/link/internal/ld/elf.go