blob: 5027b4ac28877bd246e93c280ba28c13db4107cd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2026 Meta Platforms, Inc. and affiliates. */
#include <vmlinux.h>
#include <bpf/bpf_helpers.h>
#include "bpf_arena_common.h"
struct {
__uint(type, BPF_MAP_TYPE_ARENA);
__uint(map_flags, BPF_F_MMAPABLE);
__uint(max_entries, 1); /* number of pages */
} arena SEC(".maps");
/*
* Dereferencing an arena global needs the compiler to emit an
* addr_space_cast, which only clang does. Keep the variables so the arena
* is still populated and the skeleton still has its arena member, but skip
* the test elsewhere.
*/
#ifdef __BPF_FEATURE_ADDR_SPACE_CAST
bool skip_tests __attribute((__section__(".data"))) = false;
#else
bool skip_tests = true;
#endif
long __arena_global a_val = 1;
extern long __arena_global b_val; /* defined in linked_arena2.c */
SEC("syscall")
int sum1(void *ctx)
{
#ifdef __BPF_FEATURE_ADDR_SPACE_CAST
return a_val + b_val;
#else
/*
* Reference the extern without dereferencing it, so that the relink
* test still has an extern to resolve.
*/
return (long)&b_val;
#endif
}
char _license[] SEC("license") = "GPL";
|