Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file elf_relocation.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217(*Generated by Lem from elf_relocation.lem.*)(** [elf_relocation] formalises types, functions and other definitions for working
* with ELF relocation and relocation with addend entries.
*)openLem_basic_classesopenLem_numopenLem_list(*import Set*)openEndiannessopenByte_sequenceopenErroropenLem_stringopenShowopenMissing_pervasivesopenElf_types_native_uint(** ELF relocation records *)(** [elf32_relocation] is a simple relocation record (without addend).
*)typeelf32_relocation={elf32_r_offset:Uint32_wrapper.uint32(** Address at which to relocate *);elf32_r_info:Uint32_wrapper.uint32(** Symbol table index/type of relocation to apply *)}(** [elf32_relocation_a] is a relocation record with addend.
*)typeelf32_relocation_a={elf32_ra_offset:Uint32_wrapper.uint32(** Address at which to relocate *);elf32_ra_info:Uint32_wrapper.uint32(** Symbol table index/type of relocation to apply *);elf32_ra_addend:Int32.t(** Addend used to compute value to be stored *)}(** [elf64_relocation] is a simple relocation record (without addend).
*)typeelf64_relocation={elf64_r_offset:Uint64_wrapper.uint64(** Address at which to relocate *);elf64_r_info:Uint64_wrapper.uint64(** Symbol table index/type of relocation to apply *)}(** [elf64_relocation_a] is a relocation record with addend.
*)typeelf64_relocation_a={elf64_ra_offset:Uint64_wrapper.uint64(** Address at which to relocate *);elf64_ra_info:Uint64_wrapper.uint64(** Symbol table index/type of relocation to apply *);elf64_ra_addend:Int64.t(** Addend used to compute value to be stored *)}(** [elf64_relocation_a_compare r1 r2] is an ordering comparison function for
* relocation with addend records suitable for constructing sets, finite map
* and other ordered data structures.
* NB: we exclusively use elf64_relocation_a in range tags, regardless of what
* file/reloc the info came from, so only this one needs an Ord instance.
*)(*val elf64_relocation_a_compare : elf64_relocation_a -> elf64_relocation_a ->
ordering*)letelf64_relocation_a_compareent1ent2:int=(tripleCompareNat_big_num.compareNat_big_num.compareNat_big_num.compare(Ml_bindings.nat_big_num_of_uint64ent1.elf64_ra_offset,Ml_bindings.nat_big_num_of_uint64ent1.elf64_ra_info,Nat_big_num.of_int64ent1.elf64_ra_addend)(Ml_bindings.nat_big_num_of_uint64ent2.elf64_ra_offset,Ml_bindings.nat_big_num_of_uint64ent2.elf64_ra_info,Nat_big_num.of_int64ent2.elf64_ra_addend))letinstance_Basic_classes_Ord_Elf_relocation_elf64_relocation_a_dict:(elf64_relocation_a)ord_class=({compare_method=elf64_relocation_a_compare;isLess_method=(funf1->(funf2->(Lem.orderingEqual(elf64_relocation_a_comparef1f2)(-1))));isLessEqual_method=(funf1->(funf2->Pset.mem(elf64_relocation_a_comparef1f2)(Pset.from_listcompare[(-1);0])));isGreater_method=(funf1->(funf2->(Lem.orderingEqual(elf64_relocation_a_comparef1f2)1)));isGreaterEqual_method=(funf1->(funf2->Pset.mem(elf64_relocation_a_comparef1f2)(Pset.from_listcompare[1;0])))})(** Reading relocation entries *)(** [read_elf32_relocation ed bs0] parses an [elf32_relocation] record from
* byte sequence [bs0] assuming endianness [ed]. The suffix of [bs0] remaining
* after parsing is also returned.
* Fails if the relocation record cannot be parsed.
*)(*val read_elf32_relocation : endianness -> byte_sequence ->
error (elf32_relocation * byte_sequence)*)letread_elf32_relocationendianbs:(elf32_relocation*Byte_sequence_wrapper.byte_sequence)error=(bind(read_elf32_addrendianbs)(fun(r_offset,bs)->bind(read_elf32_wordendianbs)(fun(r_info,bs)->return({elf32_r_offset=r_offset;elf32_r_info=r_info},bs))))(** [read_elf64_relocation ed bs0] parses an [elf64_relocation] record from
* byte sequence [bs0] assuming endianness [ed]. The suffix of [bs0] remaining
* after parsing is also returned.
* Fails if the relocation record cannot be parsed.
*)(*val read_elf64_relocation : endianness -> byte_sequence ->
error (elf64_relocation * byte_sequence)*)letread_elf64_relocationendianbs:(elf64_relocation*Byte_sequence_wrapper.byte_sequence)error=(bind(read_elf64_addrendianbs)(fun(r_offset,bs)->bind(read_elf64_xwordendianbs)(fun(r_info,bs)->return({elf64_r_offset=r_offset;elf64_r_info=r_info},bs))))(** [read_elf32_relocation_a ed bs0] parses an [elf32_relocation_a] record from
* byte sequence [bs0] assuming endianness [ed]. The suffix of [bs0] remaining
* after parsing is also returned.
* Fails if the relocation record cannot be parsed.
*)(*val read_elf32_relocation_a : endianness -> byte_sequence ->
error (elf32_relocation_a * byte_sequence)*)letread_elf32_relocation_aendianbs:(elf32_relocation_a*Byte_sequence_wrapper.byte_sequence)error=(bind(read_elf32_addrendianbs)(fun(r_offset,bs)->bind(read_elf32_wordendianbs)(fun(r_info,bs)->bind(read_elf32_swordendianbs)(fun(r_addend,bs)->return({elf32_ra_offset=r_offset;elf32_ra_info=r_info;elf32_ra_addend=r_addend},bs)))))(** [read_elf64_relocation_a ed bs0] parses an [elf64_relocation_a] record from
* byte sequence [bs0] assuming endianness [ed]. The suffix of [bs0] remaining
* after parsing is also returned.
* Fails if the relocation record cannot be parsed.
*)(*val read_elf64_relocation_a : endianness -> byte_sequence -> error (elf64_relocation_a * byte_sequence)*)letread_elf64_relocation_aendianbs:(elf64_relocation_a*Byte_sequence_wrapper.byte_sequence)error=(bind(read_elf64_addrendianbs)(fun(r_offset,bs)->bind(read_elf64_xwordendianbs)(fun(r_info,bs)->bind(read_elf64_sxwordendianbs)(fun(r_addend,bs)->return({elf64_ra_offset=r_offset;elf64_ra_info=r_info;elf64_ra_addend=r_addend},bs)))))(** [read_elf32_relocation_section' ed bs0] parses a list of [elf32_relocation]
* records from byte sequence [bs0], which is assumed to have the exact size
* required, assuming endianness [ed].
* Fails if any of the records cannot be parsed.
*)(*val read_elf32_relocation_section' : endianness -> byte_sequence ->
error (list elf32_relocation)*)letrecread_elf32_relocation_section'endianbs0:((elf32_relocation)list)error=(ifNat_big_num.equal(Byte_sequence.length0bs0)((Nat_big_num.of_int0))thenreturn[]elsebind(read_elf32_relocationendianbs0)(fun(entry,bs1)->bind(read_elf32_relocation_section'endianbs1)(funtail->return(entry::tail))))(** [read_elf64_relocation_section' ed bs0] parses a list of [elf64_relocation]
* records from byte sequence [bs0], which is assumed to have the exact size
* required, assuming endianness [ed].
* Fails if any of the records cannot be parsed.
*)(*val read_elf64_relocation_section' : endianness -> byte_sequence ->
error (list elf64_relocation)*)letrecread_elf64_relocation_section'endianbs0:((elf64_relocation)list)error=(ifNat_big_num.equal(Byte_sequence.length0bs0)((Nat_big_num.of_int0))thenreturn[]elsebind(read_elf64_relocationendianbs0)(fun(entry,bs1)->bind(read_elf64_relocation_section'endianbs1)(funtail->return(entry::tail))))(** [read_elf32_relocation_a_section' ed bs0] parses a list of [elf32_relocation_a]
* records from byte sequence [bs0], which is assumed to have the exact size
* required, assuming endianness [ed].
* Fails if any of the records cannot be parsed.
*)(*val read_elf32_relocation_a_section' : endianness -> byte_sequence ->
error (list elf32_relocation_a)*)letrecread_elf32_relocation_a_section'endianbs0:((elf32_relocation_a)list)error=(ifNat_big_num.equal(Byte_sequence.length0bs0)((Nat_big_num.of_int0))thenreturn[]elsebind(read_elf32_relocation_aendianbs0)(fun(entry,bs1)->bind(read_elf32_relocation_a_section'endianbs1)(funtail->return(entry::tail))))(** [read_elf64_relocation_a_section' ed bs0] parses a list of [elf64_relocation_a]
* records from byte sequence [bs0], which is assumed to have the exact size
* required, assuming endianness [ed].
* Fails if any of the records cannot be parsed.
*)(*val read_elf64_relocation_a_section' : endianness -> byte_sequence ->
error (list elf64_relocation_a)*)letrecread_elf64_relocation_a_section'endianbs0:((elf64_relocation_a)list)error=(ifNat_big_num.equal(Byte_sequence.length0bs0)((Nat_big_num.of_int0))thenreturn[]elsebind(read_elf64_relocation_aendianbs0)(fun(entry,bs1)->bind(read_elf64_relocation_a_section'endianbs1)(funtail->return(entry::tail))))(** [read_elf32_relocation_section sz ed bs0] reads in a list of [elf32_relocation]
* records from a prefix of [bs0] of size [sz] assuming endianness [ed]. The
* suffix of [bs0] remaining after parsing is also returned.
* Fails if any of the records cannot be parsed or if the length of [bs0] is
* less than [sz].
*)(*val read_elf32_relocation_section : natural -> endianness -> byte_sequence
-> error (list elf32_relocation * byte_sequence)*)letread_elf32_relocation_sectiontable_sizeendianbs0:((elf32_relocation)list*Byte_sequence_wrapper.byte_sequence)error=(bind(partition0table_sizebs0)(fun(eat,rest)->bind(read_elf32_relocation_section'endianeat)(funentries->return(entries,rest))))(** [read_elf64_relocation_section sz ed bs0] reads in a list of [elf64_relocation]
* records from a prefix of [bs0] of size [sz] assuming endianness [ed]. The
* suffix of [bs0] remaining after parsing is also returned.
* Fails if any of the records cannot be parsed or if the length of [bs0] is
* less than [sz].
*)(*val read_elf64_relocation_section : natural -> endianness -> byte_sequence
-> error (list elf64_relocation * byte_sequence)*)letread_elf64_relocation_sectiontable_sizeendianbs0:((elf64_relocation)list*Byte_sequence_wrapper.byte_sequence)error=(bind(partition0table_sizebs0)(fun(eat,rest)->bind(read_elf64_relocation_section'endianeat)(funentries->return(entries,rest))))(** [read_elf32_relocation_a_section sz ed bs0] reads in a list of [elf32_relocation_a]
* records from a prefix of [bs0] of size [sz] assuming endianness [ed]. The
* suffix of [bs0] remaining after parsing is also returned.
* Fails if any of the records cannot be parsed or if the length of [bs0] is
* less than [sz].
*)(*val read_elf32_relocation_a_section : natural -> endianness -> byte_sequence ->
error (list elf32_relocation_a * byte_sequence)*)letread_elf32_relocation_a_sectiontable_sizeendianbs0:((elf32_relocation_a)list*Byte_sequence_wrapper.byte_sequence)error=(bind(partition0table_sizebs0)(fun(eat,rest)->bind(read_elf32_relocation_a_section'endianeat)(funentries->return(entries,rest))))(** [read_elf64_relocation_a_section sz ed bs0] reads in a list of [elf64_relocation_a]
* records from a prefix of [bs0] of size [sz] assuming endianness [ed]. The
* suffix of [bs0] remaining after parsing is also returned.
* Fails if any of the records cannot be parsed or if the length of [bs0] is
* less than [sz].
*)(*val read_elf64_relocation_a_section : natural -> endianness -> byte_sequence ->
error (list elf64_relocation_a * byte_sequence)*)letread_elf64_relocation_a_sectiontable_sizeendianbs0:((elf64_relocation_a)list*Byte_sequence_wrapper.byte_sequence)error=(bind(partition0table_sizebs0)(fun(eat,rest)->bind(read_elf64_relocation_a_section'endianeat)(funentries->return(entries,rest))))