Share bss section with planschi section
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "mkoverlay"
|
||||
version = "1.1.1"
|
||||
version = "1.5.0"
|
||||
edition = "2021"
|
||||
|
||||
[profile.release]
|
||||
|
@@ -1,9 +1,7 @@
|
||||
use super::super::types::{OverlayDesc, OverlaySection};
|
||||
use tool_helper::{Error, format_if_error, Output};
|
||||
use tool_helper::{Error, Output};
|
||||
use std::io::Write;
|
||||
|
||||
const OVERLAY_DEFAULT_START:&'static str = "__planschi_start"; // < will probably be "__boot_loader_start" later
|
||||
|
||||
macro_rules! section_end_name_template {
|
||||
() => {
|
||||
"__{}_end"
|
||||
@@ -11,25 +9,8 @@ macro_rules! section_end_name_template {
|
||||
}
|
||||
|
||||
pub fn write(output: &mut Output, overlay_desc: &OverlayDesc) -> Result<(), Error> {
|
||||
fn create_heap_base(overlay_desc: &OverlayDesc) -> String {
|
||||
let (first_entry, additional_slots_iter) = (&overlay_desc[0].name, overlay_desc.iter().skip(1));
|
||||
|
||||
let mut heap_start = format!(concat!("MAX({}, ", section_end_name_template!(), ")"), OVERLAY_DEFAULT_START, first_entry);
|
||||
for slot in additional_slots_iter {
|
||||
heap_start = format!(concat!("MAX(", section_end_name_template!(), ", {})"), slot.name, heap_start);
|
||||
}
|
||||
heap_start
|
||||
}
|
||||
|
||||
if overlay_desc.is_empty() {
|
||||
write_heap_base(output, OVERLAY_DEFAULT_START)?;
|
||||
}
|
||||
|
||||
else {
|
||||
write_heap_base(output, &create_heap_base(&overlay_desc))?;
|
||||
}
|
||||
|
||||
let mut slot_start_adr = format!(section_end_name_template!(), "bss");
|
||||
let has_overlays = !overlay_desc.is_empty();
|
||||
let mut slot_start_adr = format!(section_end_name_template!(), "engine_bss");
|
||||
|
||||
writeln!(output, "")?;
|
||||
writeln!(output, "SECTIONS {{")?;
|
||||
@@ -38,22 +19,25 @@ pub fn write(output: &mut Output, overlay_desc: &OverlayDesc) -> Result<(), Erro
|
||||
writeln!(output, "\t/*{}*/", slot.name)?;
|
||||
writeln!(output, "\tOVERLAY {} : NOCROSSREFS SUBALIGN(4) {{", slot_start_adr)?;
|
||||
write_section(output, &slot.sections, false)?;
|
||||
writeln!(output, "\t}}")?;
|
||||
writeln!(output, "\t}} > ram")?;
|
||||
writeln!(output, "\t. = ALIGN(4);")?;
|
||||
writeln!(output, concat!("\t", section_end_name_template!(), " = .;"), slot.name)?;
|
||||
writeln!(output, "")?;
|
||||
|
||||
slot_start_adr = format!(section_end_name_template!(), slot.name);
|
||||
}
|
||||
|
||||
if has_overlays {
|
||||
writeln!(output, "\t__persistent_overlay_end = .;")?;
|
||||
}
|
||||
|
||||
else {
|
||||
writeln!(output, "\t__persistent_overlay_end =__engine_bss_end;")?;
|
||||
}
|
||||
writeln!(output, "}}")?;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
fn write_heap_base(output: &mut Output, heap_base: &str) -> Result<(), Error> {
|
||||
format_if_error!(writeln!(output, "__heap_base = {};", heap_base), "Writing default LD Script failed with: {error_text}")?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn write_section(output: &mut Output, sections: &Vec<OverlaySection>, add_end_name: bool) -> Result<(), Error> {
|
||||
for section in sections {
|
||||
writeln!(output, "\t\t.{} {{", section.name)?;
|
||||
|
Reference in New Issue
Block a user