Fix lcf generation for missing .sbss2

This commit is contained in:
Luke Street 2023-08-03 18:57:18 -04:00
parent bd0422e92a
commit 26a3021f45
2 changed files with 8 additions and 2 deletions

View File

@ -11,8 +11,8 @@ SECTIONS
.stack ALIGN(0x100):{} .stack ALIGN(0x100):{}
} > text } > text
_stack_addr = (_f_sbss2 + SIZEOF(.sbss2) + $STACKSIZE + 0x7) & ~0x7; _stack_end = $LAST_SECTION_SYMBOL + SIZEOF($LAST_SECTION_NAME);
_stack_end = _f_sbss2 + SIZEOF(.sbss2); _stack_addr = (_stack_end + $STACKSIZE + 0x7) & ~0x7;
_db_stack_addr = (_stack_addr + 0x2000); _db_stack_addr = (_stack_addr + 0x2000);
_db_stack_end = _stack_addr; _db_stack_end = _stack_addr;
__ArenaLo = (_db_stack_addr + 0x1f) & ~0x1f; __ArenaLo = (_db_stack_addr + 0x1f) & ~0x1f;

View File

@ -23,8 +23,14 @@ pub fn generate_ldscript(obj: &ObjInfo) -> Result<String> {
force_files.push(obj_path.file_name().unwrap().to_str().unwrap().to_string()); force_files.push(obj_path.file_name().unwrap().to_str().unwrap().to_string());
} }
// Hack to handle missing .sbss2 section... what's the proper way?
let last_section_name = obj.sections.last().unwrap().name.clone();
let last_section_symbol = format!("_f_{}", last_section_name.trim_start_matches('.'));
let out = include_str!("../../assets/ldscript.lcf") let out = include_str!("../../assets/ldscript.lcf")
.replacen("$SECTIONS", &section_defs, 1) .replacen("$SECTIONS", &section_defs, 1)
.replace("$LAST_SECTION_SYMBOL", &last_section_symbol)
.replace("$LAST_SECTION_NAME", &last_section_name)
.replacen("$STACKSIZE", &format!("{:#X}", stack_size), 1) .replacen("$STACKSIZE", &format!("{:#X}", stack_size), 1)
.replacen("$FORCEFILES", &force_files.join("\n "), 1); .replacen("$FORCEFILES", &force_files.join("\n "), 1);
Ok(out) Ok(out)