This patch set generalizes libbpf's CO-RE relocation support. It not supports field existence relocations, in addition to existing field's byte offset relocation. This patch set upgrades the format of .BTF.ext's relocation record to match latest Clang's format (12 -> 16 bytes). This is not a breaking change, as the previous format hasn't been released yet as part of official Clang version release. Andrii Nakryiko (5): libbpf: update BTF reloc support to latest Clang format libbpf: refactor bpf_object__open APIs to use common opts libbpf: add support for field existance CO-RE relocation libbpf: add BPF-side definitions of supported field relocation kinds selftests/bpf: add field existence CO-RE relocs tests tools/lib/bpf/bpf_core_read.h | 12 ++ tools/lib/bpf/btf.c | 16 +- tools/lib/bpf/btf.h | 4 +- tools/lib/bpf/libbpf.c | 169 +++++++++++------- tools/lib/bpf/libbpf.h | 4 +- tools/lib/bpf/libbpf_internal.h | 25 ++- .../selftests/bpf/prog_tests/core_reloc.c | 76 +++++++- .../bpf/progs/btf__core_reloc_existence.c | 3 + ...ore_reloc_existence___err_wrong_arr_kind.c | 3 + ...loc_existence___err_wrong_arr_value_type.c | 3 + ...ore_reloc_existence___err_wrong_int_kind.c | 3 + ..._core_reloc_existence___err_wrong_int_sz.c | 3 + ...ore_reloc_existence___err_wrong_int_type.c | 3 + ..._reloc_existence___err_wrong_struct_type.c | 3 + .../btf__core_reloc_existence___minimal.c | 3 + .../selftests/bpf/progs/core_reloc_types.h | 56 ++++++ .../bpf/progs/test_core_reloc_existence.c | 79 ++++++++ 17 files changed, 381 insertions(+), 84 deletions(-) create mode 100644 tools/testing/selftests/bpf/progs/btf__core_reloc_existence.c create mode 100644 tools/testing/selftests/bpf/progs/btf__core_reloc_existence___err_wrong_arr_kind.c create mode 100644 tools/testing/selftests/bpf/progs/btf__core_reloc_existence___err_wrong_arr_value_type.c create mode 100644 tools/testing/selftests/bpf/progs/btf__core_reloc_existence___err_wrong_int_kind.c create mode 100644 tools/testing/selftests/bpf/progs/btf__core_reloc_existence___err_wrong_int_sz.c create mode 100644 tools/testing/selftests/bpf/progs/btf__core_reloc_existence___err_wrong_int_type.c create mode 100644 tools/testing/selftests/bpf/progs/btf__core_reloc_existence___err_wrong_struct_type.c create mode 100644 tools/testing/selftests/bpf/progs/btf__core_reloc_existence___minimal.c create mode 100644 tools/testing/selftests/bpf/progs/test_core_reloc_existence.c -- 2.17.1