Skip to content

Commit 212ce41

Browse files
committed
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
1 parent 4cfcb4a commit 212ce41

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/pkg/runtime/asm_arm.s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ TEXT _rt0_arm(SB),7,$-4
3737
MOVW.NE g, R0 // first argument of initcgo is g
3838
BL.NE (R2) // will clobber R0-R3
3939

40+
BL runtime·checkgoarm(SB)
4041
BL runtime·check(SB)
4142

4243
// saved argc, argv

src/pkg/runtime/signal_linux_arm.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,21 @@ runtime·setsig(int32 i, void (*fn)(int32, Siginfo*, void*, G*), bool restart)
147147
#define AT_PLATFORM 15 // introduced in at least 2.6.11
148148
#define AT_HWCAP 16 // introduced in at least 2.6.11
149149
#define AT_RANDOM 25 // introduced in 2.6.29
150+
#define HWCAP_VFP (1 << 6)
150151
static uint32 runtime·randomNumber;
151-
uint32 runtime·hwcap;
152-
uint8 runtime·armArch = 6; // we default to ARMv6
152+
uint8 runtime·armArch = 6; // we default to ARMv6
153+
uint32 runtime·hwcap; // set by setup_auxv
154+
uint8 runtime·goarm; // set by 5l
155+
156+
void
157+
runtime·checkgoarm(void)
158+
{
159+
if(runtime·goarm > 5 && !(runtime·hwcap & HWCAP_VFP)) {
160+
runtime·printf("runtime: this CPU has no floating point hardware, so it cannot run\n");
161+
runtime·printf("this GOARM=%d binary. Recompile using GOARM=5.\n", runtime·goarm);
162+
runtime·exit(1);
163+
}
164+
}
153165

154166
#pragma textflag 7
155167
void

0 commit comments

Comments
 (0)