Skip to content
Snippets Groups Projects
Select Git revision
  • 951bb64621b8139c0cd99dcadc13e6510c08aa73
  • vme-testing default
  • ci-test
  • master
  • remoteproc
  • am625-sk-ov5640
  • pcal6534-upstreaming
  • lps22df-upstreaming
  • msc-upstreaming
  • imx8mp
  • iio/noa1305
  • vme-next
  • vme-next-4.14-rc4
  • v4.14-rc4
  • v4.14-rc3
  • v4.14-rc2
  • v4.14-rc1
  • v4.13
  • vme-next-4.13-rc7
  • v4.13-rc7
  • v4.13-rc6
  • v4.13-rc5
  • v4.13-rc4
  • v4.13-rc3
  • v4.13-rc2
  • v4.13-rc1
  • v4.12
  • v4.12-rc7
  • v4.12-rc6
  • v4.12-rc5
  • v4.12-rc4
  • v4.12-rc3
32 results

btf.c

Blame
  • btf.c 144.47 KiB
    /* SPDX-License-Identifier: GPL-2.0 */
    /* Copyright (c) 2018 Facebook */
    
    #include <uapi/linux/btf.h>
    #include <uapi/linux/bpf.h>
    #include <uapi/linux/bpf_perf_event.h>
    #include <uapi/linux/types.h>
    #include <linux/seq_file.h>
    #include <linux/compiler.h>
    #include <linux/ctype.h>
    #include <linux/errno.h>
    #include <linux/slab.h>
    #include <linux/anon_inodes.h>
    #include <linux/file.h>
    #include <linux/uaccess.h>
    #include <linux/kernel.h>
    #include <linux/idr.h>
    #include <linux/sort.h>
    #include <linux/bpf_verifier.h>
    #include <linux/btf.h>
    #include <linux/btf_ids.h>
    #include <linux/skmsg.h>
    #include <linux/perf_event.h>
    #include <linux/bsearch.h>
    #include <net/sock.h>
    
    /* BTF (BPF Type Format) is the meta data format which describes
     * the data types of BPF program/map.  Hence, it basically focus
     * on the C programming language which the modern BPF is primary
     * using.
     *
     * ELF Section:
     * ~~~~~~~~~~~
     * The BTF data is stored under the ".BTF" ELF section
     *
     * struct btf_type:
     * ~~~~~~~~~~~~~~~
     * Each 'struct btf_type' object describes a C data type.
     * Depending on the type it is describing, a 'struct btf_type'
     * object may be followed by more data.  F.e.
     * To describe an array, 'struct btf_type' is followed by
     * 'struct btf_array'.
     *
     * 'struct btf_type' and any extra data following it are
     * 4 bytes aligned.
     *
     * Type section:
     * ~~~~~~~~~~~~~
     * The BTF type section contains a list of 'struct btf_type' objects.
     * Each one describes a C type.  Recall from the above section
     * that a 'struct btf_type' object could be immediately followed by extra
     * data in order to desribe some particular C types.
     *
     * type_id:
     * ~~~~~~~
     * Each btf_type object is identified by a type_id.  The type_id
     * is implicitly implied by the location of the btf_type object in
     * the BTF type section.  The first one has type_id 1.  The second
     * one has type_id 2...etc.  Hence, an earlier btf_type has
     * a smaller type_id.
     *
     * A btf_type object may refer to another btf_type object by using
     * type_id (i.e. the "type" in the "struct btf_type").
     *
     * NOTE that we cannot assume any reference-order.
     * A btf_type object can refer to an earlier btf_type object
     * but it can also refer to a later btf_type object.
     *
     * For example, to describe "const void *".  A btf_type
     * object describing "const" may refer to another btf_type