浏览代码

btf: Add fixup for PTR types from Rust

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Dave Tucker 3 年之前
父节点
当前提交
877c76043a
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7 0
      aya/src/obj/btf/btf.rs

+ 7 - 0
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)?;