Skip to content

Conversation

iabdalkader
Copy link

@iabdalkader iabdalkader commented Oct 1, 2025

The _static_thread_data struct contains int64_t members that require 8-byte alignment. When placed in a 4-byte aligned section, it causes the linker to insert padding, which in turn causes __static_thread_data_list_start to point to the padding not to the first iterable.

GNU ld automatically aligns output sections based on the strictest alignment requirement of input sections, so moving __static_thread_data_list to its own section fixes the problem.

@iabdalkader iabdalkader force-pushed the fix_thread_section_alignment branch from 6588cbd to ccc56ce Compare October 1, 2025 13:36
@iabdalkader iabdalkader changed the title Fix thread section alignment. core: Fix thread section alignment. Oct 1, 2025
@iabdalkader iabdalkader force-pushed the fix_thread_section_alignment branch 2 times, most recently from 8bdc53e to 1bab673 Compare October 1, 2025 14:25
@iabdalkader iabdalkader force-pushed the fix_thread_section_alignment branch from 1bab673 to 9416d15 Compare October 15, 2025 12:50
Copy link

@pillo79 pillo79 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. With the following change, this PR will also fix the Region ... overlaps with ... issue AFAICS.

The _static_thread_data struct contains int64_t members that require 8-byte
alignment. When placed in a 4-byte aligned section, it causes the linker to
insert padding, which in turn causes __static_thread_data_list_start to point
to the padding not to the first iterable.

GNU ld automatically aligns output sections based on the strictest alignment
requirement of input sections, so moving __static_thread_data_list to its own
section fixes the problem.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
According to Zephyr documentation, k_thread_create() both initializes
and starts the thread. The second loop that was calling k_thread_start()
on each static thread was redundant.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
@iabdalkader iabdalkader force-pushed the fix_thread_section_alignment branch from 9416d15 to 6d9ef00 Compare October 16, 2025 07:36
@pillo79 pillo79 merged commit 658a690 into arduino:main Oct 16, 2025
24 checks passed
@iabdalkader iabdalkader deleted the fix_thread_section_alignment branch October 16, 2025 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants