Promote BTF loading failure to error on BTF relocs

reviewable/pr1251/r58
Tamir Duberstein 7 days ago
parent b2fd9493a8
commit 3ade19b869
No known key found for this signature in database

@ -942,8 +942,8 @@ impl BtfExt {
self.info_data(self.header.line_info_off, self.header.line_info_len)
}
pub(crate) fn relocations(&self) -> impl Iterator<Item = &(u32, Vec<Relocation>)> {
self.relocations.iter()
pub(crate) fn relocations(&self) -> &[(u32, Vec<Relocation>)] {
self.relocations.as_slice()
}
pub(crate) fn func_info_rec_size(&self) -> usize {

@ -529,6 +529,13 @@ impl Object {
}
}
/// Returns true if this object contains CO-RE relocations.
pub fn has_btf_relocations(&self) -> bool {
self.btf_ext
.as_ref()
.is_some_and(|ext| !ext.relocations().is_empty())
}
/// Patches map data
pub fn patch_map_data(
&mut self,

@ -436,6 +436,10 @@ impl<'a> EbpfLoader<'a> {
}
}
if obj.has_btf_relocations() {
return Err(EbpfError::BtfError(err));
}
warn!("object BTF couldn't be loaded in the kernel: {err}");
None

@ -8784,6 +8784,7 @@ pub aya_obj::obj::Object::programs: std::collections::hash::map::HashMap<alloc::
impl aya_obj::Object
pub fn aya_obj::Object::fixup_and_sanitize_btf(&mut self, features: &aya_obj::btf::BtfFeatures) -> core::result::Result<core::option::Option<&aya_obj::btf::Btf>, aya_obj::btf::BtfError>
impl aya_obj::Object
pub fn aya_obj::Object::has_btf_relocations(&self) -> bool
pub fn aya_obj::Object::parse(data: &[u8]) -> core::result::Result<Self, aya_obj::ParseError>
pub fn aya_obj::Object::patch_map_data(&mut self, globals: std::collections::hash::map::HashMap<&str, (&[u8], bool)>) -> core::result::Result<(), aya_obj::ParseError>
pub fn aya_obj::Object::sanitize_functions(&mut self, features: &aya_obj::Features)
@ -9646,6 +9647,7 @@ pub aya_obj::Object::programs: std::collections::hash::map::HashMap<alloc::strin
impl aya_obj::Object
pub fn aya_obj::Object::fixup_and_sanitize_btf(&mut self, features: &aya_obj::btf::BtfFeatures) -> core::result::Result<core::option::Option<&aya_obj::btf::Btf>, aya_obj::btf::BtfError>
impl aya_obj::Object
pub fn aya_obj::Object::has_btf_relocations(&self) -> bool
pub fn aya_obj::Object::parse(data: &[u8]) -> core::result::Result<Self, aya_obj::ParseError>
pub fn aya_obj::Object::patch_map_data(&mut self, globals: std::collections::hash::map::HashMap<&str, (&[u8], bool)>) -> core::result::Result<(), aya_obj::ParseError>
pub fn aya_obj::Object::sanitize_functions(&mut self, features: &aya_obj::Features)

Loading…
Cancel
Save