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

1 view
Skip to first unread message

Gerrit Bot (Gerrit)

unread,
Mar 17, 2026, 10:09:56 AM (2 days ago) Mar 17
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Gerrit Bot has uploaded the change for review

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: 3582de63ead615b1ebd43506269db723da5ec332
GitHub-Pull-Request: golang/go#78194

Change diff

diff --git a/src/cmd/link/internal/loadmacho/ldmacho.go b/src/cmd/link/internal/loadmacho/ldmacho.go
index ecd0150..41d99b8 100644
--- a/src/cmd/link/internal/loadmacho/ldmacho.go
+++ b/src/cmd/link/internal/loadmacho/ldmacho.go
@@ -570,6 +570,9 @@
bld.SetData(dat[sect.addr-c.seg.vmaddr:][:sect.size])
}
bld.SetSize(int64(len(bld.Data())))
+ if sect.align != 0 {
+ bld.SetAlign(1 << sect.align)
+ }

if sect.segname == "__TEXT" {
if sect.name == "__text" {

Change information

Files:
  • M src/cmd/link/internal/loadmacho/ldmacho.go
Change size: XS
Delta: 1 file changed, 3 insertions(+), 0 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Icae22be2dc726d56eaa35825b484d04ed18566f2
Gerrit-Change-Number: 756000
Gerrit-PatchSet: 1
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Gopher Robot (Gerrit)

unread,
Mar 17, 2026, 10:09:58 AM (2 days ago) Mar 17
to Gerrit Bot, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Gopher Robot added 1 comment

Patchset-level comments
File-level comment, Patchset 1 (Latest):
Gopher Robot . unresolved

I spotted some possible problems with your PR:

  1. You have a long 340 character line in the commit message body. Please add line breaks to long lines that should be wrapped. Lines in the commit message body should be wrapped at ~76 characters unless needed for things like URLs or tables. (Note: GitHub might render long lines as soft-wrapped, so double-check in the Gerrit commit message shown above.)

Please address any problems by updating the GitHub PR.

When complete, mark this comment as 'Done' and click the [blue 'Reply' button](https://go.dev/wiki/GerritBot#i-left-a-reply-to-a-comment-in-gerrit-but-no-one-but-me-can-see-it) above. These findings are based on heuristics; if a finding does not apply, briefly reply here saying so.

To update the commit title or commit message body shown here in Gerrit, you must edit the GitHub PR title and PR description (the first comment) in the GitHub web interface using the 'Edit' button or 'Edit' menu entry there. Note: pushing a new commit to the PR will not automatically update the commit message used by Gerrit.

For more details, see:

(In general for Gerrit code reviews, the change author is expected to [log in to Gerrit](https://go-review.googlesource.com/login/) with a Gmail or other Google account and then close out each piece of feedback by marking it as 'Done' if implemented as suggested or otherwise reply to each review comment. See the [Review](https://go.dev/doc/contribute#review) section of the Contributing Guide for details.)

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Icae22be2dc726d56eaa35825b484d04ed18566f2
    Gerrit-Change-Number: 756000
    Gerrit-PatchSet: 1
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-Comment-Date: Tue, 17 Mar 2026 14:09:53 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Gopher Robot (Gerrit)

    unread,
    Mar 17, 2026, 10:12:51 AM (2 days ago) Mar 17
    to Gerrit Bot, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

    Message from Gopher Robot

    Congratulations on opening your first change. Thank you for your contribution!

    Next steps:
    A maintainer will review your change and provide feedback. See
    https://go.dev/doc/contribute#review for more info and tips to get your
    patch through code review.

    Most changes in the Go project go through a few rounds of revision. This can be
    surprising to people new to the project. The careful, iterative review process
    is our way of helping mentor contributors and ensuring that their contributions
    have a lasting impact.

    During May-July and Nov-Jan the Go project is in a code freeze, during which
    little code gets reviewed or merged. If a reviewer responds with a comment like
    R=go1.11 or adds a tag like "wait-release", it means that this CL will be
    reviewed as part of the next development cycle. See https://go.dev/s/release
    for more details.

    Open in Gerrit

    Related details

    Attention set is empty
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Icae22be2dc726d56eaa35825b484d04ed18566f2
    Gerrit-Change-Number: 756000
    Gerrit-PatchSet: 1
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-Comment-Date: Tue, 17 Mar 2026 14:12:46 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Gerrit Bot (Gerrit)

    unread,
    Mar 17, 2026, 10:33:37 AM (2 days ago) Mar 17
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
    Attention needed from Cherry Mui, Ian Lance Taylor and Russ Cox

    Gerrit Bot uploaded new patchset

    Gerrit Bot uploaded patch set #2 to this change.
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Cherry Mui
    • Ian Lance Taylor
    • Russ Cox
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: newpatchset
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Icae22be2dc726d56eaa35825b484d04ed18566f2
    Gerrit-Change-Number: 756000
    Gerrit-PatchSet: 2
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Cherry Mui <cher...@google.com>
    Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
    Gerrit-Reviewer: Russ Cox <r...@golang.org>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-Attention: Russ Cox <r...@golang.org>
    Gerrit-Attention: Cherry Mui <cher...@google.com>
    Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
    unsatisfied_requirement
    open
    diffy

    penglei (fixpoint) (Gerrit)

    unread,
    Mar 17, 2026, 10:44:49 AM (2 days ago) Mar 17
    to Gerrit Bot, goph...@pubsubhelper.golang.org, Cherry Mui, Ian Lance Taylor, Russ Cox, Gopher Robot, golang-co...@googlegroups.com
    Attention needed from Cherry Mui, Ian Lance Taylor and Russ Cox

    penglei (fixpoint) added 1 comment

    Patchset-level comments
    File-level comment, Patchset 1:
    Gopher Robot . resolved

    I spotted some possible problems with your PR:

      1. You have a long 340 character line in the commit message body. Please add line breaks to long lines that should be wrapped. Lines in the commit message body should be wrapped at ~76 characters unless needed for things like URLs or tables. (Note: GitHub might render long lines as soft-wrapped, so double-check in the Gerrit commit message shown above.)

    Please address any problems by updating the GitHub PR.

    When complete, mark this comment as 'Done' and click the [blue 'Reply' button](https://go.dev/wiki/GerritBot#i-left-a-reply-to-a-comment-in-gerrit-but-no-one-but-me-can-see-it) above. These findings are based on heuristics; if a finding does not apply, briefly reply here saying so.

    To update the commit title or commit message body shown here in Gerrit, you must edit the GitHub PR title and PR description (the first comment) in the GitHub web interface using the 'Edit' button or 'Edit' menu entry there. Note: pushing a new commit to the PR will not automatically update the commit message used by Gerrit.

    For more details, see:

    (In general for Gerrit code reviews, the change author is expected to [log in to Gerrit](https://go-review.googlesource.com/login/) with a Gmail or other Google account and then close out each piece of feedback by marking it as 'Done' if implemented as suggested or otherwise reply to each review comment. See the [Review](https://go.dev/doc/contribute#review) section of the Contributing Guide for details.)

    penglei (fixpoint)

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Cherry Mui
    • Ian Lance Taylor
    • Russ Cox
    Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement is not satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: Icae22be2dc726d56eaa35825b484d04ed18566f2
      Gerrit-Change-Number: 756000
      Gerrit-PatchSet: 2
      Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
      Gerrit-Reviewer: Cherry Mui <cher...@google.com>
      Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
      Gerrit-Reviewer: Russ Cox <r...@golang.org>
      Gerrit-CC: Gopher Robot <go...@golang.org>
      Gerrit-CC: penglei (fixpoint) <yby...@gmail.com>
      Gerrit-Attention: Russ Cox <r...@golang.org>
      Gerrit-Attention: Cherry Mui <cher...@google.com>
      Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
      Gerrit-Comment-Date: Tue, 17 Mar 2026 14:44:41 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Gopher Robot <go...@golang.org>
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Cherry Mui (Gerrit)

      unread,
      Mar 17, 2026, 10:50:49 AM (2 days ago) Mar 17
      to Gerrit Bot, goph...@pubsubhelper.golang.org, penglei (fixpoint), Ian Lance Taylor, Russ Cox, Gopher Robot, golang-co...@googlegroups.com
      Attention needed from Ian Lance Taylor and Russ Cox

      Cherry Mui voted

      Code-Review+2
      Commit-Queue+1
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Ian Lance Taylor
      • Russ Cox
      Submit Requirements:
      • requirement satisfiedCode-Review
      • requirement satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement is not satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: Icae22be2dc726d56eaa35825b484d04ed18566f2
      Gerrit-Change-Number: 756000
      Gerrit-PatchSet: 2
      Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
      Gerrit-Reviewer: Cherry Mui <cher...@google.com>
      Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
      Gerrit-Reviewer: Russ Cox <r...@golang.org>
      Gerrit-CC: Gopher Robot <go...@golang.org>
      Gerrit-CC: penglei (fixpoint) <yby...@gmail.com>
      Gerrit-Attention: Russ Cox <r...@golang.org>
      Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
      Gerrit-Comment-Date: Tue, 17 Mar 2026 14:50:46 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Cherry Mui (Gerrit)

      unread,
      Mar 18, 2026, 2:20:03 PM (yesterday) Mar 18
      to Gerrit Bot, goph...@pubsubhelper.golang.org, Go LUCI, penglei (fixpoint), Ian Lance Taylor, Russ Cox, Gopher Robot, golang-co...@googlegroups.com
      Attention needed from Russ Cox

      Cherry Mui voted Commit-Queue+1

      Commit-Queue+1
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Russ Cox
      Submit Requirements:
      • requirement satisfiedCode-Review
      • requirement satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement is not satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: Icae22be2dc726d56eaa35825b484d04ed18566f2
      Gerrit-Change-Number: 756000
      Gerrit-PatchSet: 2
      Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
      Gerrit-Reviewer: Cherry Mui <cher...@google.com>
      Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
      Gerrit-Reviewer: Russ Cox <r...@golang.org>
      Gerrit-CC: Gopher Robot <go...@golang.org>
      Gerrit-CC: penglei (fixpoint) <yby...@gmail.com>
      Gerrit-Attention: Russ Cox <r...@golang.org>
      Gerrit-Comment-Date: Wed, 18 Mar 2026 18:19:59 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Dmitri Shuralyov (Gerrit)

      unread,
      5:12 PM (2 hours ago) 5:12 PM
      to Gerrit Bot, goph...@pubsubhelper.golang.org, Dmitri Shuralyov, Go LUCI, Cherry Mui, penglei (fixpoint), Ian Lance Taylor, Russ Cox, Gopher Robot, golang-co...@googlegroups.com
      Attention needed from Cherry Mui and Russ Cox

      Dmitri Shuralyov voted Code-Review+1

      Code-Review+1
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Cherry Mui
      • Russ Cox
      Submit Requirements:
        • requirement satisfiedCode-Review
        • requirement satisfiedNo-Unresolved-Comments
        • requirement satisfiedReview-Enforcement
        • requirement satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: Icae22be2dc726d56eaa35825b484d04ed18566f2
        Gerrit-Change-Number: 756000
        Gerrit-PatchSet: 2
        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>
        Gerrit-Attention: Russ Cox <r...@golang.org>
        Gerrit-Attention: Cherry Mui <cher...@google.com>
        Gerrit-Comment-Date: Thu, 19 Mar 2026 21:12:16 +0000
        Gerrit-HasComments: No
        Gerrit-Has-Labels: Yes
        satisfied_requirement
        open
        diffy
        Reply all
        Reply to author
        Forward
        0 new messages