aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Chigot <clement.chigot@atos.net>2019-03-25 10:34:57 +0100
committerIan Lance Taylor <iant@golang.org>2019-04-02 16:03:24 +0000
commit3aacfce6cf7e5f0346906e5236433852f4075368 (patch)
treeb10b2a53bdadfeaf2afc60e2a1e5c018112a319b
parent56517216c052649daab6c439f386f9dc02e90c3a (diff)
downloadgo-3aacfce6cf7e5f0346906e5236433852f4075368.tar.xz
runtime, cmd/dist, misc/cgo: enable c-archive for aix/ppc64
Change-Id: Ib9a40d5596f5735a00483e2d2db965402f05671b Reviewed-on: https://go-review.googlesource.com/c/go/+/169120 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
-rw-r--r--misc/cgo/testcarchive/carchive_test.go23
-rw-r--r--misc/cgo/testcarchive/testdata/main4.c15
-rw-r--r--misc/cgo/testcarchive/testdata/main5.c4
-rw-r--r--src/cmd/dist/test.go3
-rw-r--r--src/runtime/os3_solaris.go1
-rw-r--r--src/runtime/os_aix.go8
-rw-r--r--src/runtime/os_dragonfly.go1
-rw-r--r--src/runtime/os_freebsd.go1
-rw-r--r--src/runtime/os_linux.go1
-rw-r--r--src/runtime/os_netbsd.go1
-rw-r--r--src/runtime/os_openbsd.go1
-rw-r--r--src/runtime/signal_darwin_386.go1
-rw-r--r--src/runtime/signal_darwin_amd64.go1
-rw-r--r--src/runtime/signal_darwin_arm.go1
-rw-r--r--src/runtime/signal_darwin_arm64.go1
-rw-r--r--src/runtime/signal_unix.go1
16 files changed, 50 insertions, 14 deletions
diff --git a/misc/cgo/testcarchive/carchive_test.go b/misc/cgo/testcarchive/carchive_test.go
index 611a770245..b7f04356a9 100644
--- a/misc/cgo/testcarchive/carchive_test.go
+++ b/misc/cgo/testcarchive/carchive_test.go
@@ -110,6 +110,11 @@ func testMain(m *testing.M) int {
// TODO(crawshaw): can we do better?
cc = append(cc, []string{"-framework", "CoreFoundation", "-framework", "Foundation"}...)
}
+ if GOOS == "aix" {
+ // -Wl,-bnoobjreorder is mandatory to keep the same layout
+ // in .text section.
+ cc = append(cc, "-Wl,-bnoobjreorder")
+ }
libbase := GOOS + "_" + GOARCH
if runtime.Compiler == "gccgo" {
libbase = "gccgo_" + libgodir + "_fPIC"
@@ -318,7 +323,7 @@ func TestSignalForwarding(t *testing.T) {
}
func TestSignalForwardingExternal(t *testing.T) {
- if GOOS == "freebsd" {
+ if GOOS == "freebsd" || GOOS == "aix" {
t.Skipf("skipping on %s/%s; signal always goes to the Go runtime", GOOS, GOARCH)
}
checkSignalForwardingTest(t)
@@ -594,13 +599,15 @@ func TestPIE(t *testing.T) {
t.Fatal(err)
}
- f, err := elf.Open("testp" + exeSuffix)
- if err != nil {
- t.Fatal("elf.Open failed: ", err)
- }
- defer f.Close()
- if hasDynTag(t, f, elf.DT_TEXTREL) {
- t.Errorf("%s has DT_TEXTREL flag", "testp"+exeSuffix)
+ if GOOS != "aix" {
+ f, err := elf.Open("testp" + exeSuffix)
+ if err != nil {
+ t.Fatal("elf.Open failed: ", err)
+ }
+ defer f.Close()
+ if hasDynTag(t, f, elf.DT_TEXTREL) {
+ t.Errorf("%s has DT_TEXTREL flag", "testp"+exeSuffix)
+ }
}
}
diff --git a/misc/cgo/testcarchive/testdata/main4.c b/misc/cgo/testcarchive/testdata/main4.c
index a74763dd70..04f774008f 100644
--- a/misc/cgo/testcarchive/testdata/main4.c
+++ b/misc/cgo/testcarchive/testdata/main4.c
@@ -14,6 +14,13 @@
#include "libgo4.h"
+#ifdef _AIX
+// On AIX, CSIGSTKSZ is too small to handle Go sighandler.
+#define CSIGSTKSZ 0x4000
+#else
+#define CSIGSTKSZ SIGSTKSZ
+#endif
+
static void die(const char* msg) {
perror(msg);
exit(EXIT_FAILURE);
@@ -53,12 +60,12 @@ static void* thread1(void* arg __attribute__ ((unused))) {
// Set up an alternate signal stack for this thread.
memset(&ss, 0, sizeof ss);
- ss.ss_sp = malloc(SIGSTKSZ);
+ ss.ss_sp = malloc(CSIGSTKSZ);
if (ss.ss_sp == NULL) {
die("malloc");
}
ss.ss_flags = 0;
- ss.ss_size = SIGSTKSZ;
+ ss.ss_size = CSIGSTKSZ;
if (sigaltstack(&ss, NULL) < 0) {
die("sigaltstack");
}
@@ -112,12 +119,12 @@ static void* thread2(void* arg __attribute__ ((unused))) {
// Set up an alternate signal stack for this thread.
memset(&ss, 0, sizeof ss);
- ss.ss_sp = malloc(SIGSTKSZ);
+ ss.ss_sp = malloc(CSIGSTKSZ);
if (ss.ss_sp == NULL) {
die("malloc");
}
ss.ss_flags = 0;
- ss.ss_size = SIGSTKSZ;
+ ss.ss_size = CSIGSTKSZ;
if (sigaltstack(&ss, NULL) < 0) {
die("sigaltstack");
}
diff --git a/misc/cgo/testcarchive/testdata/main5.c b/misc/cgo/testcarchive/testdata/main5.c
index 9d0da33652..d431ce01ce 100644
--- a/misc/cgo/testcarchive/testdata/main5.c
+++ b/misc/cgo/testcarchive/testdata/main5.c
@@ -14,6 +14,8 @@
#include "libgo2.h"
+int *nilp;
+
int main(int argc, char** argv) {
int verbose;
int test;
@@ -39,7 +41,7 @@ int main(int argc, char** argv) {
printf("attempting segfault\n");
}
- volatile int crash = *(int *) 0;
+ *nilp = 0;
break;
}
diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go
index 3f8f12c9e9..df86ae7223 100644
--- a/src/cmd/dist/test.go
+++ b/src/cmd/dist/test.go
@@ -928,7 +928,8 @@ func (t *tester) supportedBuildmode(mode string) bool {
return false
}
switch pair {
- case "darwin-386", "darwin-amd64", "darwin-arm", "darwin-arm64",
+ case "aix-ppc64",
+ "darwin-386", "darwin-amd64", "darwin-arm", "darwin-arm64",
"linux-amd64", "linux-386", "linux-ppc64le", "linux-s390x",
"freebsd-amd64",
"windows-amd64", "windows-386":
diff --git a/src/runtime/os3_solaris.go b/src/runtime/os3_solaris.go
index 11d2c9b098..b5f8a7c042 100644
--- a/src/runtime/os3_solaris.go
+++ b/src/runtime/os3_solaris.go
@@ -273,6 +273,7 @@ func sigdelset(mask *sigset, i int) {
mask.__sigbits[(i-1)/32] &^= 1 << ((uint32(i) - 1) & 31)
}
+//go:nosplit
func (c *sigctxt) fixsigcode(sig uint32) {
}
diff --git a/src/runtime/os_aix.go b/src/runtime/os_aix.go
index faec9ac113..197869f989 100644
--- a/src/runtime/os_aix.go
+++ b/src/runtime/os_aix.go
@@ -296,7 +296,15 @@ func setSignalstackSP(s *stackt, sp uintptr) {
*(*uintptr)(unsafe.Pointer(&s.ss_sp)) = sp
}
+//go:nosplit
func (c *sigctxt) fixsigcode(sig uint32) {
+ switch sig {
+ case _SIGPIPE:
+ // For SIGPIPE, c.sigcode() isn't set to _SI_USER as on Linux.
+ // Therefore, raisebadsignal won't raise SIGPIPE again if
+ // it was deliver in a non-Go thread.
+ c.set_sigcode(_SI_USER)
+ }
}
//go:nosplit
diff --git a/src/runtime/os_dragonfly.go b/src/runtime/os_dragonfly.go
index eb7e159d35..4fda7ea806 100644
--- a/src/runtime/os_dragonfly.go
+++ b/src/runtime/os_dragonfly.go
@@ -252,6 +252,7 @@ func sigdelset(mask *sigset, i int) {
mask.__bits[(i-1)/32] &^= 1 << ((uint32(i) - 1) & 31)
}
+//go:nosplit
func (c *sigctxt) fixsigcode(sig uint32) {
}
diff --git a/src/runtime/os_freebsd.go b/src/runtime/os_freebsd.go
index ba0afa23bf..cbb72cf55e 100644
--- a/src/runtime/os_freebsd.go
+++ b/src/runtime/os_freebsd.go
@@ -365,6 +365,7 @@ func sigdelset(mask *sigset, i int) {
mask.__bits[(i-1)/32] &^= 1 << ((uint32(i) - 1) & 31)
}
+//go:nosplit
func (c *sigctxt) fixsigcode(sig uint32) {
}
diff --git a/src/runtime/os_linux.go b/src/runtime/os_linux.go
index 8f3afe0577..a817020c90 100644
--- a/src/runtime/os_linux.go
+++ b/src/runtime/os_linux.go
@@ -395,6 +395,7 @@ func setSignalstackSP(s *stackt, sp uintptr) {
*(*uintptr)(unsafe.Pointer(&s.ss_sp)) = sp
}
+//go:nosplit
func (c *sigctxt) fixsigcode(sig uint32) {
}
diff --git a/src/runtime/os_netbsd.go b/src/runtime/os_netbsd.go
index fa3c9fa649..da024cd309 100644
--- a/src/runtime/os_netbsd.go
+++ b/src/runtime/os_netbsd.go
@@ -328,6 +328,7 @@ func sigdelset(mask *sigset, i int) {
mask.__bits[(i-1)/32] &^= 1 << ((uint32(i) - 1) & 31)
}
+//go:nosplit
func (c *sigctxt) fixsigcode(sig uint32) {
}
diff --git a/src/runtime/os_openbsd.go b/src/runtime/os_openbsd.go
index 42fe315bcd..2d6334ec86 100644
--- a/src/runtime/os_openbsd.go
+++ b/src/runtime/os_openbsd.go
@@ -302,6 +302,7 @@ func sigdelset(mask *sigset, i int) {
*mask &^= 1 << (uint32(i) - 1)
}
+//go:nosplit
func (c *sigctxt) fixsigcode(sig uint32) {
}
diff --git a/src/runtime/signal_darwin_386.go b/src/runtime/signal_darwin_386.go
index c162959c12..3dc5334997 100644
--- a/src/runtime/signal_darwin_386.go
+++ b/src/runtime/signal_darwin_386.go
@@ -40,6 +40,7 @@ func (c *sigctxt) set_esp(x uint32) { c.regs().esp = x }
func (c *sigctxt) set_sigcode(x uint32) { c.info.si_code = int32(x) }
func (c *sigctxt) set_sigaddr(x uint32) { c.info.si_addr = x }
+//go:nosplit
func (c *sigctxt) fixsigcode(sig uint32) {
switch sig {
case _SIGTRAP:
diff --git a/src/runtime/signal_darwin_amd64.go b/src/runtime/signal_darwin_amd64.go
index 40de4812b8..abc212ad51 100644
--- a/src/runtime/signal_darwin_amd64.go
+++ b/src/runtime/signal_darwin_amd64.go
@@ -48,6 +48,7 @@ func (c *sigctxt) set_rsp(x uint64) { c.regs().rsp = x }
func (c *sigctxt) set_sigcode(x uint64) { c.info.si_code = int32(x) }
func (c *sigctxt) set_sigaddr(x uint64) { c.info.si_addr = x }
+//go:nosplit
func (c *sigctxt) fixsigcode(sig uint32) {
switch sig {
case _SIGTRAP:
diff --git a/src/runtime/signal_darwin_arm.go b/src/runtime/signal_darwin_arm.go
index 9a5d3ac5bb..9098b1053d 100644
--- a/src/runtime/signal_darwin_arm.go
+++ b/src/runtime/signal_darwin_arm.go
@@ -50,6 +50,7 @@ func (c *sigctxt) set_r10(x uint32) { c.regs().r[10] = x }
func (c *sigctxt) set_sigcode(x uint32) { c.info.si_code = int32(x) }
func (c *sigctxt) set_sigaddr(x uint32) { c.info.si_addr = x }
+//go:nosplit
func (c *sigctxt) fixsigcode(sig uint32) {
switch sig {
case _SIGTRAP:
diff --git a/src/runtime/signal_darwin_arm64.go b/src/runtime/signal_darwin_arm64.go
index 41b8fcaab9..690ffe4ae2 100644
--- a/src/runtime/signal_darwin_arm64.go
+++ b/src/runtime/signal_darwin_arm64.go
@@ -67,6 +67,7 @@ func (c *sigctxt) set_sigaddr(x uint64) {
c.info.si_addr = (*byte)(unsafe.Pointer(uintptr(x)))
}
+//go:nosplit
func (c *sigctxt) fixsigcode(sig uint32) {
switch sig {
case _SIGTRAP:
diff --git a/src/runtime/signal_unix.go b/src/runtime/signal_unix.go
index 8814f7836d..1dd56989b4 100644
--- a/src/runtime/signal_unix.go
+++ b/src/runtime/signal_unix.go
@@ -296,6 +296,7 @@ func sigtrampgo(sig uint32, info *siginfo, ctx unsafe.Pointer) {
sigprofNonGoPC(c.sigpc())
return
}
+ c.fixsigcode(sig)
badsignal(uintptr(sig), c)
return
}