From 877c76043a6d313391159523dc40046426800c43 Mon Sep 17 00:00:00 2001 From: Dave Tucker Date: Sat, 18 Dec 2021 20:54:06 +0000 Subject: [PATCH] btf: Add fixup for PTR types from Rust Signed-off-by: Dave Tucker --- aya/src/obj/btf/btf.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/aya/src/obj/btf/btf.rs b/aya/src/obj/btf/btf.rs index 3314cc05..3eced682 100644 --- a/aya/src/obj/btf/btf.rs +++ b/aya/src/obj/btf/btf.rs @@ -386,6 +386,13 @@ impl Btf { // datasec sizes aren't set by llvm // we need to fix them here before loading the btf to the kernel match t { + BtfType::Ptr(mut ty) => { + // Rust emits names for pointer types, which the kernel doesn't like + // While I figure out if this needs fixing in the Kernel or LLVM, we'll + // do a fixup here + ty.name_off = 0; + types.push(BtfType::Ptr(ty)); + } BtfType::DataSec(mut ty, data) => { // Start DataSec Fixups let sec_name = self.type_name(t)?.ok_or(BtfError::InvalidTypeInfo)?;