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 11, 2024
1 parent 9c2959c commit 1441f46
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ impl<C: ContextObject> Executable<C> {
let bytes = if is_memory_aligned(bytes.as_ptr() as usize, HOST_ALIGN) {
bytes
} else {
// debug_assert!(false);
aligned = AlignedMemory::<{ HOST_ALIGN }>::from_slice(bytes);
aligned.as_slice()
};
Expand Down Expand Up @@ -405,6 +406,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, 0), // byte code
(PT_LOAD, PF_R, ebpf::MM_PROGRAM_START), // read only data
Expand Down Expand Up @@ -492,6 +508,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 1441f46

Please sign in to comment.