aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/obj/objfile.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2025-12-04 13:45:57 -0800
committerGopher Robot <gobot@golang.org>2026-02-10 19:40:05 -0800
commit67d449c0a608ab6c9891bb9b16cc14016bde8848 (patch)
tree5ef137528eb2726e1c6d40e5cf3aa18cc55db352 /src/cmd/internal/obj/objfile.go
parent4f8aa414f0ff4af04df1554113178ee57959c706 (diff)
downloadgo-67d449c0a608ab6c9891bb9b16cc14016bde8848.tar.xz
cmd/internal/obj: add Align field to LSym
This will permit the compiler and assembler to specify the alignment of symbols that they create. Careful placement of the new field, plus rearranging an existing field, means that LSym does not change size (as tested by TestSizeof). The new alignment field is int16, permitting alignment up to 16384, more than we ever need in practice. If necessary we could change the field to uint8 and store the alignment as a power of two, as is done in the linker. This replaces the Align field in FuncInfo. For #6853 For #36313 Change-Id: I421e8238ab57958fea8e4eab0649ce5288e7f92f Reviewed-on: https://go-review.googlesource.com/c/go/+/727020 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Keith Randall <khr@google.com>
Diffstat (limited to 'src/cmd/internal/obj/objfile.go')
-rw-r--r--src/cmd/internal/obj/objfile.go11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/cmd/internal/obj/objfile.go b/src/cmd/internal/obj/objfile.go
index 4401f1bb74..53691ccb6c 100644
--- a/src/cmd/internal/obj/objfile.go
+++ b/src/cmd/internal/obj/objfile.go
@@ -369,11 +369,8 @@ func (w *writer) Sym(s *LSym) {
if strings.HasPrefix(name, "gofile..") {
name = filepath.ToSlash(name)
}
- var align uint32
- if fn := s.Func(); fn != nil {
- align = uint32(fn.Align)
- }
- if s.ContentAddressable() && s.Size != 0 {
+ align := uint32(s.Align)
+ if s.ContentAddressable() && s.Size != 0 && align == 0 {
// We generally assume data symbols are naturally aligned
// (e.g. integer constants), except for strings and a few
// compiler-emitted funcdata. If we dedup a string symbol and
@@ -895,10 +892,10 @@ func (ctxt *Link) writeSymDebugNamed(s *LSym, name string) {
if s.Func() != nil && s.Func().FuncFlag&abi.FuncFlagAsm != 0 {
fmt.Fprintf(ctxt.Bso, "asm ")
}
- fmt.Fprintf(ctxt.Bso, "size=%d", s.Size)
+ fmt.Fprintf(ctxt.Bso, "size=%d align=%#x", s.Size, s.Align)
if s.Type.IsText() {
fn := s.Func()
- fmt.Fprintf(ctxt.Bso, " args=%#x locals=%#x funcid=%#x align=%#x", uint64(fn.Args), uint64(fn.Locals), uint64(fn.FuncID), uint64(fn.Align))
+ fmt.Fprintf(ctxt.Bso, " args=%#x locals=%#x funcid=%#x", uint64(fn.Args), uint64(fn.Locals), uint64(fn.FuncID))
if s.Leaf() {
fmt.Fprintf(ctxt.Bso, " leaf")
}