Skip to content

Commit

Permalink
Fix read error on objects with no .text section (#67)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
AetiasHax and encounter authored Jun 4, 2024
1 parent fc54e93 commit a5a6a39
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions objdiff-core/src/obj/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,15 +328,10 @@ fn line_info(obj_file: &File<'_>, sections: &mut [ObjSection]) -> Result<()> {
if let Some(program) = unit.line_program.clone() {
let mut text_sections =
obj_file.sections().filter(|s| s.kind() == SectionKind::Text);
let section_index = text_sections
.next()
.ok_or_else(|| anyhow!("Next text section not found for line info"))?
.index()
.0;
let mut lines = sections
.iter_mut()
.find(|s| s.orig_index == section_index)
.map(|s| &mut s.line_info);
let section_index = text_sections.next().map(|s| s.index().0);
let mut lines = section_index.map(|index| {
&mut sections.iter_mut().find(|s| s.orig_index == index).unwrap().line_info
});

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

0 comments on commit a5a6a39

Please sign in to comment.