...
1/* This file excercises the ELF loader. It is not a valid BPF program. */
2
3#include "common.h"
4
5struct bpf_map_def dummy __section("maps") = {
6 .type = BPF_MAP_TYPE_HASH,
7 .key_size = sizeof(uint32_t),
8 .value_size = sizeof(uint64_t),
9 .max_entries = 1,
10 .map_flags = 0,
11};
12
13/* The static qualifier leads to clang not emitting a symbol. */
14static struct bpf_map_def hash_map __section("maps") = {
15 .type = BPF_MAP_TYPE_HASH,
16 .key_size = sizeof(uint32_t),
17 .value_size = sizeof(uint64_t),
18 .max_entries = 1,
19 .map_flags = 0,
20};
21
22__section("xdp") int xdp_prog() {
23 uint32_t key = 0;
24 void *p = map_lookup_elem(&hash_map, &key);
25 return !!p;
26}
View as plain text