Skip to content

Conversation

will-v-pi
Copy link
Contributor

As raised in #2513, the current way of specifying stack and heap space means that on GCC the space is not included in --print-memory-usage, because they are not marked as allocatable in order to maintain compatibility with linker scripts prior to 1.5.1 which don't KEEP the .stack and .heap sections.

This changes that default to mark them as allocatable, and adds a new CMake function to parse the linker script and check for compatibility, and enables a workaround if not compatible.

This means if you:

  • KEEP the sections - they show up in --print-memory-usage, and the binary runs fine
  • Don't KEEP the sections - they don't show up in --print-memory-usage, and CMake raises warnings at the configure stage explaining the incompatibility, but the binary still runs fine

@will-v-pi will-v-pi added this to the 2.1.2 milestone Jun 11, 2025
@will-v-pi will-v-pi requested a review from kilograham June 11, 2025 10:33
@matsobdev

This comment was marked as resolved.

@will-v-pi
Copy link
Contributor Author

None of those errors are related to this PR, they're all related to #2233 - to get those errors, did you definitely do a clean compilation with the branch from this PR. Or did you just copy the changed files from this PR into an existing 2.1.1 SDK, which will not work as crt0.S relies on changes to other files in #2233 to compile correctly.

If you can reproduce those errors in a clean compilation (deleted build directory) using the develop branch of the SDK, then please raise a separate issue with details of your compiler.

@matsobdev
Copy link

False alarm. It was clean, but just those two files copied do 2.1.1. It works with develop.

@matsobdev
Copy link

matsobdev commented Jun 11, 2025

But, 2.1.1 with copied files and work around was showing 2 KB of scratch Y usage, but now with develop (including updated libraries and picotool) it shows 0 KB. Do I miss some definition or something? But still there is something. GCC 14.2.1.

@will-v-pi
Copy link
Contributor Author

But, 2.1.1 with copied files and work around was showing 2 KB of scratch Y usage, but now with develop it shows 0 KB. Do I miss some definition or something? But still there is something.

If you use this branch in this PR (not the develop branch), it should show 2KB of scratch Y usage - this hasn't been merged into develop yet, hence why develop still shows 0KB.

@matsobdev
Copy link

Shame on me :D Yes, it works with this branch and shows 2 KB.

@will-v-pi will-v-pi marked this pull request as draft June 12, 2025 10:30
@will-v-pi
Copy link
Contributor Author

Putting back into draft due to compatibility issues with picotool encryption

@kilograham
Copy link
Contributor

note also, i'm curious if this causes the contents to be stored in the binary? This would be bad in general, but particularly egregious for the heap

@will-v-pi
Copy link
Contributor Author

note also, i'm curious if this causes the contents to be stored in the binary? This would be bad in general, but particularly egregious for the heap

This causes extra LOAD segments to appear in the ELF, but they have a filesize of 0 so have no data actually stored in the file.

@will-v-pi
Copy link
Contributor Author

Putting back into draft due to compatibility issues with picotool encryption

raspberrypi/picotool#243 fixes these issues

@kilograham kilograham merged commit f5e0371 into raspberrypi:develop Jul 17, 2025
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants