From 4c3f6ea5b25b3e934cea41341b42e93a260bb0ef Mon Sep 17 00:00:00 2001 From: Wilfried Chauveau Date: Sat, 7 Oct 2023 16:08:36 +0100 Subject: [PATCH] arch: arm: cortex_m: Document why __aeabi_read_tp impl requires ASM impl This method has special ABI requirement that requires the use of ASM. This change documents why this is required & adds reference to the related specification. Signed-off-by: Wilfried Chauveau --- arch/arm/core/cortex_m/__aeabi_read_tp.S | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/arm/core/cortex_m/__aeabi_read_tp.S b/arch/arm/core/cortex_m/__aeabi_read_tp.S index 8aeba3e5d12..745fda73b9b 100644 --- a/arch/arm/core/cortex_m/__aeabi_read_tp.S +++ b/arch/arm/core/cortex_m/__aeabi_read_tp.S @@ -12,8 +12,14 @@ GTEXT(__aeabi_read_tp) GDATA(z_arm_tls_ptr) +/* Grab the TLS pointer and store in R0. + * According to the Run-Time ABI for the ArmĀ® Architecture section 5.3.5, this + * function may only clobber r0, ip, lr & CPSR. + * + * This can only be guaranteed by either implementing a naked C function with + * inline assembly, or plain assembly. + */ SECTION_FUNC(TEXT, __aeabi_read_tp) - /* Grab the TLS pointer and store in R0 */ ldr r0, =z_arm_tls_ptr ldr r0, [r0] bx lr