diff options
| author | Simon Glass <[email protected]> | 2026-03-21 07:46:23 -0600 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2026-04-14 11:03:52 -0600 |
| commit | f9b507748080c2ef52d516345c2431182a83f19f (patch) | |
| tree | 8b39b691cb8b1bdf0af1f7991fd6f06871b9f947 /tests/git-scripts | |
| parent | eb00c710508d09b2a3b9aca75dd18280f1304703 (diff) | |
linker_lists: Fix end-marker alignment to prevent padding
Change the alignment of end markers in ll_entry_end() and ll_end_decl()
from __aligned(4) and __aligned(CONFIG_LINKER_LIST_ALIGN) respectively
to __aligned(1).
The linker places zero-size end markers at aligned boundaries based on
what follows them. When the next list's start marker has a high alignment
requirement (e.g., 32 bytes), padding gets inserted before the end
marker. This causes the byte span (end - start) to not be an exact
multiple of the struct size.
The compiler optimises pointer subtraction (end - start) using
magic-number multiplication for division. This optimisation only produces
correct results when the byte span is an exact multiple of the struct
size. With padding, the result is garbage (e.g., -858993444 instead of
15).
By using __aligned(1), the end marker is placed immediately after the
last entry with no padding, ensuring (end - start) equals exactly
(n * sizeof) where n is the number of entries. This makes
ll_entry_count() and direct pointer arithmetic work correctly.
Fixes: 0b2fa98aa5e5 ("linker_lists: Fix alignment issue")
Signed-off-by: Simon Glass <[email protected]>
Diffstat (limited to 'tests/git-scripts')
0 files changed, 0 insertions, 0 deletions
