BPF Attributes (Using the GNU Compiler Collection (GCC))

#### 6.4.2.7 BPF Attributes ¶

These attributes are supported by the BPF back end:

`kernel_helper` ¶

  This attribute applies to functions.

  It indicates that the specified function declaration is a kernel helper. The helper function is passed as an argument to the attribute. Example:

      int bpf_probe_read (void *dst, int size, const void *unsafe_ptr)
        __attribute__ ((kernel_helper (4)));

`preserve_access_index` ¶

  This attribute applies to types.

  The `preserve_access_index` attribute supports BPF Compile Once - Run Everywhere (CO-RE) support. When attached to a `struct` or `union` type definition, it indicates that CO-RE relocation information should be generated for any access to a variable of that type. The behavior is equivalent to manually wrapping every such access with `__builtin_preserve_access_index`.