Skip to content

Commit

Permalink
WIP: debug prints
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed Oct 7, 2024
1 parent 57ed448 commit 13c0344
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,21 @@ impl<C: ContextObject> Executable<C> {
bytes: &[u8],
loader: Arc<BuiltinProgram<C>>,
) -> Result<Self, ElfParserError> {
println!("{:X?}", elf.file_header());
for header in elf.program_header_table().iter() {
println!("{:X?}", header);
}
for header in elf.section_header_table().iter() {
println!(
"{} {:X?}",
elf.section_name(header.sh_name)
.ok()
.and_then(|bytes| std::str::from_utf8(bytes).ok())
.map(|str| str.to_string())
.unwrap(),
header
);
}
const EXPECTED_PROGRAM_HEADERS: [(u32, u32, u64); 4] = [
(PT_LOAD, PF_R | PF_X, ebpf::MM_PROGRAM_START), // byte code
(PT_LOAD, PF_R, ebpf::MM_PROGRAM_START), // read only data
Expand Down Expand Up @@ -478,6 +493,15 @@ impl<C: ContextObject> Executable<C> {
.saturating_sub(text_section.sh_addr)
.checked_div(ebpf::INSN_SIZE as u64)
.unwrap_or_default() as usize;
println!(
"{} {:X}",
elf.symbol_name(symbol.st_name as Elf64Word)
.ok()
.and_then(|bytes| std::str::from_utf8(bytes).ok())
.map(|str| str.to_string())
.unwrap(),
target_pc
);
function_registry
.register_function(
target_pc as u32,
Expand Down

0 comments on commit 13c0344

Please sign in to comment.