[PATCH openEuler-22.09 004/379] libbpf: Factor out common operations in BTF writing APIs