pointer_reloc.bpf.c 571 B

123456789101112131415161718192021
  1. #include "reloc.h"
  2. struct relocated_struct_with_pointer {
  3. #ifndef TARGET
  4. struct relocated_struct_with_pointer *first;
  5. #endif
  6. struct relocated_struct_with_pointer *second;
  7. #ifdef TARGET
  8. struct relocated_struct_with_pointer *first;
  9. #endif
  10. };
  11. __noinline int pointer_global() {
  12. struct relocated_struct_with_pointer s = {
  13. (struct relocated_struct_with_pointer *)42,
  14. (struct relocated_struct_with_pointer *)21,
  15. };
  16. return set_output((__u64)__builtin_preserve_access_index(s.first));
  17. }
  18. SEC("uprobe") int program(void *ctx) { return pointer_global(); }