Skip to content

Commit a65e357

Browse files
committed
build.rs: log BPF ELF first 16 bytes to diagnose aya parse error
1 parent e17a656 commit a65e357

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

crates/modules/fast-path/build.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,21 @@ fn main() {
106106
Some(built) if built.exists() => {
107107
std::fs::copy(&built, &obj_out).expect("stage BPF ELF into OUT_DIR");
108108
println!("cargo::rustc-cfg=packetframe_bpf_built");
109-
println!("cargo::warning=BPF ELF built from {}", built.display());
109+
// Debug: dump the first 16 bytes + size. ELF magic
110+
// is 7f 45 4c 46 ("..ELF"); anything else is not a
111+
// parseable ELF and aya will reject it.
112+
if let Ok(bytes) = std::fs::read(&built) {
113+
let head: Vec<String> =
114+
bytes.iter().take(16).map(|b| format!("{b:02x}")).collect();
115+
println!(
116+
"cargo::warning=BPF ELF built from {} ({} bytes); first 16: {}",
117+
built.display(),
118+
bytes.len(),
119+
head.join(" ")
120+
);
121+
} else {
122+
println!("cargo::warning=BPF ELF built from {}", built.display());
123+
}
110124
}
111125
Some(built) => {
112126
forward_output(&[], &out.stderr);

0 commit comments

Comments
 (0)