Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[build] include alignment into section size calculations #2719

Merged
merged 2 commits into from Jan 18, 2024

Conversation

avtolstoy
Copy link
Member

@avtolstoy avtolstoy commented Dec 13, 2023

Problem

Some applications that use non-trivial alignments (32, 128 etc) may fail to build with SRAM or other section overflow.

#2665 is somewhat relevant.

Solution

Account for section alignment requirements when calculating its size. Objdump provides this:

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  3 .dynalib      00000008  023e0b88  085e00b0  00010b88  2**3

The calculation is a bit trivial but should work for what we are doing: size + algn - 1

Steps to Test

  • wiring/no_fixture with MISC_02_alignment should build on all platforms

Example App

This should build:

__attribute__((used, aligned(256))) uint8_t test[63] = {};

/* executes once at startup */
void setup() {
    // To avoid compiler optimizing 'test' out
    LOG(INFO, "%d", (int)test[0]);
}

References

Links to the Community, Docs, Other Issues, etc..


Completeness

  • User is totes amazing for contributing!
  • Contributor has signed CLA (Info here)
  • Problem and Solution clearly stated
  • Run unit/integration/application tests on device
  • Added documentation
  • Added to CHANGELOG.md after merging (add links to docs and issues)

@avtolstoy avtolstoy force-pushed the fix/ram-calc-section-alignment branch from 61fb68f to 1ecdf00 Compare January 18, 2024 12:22
@avtolstoy avtolstoy merged commit a72ea7b into develop Jan 18, 2024
1 check passed
@avtolstoy avtolstoy deleted the fix/ram-calc-section-alignment branch January 18, 2024 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants