Skip to content

Commit 1f303e7

Browse files
authored
Update parser.rs
1 parent f2ad126 commit 1f303e7

File tree

1 file changed

+1
-28
lines changed

1 file changed

+1
-28
lines changed

vm/src/elf/parser.rs

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ impl Ord for PrecompileDescription<'_> {
326326
/// Parses the precompile metadata from the ELF file. This function finds all symbols that indicate
327327
/// pieces of precompile metadata and then ensures that there is a complete contiguous set of unique
328328
/// precompiles labeled 0 though N-1 via heapification.
329-
#[allow(dead_code)]
329+
#[cfg(test)]
330330
fn parse_precompile_metadata(
331331
elf: &ElfBytes<LittleEndian>,
332332
data: &[u8],
@@ -428,30 +428,6 @@ fn parse_precompile_metadata(
428428
Ok(precompiles)
429429
}
430430

431-
#[allow(dead_code)]
432-
fn debug_segment_info(segment: &ProgramHeader, section_map: &HashMap<&str, (u64, u64)>) {
433-
println!("Program Header Information:");
434-
println!(" Segment Type: 0x{:08x}", segment.p_type);
435-
println!(" File Offset: 0x{:016x}", segment.p_offset);
436-
println!(" Virtual Address: 0x{:016x}", segment.p_vaddr);
437-
println!(" Physical Address: 0x{:016x}", segment.p_paddr);
438-
println!(" File Size: {} bytes", segment.p_filesz);
439-
println!(" Memory Size: {} bytes", segment.p_memsz);
440-
println!(" Flags: 0x{:08x}", segment.p_flags);
441-
println!(" Alignment: 0x{:016x}", segment.p_align);
442-
println!(
443-
" LOADABLE: 0x{:08x} -> 0x{:08x}",
444-
segment.p_offset,
445-
segment.p_offset + segment.p_filesz
446-
);
447-
448-
for (key, (start, end)) in section_map {
449-
if !(*end < segment.p_offset || *start > segment.p_offset + segment.p_filesz) {
450-
println!("Section {key}: 0x{start:08x} -> 0x{end:08x}");
451-
}
452-
}
453-
}
454-
455431
/// Parses the segments of an ELF file and extracts relevant information.
456432
///
457433
/// This function iterates through the LOAD segments of the ELF file, extracting
@@ -489,9 +465,6 @@ pub fn parse_segments(elf: &ElfBytes<LittleEndian>, data: &[u8]) -> Result<Parse
489465
.iter()
490466
.filter(|x| x.p_type == abi::PT_LOAD || x.p_type == abi::PT_NOTE)
491467
{
492-
// TODO: Uncomment this when we need to debug the segment info
493-
// #[cfg(debug_assertions)]
494-
// debug_segment_info(&segment, &section_map);
495468
// We assume the executable section (PF_X or .text section) is the first executable segment,
496469
// thus it has the lower address, we use this information to figure out the base address of the program
497470
if (segment.p_flags & abi::PF_X) != 0 && base_address > segment.p_vaddr {

0 commit comments

Comments
 (0)