Add support for -fstack-protector in native builds

-fstack-protector only needs a small amount of runtime
support to work on native builds. It increases code size
by ~1.5% on ARM/MIPS; -fstack-protector-strong adds 3-4%.
This is disabled by default and must be enabled by passing
'--with-stack-protector' to configure.

Change-Id: If952e711d3673c9b469895f08c7bff70b3d95df6
This commit is contained in:
Aidan MacDonald 2026-04-21 14:33:58 +01:00 committed by Solomon Peachy
parent 9ac6edf750
commit d815053360
5 changed files with 68 additions and 0 deletions

View file

@ -34,6 +34,15 @@ void __aeabi_ldiv0(void) __attribute__((alias("__div0")));
#endif
#endif
#if defined(USE_STACK_PROTECTOR)
const uint32_t __stack_chk_guard = 0x3BADC0DE;
void __stack_chk_fail(void)
{
rb->panicf("plugin smashed stack");
}
#endif
void *memcpy(void *dest, const void *src, size_t n)
{
return rb->memcpy(dest, src, n);