]> Cypherpunks repositories - gostls13.git/commit
cmd/link: always use symbol-targeted relocations on Mach-O
authorCherry Mui <cherryyz@google.com>
Thu, 15 Jun 2023 21:25:08 +0000 (17:25 -0400)
committerCherry Mui <cherryyz@google.com>
Mon, 31 Jul 2023 17:02:24 +0000 (17:02 +0000)
commitbe910bf2fd6dee75bfb15aab567dc94b126bde29
tree1d36b70e31dd00806630f2febd97eabb2e912e83
parentbad9ca8a612f6fae85cfc25e07e69ed30384fc84
cmd/link: always use symbol-targeted relocations on Mach-O

In Mach-O object files, there are two kinds of relocations:
"external" relocation, which targets a symbol, and "non-external"
relocation, which targets a section. For targeting symbols not in
the current object, we must use symbol-targeted relocations. For
targeting symbols defined in the current object, for some
relocation types, both kinds can be used. We currently use
section-targeted relocations for R_ADDR targeting locally defined
symbols.

Modern Apple toolchain seems to prefer symbol-targeted relocations.
Also, Apple's new linker, ld-prime, seems to not handle section-
targeted relocations well in some cases. So this CL switches to
always generate symbol-targeted relocations. This also simplifies
the code.

One exception is that DWARF tools seem to handle only section-
targeted relocations. So generate those in DWARF sections.

This CL supersedes CL 502616.

Fixes #60694.
For #61229.

Change-Id: I3b74df64f21114635061bcd89114392b3a2d588b
Reviewed-on: https://go-review.googlesource.com/c/go/+/503935
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/cmd/link/internal/amd64/asm.go
src/cmd/link/internal/arm64/asm.go
src/cmd/link/internal/ld/data.go
src/cmd/link/internal/sym/symkind.go