Repository navigation
boards/arm: Align ARM32 idle stack to AAPCS-32 requirement - #20981
Merged
hartmannathan merged 1 commit intoOct 25, 2026
Merged
Conversation
Align the _ebss symbol (used as the base of the idle stack) to an 8-byte boundary across all remaining ARM32 board linker scripts to conform to AAPCS-32. Previously, .bss ended with . = ALIGN(4); before _ebss. If .bss ended on a non-8-byte boundary, _ebss and the resulting idle stack pointer (IDLE_STACK = _ebss + CONFIG_IDLETHREAD_STACKSIZE) were only 4-byte aligned. This caused exceptions during 64-bit vararg accesses (such as syslog timestamps) in the idle thread when va_arg forcibly 8-byte aligned the va_list pointer. Commit 8409599 addressed this for stm32 boards; this commit extends the fix to all remaining ARM32 boards. Fixes apache#18558. Signed-off-by: Swatantra Yadav <[email protected]>
Swatantra-66
requested review from
GUIDINGLI,
acassis,
btashton,
davids5,
gustavonihei,
hartmannathan,
jerpelea,
linguini1,
liuguo09,
lupyuen,
masayuki2009,
michallenc,
pkarashchenko,
pussuw,
raiden00pl,
rcsim,
xiaoxiang781216,
yamt and
yf13
as code owners
October 25, 2026 10:57
|
xiaoxiang781216
approved these changes
Oct 25, 2026
acassis
approved these changes
Oct 25, 2026
hartmannathan
approved these changes
Oct 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #18558.
The ARM Architecture Procedure Call Standard (AAPCS-32, §5.2.1.1) mandates:
In NuttX on ARM architectures (
armv6-m,armv7-m,armv8-m,armv7-a,armv7-r,armv8-r), the idle thread stack pointer is defined relative to the end of the BSS section:On Cortex-M cores,
IDLE_STACKis placed at vector table index 0 and loaded directly into the Main Stack Pointer (MSP) by hardware on reset. On Cortex-A and Cortex-R cores,SPis loaded withIDLE_STACKin startup assembly (arm_head.S).Prior to this change, board linker scripts terminated
.bsswith:If
.bssended on a 4-byte boundary that was not a multiple of 8,_ebssand the initial idle stack pointerIDLE_STACKwere only 4-byte aligned (SP % 8 == 4).When the idle thread invokes functions with 64-bit varargs (such as
syslog()withCONFIG_SYSLOG_TIMESTAMPenabled or formatting 64-bit integers withvsprintf_internal), GCC'sva_argforcibly 8-byte aligns theappointer (bic.w r9, r9, #7). On a 4-byte aligned stack, this advancesapby 12 bytes instead of 8 bytes, corrupting the varargs stream and causing subsequent parameter dereferences to fail with Data Abort / Bus Fault exceptions (as documented in issue #18558).Commit 8409599 (PR #18569) addressed this specifically for
boards/arm/stm32*/. This commit extends the fix across all remaining ARM32 boards (and any missed/newly added STM32 scripts) by aligning_ebssto an 8-byte boundary (. = ALIGN(8);).Impact
armv6-m,armv7-m,armv8-m,armv7-a,armv7-r,armv8-r).Testing
boards/arm/to confirm zero remaining 4-byte aligned or unaligned_ebssdefinitions.git diff --checkacross all 341 modified linker scripts (0 whitespace / newline errors).boards/arm/stm32*/: Align ARM STM32 idle stack).