Fix empty .lcf FORCEACTIVE with symbols_known

This commit is contained in:
Luke Street 2023-09-09 19:24:13 -04:00
parent 6abe6cc277
commit 788ffb9e17
4 changed files with 10 additions and 11 deletions

2
Cargo.lock generated
View File

@ -307,7 +307,7 @@ dependencies = [
[[package]] [[package]]
name = "decomp-toolkit" name = "decomp-toolkit"
version = "0.4.0" version = "0.4.1"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"ar", "ar",

View File

@ -3,7 +3,7 @@ name = "decomp-toolkit"
description = "Yet another GameCube/Wii decompilation toolkit." description = "Yet another GameCube/Wii decompilation toolkit."
authors = ["Luke Street <luke@street.dev>"] authors = ["Luke Street <luke@street.dev>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
version = "0.4.0" version = "0.4.1"
edition = "2021" edition = "2021"
publish = false publish = false
build = "build.rs" build = "build.rs"

View File

@ -441,7 +441,7 @@ fn info(args: InfoArgs) -> Result<()> {
type ModuleMap<'a> = BTreeMap<u32, (&'a ModuleConfig, ObjInfo)>; type ModuleMap<'a> = BTreeMap<u32, (&'a ModuleConfig, ObjInfo)>;
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); log::debug!("Updating symbols for module {}", obj.module_id);
// Find all references to this module from other modules // Find all references to this module from other modules
@ -482,7 +482,7 @@ fn update_symbols(obj: &mut ObjInfo, modules: &ModuleMap<'_>) -> Result<()> {
symbol.name symbol.name
); );
obj.symbols.flags(symbol_index).set_force_active(true); obj.symbols.flags(symbol_index).set_force_active(true);
} else { } else if create_symbols {
// Add label // Add label
log::trace!( log::trace!(
"Creating label in section {} at {:#010X}", "Creating label in section {} at {:#010X}",
@ -942,13 +942,11 @@ fn split(args: SplitArgs) -> Result<()> {
let module_ids = modules.keys().cloned().collect_vec(); let module_ids = modules.keys().cloned().collect_vec();
// Create any missing symbols (referenced from other modules) and set FORCEACTIVE // Create any missing symbols (referenced from other modules) and set FORCEACTIVE
if !config.symbols_known { update_symbols(&mut obj, &modules, !config.symbols_known)?;
update_symbols(&mut obj, &modules)?; for &module_id in &module_ids {
for &module_id in &module_ids { let (module_config, mut module_obj) = modules.remove(&module_id).unwrap();
let (module_config, mut module_obj) = modules.remove(&module_id).unwrap(); update_symbols(&mut module_obj, &modules, !config.symbols_known)?;
update_symbols(&mut module_obj, &modules)?; modules.insert(module_id, (module_config, module_obj));
modules.insert(module_id, (module_config, module_obj));
}
} }
// Create relocations to symbols in other modules // Create relocations to symbols in other modules

View File

@ -272,6 +272,7 @@ impl StateMachine {
if symbol.name.starts_with('.') // ...rodata.0 if symbol.name.starts_with('.') // ...rodata.0
|| symbol.name.starts_with('@') // @123 || symbol.name.starts_with('@') // @123
|| symbol.name.starts_with("__sinit") || symbol.name.starts_with("__sinit")
|| symbol.name.contains('$') // local$1234
|| symbol_occurrences.get(&symbol.name).cloned().unwrap_or(0) > 1 || symbol_occurrences.get(&symbol.name).cloned().unwrap_or(0) > 1
{ {
symbol.visibility = SymbolVisibility::Local; symbol.visibility = SymbolVisibility::Local;