4 void preserce_ptr_sz_fn(long x) {}
6 #define __bpf_aligned __attribute__((aligned(8)))
12 struct core_reloc_kernel_output {
14 char comm[sizeof("test_progs")];
21 struct core_reloc_flavors {
27 /* this is not a flavor, as it doesn't have triple underscore */
28 struct core_reloc_flavors__err_wrong_name {
37 /* original set up, used to record relocations in BPF program */
38 struct core_reloc_nesting_substruct {
42 union core_reloc_nesting_subunion {
46 struct core_reloc_nesting {
48 struct core_reloc_nesting_substruct a;
51 union core_reloc_nesting_subunion b;
55 /* inlined anonymous struct/union instead of named structs in original */
56 struct core_reloc_nesting___anon_embed {
57 int __just_for_padding;
70 /* different mix of nested structs/unions than in original */
71 struct core_reloc_nesting___struct_union_mixup {
90 /* extra anon structs/unions, but still valid a.a.a and b.b.b accessors */
91 struct core_reloc_nesting___extra_nesting {
118 /* three flavors of same struct with different structure but same layout for
119 * a.a.a and b.b.b, thus successfully resolved and relocatable */
120 struct core_reloc_nesting___dup_compat_types {
121 char __just_for_padding;
122 /* 3 more bytes of padding */
125 int a; /* offset 4 */
128 long long __more_padding;
131 int b; /* offset 16 */
136 struct core_reloc_nesting___dup_compat_types__2 {
137 int __aligned_padding;
139 int __trickier_noop[0];
141 char __some_more_noops[0];
142 int a; /* offset 4 */
149 int __critical_padding;
150 int b; /* offset 16 */
152 int __does_not_matter;
155 int __more_irrelevant_stuff;
158 struct core_reloc_nesting___dup_compat_types__3 {
159 char __correct_padding[4];
162 int a; /* offset 4 */
165 /* 8 byte padding due to next struct's alignment */
170 } b __attribute__((aligned(16)));
173 /* b.b.b field is missing */
174 struct core_reloc_nesting___err_missing_field {
187 /* b.b.b field is an array of integers instead of plain int */
188 struct core_reloc_nesting___err_array_field {
201 /* middle b container is missing */
202 struct core_reloc_nesting___err_missing_container {
213 /* middle b container is referenced through pointer instead of being embedded */
214 struct core_reloc_nesting___err_nonstruct_container {
227 /* middle b container is an array of structs instead of plain struct */
228 struct core_reloc_nesting___err_array_container {
241 /* two flavors of same struct with incompatible layout for b.b.b */
242 struct core_reloc_nesting___err_dup_incompat_types__1 {
245 int a; /* offset 0 */
250 int b; /* offset 4 */
255 struct core_reloc_nesting___err_dup_incompat_types__2 {
258 int a; /* offset 0 */
264 int b; /* offset 8 (!) */
269 /* two flavors of same struct having one of a.a.a and b.b.b, but not both */
270 struct core_reloc_nesting___err_partial_match_dups__a {
278 struct core_reloc_nesting___err_partial_match_dups__b {
286 struct core_reloc_nesting___err_too_deep {
292 /* 65 levels of nestedness for b.b.b */
295 struct { struct { struct { struct { struct {
296 struct { struct { struct { struct { struct {
297 struct { struct { struct { struct { struct {
298 struct { struct { struct { struct { struct {
299 struct { struct { struct { struct { struct {
300 struct { struct { struct { struct { struct {
301 struct { struct { struct { struct { struct {
302 struct { struct { struct { struct { struct {
303 struct { struct { struct { struct { struct {
304 struct { struct { struct { struct { struct {
305 struct { struct { struct { struct { struct {
306 struct { struct { struct { struct { struct {
307 /* this one is one too much */
330 struct core_reloc_arrays_output {
338 struct core_reloc_arrays_substruct {
343 struct core_reloc_arrays {
346 struct core_reloc_arrays_substruct c[3];
347 struct core_reloc_arrays_substruct d[1][2];
348 struct core_reloc_arrays_substruct f[][2];
351 /* bigger array dimensions */
352 struct core_reloc_arrays___diff_arr_dim {
355 struct core_reloc_arrays_substruct c[4];
356 struct core_reloc_arrays_substruct d[2][3];
357 struct core_reloc_arrays_substruct f[1][3];
360 /* different size of array's value (struct) */
361 struct core_reloc_arrays___diff_arr_val_sz {
381 struct core_reloc_arrays___equiv_zero_sz_arr {
384 struct core_reloc_arrays_substruct c[3];
385 struct core_reloc_arrays_substruct d[1][2];
386 /* equivalent to flexible array */
387 struct core_reloc_arrays_substruct f[][2];
390 struct core_reloc_arrays___fixed_arr {
393 struct core_reloc_arrays_substruct c[3];
394 struct core_reloc_arrays_substruct d[1][2];
395 /* not a flexible array anymore, but within access bounds */
396 struct core_reloc_arrays_substruct f[1][2];
399 struct core_reloc_arrays___err_too_small {
400 int a[2]; /* this one is too small */
402 struct core_reloc_arrays_substruct c[3];
403 struct core_reloc_arrays_substruct d[1][2];
404 struct core_reloc_arrays_substruct f[][2];
407 struct core_reloc_arrays___err_too_shallow {
409 char b[2][3]; /* this one lacks one dimension */
410 struct core_reloc_arrays_substruct c[3];
411 struct core_reloc_arrays_substruct d[1][2];
412 struct core_reloc_arrays_substruct f[][2];
415 struct core_reloc_arrays___err_non_array {
416 int a; /* not an array */
418 struct core_reloc_arrays_substruct c[3];
419 struct core_reloc_arrays_substruct d[1][2];
420 struct core_reloc_arrays_substruct f[][2];
423 struct core_reloc_arrays___err_wrong_val_type {
426 int c[3]; /* value is not a struct */
427 struct core_reloc_arrays_substruct d[1][2];
428 struct core_reloc_arrays_substruct f[][2];
431 struct core_reloc_arrays___err_bad_zero_sz_arr {
432 /* zero-sized array, but not at the end */
433 struct core_reloc_arrays_substruct f[0][2];
436 struct core_reloc_arrays_substruct c[3];
437 struct core_reloc_arrays_substruct d[1][2];
443 enum core_reloc_primitives_enum {
448 struct core_reloc_primitives {
451 enum core_reloc_primitives_enum c;
452 void *d __bpf_aligned;
453 int (*f)(const char *) __bpf_aligned;
456 struct core_reloc_primitives___diff_enum_def {
459 void *d __bpf_aligned;
460 int (*f)(const char *) __bpf_aligned;
464 } c __bpf_aligned; /* inline enum def with differing set of values */
467 struct core_reloc_primitives___diff_func_proto {
468 void (*f)(int) __bpf_aligned; /* incompatible function prototype */
469 void *d __bpf_aligned;
470 enum core_reloc_primitives_enum c __bpf_aligned;
475 struct core_reloc_primitives___diff_ptr_type {
476 const char * const d __bpf_aligned; /* different pointee type + modifiers */
477 char a __bpf_aligned;
479 enum core_reloc_primitives_enum c;
480 int (*f)(const char *) __bpf_aligned;
483 struct core_reloc_primitives___err_non_enum {
486 int c; /* int instead of enum */
487 void *d __bpf_aligned;
488 int (*f)(const char *) __bpf_aligned;
491 struct core_reloc_primitives___err_non_int {
493 int *b __bpf_aligned; /* ptr instead of int */
494 enum core_reloc_primitives_enum c __bpf_aligned;
495 void *d __bpf_aligned;
496 int (*f)(const char *) __bpf_aligned;
499 struct core_reloc_primitives___err_non_ptr {
502 enum core_reloc_primitives_enum c;
503 int d; /* int instead of ptr */
504 int (*f)(const char *) __bpf_aligned;
510 struct core_reloc_mods_output {
511 int a, b, c, d, e, f, g, h;
514 typedef const int int_t;
515 typedef const char *char_ptr_t __bpf_aligned;
516 typedef const int arr_t[7];
518 struct core_reloc_mods_substruct {
526 } core_reloc_mods_substruct_t;
528 struct core_reloc_mods {
531 char *c __bpf_aligned;
533 int e[3] __bpf_aligned;
535 struct core_reloc_mods_substruct g;
536 core_reloc_mods_substruct_t h;
539 /* a/b, c/d, e/f, and g/h pairs are swapped */
540 struct core_reloc_mods___mod_swap {
543 char *d __bpf_aligned;
545 int f[3] __bpf_aligned;
551 core_reloc_mods_substruct_t g;
555 typedef int1_t int2_t;
556 typedef int2_t int3_t;
558 typedef int arr1_t[5];
559 typedef arr1_t arr2_t;
560 typedef arr2_t arr3_t;
561 typedef arr3_t arr4_t;
563 typedef const char * const volatile fancy_char_ptr_t __bpf_aligned;
565 typedef core_reloc_mods_substruct_t core_reloc_mods_substruct_tt;
567 /* we need more typedefs */
568 struct core_reloc_mods___typedefs {
569 core_reloc_mods_substruct_tt g;
570 core_reloc_mods_substruct_tt h;
575 int3_t b __bpf_aligned;
582 struct core_reloc_ptr_as_arr {
586 struct core_reloc_ptr_as_arr___diff_sz {
587 int :32; /* padding */
588 char __some_more_padding;
595 struct core_reloc_ints {
606 /* signed/unsigned types swap */
607 struct core_reloc_ints___reverse_sign {
618 struct core_reloc_ints___bool {
619 bool u8_field; /* bool instead of uint8 */
632 struct core_reloc_misc_output {
636 struct core_reloc_misc___a {
641 struct core_reloc_misc___b {
646 /* this one extends core_reloc_misc_extensible struct from BPF prog */
647 struct core_reloc_misc_extensible {
657 struct core_reloc_existence_output {
670 struct core_reloc_existence {
682 struct core_reloc_existence___minimal {
686 struct core_reloc_existence___err_wrong_int_sz {
690 struct core_reloc_existence___err_wrong_int_type {
694 struct core_reloc_existence___err_wrong_int_kind {
698 struct core_reloc_existence___err_wrong_arr_kind {
702 struct core_reloc_existence___err_wrong_arr_value_type {
706 struct core_reloc_existence___err_wrong_struct_type {
713 /* bitfield read results, all as plain integers */
714 struct core_reloc_bitfields_output {
724 struct core_reloc_bitfields {
725 /* unsigned bitfields */
729 /* signed bitfields */
737 /* different bit sizes (both up and down) */
738 struct core_reloc_bitfields___bit_sz_change {
739 /* unsigned bitfields */
740 uint16_t ub1: 3; /* 1 -> 3 */
741 uint32_t ub2: 20; /* 2 -> 20 */
742 uint8_t ub7: 1; /* 7 -> 1 */
743 /* signed bitfields */
744 int8_t sb4: 1; /* 4 -> 1 */
745 int32_t sb20: 30; /* 20 -> 30 */
747 uint16_t u32; /* 32 -> 16 */
748 int64_t s32 __bpf_aligned; /* 32 -> 64 */
751 /* turn bitfield into non-bitfield and vice versa */
752 struct core_reloc_bitfields___bitfield_vs_int {
753 uint64_t ub1; /* 3 -> 64 non-bitfield */
754 uint8_t ub2; /* 20 -> 8 non-bitfield */
755 int64_t ub7 __bpf_aligned; /* 7 -> 64 non-bitfield signed */
756 int64_t sb4 __bpf_aligned; /* 4 -> 64 non-bitfield signed */
757 uint64_t sb20 __bpf_aligned; /* 20 -> 16 non-bitfield unsigned */
758 int32_t u32: 20; /* 32 non-bitfield -> 20 bitfield */
759 uint64_t s32: 60 __bpf_aligned; /* 32 non-bitfield -> 60 bitfield */
762 struct core_reloc_bitfields___just_big_enough {
764 uint64_t ub2: 60; /* packed tightly */
770 } __attribute__((packed)) ;
772 struct core_reloc_bitfields___err_too_big_bitfield {
774 uint64_t ub2: 61; /* packed tightly */
780 } __attribute__((packed)) ;
785 struct core_reloc_size_output {
795 struct core_reloc_size {
797 struct { int x; } struct_field;
798 union { int x; } union_field;
801 enum { VALUE = 123 } enum_field;
804 struct core_reloc_size___diff_sz {
806 struct { int x; int y; int z; } struct_field;
807 union { int x; char bla[123]; } union_field;
810 enum { OTHER_VALUE = 0xFFFFFFFFFFFFFFFF } enum_field;