• Andrii Nakryiko's avatar
    bpftool: Dump more info about DATASEC members · 5b438f01
    Andrii Nakryiko authored
    Dump succinct information for each member of DATASEC: its kinds and name. This
    is extremely helpful to see at a quick glance what is inside each DATASEC of
    a given BTF. Without this, one has to jump around BTF data to just find out
    the name of a VAR or FUNC. DATASEC's var_secinfo member is special in that
    regard because it doesn't itself contain the name of the member, delegating
    that to the referenced VAR and FUNC kinds. Other kinds, like
    STRUCT/UNION/FUNC/ENUM, encode member names directly and thus are clearly
    identifiable in BTF dump.
    
    The new output looks like this:
    
    [35] DATASEC '.bss' size=0 vlen=6
            type_id=8 offset=0 size=4 (VAR 'input_bss1')
            type_id=13 offset=0 size=4 (VAR 'input_bss_weak')
            type_id=16 offset=0 size=4 (VAR 'output_bss1')
            type_id=17 offset=0 size=4 (VAR 'output_data1')
            type_id=18 offset=0 size=4 (VAR 'output_rodata1')
            type_id=20 offset=0 size=8 (VAR 'output_sink1')
    [36] DATASEC '.data' size=0 vlen=2
            type_id=9 offset=0 size=4 (VAR 'input_data1')
            type_id=14 offset=0 size=4 (VAR 'input_data_weak')
    [37] DATASEC '.kconfig' size=0 vlen=2
            type_id=25 offset=0 size=4 (VAR 'LINUX_KERNEL_VERSION')
            type_id=28 offset=0 size=1 (VAR 'CONFIG_BPF_SYSCALL')
    [38] DATASEC '.ksyms' size=0 vlen=1
            type_id=30 offset=0 size=1 (VAR 'bpf_link_fops')
    [39] DATASEC '.rodata' size=0 vlen=2
            type_id=12 offset=0 size=4 (VAR 'input_rodata1')
            type_id=15 offset=0 size=4 (VAR 'input_rodata_weak')
    [40] DATASEC 'license' size=0 vlen=1
            type_id=24 offset=0 size=4 (VAR 'LICENSE')
    Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
    Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    Acked-by: default avatarYonghong Song <yhs@fb.com>
    Link: https://lore.kernel.org/bpf/20210423181348.1801389-3-andrii@kernel.org
    5b438f01
btf.c 22 KB