@@ -57,6 +57,8 @@ impl DFA {
57
57
builder. module . print_to_file ( path) . unwrap ( ) ;
58
58
}
59
59
60
+ builder. module . verify ( ) . unwrap ( ) ;
61
+
60
62
let target = Target :: from_name ( "bpf" ) . unwrap ( ) ;
61
63
62
64
let target_machine = target
@@ -726,21 +728,20 @@ fn define_map_def<'ctx>(
726
728
vars : & HashMap < & str , VarValue > ,
727
729
context : & ' ctx Context ,
728
730
) -> ( GlobalValue < ' ctx > , StructType < ' ctx > ) {
729
- let i32 = context. i32_type ( ) . as_basic_type_enum ( ) ;
730
- let i64 = context. i64_type ( ) . as_basic_type_enum ( ) ;
731
+ let i32 = context. i32_type ( ) ;
732
+
733
+ let field_types = vec ! [ i32 . as_basic_type_enum( ) ; 7 ] ;
731
734
732
- let field_types = vec ! [ i32 ; 7 ] ;
735
+ let bpf_map_def = context . opaque_struct_type ( "bpf_map_def" ) ;
733
736
734
- let bpf_map_def = context . struct_type ( & field_types, false ) ;
737
+ bpf_map_def. set_body ( & field_types, false ) ;
735
738
736
739
let gv = module. add_global (
737
740
bpf_map_def,
738
741
Some ( AddressSpace :: default ( ) ) ,
739
742
"decoder_state_map" ,
740
743
) ;
741
744
742
- let i32 = context. i32_type ( ) ;
743
-
744
745
let def = bpf_map_def. const_named_struct ( & [
745
746
// BPF_MAP_TYPE_ARRAY
746
747
i32. const_int ( 2 , false ) . into ( ) ,
@@ -761,9 +762,11 @@ fn define_map_def<'ctx>(
761
762
gv. set_section ( Some ( "maps" ) ) ;
762
763
gv. set_alignment ( 4 ) ;
763
764
764
- let field_types = vec ! [ i64 ; vars. len( ) ] ;
765
+ let field_types = vec ! [ context. i64_type( ) . as_basic_type_enum( ) ; vars. len( ) ] ;
766
+
767
+ let decoder_state_ty = context. opaque_struct_type ( "decoder_state_ty" ) ;
765
768
766
- let decoder_state_ty = context . struct_type ( & field_types, false ) ;
769
+ decoder_state_ty. set_body ( & field_types, false ) ;
767
770
768
771
( gv, decoder_state_ty)
769
772
}
0 commit comments