]> Cypherpunks repositories - gostls13.git/commit
cmd/link: implement trampolines for ppc64le with ext linking
authorLynn Boger <laboger@linux.vnet.ibm.com>
Thu, 8 Jun 2017 12:26:19 +0000 (08:26 -0400)
committerLynn Boger <laboger@linux.vnet.ibm.com>
Wed, 14 Jun 2017 14:12:11 +0000 (14:12 +0000)
commit738739f56543a768be1eeb9a9e33f3252f4c6da1
treea7e11c5207ba520ad9632ed76c167bd44e4d26a0
parentdf0892cbf854e76fae6e875043b05c194e37f52d
cmd/link: implement trampolines for ppc64le with ext linking

When using golang on ppc64le there have been issues
when building executables that generate extremely large text
sections.  This is due to the call instruction and the limitation
on the offset field, which is smaller than most platforms.  If the
size of the call target offset is too big for the offset field in
the call instruction, then link errors can occur.

The original solution to this problem in golang was to split the
text section when it became too large, allowing the external (GNU)
linker to insert the necessary stub to handle the long call.  That
worked fine until the another size limit for the program size was hit,
where a plt_branch was created instead of a long branch.  In that case
the plt_branch code sequence expects r2 to contain the address of the
TOC, but when golang creates dynamic executables by default
(-buildmode=exe) r2 does not always contain the address of the TOC
and as a result when building programs that reach this extremely
large size, a runtime SEGV or SIGILL can occur due to branching to a bad
address.

When using internal linking, trampolines are generated to handle the
long calls but the text sections are not split.  With this change,
text sections will still be split approrpriately with external linking
but if the buildmode being used does not maintain r2 as the TOC
addresses, then trampolines will be created for those calls.

Fixes #20497

Change-Id: If5400b0f86c2c08e106b332be6db0b259b07d93d
Reviewed-on: https://go-review.googlesource.com/45130
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/link/internal/ld/data.go
src/cmd/link/internal/ppc64/asm.go