Skip to content

Commit a5a6a39

Browse files
AetiasHaxencounter
andauthored
Fix read error on objects with no .text section (#67)
* Fix read error on objects with no .text section * Fix read error on DWARF 1.1 objects * Revert DWARF 1 changes --------- Co-authored-by: Luke Street <[email protected]>
1 parent fc54e93 commit a5a6a39

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

objdiff-core/src/obj/read.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -328,15 +328,10 @@ fn line_info(obj_file: &File<'_>, sections: &mut [ObjSection]) -> Result<()> {
328328
if let Some(program) = unit.line_program.clone() {
329329
let mut text_sections =
330330
obj_file.sections().filter(|s| s.kind() == SectionKind::Text);
331-
let section_index = text_sections
332-
.next()
333-
.ok_or_else(|| anyhow!("Next text section not found for line info"))?
334-
.index()
335-
.0;
336-
let mut lines = sections
337-
.iter_mut()
338-
.find(|s| s.orig_index == section_index)
339-
.map(|s| &mut s.line_info);
331+
let section_index = text_sections.next().map(|s| s.index().0);
332+
let mut lines = section_index.map(|index| {
333+
&mut sections.iter_mut().find(|s| s.orig_index == index).unwrap().line_info
334+
});
340335

341336
let mut rows = program.rows();
342337
while let Some((_header, row)) = rows.next_row()? {

0 commit comments

Comments
 (0)