[PATCH openEuler-22.09 v2 003/391] libbpf: Factor out common operations in BTF writing APIs