aboutsummaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorLynn Boger <laboger@linux.vnet.ibm.com>2021-05-12 12:11:03 -0500
committerLynn Boger <laboger@linux.vnet.ibm.com>2021-05-17 15:57:52 +0000
commitbade680867c9b1eecc7b5d177ed94c455a72e50a (patch)
tree6eb82846c02d914240098d208526464d2d8ae883 /misc
parentce92a2023ccd77ca609126aa8a6e881c9def57f0 (diff)
downloadgo-bade680867c9b1eecc7b5d177ed94c455a72e50a.tar.gz
go-bade680867c9b1eecc7b5d177ed94c455a72e50a.zip
runtime/cgo: fix crosscall2 on ppc64x
Some uses of crosscall2 did not work on ppc64le and probably aix-ppc64. In particular, if there was a main program compiled with -buildmode=pie and used a plugin which invoked crosscall2, then failures could occur due to R2 getting set incorrectly along the way. The problem was due to R2 being saved on the caller's stack; it is now saved on the crosscall2 stack. More details can be found in the issue. This adds a testcase where the main program is built with pie and the plugin invokes crosscall2. This also changes the save of the CR bits from MOVD to MOVW as it should be. Fixes #43228 Change-Id: Ib5673e25a2ec5ee46bf9a1ffb0cb1f3ef5449086 Reviewed-on: https://go-review.googlesource.com/c/go/+/319489 Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Trust: Heschi Kreinick <heschi@google.com>
Diffstat (limited to 'misc')
-rw-r--r--misc/cgo/testplugin/plugin_test.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/misc/cgo/testplugin/plugin_test.go b/misc/cgo/testplugin/plugin_test.go
index 28a8c669c0..a6accc1dfb 100644
--- a/misc/cgo/testplugin/plugin_test.go
+++ b/misc/cgo/testplugin/plugin_test.go
@@ -263,6 +263,13 @@ func TestIssue25756(t *testing.T) {
}
}
+// Test with main using -buildmode=pie with plugin for issue #43228
+func TestIssue25756pie(t *testing.T) {
+ goCmd(t, "build", "-buildmode=plugin", "-o", "life.so", "./issue25756/plugin")
+ goCmd(t, "build", "-buildmode=pie", "-o", "issue25756pie.exe", "./issue25756/main.go")
+ run(t, "./issue25756pie.exe")
+}
+
func TestMethod(t *testing.T) {
// Exported symbol's method must be live.
goCmd(t, "build", "-buildmode=plugin", "-o", "plugin.so", "./method/plugin.go")