github.com/cilium/ebpf@v0.15.1-0.20240517100537-8079b37aa138/btf/testdata/relocs_enum.c (about)

     1  #include "bpf_core_read.h"
     2  
     3  enum cgroup_subsys_id {
     4  	cpuset_cgrp_id,
     5  	cpuset_cgrp_id_lublub,
     6  	CGROUP_SUBSYS_COUNT,
     7  };
     8  
     9  #define __section(NAME) __attribute__((section(NAME), used))
    10  
    11  __section("socket/core_ld64imm") int core_ld64imm() {
    12  	if (bpf_core_enum_value_exists(enum cgroup_subsys_id, cpuset_cgrp_id_lublub)) {
    13  		__attribute__((unused)) const volatile int val = bpf_core_enum_value(enum cgroup_subsys_id, cpuset_cgrp_id_lublub);
    14  	}
    15  	return 0;
    16  }