diff options
| author | Cherry Mui <cherryyz@google.com> | 2023-06-15 17:25:08 -0400 |
|---|---|---|
| committer | Cherry Mui <cherryyz@google.com> | 2023-07-31 17:02:24 +0000 |
| commit | be910bf2fd6dee75bfb15aab567dc94b126bde29 (patch) | |
| tree | 1d36b70e31dd00806630f2febd97eabb2e912e83 /src/cmd/link/internal/sym | |
| parent | bad9ca8a612f6fae85cfc25e07e69ed30384fc84 (diff) | |
| download | go-be910bf2fd6dee75bfb15aab567dc94b126bde29.tar.xz | |
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>
Diffstat (limited to 'src/cmd/link/internal/sym')
| -rw-r--r-- | src/cmd/link/internal/sym/symkind.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/cmd/link/internal/sym/symkind.go b/src/cmd/link/internal/sym/symkind.go index 77dbf75a51..08cafb206b 100644 --- a/src/cmd/link/internal/sym/symkind.go +++ b/src/cmd/link/internal/sym/symkind.go @@ -184,3 +184,7 @@ var RelROMap = map[SymKind]SymKind{ func (t SymKind) IsData() bool { return t == SDATA || t == SNOPTRDATA || t == SBSS || t == SNOPTRBSS } + +func (t SymKind) IsDWARF() bool { + return t >= SDWARFSECT && t <= SDWARFLINES +} |
