diff --git a/src/util/lcf.rs b/src/util/lcf.rs index b61c6f2..00c18f5 100644 --- a/src/util/lcf.rs +++ b/src/util/lcf.rs @@ -64,7 +64,7 @@ pub fn generate_ldscript_partial( template: Option<&str>, force_active: &[String], ) -> Result { - let section_defs = obj + let mut section_defs = obj .sections .iter() .map(|(_, s)| { @@ -73,6 +73,12 @@ pub fn generate_ldscript_partial( }) .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()); for unit in &obj.link_order { let obj_path = obj_path_for_unit(&unit.name); diff --git a/src/util/rel.rs b/src/util/rel.rs index 09ff650..cfe4501 100644 --- a/src/util/rel.rs +++ b/src/util/rel.rs @@ -774,6 +774,7 @@ where .and_then(|v| v.get(permitted_section_idx)) .cloned() .unwrap_or(section.align() as u32) + .max(1) } let mut align = file