(&mut self)
| 627 | } |
| 628 | |
| 629 | fn parse_kcore(&mut self) -> Result<()> { |
| 630 | let mut buffer = vec![0u8; 1 * 0x100000]; |
| 631 | self.kcore.read(&mut buffer)?; |
| 632 | |
| 633 | // Support for x64/ARM64 version of Linux only. |
| 634 | let in_data = &*buffer; |
| 635 | let in_elf = FileHeader64::<Endianness>::parse(in_data)?; |
| 636 | let endian = in_elf.endian()?; |
| 637 | let in_segments = in_elf.program_headers(endian, in_data)?; |
| 638 | |
| 639 | // Step 1: Parse /proc/kcore to look for any missing MemoryRange through the PHdrs. |
| 640 | // We filter out the invalid PT_LOAD. |
| 641 | self.associate_mem_ranges(endian, &in_segments)?; |
| 642 | |
| 643 | // Step 2.1 - Check if VMCOREINFO is present. This happens with old Linux OSes. |
| 644 | let is_vmci_present = self.is_vmcoreinfo_present(endian, &in_segments, in_data); |
| 645 | |
| 646 | // Step 2.2 - VMCOREINFO is missing so we need to add it manually. |
| 647 | if is_vmci_present == false { |
| 648 | info!("VMCOREINFO is absent from /proc/kcore."); |
| 649 | info!("Reading vmcoreinfo_data..."); |
| 650 | self.read_vmcoreinfo()?; |
| 651 | } else { |
| 652 | info!("VMCOREINFO is present in /proc/kcore."); |
| 653 | } |
| 654 | |
| 655 | // Step 3 - We are building a new ELF file header. |
| 656 | // This means, that we: |
| 657 | // - Add the VMCOREINFO PT_NOTE if it's not present. |
| 658 | // - Keep only the useful PT_LOAD headers, with the correct p_offset. |
| 659 | let out_header = self.build_elf_header(endian, |
| 660 | &in_elf, |
| 661 | &in_segments, |
| 662 | in_data, |
| 663 | in_elf.is_class_64())?; |
| 664 | self.out_header = Some(out_header); |
| 665 | |
| 666 | Ok(()) |
| 667 | } |
| 668 | |
| 669 | #[allow(dead_code)] |
| 670 | fn display(&self) { |
no test coverage detected