]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/link: support 32b TLS_LE offsets on PPC64
authorPaul E. Murphy <murp@ibm.com>
Mon, 15 Mar 2021 20:21:57 +0000 (15:21 -0500)
committerLynn Boger <laboger@linux.vnet.ibm.com>
Tue, 13 Apr 2021 13:54:51 +0000 (13:54 +0000)
commit3e5bba0a44b880541fb72220a883e259d0f34a83
treee46197b7dc5f36222ceebcd73cc765f12bdff1a9
parentd948b8633d4ae3d4501d0a5382b24431a96c0cba
cmd/link: support 32b TLS_LE offsets on PPC64

When using the GCC thread sanitizer, it links in additional
code which uses TLS, which causes us to exceed the range of
the 16 bit TLS relocation used by statically compiled go
code.

Rewrite objabi.R_POWER_TLS_LE to handle 32b offsets when
linking internally or externally into an ELF binary. The
elf relocation translation is changed to generate a pair
of R_PPC64_TPREL16_HA/LO relocations instead of a single
R_PPC64_TPREL16.

Likewise, updating the above exposed some behavioral differences
in gnu ld which can rewrite TLS sequences. It expects the
sequence to generate a valid TLS address, not offset. This was
exposed when compiling PIC code. The proper fix is to generate
the full TLS address in the destination register of the
"MOVD tlsaddr, $Rx" pseudo-op. This removes the need to insert
special objabi.R_POWER_TLS relocations elsewhere.

Unfortunately, XCOFF (used by aix) doesn't appear to support 32
bit offsets, so we rewrite this back into a 16b relocation when
externally linking a static binary.

Fixes #45040

Change-Id: I1ee9afd0b427cd79888032aa1f60d3e265073e1d
Reviewed-on: https://go-review.googlesource.com/c/go/+/302209
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
src/cmd/internal/obj/ppc64/asm9.go
src/cmd/internal/objabi/reloctype.go
src/cmd/link/internal/ppc64/asm.go
src/runtime/race_ppc64le.s
src/runtime/tls_ppc64x.s