From 9fd5a5fa7d9d629ded8d4685dcc5984268258edb Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 30 Jan 2026 19:06:19 -0800 Subject: cmd/link: use correct alignment for type descriptors on AIX CL 724261 changed the linker to put all type descriptors that are used for typelinks in a single list. This caused trouble on AIX when linking externally, because the AIX linker aligns symbols individually, rather than honoring the layout of the object file generated by the internal linker. I fixed internal linking problems with CL 740220, but that just made things worse for the external linker. This CL rolls back 740220, and adds commentary. With this CL we force a smaller alignment for type descriptors, use the same alignment for runtime.types and type:*, and use a consistent size for runtime.types in all cases. With this change all the type descriptor related code passes again on AIX, except for the new TestTypePlacement test which I will fix in a followup CL. Fixes #77400 Change-Id: I9f25847eb0588001cb4ce453f211a655400d6a59 Reviewed-on: https://go-review.googlesource.com/c/go/+/740820 Reviewed-by: Michael Pratt Reviewed-by: Cherry Mui Auto-Submit: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI --- src/runtime/type.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/runtime') diff --git a/src/runtime/type.go b/src/runtime/type.go index 78018fd9a8..82ac5120bb 100644 --- a/src/runtime/type.go +++ b/src/runtime/type.go @@ -520,6 +520,11 @@ func moduleTypelinks(md *moduledata) []*_type { // We have to increment by 1 to match the increment done in // cmd/link/internal/data.go createRelroSect in allocateDataSections. + // + // We don't do that increment on AIX, but on AIX we need to adjust + // for the fact that the runtime.types symbol has a size of 8, + // and the type descriptors will follow that. This increment, + // followed by the forced alignment to 8, will do that. td++ etypedesc := md.types + md.typedesclen @@ -528,6 +533,9 @@ func moduleTypelinks(md *moduledata) []*_type { // 0x20 does not make sense. if GOARCH == "arm" { td = alignUp(td, 0x8) + } else if GOOS == "aix" { + // The alignment of 8 is forced in the linker on AIX. + td = alignUp(td, 0x8) } else { td = alignUp(td, 0x20) } -- cgit v1.3-5-g9baa