Skip to content

Conversation

maribu
Copy link
Member

@maribu maribu commented Sep 28, 2020

Contribution description

  • Enforced that stacks are aligned to word size in C code
    • Hopefully, this was already the case through the linker script. In this case, the actual alignment just got more explicit and visible in the C code. Otherwise, this fixes a bug
  • Enforced that ISR_STACKSIZE is a multiple of 4 (so that the end pointer is also aligned to word size)
  • With this, all casts from pointer to uint32_t pointers now don't drop alignment requirements
    • Silenced all -Wcast-align warnings

Testing procedure

Hopefully, this doesn't change binaries. But if so, stack usage should still be properly measured.

Issues/PRs references

Split out of #14955

This didn't change binaries for me. Either the linker script already took care
of it through the section names of the stacks, or I just was lucky. If I was
just luck, this fixes a bug. If not, it makes the hidden alignment explicit in
the C code, so that code review is easier.
- Enforced that ISR_STACKSIZE is indeed a multiple of 4
- With this enforced, every cast that triggers a -Wcast-align warning is now
  a false positives, so those were silenced by (intermediately) casting to
  `uintptr_t`.
@maribu maribu added Platform: ARM Platform: This PR/issue effects ARM-based platforms Impact: minor The PR is small in size and might only require a quick look of a knowledgeable reviewer Area: cpu Area: CPU/MCU ports labels Sep 28, 2020
@maribu maribu requested a review from benpicco September 28, 2020 09:06
@maribu maribu requested a review from kaspar030 as a code owner September 28, 2020 09:06
@benpicco benpicco added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Sep 28, 2020
Copy link
Contributor

@benpicco benpicco left a comment

Choose a reason for hiding this comment

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

Binaries do no change (build examples/default for msba2)

@maribu maribu merged commit c6fe777 into RIOT-OS:master Sep 28, 2020
@maribu
Copy link
Member Author

maribu commented Sep 28, 2020

Thanks! :-)

@maribu maribu deleted the arm7-cast-align branch September 28, 2020 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: cpu Area: CPU/MCU ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Impact: minor The PR is small in size and might only require a quick look of a knowledgeable reviewer Platform: ARM Platform: This PR/issue effects ARM-based platforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants