-fstack-check undefined reference to __gnat_stack_check

When I have added -fstack-check to an ARM cortex light project then I get the build error undefined reference to __gnat_stack_check.

It works fine on a full runtime.

Is that expected?

Can it be fixed?

It seems that I would need to implement __gnat_stack_check myself :thinking:

Would storage_error still be raised without it upon allocations using new?

I have been looking into the '83 Booch components as well as the SPARK containers and I can use bounded forms but they aren’t so easily considered as bytes due to the convenience of handling records etc… (not a huge deal). Handling storage_error the way the unbounded forms do seems pretty neat, though. Obviously it would require testing.

You might see if @simonjwright 's lighter FreeRTOS runtime has a good example of the stack checker. I don’t know for certain if he implemented it, but given the scope of the runtime, it might be likely.

1 Like

No, sorry. My usual scheme of compiling with -c -u -gnatG (to see what the compiler does when calling the runtime) fails; must be at a lower level.

Given that, the obvious scheme would be to look at one of the full (embedded ?) runtimes and see what they do,