Skip to content

Instantly share code, notes, and snippets.

@eblot
Created May 1, 2020 19:05
Show Gist options
  • Save eblot/fe5e53fc28b77267be7a7748a003f425 to your computer and use it in GitHub Desktop.
Save eblot/fe5e53fc28b77267be7a7748a003f425 to your computer and use it in GitHub Desktop.
Newlib-3.3.0 fix for ARMv6m
diff --git a/libgloss/arm/crt0.S b/libgloss/arm/crt0.S
index 48f3d6b1d..1a0a446e4 100644
--- a/libgloss/arm/crt0.S
+++ b/libgloss/arm/crt0.S
@@ -565,7 +565,7 @@
/* For Thumb, constants must be after the code since only
positive offsets are supported for PC relative addresses. */
- .align 0
+ .align 2
.LC0:
#ifdef ARM_RDI_MONITOR
.word HeapBase
diff --git a/newlib/libc/machine/arm/setjmp.S b/newlib/libc/machine/arm/setjmp.S
index 1ba711d5e..b8511779f 100644
--- a/newlib/libc/machine/arm/setjmp.S
+++ b/newlib/libc/machine/arm/setjmp.S
@@ -74,11 +74,11 @@ SYM (setjmp):
mov r5, sp
mov r6, lr
stmia r0!, {r1, r2, r3, r4, r5, r6}
- sub r0, r0, #40
+ subs r0, r0, #40
/* Restore callee-saved low regs. */
ldmia r0!, {r4, r5, r6, r7}
/* Return zero. */
- mov r0, #0
+ movs r0, #0
bx lr
.thumb_func
@@ -86,7 +86,7 @@ SYM (setjmp):
TYPE (longjmp)
SYM (longjmp):
/* Restore High regs. */
- add r0, r0, #16
+ adds r0, r0, #16
ldmia r0!, {r2, r3, r4, r5, r6}
mov r8, r2
mov r9, r3
@@ -95,12 +95,12 @@ SYM (longjmp):
mov sp, r6
ldmia r0!, {r3} /* lr */
/* Restore low regs. */
- sub r0, r0, #40
+ subs r0, r0, #40
ldmia r0!, {r4, r5, r6, r7}
/* Return the result argument, or 1 if it is zero. */
mov r0, r1
bne 1f
- mov r0, #1
+ movs r0, #1
1:
bx r3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment