[go] cmd/link: propagate Mach-O section alignment to symbol in loadmacho

0 views
Skip to first unread message

Cherry Mui (Gerrit)

unread,
Mar 19, 2026, 8:46:49 PM (23 hours ago) Mar 19
to Gerrit Bot, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Dmitri Shuralyov, Dmitri Shuralyov, Go LUCI, penglei (fixpoint), Ian Lance Taylor, Russ Cox, Gopher Robot, golang-co...@googlegroups.com

Cherry Mui submitted the change

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
Reviewed-by: Cherry Mui <cher...@google.com>
Reviewed-by: Dmitri Shuralyov <dmit...@google.com>
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:
  • requirement satisfiedCode-Review: +2 by Cherry Mui, +1 by Dmitri Shuralyov
  • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Icae22be2dc726d56eaa35825b484d04ed18566f2
Gerrit-Change-Number: 756000
Gerrit-PatchSet: 3
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-Reviewer: Dmitri Shuralyov <dmit...@google.com>
Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
Gerrit-Reviewer: Russ Cox <r...@golang.org>
Gerrit-CC: Dmitri Shuralyov <dmit...@golang.org>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-CC: penglei (fixpoint) <yby...@gmail.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages