From f54f9c4643494973a6a7143742217de01820bbd5 Mon Sep 17 00:00:00 2001 From: qiuchengxuan Date: Mon, 1 Mar 2021 23:13:18 +0800 Subject: [PATCH] Add support for customized text start address --- config/src/config.rs | 8 ++++++++ src/templates/layout.ld.hbs | 8 +++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/config/src/config.rs b/config/src/config.rs index 8eba894..9e66549 100644 --- a/config/src/config.rs +++ b/config/src/config.rs @@ -12,6 +12,7 @@ pub struct Config { pub memory: Memory, pub heap: Heap, pub linker: Linker, + pub text: Option, pub probe: Option, pub log: Option, } @@ -71,6 +72,13 @@ pub struct HeapPool { pub capacity: u32, } +#[non_exhaustive] +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(rename_all = "kebab-case")] +pub struct Text { + pub start: u32, +} + #[non_exhaustive] #[derive(Clone, Debug, Serialize, Deserialize)] #[serde(rename_all = "kebab-case")] diff --git a/src/templates/layout.ld.hbs b/src/templates/layout.ld.hbs index 58c751a..753cd0a 100644 --- a/src/templates/layout.ld.hbs +++ b/src/templates/layout.ld.hbs @@ -30,7 +30,13 @@ SECTIONS } > FLASH {{~ /if}} - .text : +{{~ #if config.text.start }} + _stext = {{addr config.text.start}}; +{{~ else}} + _stext = ADDR(.vtable) + SIZEOF(.vtable); +{{~ /if}} + + .text _stext: { *(.text.reset); *(.text.*);