[go] cmd/link: support Mach-O UNSIGNED relocations for dynamic imports on darwin

0 views
Skip to first unread message

Gopher Robot (Gerrit)

unread,
Mar 4, 2026, 1:00:49 PM (yesterday) Mar 4
to George Adams, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Michael Pratt, Go LUCI, Cherry Mui, Michael Knyszek, Quim Muntal, golang-co...@googlegroups.com

Gopher Robot submitted the change

Change information

Commit message:
cmd/link: support Mach-O UNSIGNED relocations for dynamic imports on darwin

When internally linking darwin binaries, the linker rejected Mach-O
UNSIGNED (pointer) relocations targeting dynamic import symbols,
producing errors like:

unexpected reloc for dynamic symbol _swift_FORCE_LOAD_$_swiftIOKit

These relocations are legitimate and appear in data sections (e.g.
__DATA/__const) of object files that reference external symbols such as
Swift force-load symbols. The dynamic linker (dyld) needs to bind these
pointers at load time.
Cq-Include-Trybots: luci.golang.try:gotip-darwin-arm64_15,gotip-darwin-amd64_14
Change-Id: I1cc759dec28b8aa076602a45062f403d0d9f45fe
Reviewed-by: Cherry Mui <cher...@google.com>
Reviewed-by: Michael Pratt <mpr...@google.com>
Auto-Submit: Michael Pratt <mpr...@google.com>
Files:
  • M src/cmd/cgo/internal/test/cgo_darwin_test.go
  • A src/cmd/cgo/internal/test/unsigned_reloc_darwin.go
  • M src/cmd/link/internal/amd64/asm.go
  • M src/cmd/link/internal/arm64/asm.go
  • M src/cmd/link/internal/ld/lib.go
  • M src/cmd/link/internal/ld/macho.go
Change size: M
Delta: 6 files changed, 73 insertions(+), 18 deletions(-)
Branch: refs/heads/master
Submit Requirements:
  • requirement satisfiedCode-Review: +2 by Cherry Mui, +1 by Michael Pratt
  • 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: I1cc759dec28b8aa076602a45062f403d0d9f45fe
Gerrit-Change-Number: 745220
Gerrit-PatchSet: 7
Gerrit-Owner: George Adams <georgea...@gmail.com>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
Gerrit-Reviewer: Quim Muntal <quimm...@gmail.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages