From 788ffb9e17bc3b46b01c314b0bacb8cee408c379 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sat, 9 Sep 2023 19:24:13 -0400 Subject: [PATCH] Fix empty .lcf FORCEACTIVE with symbols_known --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/cmd/dol.rs | 16 +++++++--------- src/util/map.rs | 1 + 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3c1abe0..d5ca81c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -307,7 +307,7 @@ dependencies = [ [[package]] name = "decomp-toolkit" -version = "0.4.0" +version = "0.4.1" dependencies = [ "anyhow", "ar", diff --git a/Cargo.toml b/Cargo.toml index 8c1a82b..76c4996 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "decomp-toolkit" description = "Yet another GameCube/Wii decompilation toolkit." authors = ["Luke Street "] license = "MIT OR Apache-2.0" -version = "0.4.0" +version = "0.4.1" edition = "2021" publish = false build = "build.rs" diff --git a/src/cmd/dol.rs b/src/cmd/dol.rs index 40e41fa..5a26be4 100644 --- a/src/cmd/dol.rs +++ b/src/cmd/dol.rs @@ -441,7 +441,7 @@ fn info(args: InfoArgs) -> Result<()> { type ModuleMap<'a> = BTreeMap; -fn update_symbols(obj: &mut ObjInfo, modules: &ModuleMap<'_>) -> Result<()> { +fn update_symbols(obj: &mut ObjInfo, modules: &ModuleMap<'_>, create_symbols: bool) -> Result<()> { log::debug!("Updating symbols for module {}", obj.module_id); // Find all references to this module from other modules @@ -482,7 +482,7 @@ fn update_symbols(obj: &mut ObjInfo, modules: &ModuleMap<'_>) -> Result<()> { symbol.name ); obj.symbols.flags(symbol_index).set_force_active(true); - } else { + } else if create_symbols { // Add label log::trace!( "Creating label in section {} at {:#010X}", @@ -942,13 +942,11 @@ fn split(args: SplitArgs) -> Result<()> { let module_ids = modules.keys().cloned().collect_vec(); // Create any missing symbols (referenced from other modules) and set FORCEACTIVE - if !config.symbols_known { - update_symbols(&mut obj, &modules)?; - for &module_id in &module_ids { - let (module_config, mut module_obj) = modules.remove(&module_id).unwrap(); - update_symbols(&mut module_obj, &modules)?; - modules.insert(module_id, (module_config, module_obj)); - } + update_symbols(&mut obj, &modules, !config.symbols_known)?; + for &module_id in &module_ids { + let (module_config, mut module_obj) = modules.remove(&module_id).unwrap(); + update_symbols(&mut module_obj, &modules, !config.symbols_known)?; + modules.insert(module_id, (module_config, module_obj)); } // Create relocations to symbols in other modules diff --git a/src/util/map.rs b/src/util/map.rs index d7ca168..327b08d 100644 --- a/src/util/map.rs +++ b/src/util/map.rs @@ -272,6 +272,7 @@ impl StateMachine { if symbol.name.starts_with('.') // ...rodata.0 || symbol.name.starts_with('@') // @123 || symbol.name.starts_with("__sinit") + || symbol.name.contains('$') // local$1234 || symbol_occurrences.get(&symbol.name).cloned().unwrap_or(0) > 1 { symbol.visibility = SymbolVisibility::Local;