@@ -169,15 +169,16 @@ type sh_flags =
169
169
170
170
171
171
let section_header
172
+ ?(sh_link :int64 option=None )
173
+ ?(sh_info :int64 option=None )
174
+ ?(zero_sh_addr :bool=false )
175
+ ?(sh_flags :sh_flags list=[] )
176
+ ?(section_fixup :fixup option=None )
177
+ ?(sh_addralign :int64=1L )
178
+ ?(sh_entsize :int64=0L )
172
179
~(shstring_table_fixup :fixup )
173
180
~(shname_string_fixup :fixup )
174
- ~(sh_type :sh_type )
175
- ~(sh_flags :sh_flags list )
176
- ~(section_fixup :fixup option )
177
- ~(sh_addralign :int64 )
178
- ~(sh_entsize :int64 )
179
- ~(sh_link :int64 option )
180
- ~(sh_info :int64 option )
181
+ (sh_type :sh_type )
181
182
: frag =
182
183
SEQ
183
184
[|
@@ -202,9 +203,12 @@ let section_header
202
203
SHF_WRITE -> 0x1L
203
204
| SHF_ALLOC -> 0x2L
204
205
| SHF_EXECINSTR -> 0x4L ) sh_flags)));
205
- WORD (TY_u32 , (match section_fixup with
206
- None -> (IMM 0L )
207
- | Some s -> (M_POS s)));
206
+ WORD (TY_u32 ,
207
+ if zero_sh_addr
208
+ then IMM 0L
209
+ else (match section_fixup with
210
+ None -> (IMM 0L )
211
+ | Some s -> (M_POS s)));
208
212
WORD (TY_u32 , (match section_fixup with
209
213
None -> (IMM 0L )
210
214
| Some s -> (F_POS s)));
@@ -693,169 +697,129 @@ let elf32_linux_x86_file
693
697
(section_header
694
698
~shstring_table_fixup: shstrtab_section_fixup
695
699
~shname_string_fixup: null_section_name_fixup
696
- ~sh_type: SHT_NULL
697
- ~sh_flags: []
698
700
~section_fixup: None
699
701
~sh_addralign: 0L
700
- ~sh_entsize: 0L
701
- ~sh_link: None
702
- ~sh_info: None );
702
+ SHT_NULL );
703
703
704
704
(* .interp *)
705
705
(section_header
706
706
~shstring_table_fixup: shstrtab_section_fixup
707
707
~shname_string_fixup: interp_section_name_fixup
708
- ~sh_type: SHT_PROGBITS
709
708
~sh_flags: [ SHF_ALLOC ]
710
709
~section_fixup: (Some interp_section_fixup)
711
- ~sh_addralign: 1L
712
- ~sh_entsize: 0L
713
- ~sh_link: None
714
- ~sh_info: None );
710
+ SHT_PROGBITS );
715
711
716
712
(* .text *)
717
713
(section_header
718
714
~shstring_table_fixup: shstrtab_section_fixup
719
715
~shname_string_fixup: text_section_name_fixup
720
- ~sh_type: SHT_PROGBITS
721
716
~sh_flags: [ SHF_ALLOC ; SHF_EXECINSTR ]
722
717
~section_fixup: (Some text_section_fixup)
723
718
~sh_addralign: 32L
724
- ~sh_entsize: 0L
725
- ~sh_link: None
726
- ~sh_info: None );
719
+ SHT_PROGBITS );
727
720
728
721
(* .rodata *)
729
722
(section_header
730
723
~shstring_table_fixup: shstrtab_section_fixup
731
724
~shname_string_fixup: rodata_section_name_fixup
732
- ~sh_type: SHT_PROGBITS
733
725
~sh_flags: [ SHF_ALLOC ]
734
726
~section_fixup: (Some rodata_section_fixup)
735
727
~sh_addralign: 32L
736
- ~sh_entsize: 0L
737
- ~sh_link: None
738
- ~sh_info: None );
728
+ SHT_PROGBITS );
739
729
740
730
(* .dynsym *)
741
731
(section_header
742
732
~shstring_table_fixup: shstrtab_section_fixup
743
733
~shname_string_fixup: dynsym_section_name_fixup
744
- ~sh_type: SHT_DYNSYM
745
734
~sh_flags: [ SHF_ALLOC ]
746
735
~section_fixup: (Some dynsym_section_fixup)
747
736
~sh_addralign: 4L
748
737
~sh_entsize: elf32_symsize
749
738
~sh_link: (Some dynstrndx)
750
- ~sh_info: None );
739
+ SHT_DYNSYM );
751
740
752
741
(* .dynstr *)
753
742
(section_header
754
743
~shstring_table_fixup: shstrtab_section_fixup
755
744
~shname_string_fixup: dynstr_section_name_fixup
756
- ~sh_type: SHT_STRTAB
757
745
~sh_flags: [ SHF_ALLOC ]
758
746
~section_fixup: (Some dynstr_section_fixup)
759
- ~sh_addralign: 1L
760
- ~sh_entsize: 0L
761
- ~sh_link: None
762
- ~sh_info: None );
747
+ SHT_STRTAB );
763
748
764
749
(* .hash *)
765
750
(section_header
766
751
~shstring_table_fixup: shstrtab_section_fixup
767
752
~shname_string_fixup: hash_section_name_fixup
768
- ~sh_type: SHT_PROGBITS
769
753
~sh_flags: [ SHF_ALLOC ]
770
754
~section_fixup: (Some hash_section_fixup)
771
755
~sh_addralign: 4L
772
756
~sh_entsize: 4L
773
- ~sh_link: (Some dynsymndx)
774
- ~sh_info: None );
757
+ SHT_PROGBITS );
775
758
776
759
(* .plt *)
777
760
(section_header
778
761
~shstring_table_fixup: shstrtab_section_fixup
779
762
~shname_string_fixup: plt_section_name_fixup
780
- ~sh_type: SHT_PROGBITS
781
763
~sh_flags: [ SHF_ALLOC ; SHF_EXECINSTR ]
782
764
~section_fixup: (Some plt_section_fixup)
783
765
~sh_addralign: 4L
784
- ~sh_entsize: 0L
785
- ~sh_link: None
786
- ~sh_info: None );
766
+ SHT_PROGBITS );
787
767
788
768
(* .got.plt *)
789
769
(section_header
790
770
~shstring_table_fixup: shstrtab_section_fixup
791
771
~shname_string_fixup: got_plt_section_name_fixup
792
- ~sh_type: SHT_PROGBITS
793
772
~sh_flags: [ SHF_ALLOC ; SHF_WRITE ]
794
773
~section_fixup: (Some got_plt_section_fixup)
795
774
~sh_addralign: 4L
796
- ~sh_entsize: 0L
797
- ~sh_link: None
798
- ~sh_info: None );
775
+ SHT_PROGBITS );
799
776
800
777
(* .rela.plt *)
801
778
(section_header
802
779
~shstring_table_fixup: shstrtab_section_fixup
803
780
~shname_string_fixup: rela_plt_section_name_fixup
804
- ~sh_type: SHT_RELA
805
781
~sh_flags: [ SHF_ALLOC ]
806
782
~section_fixup: (Some rela_plt_section_fixup)
807
783
~sh_addralign: 4L
808
784
~sh_entsize: elf32_rela_entsz
809
785
~sh_link: (Some dynsymndx)
810
- ~sh_info: (Some pltndx));
786
+ ~sh_info: (Some pltndx)
787
+ SHT_RELA );
811
788
812
789
(* .data *)
813
790
(section_header
814
791
~shstring_table_fixup: shstrtab_section_fixup
815
792
~shname_string_fixup: data_section_name_fixup
816
- ~sh_type: SHT_PROGBITS
817
793
~sh_flags: [ SHF_ALLOC ; SHF_WRITE ]
818
794
~section_fixup: (Some data_section_fixup)
819
795
~sh_addralign: 32L
820
- ~sh_entsize: 0L
821
- ~sh_link: None
822
- ~sh_info: None );
796
+ SHT_PROGBITS );
823
797
824
798
(* .bss *)
825
799
(section_header
826
800
~shstring_table_fixup: shstrtab_section_fixup
827
801
~shname_string_fixup: bss_section_name_fixup
828
- ~sh_type: SHT_NOBITS
829
802
~sh_flags: [ SHF_ALLOC ; SHF_WRITE ]
830
803
~section_fixup: (Some bss_section_fixup)
831
804
~sh_addralign: 32L
832
- ~sh_entsize: 0L
833
- ~sh_link: None
834
- ~sh_info: None );
805
+ SHT_NOBITS );
835
806
836
807
(* .dynamic *)
837
808
(section_header
838
809
~shstring_table_fixup: shstrtab_section_fixup
839
810
~shname_string_fixup: dynamic_section_name_fixup
840
- ~sh_type: SHT_DYNAMIC
841
811
~sh_flags: [ SHF_ALLOC ; SHF_WRITE ]
842
812
~section_fixup: (Some dynamic_section_fixup)
843
813
~sh_addralign: 8L
844
- ~sh_entsize: 0L
845
814
~sh_link: (Some dynstrndx)
846
- ~sh_info: None );
815
+ SHT_DYNAMIC );
847
816
848
817
(* .shstrtab *)
849
818
(section_header
850
819
~shstring_table_fixup: shstrtab_section_fixup
851
820
~shname_string_fixup: shstrtab_section_name_fixup
852
- ~sh_type: SHT_STRTAB
853
- ~sh_flags: []
854
821
~section_fixup: (Some shstrtab_section_fixup)
855
- ~sh_addralign: 1L
856
- ~sh_entsize: 0L
857
- ~sh_link: None
858
- ~sh_info: None );
822
+ SHT_STRTAB );
859
823
860
824
(*
861
825
FIXME: uncomment the dwarf section headers as you make use of them;
@@ -869,91 +833,64 @@ let elf32_linux_x86_file
869
833
(section_header
870
834
~shstring_table_fixup: shstrtab_section_fixup
871
835
~shname_string_fixup: debug_aranges_section_name_fixup
872
- ~sh_type: SHT_PROGBITS
873
- ~sh_flags: []
874
836
~section_fixup: (Some sem.Semant.ctxt_debug_aranges_fixup)
875
837
~sh_addralign: 8L
876
- ~sh_entsize: 0L
877
- ~sh_link: None
878
- ~sh_info: None);
838
+ ~zero_sh_addr: true
839
+ SHT_PROGBITS);
879
840
*)
880
841
(* .debug_pubnames *)
881
842
(*
882
843
(section_header
883
844
~shstring_table_fixup: shstrtab_section_fixup
884
845
~shname_string_fixup: debug_pubnames_section_name_fixup
885
- ~sh_type: SHT_PROGBITS
886
- ~sh_flags: []
887
846
~section_fixup: (Some sem.Semant.ctxt_debug_pubnames_fixup)
888
- ~sh_addralign: 1L
889
- ~sh_entsize: 0L
890
- ~sh_link: None
891
- ~sh_info: None);
847
+ ~zero_sh_addr: true
848
+ SHT_PROGBITS);
892
849
*)
893
850
894
851
(* .debug_info *)
895
852
(section_header
896
853
~shstring_table_fixup: shstrtab_section_fixup
897
854
~shname_string_fixup: debug_info_section_name_fixup
898
- ~sh_type: SHT_PROGBITS
899
- ~sh_flags: []
900
855
~section_fixup: (Some sem.Semant. ctxt_debug_info_fixup)
901
- ~sh_addralign: 1L
902
- ~sh_entsize: 0L
903
- ~sh_link: None
904
- ~sh_info: None );
856
+ ~zero_sh_addr: true
857
+ SHT_PROGBITS );
905
858
906
859
(* .debug_abbrev *)
907
860
(section_header
908
861
~shstring_table_fixup: shstrtab_section_fixup
909
862
~shname_string_fixup: debug_abbrev_section_name_fixup
910
- ~sh_type: SHT_PROGBITS
911
- ~sh_flags: []
912
863
~section_fixup: (Some sem.Semant. ctxt_debug_abbrev_fixup)
913
- ~sh_addralign: 1L
914
- ~sh_entsize: 0L
915
- ~sh_link: None
916
- ~sh_info: None );
864
+ ~zero_sh_addr: true
865
+ SHT_PROGBITS );
917
866
918
867
(* .debug_line *)
919
868
(*
920
869
(section_header
921
870
~shstring_table_fixup: shstrtab_section_fixup
922
871
~shname_string_fixup: debug_line_section_name_fixup
923
- ~sh_type: SHT_PROGBITS
924
- ~sh_flags: []
925
872
~section_fixup: (Some sem.Semant.ctxt_debug_line_fixup)
926
- ~sh_addralign: 1L
927
- ~sh_entsize: 0L
928
- ~sh_link: None
929
- ~sh_info: None);
873
+ ~zero_sh_addr: true
874
+ SHT_PROGBITS);
930
875
*)
931
876
932
877
(* .debug_frame *)
933
878
(*
934
879
(section_header
935
880
~shstring_table_fixup: shstrtab_section_fixup
936
881
~shname_string_fixup: debug_frame_section_name_fixup
937
- ~sh_type: SHT_PROGBITS
938
- ~sh_flags: []
939
882
~section_fixup: (Some sem.Semant.ctxt_debug_frame_fixup)
940
883
~sh_addralign: 4L
941
- ~sh_entsize: 0L
942
- ~sh_link: None
943
- ~sh_info: None);
884
+ ~zero_sh_addr: true
885
+ SHT_PROGBITS);
944
886
*)
945
887
946
888
(* .note.rust *)
947
889
(section_header
948
890
~shstring_table_fixup: shstrtab_section_fixup
949
891
~shname_string_fixup: note_rust_section_name_fixup
950
- ~sh_type: SHT_NOTE
951
- ~sh_flags: []
952
892
~section_fixup: (Some note_rust_section_fixup)
953
- ~sh_addralign: 1L
954
- ~sh_entsize: 0L
955
- ~sh_link: None
956
- ~sh_info: None );
893
+ SHT_NOTE );
957
894
958
895
|]
959
896
in
0 commit comments