Skip to content

Commit 0e7db6e

Browse files
authored
[picolibc patch] AArch32 crt0: don't write to VBAR on Armv7-R (#229)
This is logically a cherry-pick of picolibc/picolibc#973 aka picolibc commit b399940a9e590032b6dff9f325215c41ac6dbde2 by turning it into a patch to be applied against the version of picolibc checked out by our build scripts.
1 parent e6561ed commit 0e7db6e

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
From b399940a9e590032b6dff9f325215c41ac6dbde2 Mon Sep 17 00:00:00 2001
2+
From: Simon Tatham <[email protected]>
3+
Date: Mon, 24 Mar 2025 11:36:35 +0000
4+
Subject: [PATCH] AArch32 crt0: don't write to VBAR on Armv7-R systems.
5+
6+
This CP15 register, which controls the exception vector table base
7+
address, is part of the Security Extensions, which are not available
8+
in Armv7-R. So the MCR instruction which writes to them will provoke
9+
an UNDEF exception on an Armv7-R CPU.
10+
11+
This MCR instruction was already conditionally compiled: if you're
12+
compiling crt0.c for a platform without it, you just have to make sure
13+
your ld script puts the exception vectors in the default place. This
14+
patch tightens the existing condition to exclude Armv7-R.
15+
---
16+
picocrt/machine/arm/crt0.c | 2 +-
17+
1 file changed, 1 insertion(+), 1 deletion(-)
18+
19+
diff --git a/picocrt/machine/arm/crt0.c b/picocrt/machine/arm/crt0.c
20+
index f4d2d28ac..792bf5978 100644
21+
--- a/picocrt/machine/arm/crt0.c
22+
+++ b/picocrt/machine/arm/crt0.c
23+
@@ -259,7 +259,7 @@ _cstart(void)
24+
25+
/* Set up exception table base address (register VBAR_ELx).
26+
Architectures earlier than v7 have the base address fixed. */
27+
-#if __ARM_ARCH >= 7
28+
+#if __ARM_ARCH >= 7 && __ARM_ARCH_PROFILE != 'R'
29+
__asm__("mcr p15, #0, %0, c12, c0, 0" : : "r"(__vector_table) :);
30+
#endif
31+
32+
--
33+
2.43.0
34+

0 commit comments

Comments
 (0)