1 #include <stdint.h> 2 #include <stdbool.h> 3 4 void preserce_ptr_sz_fn(long x) {} 5 6 #define __bpf_aligned __attribute__((aligned(8))) 7 8 /* 9 * KERNEL 10 */ 11 12 struct core_reloc_kernel_output { 13 int valid[10]; 14 char comm[sizeof("test_progs")]; 15 int comm_len; 16 }; 17 18 /* 19 * FLAVORS 20 */ 21 struct core_reloc_flavors { 22 int a; 23 int b; 24 int c; 25 }; 26 27 /* this is not a flavor, as it doesn't have triple underscore */ 28 struct core_reloc_flavors__err_wrong_name { 29 int a; 30 int b; 31 int c; 32 }; 33 34 /* 35 * NESTING 36 */ 37 /* original set up, used to record relocations in BPF program */ 38 struct core_reloc_nesting_substruct { 39 int a; 40 }; 41 42 union core_reloc_nesting_subunion { 43 int b; 44 }; 45 46 struct core_reloc_nesting { 47 union { 48 struct core_reloc_nesting_substruct a; 49 } a; 50 struct { 51 union core_reloc_nesting_subunion b; 52 } b; 53 }; 54 55 /* inlined anonymous struct/union instead of named structs in original */ 56 struct core_reloc_nesting___anon_embed { 57 int __just_for_padding; 58 union { 59 struct { 60 int a; 61 } a; 62 } a; 63 struct { 64 union { 65 int b; 66 } b; 67 } b; 68 }; 69 70 /* different mix of nested structs/unions than in original */ 71 struct core_reloc_nesting___struct_union_mixup { 72 int __a; 73 struct { 74 int __a; 75 union { 76 char __a; 77 int a; 78 } a; 79 } a; 80 int __b; 81 union { 82 int __b; 83 union { 84 char __b; 85 int b; 86 } b; 87 } b; 88 }; 89 90 /* extra anon structs/unions, but still valid a.a.a and b.b.b accessors */ 91 struct core_reloc_nesting___extra_nesting { 92 int __padding; 93 struct { 94 struct { 95 struct { 96 struct { 97 union { 98 int a; 99 } a; 100 }; 101 }; 102 } a; 103 int __some_more; 104 struct { 105 union { 106 union { 107 union { 108 struct { 109 int b; 110 }; 111 } b; 112 }; 113 } b; 114 }; 115 }; 116 }; 117 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 */ 123 struct { 124 struct { 125 int a; /* offset 4 */ 126 } a; 127 } a; 128 long long __more_padding; 129 struct { 130 struct { 131 int b; /* offset 16 */ 132 } b; 133 } b; 134 }; 135 136 struct core_reloc_nesting___dup_compat_types__2 { 137 int __aligned_padding; 138 struct { 139 int __trickier_noop[0]; 140 struct { 141 char __some_more_noops[0]; 142 int a; /* offset 4 */ 143 } a; 144 } a; 145 int __more_padding; 146 struct { 147 struct { 148 struct { 149 int __critical_padding; 150 int b; /* offset 16 */ 151 } b; 152 int __does_not_matter; 153 }; 154 } b; 155 int __more_irrelevant_stuff; 156 }; 157 158 struct core_reloc_nesting___dup_compat_types__3 { 159 char __correct_padding[4]; 160 struct { 161 struct { 162 int a; /* offset 4 */ 163 } a; 164 } a; 165 /* 8 byte padding due to next struct's alignment */ 166 struct { 167 struct { 168 int b; 169 } b; 170 } b __attribute__((aligned(16))); 171 }; 172 173 /* b.b.b field is missing */ 174 struct core_reloc_nesting___err_missing_field { 175 struct { 176 struct { 177 int a; 178 } a; 179 } a; 180 struct { 181 struct { 182 int x; 183 } b; 184 } b; 185 }; 186 187 /* b.b.b field is an array of integers instead of plain int */ 188 struct core_reloc_nesting___err_array_field { 189 struct { 190 struct { 191 int a; 192 } a; 193 } a; 194 struct { 195 struct { 196 int b[1]; 197 } b; 198 } b; 199 }; 200 201 /* middle b container is missing */ 202 struct core_reloc_nesting___err_missing_container { 203 struct { 204 struct { 205 int a; 206 } a; 207 } a; 208 struct { 209 int x; 210 } b; 211 }; 212 213 /* middle b container is referenced through pointer instead of being embedded */ 214 struct core_reloc_nesting___err_nonstruct_container { 215 struct { 216 struct { 217 int a; 218 } a; 219 } a; 220 struct { 221 struct { 222 int b; 223 } *b; 224 } b; 225 }; 226 227 /* middle b container is an array of structs instead of plain struct */ 228 struct core_reloc_nesting___err_array_container { 229 struct { 230 struct { 231 int a; 232 } a; 233 } a; 234 struct { 235 struct { 236 int b; 237 } b[1]; 238 } b; 239 }; 240 241 /* two flavors of same struct with incompatible layout for b.b.b */ 242 struct core_reloc_nesting___err_dup_incompat_types__1 { 243 struct { 244 struct { 245 int a; /* offset 0 */ 246 } a; 247 } a; 248 struct { 249 struct { 250 int b; /* offset 4 */ 251 } b; 252 } b; 253 }; 254 255 struct core_reloc_nesting___err_dup_incompat_types__2 { 256 struct { 257 struct { 258 int a; /* offset 0 */ 259 } a; 260 } a; 261 int __extra_padding; 262 struct { 263 struct { 264 int b; /* offset 8 (!) */ 265 } b; 266 } b; 267 }; 268 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 { 271 struct { 272 struct { 273 int a; 274 } a; 275 } a; 276 }; 277 278 struct core_reloc_nesting___err_partial_match_dups__b { 279 struct { 280 struct { 281 int b; 282 } b; 283 } b; 284 }; 285 286 struct core_reloc_nesting___err_too_deep { 287 struct { 288 struct { 289 int a; 290 } a; 291 } a; 292 /* 65 levels of nestedness for b.b.b */ 293 struct { 294 struct { 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 */ 308 struct { 309 int b; 310 }; 311 }; }; }; }; }; 312 }; }; }; }; }; 313 }; }; }; }; }; 314 }; }; }; }; }; 315 }; }; }; }; }; 316 }; }; }; }; }; 317 }; }; }; }; }; 318 }; }; }; }; }; 319 }; }; }; }; }; 320 }; }; }; }; }; 321 }; }; }; }; }; 322 }; }; }; }; }; 323 } b; 324 } b; 325 }; 326 327 /* 328 * ARRAYS 329 */ 330 struct core_reloc_arrays_output { 331 int a2; 332 char b123; 333 int c1c; 334 int d00d; 335 int f10c; 336 }; 337 338 struct core_reloc_arrays_substruct { 339 int c; 340 int d; 341 }; 342 343 struct core_reloc_arrays { 344 int a[5]; 345 char b[2][3][4]; 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]; 349 }; 350 351 /* bigger array dimensions */ 352 struct core_reloc_arrays___diff_arr_dim { 353 int a[7]; 354 char b[3][4][5]; 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]; 358 }; 359 360 /* different size of array's value (struct) */ 361 struct core_reloc_arrays___diff_arr_val_sz { 362 int a[5]; 363 char b[2][3][4]; 364 struct { 365 int __padding1; 366 int c; 367 int __padding2; 368 } c[3]; 369 struct { 370 int __padding1; 371 int d; 372 int __padding2; 373 } d[1][2]; 374 struct { 375 int __padding1; 376 int c; 377 int __padding2; 378 } f[][2]; 379 }; 380 381 struct core_reloc_arrays___equiv_zero_sz_arr { 382 int a[5]; 383 char b[2][3][4]; 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]; 388 }; 389 390 struct core_reloc_arrays___fixed_arr { 391 int a[5]; 392 char b[2][3][4]; 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]; 397 }; 398 399 struct core_reloc_arrays___err_too_small { 400 int a[2]; /* this one is too small */ 401 char b[2][3][4]; 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]; 405 }; 406 407 struct core_reloc_arrays___err_too_shallow { 408 int a[5]; 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]; 413 }; 414 415 struct core_reloc_arrays___err_non_array { 416 int a; /* not an array */ 417 char b[2][3][4]; 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]; 421 }; 422 423 struct core_reloc_arrays___err_wrong_val_type { 424 int a[5]; 425 char b[2][3][4]; 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]; 429 }; 430 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]; 434 int a[5]; 435 char b[2][3][4]; 436 struct core_reloc_arrays_substruct c[3]; 437 struct core_reloc_arrays_substruct d[1][2]; 438 }; 439 440 /* 441 * PRIMITIVES 442 */ 443 enum core_reloc_primitives_enum { 444 A = 0, 445 B = 1, 446 }; 447 448 struct core_reloc_primitives { 449 char a; 450 int b; 451 enum core_reloc_primitives_enum c; 452 void *d __bpf_aligned; 453 int (*f)(const char *) __bpf_aligned; 454 }; 455 456 struct core_reloc_primitives___diff_enum_def { 457 char a; 458 int b; 459 void *d __bpf_aligned; 460 int (*f)(const char *) __bpf_aligned; 461 enum { 462 X = 100, 463 Y = 200, 464 } c __bpf_aligned; /* inline enum def with differing set of values */ 465 }; 466 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; 471 int b; 472 char a; 473 }; 474 475 struct core_reloc_primitives___diff_ptr_type { 476 const char * const d __bpf_aligned; /* different pointee type + modifiers */ 477 char a __bpf_aligned; 478 int b; 479 enum core_reloc_primitives_enum c; 480 int (*f)(const char *) __bpf_aligned; 481 }; 482 483 struct core_reloc_primitives___err_non_enum { 484 char a[1]; 485 int b; 486 int c; /* int instead of enum */ 487 void *d __bpf_aligned; 488 int (*f)(const char *) __bpf_aligned; 489 }; 490 491 struct core_reloc_primitives___err_non_int { 492 char a[1]; 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; 497 }; 498 499 struct core_reloc_primitives___err_non_ptr { 500 char a[1]; 501 int b; 502 enum core_reloc_primitives_enum c; 503 int d; /* int instead of ptr */ 504 int (*f)(const char *) __bpf_aligned; 505 }; 506 507 /* 508 * MODS 509 */ 510 struct core_reloc_mods_output { 511 int a, b, c, d, e, f, g, h; 512 }; 513 514 typedef const int int_t; 515 typedef const char *char_ptr_t __bpf_aligned; 516 typedef const int arr_t[7]; 517 518 struct core_reloc_mods_substruct { 519 int x; 520 int y; 521 }; 522 523 typedef struct { 524 int x; 525 int y; 526 } core_reloc_mods_substruct_t; 527 528 struct core_reloc_mods { 529 int a; 530 int_t b; 531 char *c __bpf_aligned; 532 char_ptr_t d; 533 int e[3] __bpf_aligned; 534 arr_t f; 535 struct core_reloc_mods_substruct g; 536 core_reloc_mods_substruct_t h; 537 }; 538 539 /* a/b, c/d, e/f, and g/h pairs are swapped */ 540 struct core_reloc_mods___mod_swap { 541 int b; 542 int_t a; 543 char *d __bpf_aligned; 544 char_ptr_t c; 545 int f[3] __bpf_aligned; 546 arr_t e; 547 struct { 548 int y; 549 int x; 550 } h; 551 core_reloc_mods_substruct_t g; 552 }; 553 554 typedef int int1_t; 555 typedef int1_t int2_t; 556 typedef int2_t int3_t; 557 558 typedef int arr1_t[5]; 559 typedef arr1_t arr2_t; 560 typedef arr2_t arr3_t; 561 typedef arr3_t arr4_t; 562 563 typedef const char * const volatile fancy_char_ptr_t __bpf_aligned; 564 565 typedef core_reloc_mods_substruct_t core_reloc_mods_substruct_tt; 566 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; 571 arr4_t f; 572 arr4_t e; 573 fancy_char_ptr_t d; 574 fancy_char_ptr_t c; 575 int3_t b __bpf_aligned; 576 int3_t a; 577 }; 578 579 /* 580 * PTR_AS_ARR 581 */ 582 struct core_reloc_ptr_as_arr { 583 int a; 584 }; 585 586 struct core_reloc_ptr_as_arr___diff_sz { 587 int :32; /* padding */ 588 char __some_more_padding; 589 int a; 590 }; 591 592 /* 593 * INTS 594 */ 595 struct core_reloc_ints { 596 uint8_t u8_field; 597 int8_t s8_field; 598 uint16_t u16_field; 599 int16_t s16_field; 600 uint32_t u32_field; 601 int32_t s32_field; 602 uint64_t u64_field; 603 int64_t s64_field; 604 }; 605 606 /* signed/unsigned types swap */ 607 struct core_reloc_ints___reverse_sign { 608 int8_t u8_field; 609 uint8_t s8_field; 610 int16_t u16_field; 611 uint16_t s16_field; 612 int32_t u32_field; 613 uint32_t s32_field; 614 int64_t u64_field; 615 uint64_t s64_field; 616 }; 617 618 struct core_reloc_ints___bool { 619 bool u8_field; /* bool instead of uint8 */ 620 int8_t s8_field; 621 uint16_t u16_field; 622 int16_t s16_field; 623 uint32_t u32_field; 624 int32_t s32_field; 625 uint64_t u64_field; 626 int64_t s64_field; 627 }; 628 629 /* 630 * MISC 631 */ 632 struct core_reloc_misc_output { 633 int a, b, c; 634 }; 635 636 struct core_reloc_misc___a { 637 int a1; 638 int a2; 639 }; 640 641 struct core_reloc_misc___b { 642 int b1; 643 int b2; 644 }; 645 646 /* this one extends core_reloc_misc_extensible struct from BPF prog */ 647 struct core_reloc_misc_extensible { 648 int a; 649 int b; 650 int c; 651 int d; 652 }; 653 654 /* 655 * FIELD EXISTENCE 656 */ 657 struct core_reloc_existence_output { 658 int a_exists; 659 int a_value; 660 int b_exists; 661 int b_value; 662 int c_exists; 663 int c_value; 664 int arr_exists; 665 int arr_value; 666 int s_exists; 667 int s_value; 668 }; 669 670 struct core_reloc_existence { 671 int a; 672 struct { 673 int b; 674 }; 675 int c; 676 int arr[1]; 677 struct { 678 int x; 679 } s; 680 }; 681 682 struct core_reloc_existence___minimal { 683 int a; 684 }; 685 686 struct core_reloc_existence___err_wrong_int_sz { 687 short a; 688 }; 689 690 struct core_reloc_existence___err_wrong_int_type { 691 int b[1]; 692 }; 693 694 struct core_reloc_existence___err_wrong_int_kind { 695 struct{ int x; } c; 696 }; 697 698 struct core_reloc_existence___err_wrong_arr_kind { 699 int arr; 700 }; 701 702 struct core_reloc_existence___err_wrong_arr_value_type { 703 short arr[1]; 704 }; 705 706 struct core_reloc_existence___err_wrong_struct_type { 707 int s; 708 }; 709 710 /* 711 * BITFIELDS 712 */ 713 /* bitfield read results, all as plain integers */ 714 struct core_reloc_bitfields_output { 715 int64_t ub1; 716 int64_t ub2; 717 int64_t ub7; 718 int64_t sb4; 719 int64_t sb20; 720 int64_t u32; 721 int64_t s32; 722 }; 723 724 struct core_reloc_bitfields { 725 /* unsigned bitfields */ 726 uint8_t ub1: 1; 727 uint8_t ub2: 2; 728 uint32_t ub7: 7; 729 /* signed bitfields */ 730 int8_t sb4: 4; 731 int32_t sb20: 20; 732 /* non-bitfields */ 733 uint32_t u32; 734 int32_t s32; 735 }; 736 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 */ 746 /* non-bitfields */ 747 uint16_t u32; /* 32 -> 16 */ 748 int64_t s32 __bpf_aligned; /* 32 -> 64 */ 749 }; 750 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 */ 760 }; 761 762 struct core_reloc_bitfields___just_big_enough { 763 uint64_t ub1: 4; 764 uint64_t ub2: 60; /* packed tightly */ 765 uint32_t ub7; 766 uint32_t sb4; 767 uint32_t sb20; 768 uint32_t u32; 769 uint32_t s32; 770 } __attribute__((packed)) ; 771 772 struct core_reloc_bitfields___err_too_big_bitfield { 773 uint64_t ub1: 4; 774 uint64_t ub2: 61; /* packed tightly */ 775 uint32_t ub7; 776 uint32_t sb4; 777 uint32_t sb20; 778 uint32_t u32; 779 uint32_t s32; 780 } __attribute__((packed)) ; 781 782 /* 783 * SIZE 784 */ 785 struct core_reloc_size_output { 786 int int_sz; 787 int struct_sz; 788 int union_sz; 789 int arr_sz; 790 int arr_elem_sz; 791 int ptr_sz; 792 int enum_sz; 793 }; 794 795 struct core_reloc_size { 796 int int_field; 797 struct { int x; } struct_field; 798 union { int x; } union_field; 799 int arr_field[4]; 800 void *ptr_field; 801 enum { VALUE = 123 } enum_field; 802 }; 803 804 struct core_reloc_size___diff_sz { 805 uint64_t int_field; 806 struct { int x; int y; int z; } struct_field; 807 union { int x; char bla[123]; } union_field; 808 char arr_field[10]; 809 void *ptr_field; 810 enum { OTHER_VALUE = 0xFFFFFFFFFFFFFFFF } enum_field; 811 }; 812 813 /* Error case of two candidates with the fields (int_field) at the same 814 * offset, but with differing final relocation values: size 4 vs size 1 815 */ 816 struct core_reloc_size___err_ambiguous1 { 817 /* int at offset 0 */ 818 int int_field; 819 820 struct { int x; } struct_field; 821 union { int x; } union_field; 822 int arr_field[4]; 823 void *ptr_field; 824 enum { VALUE___1 = 123 } enum_field; 825 }; 826 827 struct core_reloc_size___err_ambiguous2 { 828 /* char at offset 0 */ 829 char int_field; 830 831 struct { int x; } struct_field; 832 union { int x; } union_field; 833 int arr_field[4]; 834 void *ptr_field; 835 enum { VALUE___2 = 123 } enum_field; 836 }; 837 838 /* 839 * TYPE EXISTENCE & SIZE 840 */ 841 struct core_reloc_type_based_output { 842 bool struct_exists; 843 bool union_exists; 844 bool enum_exists; 845 bool typedef_named_struct_exists; 846 bool typedef_anon_struct_exists; 847 bool typedef_struct_ptr_exists; 848 bool typedef_int_exists; 849 bool typedef_enum_exists; 850 bool typedef_void_ptr_exists; 851 bool typedef_func_proto_exists; 852 bool typedef_arr_exists; 853 854 int struct_sz; 855 int union_sz; 856 int enum_sz; 857 int typedef_named_struct_sz; 858 int typedef_anon_struct_sz; 859 int typedef_struct_ptr_sz; 860 int typedef_int_sz; 861 int typedef_enum_sz; 862 int typedef_void_ptr_sz; 863 int typedef_func_proto_sz; 864 int typedef_arr_sz; 865 }; 866 867 struct a_struct { 868 int x; 869 }; 870 871 union a_union { 872 int y; 873 int z; 874 }; 875 876 typedef struct a_struct named_struct_typedef; 877 878 typedef struct { int x, y, z; } anon_struct_typedef; 879 880 typedef struct { 881 int a, b, c; 882 } *struct_ptr_typedef; 883 884 enum an_enum { 885 AN_ENUM_VAL1 = 1, 886 AN_ENUM_VAL2 = 2, 887 AN_ENUM_VAL3 = 3, 888 }; 889 890 typedef int int_typedef; 891 892 typedef enum { TYPEDEF_ENUM_VAL1, TYPEDEF_ENUM_VAL2 } enum_typedef; 893 894 typedef void *void_ptr_typedef; 895 896 typedef int (*func_proto_typedef)(long); 897 898 typedef char arr_typedef[20]; 899 900 struct core_reloc_type_based { 901 struct a_struct f1; 902 union a_union f2; 903 enum an_enum f3; 904 named_struct_typedef f4; 905 anon_struct_typedef f5; 906 struct_ptr_typedef f6; 907 int_typedef f7; 908 enum_typedef f8; 909 void_ptr_typedef f9; 910 func_proto_typedef f10; 911 arr_typedef f11; 912 }; 913 914 /* no types in target */ 915 struct core_reloc_type_based___all_missing { 916 }; 917 918 /* different type sizes, extra modifiers, anon vs named enums, etc */ 919 struct a_struct___diff_sz { 920 long x; 921 int y; 922 char z; 923 }; 924 925 union a_union___diff_sz { 926 char yy; 927 char zz; 928 }; 929 930 typedef struct a_struct___diff_sz named_struct_typedef___diff_sz; 931 932 typedef struct { long xx, yy, zzz; } anon_struct_typedef___diff_sz; 933 934 typedef struct { 935 char aa[1], bb[2], cc[3]; 936 } *struct_ptr_typedef___diff_sz; 937 938 enum an_enum___diff_sz { 939 AN_ENUM_VAL1___diff_sz = 0x123412341234, 940 AN_ENUM_VAL2___diff_sz = 2, 941 }; 942 943 typedef unsigned long int_typedef___diff_sz; 944 945 typedef enum an_enum___diff_sz enum_typedef___diff_sz; 946 947 typedef const void * const void_ptr_typedef___diff_sz; 948 949 typedef int_typedef___diff_sz (*func_proto_typedef___diff_sz)(char); 950 951 typedef int arr_typedef___diff_sz[2]; 952 953 struct core_reloc_type_based___diff_sz { 954 struct a_struct___diff_sz f1; 955 union a_union___diff_sz f2; 956 enum an_enum___diff_sz f3; 957 named_struct_typedef___diff_sz f4; 958 anon_struct_typedef___diff_sz f5; 959 struct_ptr_typedef___diff_sz f6; 960 int_typedef___diff_sz f7; 961 enum_typedef___diff_sz f8; 962 void_ptr_typedef___diff_sz f9; 963 func_proto_typedef___diff_sz f10; 964 arr_typedef___diff_sz f11; 965 }; 966 967 /* incompatibilities between target and local types */ 968 union a_struct___incompat { /* union instead of struct */ 969 int x; 970 }; 971 972 struct a_union___incompat { /* struct instead of union */ 973 int y; 974 int z; 975 }; 976 977 /* typedef to union, not to struct */ 978 typedef union a_struct___incompat named_struct_typedef___incompat; 979 980 /* typedef to void pointer, instead of struct */ 981 typedef void *anon_struct_typedef___incompat; 982 983 /* extra pointer indirection */ 984 typedef struct { 985 int a, b, c; 986 } **struct_ptr_typedef___incompat; 987 988 /* typedef of a struct with int, instead of int */ 989 typedef struct { int x; } int_typedef___incompat; 990 991 /* typedef to func_proto, instead of enum */ 992 typedef int (*enum_typedef___incompat)(void); 993 994 /* pointer to char instead of void */ 995 typedef char *void_ptr_typedef___incompat; 996 997 /* void return type instead of int */ 998 typedef void (*func_proto_typedef___incompat)(long); 999 1000 /* multi-dimensional array instead of a single-dimensional */ 1001 typedef int arr_typedef___incompat[20][2]; 1002 1003 struct core_reloc_type_based___incompat { 1004 union a_struct___incompat f1; 1005 struct a_union___incompat f2; 1006 /* the only valid one is enum, to check that something still succeeds */ 1007 enum an_enum f3; 1008 named_struct_typedef___incompat f4; 1009 anon_struct_typedef___incompat f5; 1010 struct_ptr_typedef___incompat f6; 1011 int_typedef___incompat f7; 1012 enum_typedef___incompat f8; 1013 void_ptr_typedef___incompat f9; 1014 func_proto_typedef___incompat f10; 1015 arr_typedef___incompat f11; 1016 }; 1017 1018 /* func_proto with incompatible signature */ 1019 typedef void (*func_proto_typedef___fn_wrong_ret1)(long); 1020 typedef int * (*func_proto_typedef___fn_wrong_ret2)(long); 1021 typedef struct { int x; } int_struct_typedef; 1022 typedef int_struct_typedef (*func_proto_typedef___fn_wrong_ret3)(long); 1023 typedef int (*func_proto_typedef___fn_wrong_arg)(void *); 1024 typedef int (*func_proto_typedef___fn_wrong_arg_cnt1)(long, long); 1025 typedef int (*func_proto_typedef___fn_wrong_arg_cnt2)(void); 1026 1027 struct core_reloc_type_based___fn_wrong_args { 1028 /* one valid type to make sure relos still work */ 1029 struct a_struct f1; 1030 func_proto_typedef___fn_wrong_ret1 f2; 1031 func_proto_typedef___fn_wrong_ret2 f3; 1032 func_proto_typedef___fn_wrong_ret3 f4; 1033 func_proto_typedef___fn_wrong_arg f5; 1034 func_proto_typedef___fn_wrong_arg_cnt1 f6; 1035 func_proto_typedef___fn_wrong_arg_cnt2 f7; 1036 }; 1037