Skip to content

Commit 42dde69

Browse files
committed
rt: automatically align .text by default
1 parent 87d67dc commit 42dde69

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

‎cortex-m-rt/CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
- Align the default `_stext` to the alignment required by the `.text` section. Fixes
11+
the lld warning `address (...) of section .text is not a multiple of alignment (...)`.
12+
- 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.
13+
1014
## [v0.7.6]
1115

1216
- Mark `pre_init` as deprecated

‎cortex-m-rt/link.x.in‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ SECTIONS
8989
KEEP(*(.vector_table.interrupts)); /* this is the `__INTERRUPTS` symbol */
9090
} > FLASH
9191

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

9498
/* ### .text */
9599
.text _stext :

0 commit comments

Comments
 (0)