Bläddra i källkod

btf: Add fixup for PTR types from Rust

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Dave Tucker 3 år sedan
förälder
incheckning
877c760
1 ändrade filer med 7 tillägg och 0 borttagningar
  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)?;