text_64_64_reloc.c 538 B

12345678910111213141516171819202122232425262728
  1. #include <linux/bpf.h>
  2. #include <bpf/bpf_helpers.h>
  3. char _license[] SEC("license") = "GPL";
  4. struct {
  5. __uint(type, BPF_MAP_TYPE_ARRAY);
  6. __type(key, __u32);
  7. __type(value, __u64);
  8. __uint(max_entries, 2);
  9. } RESULTS SEC(".maps");
  10. static __u64
  11. inc_cb(void *map, __u32 *key, void *val,
  12. void *data)
  13. {
  14. __u64 *value = val;
  15. *value += 1;
  16. return 0;
  17. }
  18. SEC("uprobe/test_text_64_64_reloc")
  19. int test_text_64_64_reloc(struct pt_regs *ctx)
  20. {
  21. bpf_for_each_map_elem(&RESULTS, inc_cb, NULL, 0);
  22. return 0;
  23. }