]> Cypherpunks repositories - gostls13.git/commit
cmd/link/internal/ppc64: fix trampoline reuse distance calculation
authorPaul E. Murphy <murp@ibm.com>
Wed, 16 Nov 2022 20:53:39 +0000 (14:53 -0600)
committerPaul Murphy <murp@ibm.com>
Fri, 18 Nov 2022 14:31:23 +0000 (14:31 +0000)
commit1ed636dc97556e12fd9788d13de6de2f06aa3868
tree2f42c1c79668234c7ea5aba8fd5387fb75bfb467
parent349d398ea3d2f12b09791a1946e3d8d5baecd0c4
cmd/link/internal/ppc64: fix trampoline reuse distance calculation

If a compatible trampoline has been inserted by a previously laid
function in the same section, and is known to be sufficiently close,
it can be reused.

When testing if the trampoline can be reused, the addend of the direct
call should be ignored. It is already encoded in the trampoline. If the
addend is non-zero, and the target sufficiently far away, and just
beyond direct call reach, this may cause the trampoline to be
incorrectly reused.

This was observed on go1.17.13 and openshift-installer commit f3c53b382
building in release mode with the following error:

github.com/aliyun/alibaba-cloud-sdk-go/services/cms.(*Client).DescribeMonitoringAgentAccessKeyWithChan.func1: direct call too far: runtime.duffzero+1f0-tramp0-1 -2000078

Fixes #56775

Change-Id: I54af957302506d4e3cd5d3121542c83fe980e912
Reviewed-on: https://go-review.googlesource.com/c/go/+/451415
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Than McIntosh <thanm@google.com>
src/cmd/go/testdata/script/trampoline_reuse_test.txt [new file with mode: 0644]
src/cmd/link/internal/ppc64/asm.go