mirror of
https://github.com/encounter/decomp-toolkit.git
synced 2025-12-12 14:46:17 +00:00
Overhauled common BSS support & more
- With a map, attempts to detect and handle common BSS automatically - With a map, attempts to detect and correct inflated common BSS bug (< GC 2.7 linker) - Support for "stripped" symbols, sometimes required to match inflated common BSS sizes - Warns on duplicated TUs in a map (other than common BSS) - Automatically adds `comment:0` to `.s` TUs from a map (avoids linker crash)
This commit is contained in:
@@ -739,7 +739,7 @@ fn load_analyze_dol(config: &ProjectConfig) -> Result<AnalyzeResult> {
|
||||
}
|
||||
|
||||
if let Some(map_path) = &config.base.map {
|
||||
apply_map_file(map_path, &mut obj)?;
|
||||
apply_map_file(map_path, &mut obj, config.common_start, config.mw_comment_version)?;
|
||||
dep.push(map_path.clone());
|
||||
}
|
||||
|
||||
@@ -963,7 +963,7 @@ fn load_analyze_rel(config: &ProjectConfig, module_config: &ModuleConfig) -> Res
|
||||
|
||||
let mut dep = vec![module_config.object.clone()];
|
||||
if let Some(map_path) = &module_config.map {
|
||||
apply_map_file(map_path, &mut module_obj)?;
|
||||
apply_map_file(map_path, &mut module_obj, None, None)?;
|
||||
dep.push(map_path.clone());
|
||||
}
|
||||
|
||||
@@ -1451,11 +1451,10 @@ fn diff(args: DiffArgs) -> Result<()> {
|
||||
log::info!("Loading {}", args.elf_file.display());
|
||||
let linked_obj = process_elf(&args.elf_file)?;
|
||||
|
||||
for orig_sym in obj
|
||||
.symbols
|
||||
.iter()
|
||||
.filter(|s| !matches!(s.kind, ObjSymbolKind::Unknown | ObjSymbolKind::Section))
|
||||
{
|
||||
let common_bss = obj.sections.common_bss_start();
|
||||
for orig_sym in obj.symbols.iter().filter(|s| {
|
||||
!matches!(s.kind, ObjSymbolKind::Unknown | ObjSymbolKind::Section) && !s.flags.is_stripped()
|
||||
}) {
|
||||
let Some(orig_section_index) = orig_sym.section else { continue };
|
||||
let orig_section = &obj.sections[orig_section_index];
|
||||
let (linked_section_index, linked_section) =
|
||||
@@ -1474,7 +1473,12 @@ fn diff(args: DiffArgs) -> Result<()> {
|
||||
let mut found = false;
|
||||
if let Some((_, linked_sym)) = linked_sym {
|
||||
if linked_sym.name.starts_with(&orig_sym.name) {
|
||||
if linked_sym.size != orig_sym.size {
|
||||
if linked_sym.size != orig_sym.size &&
|
||||
// TODO validate common symbol sizes
|
||||
// (need to account for inflation bug)
|
||||
matches!(common_bss, Some((idx, addr)) if
|
||||
orig_section_index == idx && orig_sym.address as u32 >= addr)
|
||||
{
|
||||
log::error!(
|
||||
"Expected {} (type {:?}) to have size {:#X}, but found {:#X}",
|
||||
orig_sym.name,
|
||||
|
||||
@@ -57,7 +57,7 @@ pub fn run(args: Args) -> Result<()> {
|
||||
|
||||
fn entries(args: EntriesArgs) -> Result<()> {
|
||||
let file = map_file(&args.map_file)?;
|
||||
let entries = process_map(&mut file.as_reader())?;
|
||||
let entries = process_map(&mut file.as_reader(), None, None)?;
|
||||
match entries.unit_entries.get_vec(&args.unit) {
|
||||
Some(vec) => {
|
||||
println!("Entries for {}:", args.unit);
|
||||
@@ -89,7 +89,7 @@ fn entries(args: EntriesArgs) -> Result<()> {
|
||||
fn symbol(args: SymbolArgs) -> Result<()> {
|
||||
let file = map_file(&args.map_file)?;
|
||||
log::info!("Processing map...");
|
||||
let entries = process_map(&mut file.as_reader())?;
|
||||
let entries = process_map(&mut file.as_reader(), None, None)?;
|
||||
log::info!("Done!");
|
||||
let mut opt_ref: Option<(String, SymbolEntry)> = None;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user