Skip to content

Commit 43d602b

Browse files
committed
Warn and continue on missing REL relocation target
Allows Epic Mickey's broken REL to analyze without failing. Fixes #124
1 parent af8595e commit 43d602b

1 file changed

Lines changed: 22 additions & 18 deletions

File tree

src/cmd/dol.rs

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -667,18 +667,17 @@ fn update_symbols(
667667
}
668668
}
669669

670-
let (target_section_index, target_section) = obj
670+
let Some((target_section_index, target_section)) = obj
671671
.sections
672672
.get_elf_index(rel_reloc.target_section as SectionIndex)
673-
.ok_or_else(|| {
674-
anyhow!(
675-
"Failed to locate REL section {} in module ID {}: source module {}, {:?}",
676-
rel_reloc.target_section,
677-
obj.module_id,
678-
source_module_id,
679-
rel_reloc
680-
)
681-
})?;
673+
else {
674+
log::warn!(
675+
"Missing relocation target section {} in module {}; skipping",
676+
rel_reloc.target_section,
677+
obj.module_id,
678+
);
679+
continue;
680+
};
682681

683682
if let Some((symbol_index, symbol)) = obj.symbols.for_relocation(
684683
SectionAddress::new(target_section_index, rel_reloc.addend),
@@ -762,15 +761,20 @@ fn create_relocations(
762761
anyhow!("Failed to locate DOL section at {:#010X}", rel_reloc.addend)
763762
})?
764763
} else {
765-
target_obj.sections.get_elf_index(rel_reloc.target_section as SectionIndex).ok_or_else(
766-
|| {
767-
anyhow!(
768-
"Failed to locate module {} section {}",
764+
match target_obj
765+
.sections
766+
.get_elf_index(rel_reloc.target_section as SectionIndex)
767+
{
768+
Some(v) => v,
769+
None => {
770+
log::warn!(
771+
"Missing relocation target section {} in module {}; skipping",
772+
rel_reloc.target_section,
769773
rel_reloc.module_id,
770-
rel_reloc.target_section
771-
)
772-
},
773-
)?
774+
);
775+
continue;
776+
}
777+
}
774778
};
775779

776780
let Some((symbol_index, symbol)) = target_obj.symbols.for_relocation(

0 commit comments

Comments
 (0)