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

rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]>
Newsgroups gmane.comp.systems.archos.rockbox.cvs
Message-ID <[email protected]>
commit 2f2b90535ae22c07ebaa19cc2f61cf9f0b0ee97f
Author: Aidan MacDonald <[email protected]>
Date:   Thu Jan 8 14:59:34 2026 +0000

    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

diff --git a/firmware/asm/SOURCES b/firmware/asm/SOURCES
index 5aa9b1c0f7..dc8d7b5dfc 100644
--- a/firmware/asm/SOURCES
+++ b/firmware/asm/SOURCES
@@ -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
-- 
rockbox-cvs mailing list
[email protected]
https://lists.haxx.se/mailman/listinfo/rockbox-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.