mirror of
https://github.com/encounter/objdiff.git
synced 2026-07-10 12:18:36 -07:00
Fix PS2 MWCC line number parsing (#363)
This commit is contained in:
@@ -732,11 +732,11 @@ fn parse_line_info(
|
||||
|
||||
/// Parse .line section from DWARF 1.1 format.
|
||||
fn parse_line_info_dwarf1(obj_file: &object::File, sections: &mut [Section]) -> Result<()> {
|
||||
if let Some(section) = obj_file.section_by_name(".line") {
|
||||
let mut text_sections = sections.iter_mut().filter(|s| s.kind == SectionKind::Code);
|
||||
for section in obj_file.sections().filter(|s| s.name().is_ok_and(|n| n == ".line")) {
|
||||
let data = section.uncompressed_data()?;
|
||||
let mut reader: &[u8] = data.as_ref();
|
||||
|
||||
let mut text_sections = sections.iter_mut().filter(|s| s.kind == SectionKind::Code);
|
||||
while !reader.is_empty() {
|
||||
let mut section_data = reader;
|
||||
let size = read_u32(obj_file, &mut section_data)? as usize;
|
||||
|
||||
@@ -80,3 +80,25 @@ fn ido_mdebug_line_numbers() {
|
||||
assert_eq!(text_section.line_info.get(&56), Some(&9));
|
||||
assert_eq!(text_section.line_info.len(), 66);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "mips")]
|
||||
fn mwcc_dwarf1_line_numbers_multiple_functions() {
|
||||
let diff_config = diff::DiffObjConfig::default();
|
||||
let obj = obj::read::parse(
|
||||
include_object!("data/mips/mwcc_lines_example.o"),
|
||||
&diff_config,
|
||||
diff::DiffSide::Base,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
for function_name in ["foo", "bar"] {
|
||||
let symbol = obj.symbols.iter().find(|s| s.name == function_name).unwrap();
|
||||
let section_idx = symbol.section.unwrap();
|
||||
let section = &obj.sections[section_idx];
|
||||
assert!(
|
||||
section.line_info.values().any(|line| *line > 0),
|
||||
"{function_name} should have valid line numbers"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user