From 08e993dde3c902d13203b7855783c772b6612436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Medina?= Date: Thu, 18 May 2023 20:32:40 -0700 Subject: [PATCH] do not attempt to load a BTF object that has no types --- aya-obj/src/btf/btf.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/aya-obj/src/btf/btf.rs b/aya-obj/src/btf/btf.rs index fd24d93d..93c57cf5 100644 --- a/aya-obj/src/btf/btf.rs +++ b/aya-obj/src/btf/btf.rs @@ -210,6 +210,11 @@ impl Btf { } } + pub(crate) fn is_empty(&self) -> bool { + // the first one is awlays BtfType::Unknown + self.types.types.len() < 2 + } + pub(crate) fn types(&self) -> impl Iterator { self.types.types.iter() } @@ -628,7 +633,10 @@ impl Object { &mut self, features: &BtfFeatures, ) -> Result, BtfError> { - if let Some(ref mut obj_btf) = self.btf { + if let Some(ref mut obj_btf) = &mut self.btf { + if obj_btf.is_empty() { + return Ok(None); + } // fixup btf obj_btf.fixup_and_sanitize( &self.section_sizes,