Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions build_scripts/libtock_layout.ld
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,23 @@ SECTIONS {
*(.ARM.exidx .eh_frame)
}
}

/* Check that the linker thinks our start of flash is page aligned. Now, the
* linker doesn't actually know the size of pages, and for our purposes we don't
* necessarily care that these are aligned, but the linker will generate
* segments which are aligned to what it thinks the page size is. This will
* cause the linker to insert segments _before_ `FLASH_START`, which is not what
* we intend. To ensure more valid-looking .elf files, we check that
* `FLASH_START` is aligned to what the linker thinks is the page size.
*
* If this check fails, it is likely the linker is using a page size of 0x10000
* (based on observations in Aug 2023). The linker argument `-z
* max-page-size=4096` changes this setting. We recommend adding
* `println!("cargo:rustc-link-arg=-zmax-page-size=4096");` to your build.rs
* file to fix this issue.
*/
ASSERT(FLASH_START % CONSTANT(MAXPAGESIZE)==0, "
FLASH_START not page aligned according to the linker.
This will cause issues with generated .elf segments.
The linker is probably assuming too large of a page size.
Add `println!('cargo:rustc-link-arg=-zmax-page-size=4096');` to build.rs to fix.")