firmware: use C versions of memcpy and memmove for ARM Cortex-M

The ARM assembly versions of memcpy and memmove try to
directly modify the PC based on the number of bytes to
be copied as an "optimization"; but this only works if
instructions are guaranteed to be 4 bytes wide.

This trick is completely broken on Cortex-M, since an
instruction can be 2-4 bytes wide: for example a memcpy
of 4 bytes ends up storing 32 bytes worth of garbage to
the target address!

Use the C memcpy/memmove implementations for Cortex-M
instead; fixing the ASM version is more trouble than
it's worth.

Change-Id: I695587fd585ec25ef276f2dbc61e2290b7015e13
This commit is contained in:
Aidan MacDonald 2026-01-08 14:59:34 +00:00
parent 6f4b6a8078
commit 2f2b90535a

View file

@ -1,5 +1,7 @@
#if defined(CPU_ARM)
#if defined(CPU_ARM_CLASSIC)
arm/ffs.S
#endif
arm/memset16.S
#elif defined(CPU_MIPS)
mips/ffs.S
@ -13,11 +15,17 @@ memset16.c
#endif
#if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(HAVE_ROCKBOX_C_LIBRARY)
#if defined(CPU_ARM)
#if defined(CPU_ARM_CLASSIC)
arm/memcpy.S
arm/memmove.S
arm/memset.S
strlen.c
#elif defined(CPU_ARM_MICRO)
memcpy.c
mempcpy.c
memmove.c
arm/memset.S
strlen.c
#elif defined(CPU_MIPS)
mips/memcpy.S
memmove.c