@@ -177,6 +177,7 @@ let section_header
177
177
~(sh_addralign :int64 )
178
178
~(sh_entsize :int64 )
179
179
~(sh_link :int64 option )
180
+ ~(sh_info :int64 option )
180
181
: frag =
181
182
SEQ
182
183
[|
@@ -213,7 +214,9 @@ let section_header
213
214
WORD (TY_u32 , (IMM (match sh_link with
214
215
None -> 0L
215
216
| Some i -> i)));
216
- WORD (TY_u32 , (IMM 0L )); (* sh_info *)
217
+ WORD (TY_u32 , (IMM (match sh_info with
218
+ None -> 0L
219
+ | Some i -> i)));
217
220
WORD (TY_u32 , (IMM sh_addralign));
218
221
WORD (TY_u32 , (IMM sh_entsize));
219
222
|]
@@ -633,7 +636,7 @@ let elf32_linux_x86_file
633
636
let dynsymndx = 4L in (* Section index of .dynsym *)
634
637
let dynstrndx = 5L in (* Section index of .dynstr *)
635
638
(* let hashndx = 6L in *) (* Section index of .hash *)
636
- (* let pltndx = 7L in *) (* Section index of .plt *)
639
+ let pltndx = 7L in (* Section index of .plt *)
637
640
(* let gotpltndx = 8L in *) (* Section index of .got.plt *)
638
641
(* let relapltndx = 9L in *) (* Section index of .rela.plt *)
639
642
let datandx = 10L in (* Section index of .data *)
@@ -695,7 +698,8 @@ let elf32_linux_x86_file
695
698
~section_fixup: None
696
699
~sh_addralign: 0L
697
700
~sh_entsize: 0L
698
- ~sh_link: None );
701
+ ~sh_link: None
702
+ ~sh_info: None );
699
703
700
704
(* .interp *)
701
705
(section_header
@@ -706,7 +710,8 @@ let elf32_linux_x86_file
706
710
~section_fixup: (Some interp_section_fixup)
707
711
~sh_addralign: 1L
708
712
~sh_entsize: 0L
709
- ~sh_link: None );
713
+ ~sh_link: None
714
+ ~sh_info: None );
710
715
711
716
(* .text *)
712
717
(section_header
@@ -717,7 +722,8 @@ let elf32_linux_x86_file
717
722
~section_fixup: (Some text_section_fixup)
718
723
~sh_addralign: 32L
719
724
~sh_entsize: 0L
720
- ~sh_link: None );
725
+ ~sh_link: None
726
+ ~sh_info: None );
721
727
722
728
(* .rodata *)
723
729
(section_header
@@ -728,7 +734,8 @@ let elf32_linux_x86_file
728
734
~section_fixup: (Some rodata_section_fixup)
729
735
~sh_addralign: 32L
730
736
~sh_entsize: 0L
731
- ~sh_link: None );
737
+ ~sh_link: None
738
+ ~sh_info: None );
732
739
733
740
(* .dynsym *)
734
741
(section_header
@@ -737,9 +744,10 @@ let elf32_linux_x86_file
737
744
~sh_type: SHT_DYNSYM
738
745
~sh_flags: [ SHF_ALLOC ]
739
746
~section_fixup: (Some dynsym_section_fixup)
740
- ~sh_addralign: 8L
747
+ ~sh_addralign: 4L
741
748
~sh_entsize: elf32_symsize
742
- ~sh_link: (Some dynstrndx) );
749
+ ~sh_link: (Some dynstrndx)
750
+ ~sh_info: None );
743
751
744
752
(* .dynstr *)
745
753
(section_header
@@ -750,7 +758,8 @@ let elf32_linux_x86_file
750
758
~section_fixup: (Some dynstr_section_fixup)
751
759
~sh_addralign: 1L
752
760
~sh_entsize: 0L
753
- ~sh_link: None );
761
+ ~sh_link: None
762
+ ~sh_info: None );
754
763
755
764
(* .hash *)
756
765
(section_header
@@ -761,7 +770,8 @@ let elf32_linux_x86_file
761
770
~section_fixup: (Some hash_section_fixup)
762
771
~sh_addralign: 4L
763
772
~sh_entsize: 4L
764
- ~sh_link: (Some dynsymndx));
773
+ ~sh_link: (Some dynsymndx)
774
+ ~sh_info: None );
765
775
766
776
(* .plt *)
767
777
(section_header
@@ -772,7 +782,8 @@ let elf32_linux_x86_file
772
782
~section_fixup: (Some plt_section_fixup)
773
783
~sh_addralign: 4L
774
784
~sh_entsize: 0L
775
- ~sh_link: None );
785
+ ~sh_link: None
786
+ ~sh_info: None );
776
787
777
788
(* .got.plt *)
778
789
(section_header
@@ -783,7 +794,8 @@ let elf32_linux_x86_file
783
794
~section_fixup: (Some got_plt_section_fixup)
784
795
~sh_addralign: 4L
785
796
~sh_entsize: 0L
786
- ~sh_link: None );
797
+ ~sh_link: None
798
+ ~sh_info: None );
787
799
788
800
(* .rela.plt *)
789
801
(section_header
@@ -794,7 +806,8 @@ let elf32_linux_x86_file
794
806
~section_fixup: (Some rela_plt_section_fixup)
795
807
~sh_addralign: 4L
796
808
~sh_entsize: elf32_rela_entsz
797
- ~sh_link: (Some dynsymndx));
809
+ ~sh_link: (Some dynsymndx)
810
+ ~sh_info: (Some pltndx));
798
811
799
812
(* .data *)
800
813
(section_header
@@ -805,7 +818,8 @@ let elf32_linux_x86_file
805
818
~section_fixup: (Some data_section_fixup)
806
819
~sh_addralign: 32L
807
820
~sh_entsize: 0L
808
- ~sh_link: None );
821
+ ~sh_link: None
822
+ ~sh_info: None );
809
823
810
824
(* .bss *)
811
825
(section_header
@@ -816,7 +830,8 @@ let elf32_linux_x86_file
816
830
~section_fixup: (Some bss_section_fixup)
817
831
~sh_addralign: 32L
818
832
~sh_entsize: 0L
819
- ~sh_link: None );
833
+ ~sh_link: None
834
+ ~sh_info: None );
820
835
821
836
(* .dynamic *)
822
837
(section_header
@@ -827,7 +842,8 @@ let elf32_linux_x86_file
827
842
~section_fixup: (Some dynamic_section_fixup)
828
843
~sh_addralign: 8L
829
844
~sh_entsize: 0L
830
- ~sh_link: None );
845
+ ~sh_link: (Some dynstrndx)
846
+ ~sh_info: None );
831
847
832
848
(* .shstrtab *)
833
849
(section_header
@@ -838,7 +854,8 @@ let elf32_linux_x86_file
838
854
~section_fixup: (Some shstrtab_section_fixup)
839
855
~sh_addralign: 1L
840
856
~sh_entsize: 0L
841
- ~sh_link: None );
857
+ ~sh_link: None
858
+ ~sh_info: None );
842
859
843
860
(*
844
861
FIXME: uncomment the dwarf section headers as you make use of them;
@@ -857,7 +874,8 @@ let elf32_linux_x86_file
857
874
~section_fixup: (Some sem.Semant.ctxt_debug_aranges_fixup)
858
875
~sh_addralign: 8L
859
876
~sh_entsize: 0L
860
- ~sh_link: None);
877
+ ~sh_link: None
878
+ ~sh_info: None);
861
879
*)
862
880
(* .debug_pubnames *)
863
881
(*
@@ -869,7 +887,8 @@ let elf32_linux_x86_file
869
887
~section_fixup: (Some sem.Semant.ctxt_debug_pubnames_fixup)
870
888
~sh_addralign: 1L
871
889
~sh_entsize: 0L
872
- ~sh_link: None);
890
+ ~sh_link: None
891
+ ~sh_info: None);
873
892
*)
874
893
875
894
(* .debug_info *)
@@ -881,7 +900,8 @@ let elf32_linux_x86_file
881
900
~section_fixup: (Some sem.Semant. ctxt_debug_info_fixup)
882
901
~sh_addralign: 1L
883
902
~sh_entsize: 0L
884
- ~sh_link: None );
903
+ ~sh_link: None
904
+ ~sh_info: None );
885
905
886
906
(* .debug_abbrev *)
887
907
(section_header
@@ -892,7 +912,9 @@ let elf32_linux_x86_file
892
912
~section_fixup: (Some sem.Semant. ctxt_debug_abbrev_fixup)
893
913
~sh_addralign: 1L
894
914
~sh_entsize: 0L
895
- ~sh_link: None );
915
+ ~sh_link: None
916
+ ~sh_info: None );
917
+
896
918
(* .debug_line *)
897
919
(*
898
920
(section_header
@@ -903,7 +925,8 @@ let elf32_linux_x86_file
903
925
~section_fixup: (Some sem.Semant.ctxt_debug_line_fixup)
904
926
~sh_addralign: 1L
905
927
~sh_entsize: 0L
906
- ~sh_link: None);
928
+ ~sh_link: None
929
+ ~sh_info: None);
907
930
*)
908
931
909
932
(* .debug_frame *)
@@ -916,7 +939,8 @@ let elf32_linux_x86_file
916
939
~section_fixup: (Some sem.Semant.ctxt_debug_frame_fixup)
917
940
~sh_addralign: 4L
918
941
~sh_entsize: 0L
919
- ~sh_link: None);
942
+ ~sh_link: None
943
+ ~sh_info: None);
920
944
*)
921
945
922
946
(* .note.rust *)
@@ -928,7 +952,8 @@ let elf32_linux_x86_file
928
952
~section_fixup: (Some note_rust_section_fixup)
929
953
~sh_addralign: 1L
930
954
~sh_entsize: 0L
931
- ~sh_link: None );
955
+ ~sh_link: None
956
+ ~sh_info: None );
932
957
933
958
|]
934
959
in
@@ -999,7 +1024,7 @@ let elf32_linux_x86_file
999
1024
elf32_header
1000
1025
~sess
1001
1026
~ei_data: ELFDATA2LSB
1002
- ~e_type: ET_DYN
1027
+ ~e_type: ( if sess. Session. sess_library_mode then ET_DYN else ET_EXEC )
1003
1028
~e_machine: EM_386
1004
1029
~e_version: EV_CURRENT
1005
1030
0 commit comments