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
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:
Code-Review: +2 by Cherry Mui, +1 by Michael Pratt
TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI