Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 1 addition & 41 deletions vm/src/elf/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,26 +307,10 @@ fn parse_segment_content(
Ok(())
}

/// Represents a precompile description as found in the ELF file.
#[derive(PartialEq, Eq)]
pub struct PrecompileDescription<'a>(u16, &'a str);

impl PartialOrd for PrecompileDescription<'_> {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.0.cmp(&other.0))
}
}

impl Ord for PrecompileDescription<'_> {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.0.cmp(&other.0)
}
}

/// Parses the precompile metadata from the ELF file. This function finds all symbols that indicate
/// pieces of precompile metadata and then ensures that there is a complete contiguous set of unique
/// precompiles labeled 0 though N-1 via heapification.
#[allow(dead_code)]
#[cfg(test)]
fn parse_precompile_metadata(
elf: &ElfBytes<LittleEndian>,
data: &[u8],
Expand Down Expand Up @@ -428,30 +412,6 @@ fn parse_precompile_metadata(
Ok(precompiles)
}

#[allow(dead_code)]
fn debug_segment_info(segment: &ProgramHeader, section_map: &HashMap<&str, (u64, u64)>) {
println!("Program Header Information:");
println!(" Segment Type: 0x{:08x}", segment.p_type);
println!(" File Offset: 0x{:016x}", segment.p_offset);
println!(" Virtual Address: 0x{:016x}", segment.p_vaddr);
println!(" Physical Address: 0x{:016x}", segment.p_paddr);
println!(" File Size: {} bytes", segment.p_filesz);
println!(" Memory Size: {} bytes", segment.p_memsz);
println!(" Flags: 0x{:08x}", segment.p_flags);
println!(" Alignment: 0x{:016x}", segment.p_align);
println!(
" LOADABLE: 0x{:08x} -> 0x{:08x}",
segment.p_offset,
segment.p_offset + segment.p_filesz
);

for (key, (start, end)) in section_map {
if !(*end < segment.p_offset || *start > segment.p_offset + segment.p_filesz) {
println!("Section {}: 0x{:08x} -> 0x{:08x}", key, start, end);
}
}
}

/// Parses the segments of an ELF file and extracts relevant information.
///
/// This function iterates through the LOAD segments of the ELF file, extracting
Expand Down
Loading