struct_flavors_reloc.bpf.c 522 B

123456789101112131415161718
  1. #include "reloc.h"
  2. #include "struct_with_scalars.h"
  3. __noinline int struct_flavors_global() {
  4. struct relocated_struct_with_scalars s = {1, 2, 3};
  5. #ifndef TARGET
  6. if (bpf_core_field_exists(s.a)) {
  7. return set_output(__builtin_preserve_access_index(s.a));
  8. #else
  9. if (bpf_core_field_exists(s.d)) {
  10. return set_output(__builtin_preserve_access_index(s.d));
  11. #endif
  12. } else {
  13. return set_output(__builtin_preserve_access_index(s.c));
  14. }
  15. }
  16. SEC("uprobe") int program(void *ctx) { return struct_flavors_global(); }