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,