arm: add div0 handler for 64-bit division on ARMv7-M

Even though ARMv7-M has a hardware divider, 64-bit division is
handled in software and needs a div0 handler. The libgcc routines
call __aeabi_{i,l}div0 so we alias those to __div0.

Change-Id: I5152c43d39e25e03f31404753f13978a614aca06
This commit is contained in:
Aidan MacDonald 2025-02-18 16:47:41 +00:00
parent 545506c923
commit 6ea328f0f1
3 changed files with 14 additions and 1 deletions

View file

@ -27,6 +27,11 @@ void __attribute__((naked)) __div0(void)
{
asm volatile("bx %0" : : "r"(rb->__div0));
}
#if defined(CPU_ARM_MICRO)
void __aeabi_idiv0(void) __attribute__((alias("__div0")));
void __aeabi_ldiv0(void) __attribute__((alias("__div0")));
#endif
#endif
void *memcpy(void *dest, const void *src, size_t n)

View file

@ -710,7 +710,7 @@ Lyre prototype 1 */
# elif ARM_PROFILE == ARM_PROFILE_CLASSIC
# define CPU_ARM_CLASSIC
# endif
# if !defined(ARM_HAVE_HW_DIV) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
# if (CONFIG_PLATFORM & PLATFORM_NATIVE)
# define ARM_NEED_DIV0
# endif
#endif

View file

@ -38,6 +38,14 @@ void UIE(void)
while (1);
}
void __div0(void)
{
while (1);
}
void __aeabi_idiv0(void) __attribute__((alias("__div0")));
void __aeabi_ldiv0(void) __attribute__((alias("__div0")));
#define ATTR_IRQ_HANDLER __attribute__((weak, alias("UIE")))
void nmi_handler(void) ATTR_IRQ_HANDLER;