diff --git a/src/pkg/runtime/defs_linux_arm.h b/src/pkg/runtime/defs_linux_arm.h index 92160966e11..05a17af64b8 100644 --- a/src/pkg/runtime/defs_linux_arm.h +++ b/src/pkg/runtime/defs_linux_arm.h @@ -16,7 +16,7 @@ enum { MADV_DONTNEED = 0x4, SA_RESTART = 0x10000000, SA_ONSTACK = 0x8000000, - SA_RESTORER = 0x4000000, + SA_RESTORER = 0, // unused on ARM SA_SIGINFO = 0x4, SIGHUP = 0x1, SIGINT = 0x2, diff --git a/src/pkg/runtime/os_linux.c b/src/pkg/runtime/os_linux.c index 31cbdb0ad53..77754f481ca 100644 --- a/src/pkg/runtime/os_linux.c +++ b/src/pkg/runtime/os_linux.c @@ -288,7 +288,7 @@ runtime·memlimit(void) * and calls sighandler(). */ extern void runtime·sigtramp(void); -extern void runtime·sigreturn(void); // calls runtime·sigreturn +extern void runtime·sigreturn(void); // calls rt_sigreturn, only used with SA_RESTORER void runtime·setsig(int32 i, GoSighandler *fn, bool restart) @@ -300,9 +300,15 @@ runtime·setsig(int32 i, GoSighandler *fn, bool restart) if(restart) sa.sa_flags |= SA_RESTART; sa.sa_mask = ~0ULL; - // TODO(adonovan): Linux manpage says "sa_restorer element is - // obsolete and should not be used". Avoid it here, and test. + // Although Linux manpage says "sa_restorer element is obsolete and + // should not be used". x86_64 kernel requires it. Only use it on + // x86. +#ifdef GOARCH_386 sa.sa_restorer = (void*)runtime·sigreturn; +#endif +#ifdef GOARCH_amd64 + sa.sa_restorer = (void*)runtime·sigreturn; +#endif if(fn == runtime·sighandler) fn = (void*)runtime·sigtramp; sa.sa_handler = fn; diff --git a/src/pkg/runtime/sys_linux_arm.s b/src/pkg/runtime/sys_linux_arm.s index 8bfc72b5710..770b963d242 100644 --- a/src/pkg/runtime/sys_linux_arm.s +++ b/src/pkg/runtime/sys_linux_arm.s @@ -340,11 +340,6 @@ TEXT runtime·rt_sigaction(SB),NOSPLIT,$0 SWI $0 RET -TEXT runtime·sigreturn(SB),NOSPLIT,$0 - MOVW $SYS_rt_sigreturn, R7 - SWI $0 - RET - TEXT runtime·usleep(SB),NOSPLIT,$12 MOVW usec+0(FP), R0 MOVW R0, R1