Change information
Commit message:
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
Files:
- M src/cmd/link/internal/loadmacho/ldmacho.go
Change size: XS
Delta: 1 file changed, 3 insertions(+), 0 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Code-Review: +2 by Cherry Mui, +1 by Dmitri Shuralyov
TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI