Parse .line section from DWARF 1.1 format.
(obj_file: &object::File, sections: &mut [Section])
| 732 | |
| 733 | /// Parse .line section from DWARF 1.1 format. |
| 734 | fn parse_line_info_dwarf1(obj_file: &object::File, sections: &mut [Section]) -> Result<()> { |
| 735 | if let Some(section) = obj_file.section_by_name(".line") { |
| 736 | let data = section.uncompressed_data()?; |
| 737 | let mut reader: &[u8] = data.as_ref(); |
| 738 | |
| 739 | let mut text_sections = sections.iter_mut().filter(|s| s.kind == SectionKind::Code); |
| 740 | while !reader.is_empty() { |
| 741 | let mut section_data = reader; |
| 742 | let size = read_u32(obj_file, &mut section_data)? as usize; |
| 743 | if size > reader.len() { |
| 744 | bail!("Line info size {size} exceeds remaining size {}", reader.len()); |
| 745 | } |
| 746 | (section_data, reader) = reader.split_at(size); |
| 747 | |
| 748 | section_data = §ion_data[4..]; // Skip the size field |
| 749 | let base_address = read_u32(obj_file, &mut section_data)? as u64; |
| 750 | let out_section = text_sections.next().context("No text section for line info")?; |
| 751 | while !section_data.is_empty() { |
| 752 | let line_number = read_u32(obj_file, &mut section_data)?; |
| 753 | let statement_pos = read_u16(obj_file, &mut section_data)?; |
| 754 | if statement_pos != 0xFFFF { |
| 755 | log::warn!("Unhandled statement pos {statement_pos}"); |
| 756 | } |
| 757 | let address_delta = read_u32(obj_file, &mut section_data)? as u64; |
| 758 | out_section.line_info.insert(base_address + address_delta, line_number); |
| 759 | } |
| 760 | } |
| 761 | } |
| 762 | Ok(()) |
| 763 | } |
| 764 | |
| 765 | fn parse_line_info_coff( |
| 766 | coff: &object::coff::CoffFile, |
no test coverage detected