aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/staticdata/data.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2025-12-07 21:55:24 -0800
committerGopher Robot <gobot@golang.org>2026-02-12 09:27:34 -0800
commit174c92bd7428b41b9b5b59274a83f387a12261c9 (patch)
tree8af1f38f18ecccb8e2b67e3f812866d383a9177c /src/cmd/compile/internal/staticdata/data.go
parentfbe55325ddce51a7fc099e1efb0d326e7a2e1ed8 (diff)
downloadgo-174c92bd7428b41b9b5b59274a83f387a12261c9.tar.xz
cmd/compile: set alignment for all content-addressable symbols
There is nothing particularly special about content-addressable symbols, it's just a place to start. This reduces the size of the tailscaled binary by about 16K. This happens mainly because before this CL the linker's symalign function kicks in for all static composite literals and PCDATA symbols, and gives them an alignment based on their size. If the size happens to be a multiple of 32, it gets an alignment of 32. That wastes space. For #6853 For #36313 Change-Id: I2f049eee8f2463dd2b5e20d7c9a270ac32a31e50 Reviewed-on: https://go-review.googlesource.com/c/go/+/727920 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/cmd/compile/internal/staticdata/data.go')
-rw-r--r--src/cmd/compile/internal/staticdata/data.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/staticdata/data.go b/src/cmd/compile/internal/staticdata/data.go
index acafe9d339..51d576e7f2 100644
--- a/src/cmd/compile/internal/staticdata/data.go
+++ b/src/cmd/compile/internal/staticdata/data.go
@@ -92,6 +92,7 @@ func StringSym(pos src.XPos, s string) (data *obj.LSym) {
off := dstringdata(symdata, 0, s, pos, "string")
objw.Global(symdata, int32(off), obj.DUPOK|obj.RODATA|obj.LOCAL)
symdata.Set(obj.AttrContentAddressable, true)
+ symdata.Align = 1
}
return symdata
@@ -185,6 +186,7 @@ func fileStringSym(pos src.XPos, file string, readonly bool, hashBytes []byte) (
info.Name = file
info.Size = size
objw.Global(symdata, int32(size), obj.DUPOK|obj.RODATA|obj.LOCAL)
+ symdata.Align = 1
// Note: AttrContentAddressable cannot be set here,
// because the content-addressable-handling code
// does not know about file symbols.
@@ -211,6 +213,7 @@ func slicedata(pos src.XPos, s string) *obj.LSym {
lsym := types.LocalPkg.Lookup(symname).LinksymABI(obj.ABI0)
off := dstringdata(lsym, 0, s, pos, "slice")
objw.Global(lsym, int32(off), obj.NOPTR|obj.LOCAL)
+ lsym.Align = 1
return lsym
}