Skip to content
This repository was archived by the owner on Jan 10, 2025. It is now read-only.

Commit 7a939fd

Browse files
committed
WIP: debug prints
1 parent 48bf08a commit 7a939fd

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/elf.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ impl<C: ContextObject> Executable<C> {
376376
let bytes = if is_memory_aligned(bytes.as_ptr() as usize, HOST_ALIGN) {
377377
bytes
378378
} else {
379+
// debug_assert!(false);
379380
aligned = AlignedMemory::<{ HOST_ALIGN }>::from_slice(bytes);
380381
aligned.as_slice()
381382
};
@@ -404,6 +405,21 @@ impl<C: ContextObject> Executable<C> {
404405
bytes: &[u8],
405406
loader: Arc<BuiltinProgram<C>>,
406407
) -> Result<Self, ElfParserError> {
408+
println!("{:X?}", elf.file_header());
409+
for header in elf.program_header_table().iter() {
410+
println!("{:X?}", header);
411+
}
412+
for header in elf.section_header_table().iter() {
413+
println!(
414+
"{} {:X?}",
415+
elf.section_name(header.sh_name)
416+
.ok()
417+
.and_then(|bytes| std::str::from_utf8(bytes).ok())
418+
.map(|str| str.to_string())
419+
.unwrap(),
420+
header
421+
);
422+
}
407423
const EXPECTED_PROGRAM_HEADERS: [(u32, u32, u64); 4] = [
408424
(PT_LOAD, PF_R | PF_X, 0), // byte code
409425
(PT_LOAD, PF_R, ebpf::MM_RODATA_START), // read only data
@@ -454,6 +470,15 @@ impl<C: ContextObject> Executable<C> {
454470
.saturating_sub(text_section.sh_addr)
455471
.checked_div(ebpf::INSN_SIZE as u64)
456472
.unwrap_or_default() as usize;
473+
println!(
474+
"{} {:X}",
475+
elf.symbol_name(symbol.st_name as Elf64Word)
476+
.ok()
477+
.and_then(|bytes| std::str::from_utf8(bytes).ok())
478+
.map(|str| str.to_string())
479+
.unwrap(),
480+
target_pc
481+
);
457482
function_registry
458483
.register_function(
459484
target_pc as u32,

0 commit comments

Comments
 (0)