Fix lcf generation for empty RELs

Also, handle alignment of 0 in rel make
This commit is contained in:
Luke Street 2024-05-19 22:28:14 -06:00
parent bf0d1a823f
commit e1c80655b7
2 changed files with 8 additions and 1 deletions

View File

@ -64,7 +64,7 @@ pub fn generate_ldscript_partial(
template: Option<&str>, template: Option<&str>,
force_active: &[String], force_active: &[String],
) -> Result<String> { ) -> Result<String> {
let section_defs = obj let mut section_defs = obj
.sections .sections
.iter() .iter()
.map(|(_, s)| { .map(|(_, s)| {
@ -73,6 +73,12 @@ pub fn generate_ldscript_partial(
}) })
.join("\n "); .join("\n ");
// Some RELs have no entry point (`.text` was stripped) so mwld requires at least an empty
// `.init` section to be present in the linker script, for some reason.
if obj.entry.is_none() {
section_defs = format!(".init :{{}}\n {}", section_defs);
}
let mut force_files = Vec::with_capacity(obj.link_order.len()); let mut force_files = Vec::with_capacity(obj.link_order.len());
for unit in &obj.link_order { for unit in &obj.link_order {
let obj_path = obj_path_for_unit(&unit.name); let obj_path = obj_path_for_unit(&unit.name);

View File

@ -774,6 +774,7 @@ where
.and_then(|v| v.get(permitted_section_idx)) .and_then(|v| v.get(permitted_section_idx))
.cloned() .cloned()
.unwrap_or(section.align() as u32) .unwrap_or(section.align() as u32)
.max(1)
} }
let mut align = file let mut align = file