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
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 <[email protected]>
@iabdalkader iabdalkader force-pushed the fix_thread_section_alignment branch from ccc56ce to 8bdc53e Compare October 1, 2025 13:59
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 <[email protected]>
@iabdalkader iabdalkader force-pushed the fix_thread_section_alignment branch from 8bdc53e to 1bab673 Compare October 1, 2025 14:25
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.

1 participant