Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions cortex-m-rt/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

- Align the default `_stext` to the alignment required by the `.text` section. Fixes
the lld warning `address (...) of section .text is not a multiple of alignment (...)`.
- Note: `_stext` is not auto-aligned if it's explicitly overridden by the user. It's their responsibility to align it, else the warning will show.

## [v0.7.6]

- Mark `pre_init` as deprecated
Expand Down
6 changes: 5 additions & 1 deletion cortex-m-rt/link.x.in
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ SECTIONS
KEEP(*(.vector_table.interrupts)); /* this is the `__INTERRUPTS` symbol */
} > FLASH

PROVIDE(_stext = ADDR(.vector_table) + SIZEOF(.vector_table));
/* The alignment of .text is the maximum alignment required by its input sections, which
can be more than 4 (e.g. `.p2align` directives inside inline assembly). Since the
start address of .text is set explicitly, the linker won't align it automatically, so do it
here. */
PROVIDE(_stext = ALIGN(ADDR(.vector_table) + SIZEOF(.vector_table), ALIGNOF(.text)));

/* ### .text */
.text _stext :
Expand Down
4 changes: 4 additions & 0 deletions cortex-m-rt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
//! _stext = ORIGIN(FLASH) + 0x40C;
//! ```
//!
//! It is your responsibility to ensure `_stext` is aligned to what the `.text` section requires.
//! This is typically 4 but can ocasionally be higher, such as when using `.p2align` directives inside ASM.
//! If you fail to do so you will see a linker warning like `address (...) of section .text is not a multiple of alignment (...)`.
//!
//! # An example
//!
//! This section presents a minimal application built on top of `cortex-m-rt`. Apart from the
Expand Down
Loading