- Notifications
You must be signed in to change notification settings - Fork1k
Support a .noinit section for variables#996
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
4 changes: 2 additions & 2 deletionsplatform.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletionssystem/ldscript.ld
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /* | ||
| * This script extends the default linker script to add a .noinit | ||
| * section. This section is just mapped to RAM, but it is emitted | ||
| * separately from the .data and .bss sections (both of which are | ||
| * initialized by startup code), so any variables in this section are | ||
| * untouched on startup (so they survive across resets). | ||
| * | ||
| * This script is intended to supplied to the linker's -T / --script | ||
| * option as the primary linker script. When the linker sees an INSERT | ||
| * command, this will cause it to *also* read the default linker script | ||
| * (after reading this script) and then executing the INSERT commands | ||
| * after both scripts have been read. | ||
| * | ||
| * Note that parsing of linker scripts is a bit peculiar, e.g. INSERT | ||
| * does not textually inserts, it inserts any generated output sections. | ||
| * Also, because this script is read *first*, we cannot refer to things | ||
| * in the default script. In particular, it would make sense to add > | ||
| * RAM to the output section below to ensure that the section is mapped | ||
| * into RAM, but the RAM region is not defined yet (I think it would | ||
| * work though, but produces warnings). Instead, we just rely on the | ||
| * defaults used by the linker: If no region is defined for an output | ||
| * section, it will just map to first address after the previous section | ||
| * (.bss in this case, which is fine). | ||
| */ | ||
| SECTIONS | ||
| { | ||
| /* Define a noinit output section and mark it as NOLOAD to prevent | ||
| * putting its contents into the resulting .bin file (which is the | ||
| * default). */ | ||
| .noinit (NOLOAD) : | ||
| { | ||
| /* Ensure output is aligned */ | ||
| . = ALIGN(4); | ||
| /* Define a global _snoinit (and _enoinit below) symbol just in case | ||
| * code wants to iterate over all noinit variables for some reason */ | ||
| _snoinit = .; | ||
| /* Actually import the .noinit and .noinit* import sections */ | ||
| *(.noinit) | ||
| *(.noinit*) | ||
| . = ALIGN(4); | ||
| _enoinit = .; | ||
| } | ||
| } | ||
| INSERT AFTER .bss; |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.