xref: /linux/tools/testing/selftests/bpf/progs/btf__verifier_stack_arg_order.c (revision b2128290c29902315e632ea59e0504d6bc9e9b42)
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2026 Meta Platforms, Inc. and affiliates. */
3 #include <vmlinux.h>
4 #include <bpf/bpf_helpers.h>
5 
6 #if (defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64)) && \
7 	defined(__BPF_FEATURE_STACK_ARGUMENT)
8 
9 int subprog_bad_order_6args(int a, int b, int c, int d, int e, int f)
10 {
11 	return a + b + c + d + e + f;
12 }
13 
14 int subprog_call_before_load_6args(int a, int b, int c, int d, int e, int f)
15 {
16 	return a + b + c + d + e + f;
17 }
18 
19 int subprog_pruning_call_before_load_6args(int a, int b, int c, int d, int e, int f)
20 {
21 	return a + b + c + d + e + f;
22 }
23 
24 void subprog_bad_ptr_7args(long *a, int b, int c, int d, int e, int f, int g)
25 {
26 }
27 
28 #else
29 
30 int subprog_bad_order_6args(void)
31 {
32 	return 0;
33 }
34 
35 int subprog_call_before_load_6args(void)
36 {
37 	return 0;
38 }
39 
40 int subprog_pruning_call_before_load_6args(void)
41 {
42 	return 0;
43 }
44 
45 void subprog_bad_ptr_7args(void)
46 {
47 }
48 
49 #endif
50