Finish mkoverlay
This commit is contained in:
parent
d61bf7b95c
commit
68e46d3685
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "mkoverlay"
|
name = "mkoverlay"
|
||||||
version = "0.1.0"
|
version = "1.0.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
|
@ -6,10 +6,10 @@ const OVERLAY_DEFAULT_START:&'static str = "__boot_loader_end"; // < will probab
|
||||||
|
|
||||||
pub fn write(output: &mut Output, overlay_desc: &Vec<OverlaySlot>) -> Result<(), Error> {
|
pub fn write(output: &mut Output, overlay_desc: &Vec<OverlaySlot>) -> Result<(), Error> {
|
||||||
fn create_heap_base(overlay_desc: &Vec<OverlaySlot>) -> String {
|
fn create_heap_base(overlay_desc: &Vec<OverlaySlot>) -> String {
|
||||||
let mut heap_start = format!("MAX({}, {}_end)", OVERLAY_DEFAULT_START, overlay_desc[0].name);
|
let mut heap_start = format!("MAX({}, __{}_end)", OVERLAY_DEFAULT_START, overlay_desc[0].name);
|
||||||
|
|
||||||
for slot in overlay_desc.iter().skip(1) {
|
for slot in overlay_desc.iter().skip(1) {
|
||||||
heap_start = format!("MAX({}_end, {})", slot.name, heap_start);
|
heap_start = format!("MAX(__{}_end, {})", slot.name, heap_start);
|
||||||
}
|
}
|
||||||
heap_start
|
heap_start
|
||||||
}
|
}
|
||||||
|
@ -30,14 +30,14 @@ pub fn write(output: &mut Output, overlay_desc: &Vec<OverlaySlot>) -> Result<(),
|
||||||
|
|
||||||
write_heap_base(output, &create_heap_base(overlay_desc))?;
|
write_heap_base(output, &create_heap_base(overlay_desc))?;
|
||||||
writeln!(output, "")?;
|
writeln!(output, "")?;
|
||||||
writeln!(output, "SECTION {{")?;
|
writeln!(output, "SECTIONS {{")?;
|
||||||
for slot in overlay_desc {
|
for slot in overlay_desc {
|
||||||
writeln!(output, "\t// {}", slot.name)?;
|
writeln!(output, "\t/*{}*/", slot.name)?;
|
||||||
writeln!(output, "\tOVERLAY {} : NOCROSSREFS SUBALIGN(4) {{", get_slot_start_adr(slot))?;
|
writeln!(output, "\tOVERLAY {} : NOCROSSREFS SUBALIGN(4) {{", get_slot_start_adr(slot))?;
|
||||||
for section in &slot.sections {
|
for section in &slot.sections {
|
||||||
writeln!(output, "\t\t.{} {{", section.name)?;
|
writeln!(output, "\t\t.{} {{", section.name)?;
|
||||||
writeln!(output, "\t\t\t__{}_start = .;", section.name)?;
|
writeln!(output, "\t\t\t__{}_start = .;", section.name)?;
|
||||||
section.file_pattern.iter().try_for_each(|patr| writeln!(output, "\t\t\tKEEP({}(.header)", patr))?;
|
section.file_pattern.iter().try_for_each(|patr| writeln!(output, "\t\t\tKEEP({}(.header))", patr))?;
|
||||||
writeln!(output, "\t\t\t__{}_ctor = .;", section.name)?;
|
writeln!(output, "\t\t\t__{}_ctor = .;", section.name)?;
|
||||||
|
|
||||||
for section_type in [".text.startup._GLOBAL__*", ".ctors", ".text.*", ".rodata*", ".sdata*", ".data*", ".sbss*", ".bss*"] {
|
for section_type in [".text.startup._GLOBAL__*", ".ctors", ".text.*", ".rodata*", ".sdata*", ".data*", ".sbss*", ".bss*"] {
|
||||||
|
|
Loading…
Reference in New Issue