Skip to content

Commit

Permalink
runtime, cmd/dist, misc/cgo: enable c-archive for aix/ppc64
Browse files Browse the repository at this point in the history
Change-Id: Ib9a40d5596f5735a00483e2d2db965402f05671b
Reviewed-on: https://go-review.googlesource.com/c/go/+/169120
Run-TryBot: Tobias Klauser <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
  • Loading branch information
Clément Chigot authored and ianlancetaylor committed Apr 2, 2019
1 parent 5651721 commit 3aacfce
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 14 deletions.
23 changes: 15 additions & 8 deletions misc/cgo/testcarchive/carchive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
}
}

Expand Down
15 changes: 11 additions & 4 deletions misc/cgo/testcarchive/testdata/main4.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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");
}
Expand Down
4 changes: 3 additions & 1 deletion misc/cgo/testcarchive/testdata/main5.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#include "libgo2.h"

int *nilp;

int main(int argc, char** argv) {
int verbose;
int test;
Expand All @@ -39,7 +41,7 @@ int main(int argc, char** argv) {
printf("attempting segfault\n");
}

volatile int crash = *(int *) 0;
*nilp = 0;
break;
}

Expand Down
3 changes: 2 additions & 1 deletion src/cmd/dist/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
1 change: 1 addition & 0 deletions src/runtime/os3_solaris.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
}

Expand Down
8 changes: 8 additions & 0 deletions src/runtime/os_aix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/runtime/os_dragonfly.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
}

Expand Down
1 change: 1 addition & 0 deletions src/runtime/os_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
}

Expand Down
1 change: 1 addition & 0 deletions src/runtime/os_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
}

Expand Down
1 change: 1 addition & 0 deletions src/runtime/os_netbsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
}

Expand Down
1 change: 1 addition & 0 deletions src/runtime/os_openbsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ func sigdelset(mask *sigset, i int) {
*mask &^= 1 << (uint32(i) - 1)
}

//go:nosplit
func (c *sigctxt) fixsigcode(sig uint32) {
}

Expand Down
1 change: 1 addition & 0 deletions src/runtime/signal_darwin_386.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions src/runtime/signal_darwin_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions src/runtime/signal_darwin_arm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions src/runtime/signal_darwin_arm64.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions src/runtime/signal_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 3aacfce

Please sign in to comment.