1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
diff --git a/firmware/target/arm/memcpy-arm.S b/firmware/target/arm/memcpy-arm.S
index d17d659..47bab82 100644
--- a/firmware/target/arm/memcpy-arm.S
+++ b/firmware/target/arm/memcpy-arm.S
@@ -98,7 +98,8 @@ memcpy:
         strcsb  r4, [r0], #1
         strcsb  ip, [r0]

-        ldmfd   sp!, {r0, r4, pc}
+        ldmfd   sp!, {r0, r4, lr}
+        bx      lr

 9:      rsb ip, ip, #4
         cmp ip, #2
diff --git a/firmware/target/arm/memmove-arm.S b/firmware/target/arm/memmove-arm.S
index ce056d9..fe7a204 100644
--- a/firmware/target/arm/memmove-arm.S
+++ b/firmware/target/arm/memmove-arm.S
@@ -112,7 +112,8 @@ memmove:
         strneb  r3, [r0, #-1]!
         strcsb  r4, [r0, #-1]!
         strcsb  ip, [r0, #-1]
-        ldmfd   sp!, {r0, r4, pc}
+        ldmfd   sp!, {r0, r4, lr}
+        bx      lr

 9:      cmp ip, #2
         ldrgtb  r3, [r1, #-1]!
diff --git a/firmware/target/arm/memset-arm.S b/firmware/target/arm/memset-arm.S
index 4d46b6f..0f83a5b 100644
--- a/firmware/target/arm/memset-arm.S
+++ b/firmware/target/arm/memset-arm.S
@@ -69,7 +69,8 @@ memset:
         stmgedb r0!, {r1, r3, ip, lr}
         stmgedb r0!, {r1, r3, ip, lr}
         bgt     3b
-        ldmeqfd sp!, {pc}               @ Now <64 bytes to go.
+        ldmeqfd sp!, {lr}               @ Now <64 bytes to go.
+        bxeq    lr
 /*
  * No need to correct the count; we're only testing bits from now on
  */
diff --git a/firmware/target/arm/memset16-arm.S b/firmware/target/arm/memset16-arm.S
index 47034ab..c48740c 100644
--- a/firmware/target/arm/memset16-arm.S
+++ b/firmware/target/arm/memset16-arm.S
@@ -59,7 +59,8 @@ memset16:
         stmgeia r0!, {r1, r3, ip, lr}
         stmgeia r0!, {r1, r3, ip, lr}
         bgt     2b
-        ldmeqfd sp!, {pc}               @ Now <64 bytes to go.
+        ldmeqfd sp!, {lr}               @ Now <64 bytes to go.
+        bxeq    lr
 /*
  * No need to correct the count; we're only testing bits from now on
  */