• Alan Maguire's avatar
    libbpf: Split BTF relocation · 19e00c89
    Alan Maguire authored
    Map distilled base BTF type ids referenced in split BTF and their
    references to the base BTF passed in, and if the mapping succeeds,
    reparent the split BTF to the base BTF.
    
    Relocation is done by first verifying that distilled base BTF
    only consists of named INT, FLOAT, ENUM, FWD, STRUCT and
    UNION kinds; then we sort these to speed lookups.  Once sorted,
    the base BTF is iterated, and for each relevant kind we check
    for an equivalent in distilled base BTF.  When found, the
    mapping from distilled -> base BTF id and string offset is recorded.
    In establishing mappings, we need to ensure we check STRUCT/UNION
    size when the STRUCT/UNION is embedded in a split BTF STRUCT/UNION,
    and when duplicate names exist for the same STRUCT/UNION.  Otherwise
    size is ignored in matching STRUCT/UNIONs.
    
    Once all mappings are established, we can update type ids
    and string offsets in split BTF and reparent it to the new base.
    Signed-off-by: default avatarAlan Maguire <alan.maguire@oracle.com>
    Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
    Acked-by: default avatarEduard Zingerman <eddyz87@gmail.com>
    Link: https://lore.kernel.org/bpf/20240613095014.357981-4-alan.maguire@oracle.com
    19e00c89
Build 252 Bytes