From 212ce41d004cc9e33d35b64cc13c2c9baf843452 Mon Sep 17 00:00:00 2001 From: Dave Cheney Date: Fri, 7 Sep 2012 14:26:42 +1000 Subject: [PATCH] runtime: arm: abort if hardware floating point missing Fixes #3911. Requires CL 6449127. dfc@qnap:~$ ./runtime.test runtime: this CPU has no floating point hardware, so it cannot run this GOARM=7 binary. Recompile using GOARM=5. R=rsc, minux.ma CC=golang-dev https://golang.org/cl/6442109 --- src/pkg/runtime/asm_arm.s | 1 + src/pkg/runtime/signal_linux_arm.c | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/pkg/runtime/asm_arm.s b/src/pkg/runtime/asm_arm.s index 2c89139805..57df8c9c63 100644 --- a/src/pkg/runtime/asm_arm.s +++ b/src/pkg/runtime/asm_arm.s @@ -37,6 +37,7 @@ TEXT _rt0_arm(SB),7,$-4 MOVW.NE g, R0 // first argument of initcgo is g BL.NE (R2) // will clobber R0-R3 + BL runtime·checkgoarm(SB) BL runtime·check(SB) // saved argc, argv diff --git a/src/pkg/runtime/signal_linux_arm.c b/src/pkg/runtime/signal_linux_arm.c index c35d139b27..7f93db5fb0 100644 --- a/src/pkg/runtime/signal_linux_arm.c +++ b/src/pkg/runtime/signal_linux_arm.c @@ -147,9 +147,21 @@ runtime·setsig(int32 i, void (*fn)(int32, Siginfo*, void*, G*), bool restart) #define AT_PLATFORM 15 // introduced in at least 2.6.11 #define AT_HWCAP 16 // introduced in at least 2.6.11 #define AT_RANDOM 25 // introduced in 2.6.29 +#define HWCAP_VFP (1 << 6) static uint32 runtime·randomNumber; -uint32 runtime·hwcap; -uint8 runtime·armArch = 6; // we default to ARMv6 +uint8 runtime·armArch = 6; // we default to ARMv6 +uint32 runtime·hwcap; // set by setup_auxv +uint8 runtime·goarm; // set by 5l + +void +runtime·checkgoarm(void) +{ + if(runtime·goarm > 5 && !(runtime·hwcap & HWCAP_VFP)) { + runtime·printf("runtime: this CPU has no floating point hardware, so it cannot run\n"); + runtime·printf("this GOARM=%d binary. Recompile using GOARM=5.\n", runtime·goarm); + runtime·exit(1); + } +} #pragma textflag 7 void -- 2.48.1