cmd/link: propagate Mach-O section alignment to symbol in loadmacho
The Mach-O object file loader reads the section alignment from the section header into ldMachoSect.align, but never calls SetAlign on the symbol builder when converting sections to linker symbols. This causes all Mach-O .syso sections to fall back to Funcalign (16 bytes on ARM64) regardless of the alignment declared in the section header. For .syso files containing C-compiled code with ADRP instructions on ARM64, the lack of page alignment (4096 bytes) leads to incorrect PC-relative address computation and runtime crashes. The ELF loader already correctly propagates section alignment via sb.SetAlign (ldelf.go:543). Apply the same treatment to the Mach-O loader. Note that Mach-O stores alignment as log2 (e.g. 12 for 4096), so we use 1 << sect.align. Fixes #78192 Change-Id: Icae22be2dc726d56eaa35825b484d04ed18566f2 GitHub-Last-Rev: 85aa42b59a663335b3ce72f7b60ffa240aadeff8 GitHub-Pull-Request: golang/go#78194 Reviewed-on: https://go-review.googlesource.com/c/go/+/756000 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
P
penglei committed
fdd38337f0802ada78e70c4f3db1f440ba08ba2f
Parent: 0520d3f
Committed by Cherry Mui <cherryyz@google.com>
on 3/20/2026, 12:46:44 AM