From 308ab851733d770c0880541b1c884d43c77b483d Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Wed, 10 Oct 2018 15:20:15 +0200 Subject: [PATCH] [ion/device] Make sure start()'s prologue doesn't use VFP registers --- ion/src/device/boot/rt0.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/ion/src/device/boot/rt0.cpp b/ion/src/device/boot/rt0.cpp index e822bc781..f72aa4edd 100644 --- a/ion/src/device/boot/rt0.cpp +++ b/ion/src/device/boot/rt0.cpp @@ -28,6 +28,19 @@ void abort() { #endif } +/* By default, the compiler is free to inline any function call he wants. If the + * compiler decides to inline some functions that make use of VFP registers, it + * will need to push VFP them onto the stack in calling function's prologue. + * Problem: in start()'s prologue, we would never had a chance to enable the FPU + * since this function is the first thing called after reset. + * We can safely assume that neither memcpy, memset, nor any Ion::Device::init* + * method will use floating-point numbers, but ion_main very well can. + * To make sure ion_main's potential usage of VFP registers doesn't bubble-up to + * start(), we isolate it in its very own non-inlined function call. */ +static void __attribute__((noinline)) non_inlined_ion_main() { + return ion_main(0, nullptr); +} + void start() { // This is where execution starts after reset. // Many things are not initialized yet so the code here has to pay attention. @@ -75,7 +88,7 @@ void start() { Ion::Device::init(); - ion_main(0, nullptr); + non_inlined_ion_main(); abort(); }